query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
Overrides local method from the ones in module
|
def print_id
puts "Id"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def overrides; end",
"def extended(*) end",
"def special\n override\n end",
"def custom; end",
"def custom; end",
"def internal; end",
"def original_method; end",
"def internal_methods; end",
"def source(override); end",
"def implementation; end",
"def implementation; end",
"def methods() end",
"def extended(a_module)\n end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def extended_modules; end",
"def private; end",
"def original; end",
"def global\n raise NotImplementedError\n end",
"def super_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 method; end",
"def override() # Note that despite the module.override, this still overrides\r\n puts \"CHILD override()\"\r\n end",
"def extra; end",
"def modify\n super\n end",
"def method_731(base); end",
"def extended( hooked_instance )\n\n super if defined?( super )\n \n end",
"def get_module()\n raise NoMethodError, 'This method needs to be overridden'\n end",
"def acts_as_msfte\n extend ClassMethods\n end",
"def tag; raise 'Override this method'; end",
"def wrapper; end",
"def overrides=(_arg0); end",
"def method_missing(method, *args, &block)\n super unless original_self\n original_self.send method, *args, &block\n end",
"def oldmtd \n \"old method\" \nend",
"def modules; end",
"def modules; end",
"def modules; end",
"def module_move_up(mod) end",
"def private_method\n end",
"def oldmtd\r\n \"old method\"\r\nend",
"def import\n raise \"#{self.class.name}::#{__method__} must be overridden\"\n end",
"def external; end",
"def initialize ( _caller )\n super\n end",
"def initialize ( _caller )\n super\n end",
"def method_missing(wh,*therest)\n # xxx internal methods must be protected at some point\n end",
"def public_instance_methods(include_super=true) end",
"def old_method\n \"old improved method\"\nend",
"def oldmtd\n \"old method\"\nend",
"def extend(mod)\n @modules << mod\n super(mod)\n end",
"def before_import ; end",
"def isolated; end",
"def isolated; end",
"def method_override(ver,name)\n @method_names[ver]=name\n end",
"def methods\n super + DELEGATED_METHODS\n end",
"def ignore_method_conflicts; end",
"def local_method\n :local_method\n end",
"def hidden_apis=(_arg0); end",
"def delegating_method; end",
"def helpers; end",
"def helpers; end",
"def helpers; end",
"def private_instance_methods(include_super=true) end",
"def protected_instance_methods(include_super=true) end",
"def instance_methods(include_super=true) end",
"def included(othermod) end",
"def included_modules() end",
"def override_execute(mod, hbsession, opts); end",
"def ignore_method_conflicts=(_arg0); end",
"def common\n \n end",
"def methods=(_arg0); end",
"def included(mod); end",
"def define_helpers; end",
"def before_all\n super if defined?(super)\n end",
"def process_hook\n fail 'sub class to implement'\n end",
"def proxy\n super\n end",
"def weber; end",
"def called_from; end",
"def called_from; end",
"def set_functions\n super\n end",
"def work\n raise \"implement this in a class that includes this module\"\n end",
"def prepended_modules; end",
"def global; end",
"def main\n super\n return self\n end",
"def ignores; end",
"def method\n\t\t# code code\n\tend",
"def process_custom_method\n # da implementare per eventuali estensioni\n end",
"def specie; end",
"def specie; end",
"def specie; end"
] |
[
"0.7090869",
"0.7059276",
"0.6968681",
"0.6967124",
"0.6967124",
"0.6924156",
"0.66856176",
"0.6528463",
"0.6528079",
"0.64420974",
"0.64420974",
"0.6437933",
"0.64330304",
"0.63925123",
"0.63925123",
"0.63925123",
"0.63925123",
"0.6380315",
"0.63799816",
"0.6377472",
"0.6241911",
"0.6237137",
"0.62353987",
"0.62353987",
"0.62353987",
"0.62353987",
"0.62353987",
"0.62353987",
"0.62353987",
"0.62353987",
"0.62353987",
"0.62353987",
"0.62353987",
"0.62353987",
"0.6219458",
"0.6200675",
"0.618502",
"0.61572146",
"0.61329716",
"0.61277586",
"0.61046004",
"0.60977167",
"0.60975665",
"0.60904294",
"0.6073402",
"0.6050275",
"0.6047819",
"0.6047819",
"0.6047819",
"0.6045295",
"0.6045039",
"0.6033005",
"0.60191023",
"0.6017784",
"0.5995862",
"0.5995862",
"0.59944487",
"0.5991796",
"0.59907603",
"0.59836185",
"0.59779155",
"0.59585166",
"0.5957204",
"0.5957204",
"0.59529036",
"0.59432364",
"0.5932923",
"0.5917899",
"0.59130865",
"0.59103715",
"0.5908783",
"0.5908783",
"0.5908783",
"0.5876496",
"0.5876319",
"0.5846528",
"0.58386004",
"0.5826872",
"0.5826697",
"0.5825353",
"0.58224785",
"0.58136165",
"0.5804146",
"0.580238",
"0.5800826",
"0.5799315",
"0.57959163",
"0.5784644",
"0.5774785",
"0.5774785",
"0.5764966",
"0.5762785",
"0.575684",
"0.573994",
"0.57334864",
"0.5729776",
"0.5721011",
"0.57043636",
"0.57010454",
"0.57010454",
"0.57010454"
] |
0.0
|
-1
|
Encoding Encodes the node into a hash.
|
def to_hash(*a)
hash = {}
hash['id'] = id
hash['label'] = label unless label.nil?
hash['x'] = x unless x.nil?
hash['y'] = y unless y.nil?
hash['width'] = width unless width.nil?
hash['height'] = height unless height.nil?
hash['label_x'] = label_x unless label_x.nil?
hash['label_y'] = label_y unless label_y.nil?
hash['points'] = points unless points.nil?
hash['nodes'] = nodes.to_a.map{|n| n.to_hash()} if nodes.to_a.length > 0
return hash
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hash_encode(i)\n @hasher.encode i\n end",
"def hex; @node_id.hexlify; end",
"def hash\n node_id.hash\n end",
"def hash # Hack for Ruby 1.8.6\n @node.id.hash ^ self.class.hash\n end",
"def calculate_hash!\n prefix = PREFIX_NAME_LOOKUP[self.type]\n # add special cases for refs\n self.hash_id = NodeId.sha1(\"#{prefix} #{self.size}\\0#{self.content}\")\n end",
"def hash\n @node.sort.push(@edge).hash\n end",
"def []=(node, value)\n return @hash[node.sha1] = value\n end",
"def encode\n type_byte + encode_data\n end",
"def node_hash(node_id)\n \n end",
"def encode\n # no op\n end",
"def encode(hash)\n [Marshal.dump(hash)].pack('m')\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def encode_end(state)\n\t\tstate.encoded += [ state.key.to_i ].pack('N')\n\tend",
"def hexhash\n hash.to_s(16)\n end",
"def correct_node_hash(node_id)\n SpStore::Crypto.hash_for_tree_node node_id, node_hash(left_child(node_id)),\n node_hash(right_child(node_id))\n end",
"def hash\n bytes.hash\n end",
"def encode\n transform :encode \n end",
"def encode!; end",
"def encode\n index = e_byte(@idx)\n e_byte(NEW_CACHE)+index+@value.encode\n end",
"def hash(block)\n Digest::SHA256.hexdigest(block.to_s.encode)\n end",
"def hash(tx)\n Digest::SHA256.hexdigest(Digest::SHA256.hexdigest(tx))\nend",
"def to_hash() end",
"def serialize\n Base64.encode64(Marshal.dump(self.to_hash)).chop\n end",
"def change_sha\n DeliveryGolang::Helpers.change_sha(node)\n end",
"def hash(*) end",
"def hash\n raw = [name, type, values.join('/')].join(' ')\n Digest::MD5.hexdigest(raw)\n end",
"def serialize(hash, salt)\n hash + salt\n end",
"def encode\n [@signature1].pack('L*') <<\n [@signature2].pack('L*') <<\n [@flags].pack('L*') <<\n [@version].pack('L*') <<\n @master_seed <<\n @encryption_iv <<\n [@groups_count].pack('L*') <<\n [@entries_count].pack('L*') <<\n @content_hash <<\n @master_seed2 <<\n [@rounds].pack('L*')\n end",
"def encode_block(state, block)\n buf = ((@dictionary.index(block[0]) + 1) ^ state.key).chr\n\n buf\n end",
"def encode\n raise NotImplementedError\n end",
"def update_hash\n nh = nil\n\n if is_branch != 0\n sha512 = OpenSSL::Digest::SHA512.new\n sha512 << HASH_+PREFIXES[:inner_node]\n hashes.each { |k,h|\n sha512 << v\n }\n nh = sha512.digest\n end\n\n return false if nh == self.hash\n self.hash = nh\n return true\n end",
"def recalculate_hash_at(node)\n return node._hash = node.value if node.value\n recalculate_hash_at(node.left) if node.left\n recalculate_hash_at(node.right) if node.right\n node._hash = self.class.hash_children(*node_subhashes(node))\n end",
"def node_to_hash(node)\n puts \"You must define a `node_to_hash` method in your child class to parse the Nokogiri nodes\"\n end",
"def encode(plain_pass)\n md5 salt + plain_pass + salt\n end",
"def encode_end(state)\n\t\tstate.encoded += [ state.key ].pack(state.decoder_key_pack)\n\tend",
"def encode(object)\n engine.encode(object)\n end",
"def serializable_hash\n return nil if @object.nil?\n @node = attributes\n include_links!\n # include_associations! if _embed\n @node\n end",
"def encode_chunk(chunk); end",
"def hash\n @hash ||= begin\n result = 17\n result = 31 * result + self.class.hash\n result = 31 * result + ord\n result.is_a?(Fixnum) ? result : result.hash\n end\n end",
"def hash\n @hash ||= begin\n result = 17\n result = 31 * result + self.class.hash\n result = 31 * result + ord\n result.is_a?(Fixnum) ? result : result.hash\n end\n end",
"def to_hash\n {\n amount: self.amount,\n address: self.to_node.address\n }\n end",
"def hexdigest\n DigestUtils.pack_hexdigest(digest)\n end",
"def hash\n id.hash + 32 * bs_request.hash\n end",
"def encode_entity(entity)\n Yajl::Encoder.encode(entity)\n end",
"def encode(string); end",
"def namehash(name)\n node = '0' * 64\n if (name != '')\n name.split('.').reverse.each do |label|\n node = sha3(node + sha3(label),encoding: :hex);\n end\n end\n '0x'+node\n end",
"def encode(obj); end",
"def encode h\n return h.init_data if h.vanila?\n str = h.to_json\n str = @cipher_key ? cipher(str) : encode64(str)\n digest = @dss.digest str\n return h.init_data if digest == h.init_digest\n\n sig = @dsa.syssign digest\n \"#{encode64 sig}/#{str}\"\n end",
"def encode_string; end",
"def to_hash160\n Tapyrus.hash160(to_hex)\n end",
"def to_hexa\n [self.token].pack('H*')\n end",
"def encode(encoding)\n to_s.encode(encoding)\n end",
"def encode(digest)\n seed = 1\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\", \"y\"]\n consonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"k\", \"l\", \"m\", \"n\", \"p\", \"r\", \"s\", \"t\", \"v\", \"z\", \"x\"]\n digest = digest.to_s.bytes.to_a\n digest_len = digest.length\n result = \"\"\n\n i = j = 0\n result[j] = \"x\";\n j += 1\n\n while true\n if i >= digest_len\n result[j] = vowels[seed % 6]\n j += 1\n result[j] = consonants[16]\n j += 1\n result[j] = vowels[seed / 6]\n j += 1\n break\n end\n\n byte1 = digest[i]\n i += 1\n result[j] = vowels[(((byte1 >> 6) & 3) + seed) % 6]\n j += 1\n result[j] = consonants[(byte1 >> 2) & 15]\n j += 1\n result[j] = vowels[((byte1 & 3) + (seed / 6)) % 6]\n j += 1\n\n if i >= digest_len\n break\n end\n\n byte2 = digest[i]\n i += 1\n result[j] = consonants[(byte2 >> 4) & 15]\n j += 1\n result[j] = \"-\"\n j += 1\n result[j] = consonants[byte2 & 15]\n j += 1\n\n seed = (seed * 5 + byte1 * 7 + byte2) % 36\n end\n\n result[j] = \"x\"\n result\n end",
"def encode\n Logger.debug \"encoding #{self.inspect}\"\n class_mapper = RocketAMF::ClassMapper.new\n ser = RocketAMF::Serializer.new class_mapper\n\n if amf3?\n ser.stream << \"\\x00\"\n end\n\n ser.serialize 0, command\n ser.serialize 0, transaction_id\n\n if amf3?\n ser.stream << \"\\x05\"\n ser.stream << \"\\x11\"\n ser.serialize 3, values.first\n else\n values.each do |value|\n ser.serialize 0, value\n end\n end\n\n ser.stream\n end",
"def encode_mac(mac_address)\n Digest::SHA1.hexdigest(mac_address).upcase\n end",
"def encode(value)\n Base64.encode64 value\n end",
"def to_sha256\n Tapyrus.sha256(to_payload).bth\n end",
"def binary_hash\n [@hash].pack(\"H*\").reverse\n end",
"def encode(value)\n raise NotImplementedError, \"#{self.class.name}\\#encode\"\n end",
"def node_hash_from_node(ast)\n hash = {}\n ast.children.each { |cn| hash[cn.children[0]] = cn.children[1] }\n hash\n end",
"def mining_hash\n Utils.keccak(rlp_encode skip_keys: [:mix_hash, :nonce])\n end",
"def serializable_hash\n @node = links.any? ? super.merge(_links: links) : super\n end",
"def hash\r\n return to_s.hash\r\n end",
"def encode(_)\n raise NotImplementedError\n end",
"def encode_with(coder); end",
"def to_hash(hash={})\n node_hash = {}\n\n # Insert node hash into parent hash correctly.\n insert_node_hash_into_parent(hash, name, node_hash)\n\n # Handle child elements\n each_child do |child|\n handle_child_element(child, node_hash)\n end\n\n # Remove content node if it is blank\n remove_blank_content_node node_hash\n\n # Handle attributes\n each_attr { |a| node_hash[a.name] = a.value }\n\n hash\n end",
"def encode_end(state)\n state.encoded << [state.key].pack('C') + @dictionary\n end",
"def hash_bytes(blob)\n tlsh_hash(blob)\n end",
"def encoder; end",
"def encoder; end",
"def hash\n num = @high << 64\n num |= @low\n num.hash\n end",
"def encode\n return @_data unless @_data.nil?\n @_data = [@bin_data].pack( 'm' ).chomp if @bin_data \n @_data\n end",
"def hash_token(token)\n Digest::SHA256.hexdigest(token)\n end",
"def hash\n Digest::SHA256.hexdigest( \"#{nonce}#{time}#{difficulty}#{prev}#{data}\" )\n end",
"def hash\n end",
"def hash\n end",
"def hash\n end",
"def hash(key); end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def to_sha(hash)\n # converts a hash to a SHA256\n return Digest::SHA256.hexdigest(JSON.dump(hash))\nend",
"def encode(value)\n value.to_s(BASE)\n end",
"def encode(hrp, data, spec)\n checksummed = data + create_checksum(hrp, data, spec)\n hrp + SEPARATOR + checksummed.map{|i|CHARSET[i]}.join\n end",
"def hash\n [oct, pc].hash\n end",
"def to_hash\n index_hash = Hash.new\n self.each do |node|\n index_hash[node.node_name] = node.to_s\n end\n index_hash\n end",
"def block_hash\n\t\tdigest = Digest::SHA2.new\n\n\t\tdigest << '%d' % [ self.index ]\n\t\tdigest << self.timestamp.strftime( '%s%N' )\n\t\tdigest << self.payload\n\t\tdigest << self.payload_hash\n\t\tdigest << self.proof.to_s\n\t\tdigest << self.previous_hash\n\t\t\n\t\treturn digest.hexdigest\n\tend",
"def hash\n to_s.hash\n end"
] |
[
"0.6484534",
"0.6447756",
"0.6426405",
"0.61961347",
"0.6160188",
"0.6090646",
"0.60711783",
"0.6063737",
"0.60512066",
"0.60324234",
"0.5993535",
"0.59742177",
"0.59742177",
"0.59742177",
"0.59742177",
"0.59742177",
"0.59742177",
"0.59742177",
"0.5871934",
"0.58716244",
"0.58386314",
"0.5810342",
"0.5802127",
"0.57768375",
"0.57150453",
"0.5705593",
"0.5696327",
"0.5682396",
"0.5663808",
"0.56002283",
"0.5598151",
"0.55898994",
"0.55796164",
"0.55699587",
"0.55442744",
"0.55375075",
"0.5521795",
"0.5513492",
"0.5503069",
"0.54817116",
"0.5481085",
"0.5478189",
"0.5473732",
"0.5466298",
"0.54586965",
"0.54586965",
"0.5455684",
"0.5432795",
"0.54298425",
"0.5418516",
"0.54153395",
"0.54142123",
"0.5412968",
"0.5404839",
"0.5400438",
"0.5397505",
"0.53952307",
"0.53927547",
"0.5385868",
"0.537164",
"0.53702754",
"0.53682053",
"0.53663087",
"0.5359264",
"0.5357891",
"0.53449875",
"0.53383803",
"0.5335813",
"0.5327038",
"0.5318036",
"0.5315425",
"0.53033847",
"0.53032506",
"0.53021",
"0.5292507",
"0.5292507",
"0.5286333",
"0.5284611",
"0.5278508",
"0.5273808",
"0.5269472",
"0.5269472",
"0.5269472",
"0.5266652",
"0.5260448",
"0.5260448",
"0.5260448",
"0.5260448",
"0.5260448",
"0.5260448",
"0.5260448",
"0.5260448",
"0.5260448",
"0.5260448",
"0.5257338",
"0.5256013",
"0.52500194",
"0.52494544",
"0.5248069",
"0.52448195",
"0.52387065"
] |
0.0
|
-1
|
Layout Applies layout information to the source object.
|
def apply_layout(options={})
if object.is_a?(Hash)
object["x"] = x
object["y"] = y
object["width"] = width
object["height"] = height
object["points"] = points
object["label_x"] = label_x
object["label_y"] = label_y
end
nodes.each do |node|
node.apply_layout(options)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def _layout(*_arg0); end",
"def layout()\n layout_children()\n end",
"def layout(layout)\n self._layout = layout\n end",
"def render_layout(output, layout, info); end",
"def do_layout(payload, layouts)\n end",
"def layout=(_arg0); end",
"def layout\n\n raise \"Missing bulletin for layout object!\" if (! self.bulletin)\n \n raise \"Missing layout style/name for layout object!\" if (! self.name)\n\n # assume everything prepared if this is already set (caching!)\n return @layout if (@layout)\n\n # Load layout from the database\n while (! @layout)\n @layout = TempletLayout.find(:first, \n :conditions => ['templet_id = ? AND name = ?', self.bulletin.templet_id, self.name ])\n if !@layout and self.name == 'print'\n # set to main, if print layout not found\n self.name = 'main'\n elsif not @layout\n raise \"Invalid layout selected!\" if (! @layout) \n end\n end\n \n \n # copy the details accross for the layout\n self.filetype = @layout.filetype\n self.charset = @layout.charset\n \n return @layout\n end",
"def layout(name)\n $stderr.puts \"Overwriting Layout: #{self.class.def_layout.inspect} with #{name}\"\n @_layout = name\n end",
"def layout_contents\n layout.render(self)\n end",
"def create_layout\n self.bitmap = Cache.UI(LayoutImage)\n self.x = Graphics.center_width(self.bitmap.width)\n self.y = Graphics.height - self.bitmap.height - 16\n end",
"def apply_layout(options={})\n if object.is_a?(Hash)\n object[\"d\"] = d\n object[\"stroke_width\"] = stroke_width || 1\n object[\"arrowhead_points\"] = arrowhead_points\n object[\"label_x\"] = label_x\n object[\"label_y\"] = label_y\n end\n end",
"def reset_layout layout\n @layout = layout # 2010-02-13 22:23 \n @height = layout[:height]\n @width = layout[:width]\n @top = layout[:top]\n @left = layout[:left]\n end",
"def layout\n yield(monitoring_layout)\n monitoring_layout\n end",
"def layout(new_layout = nil)\n @layout = new_layout if new_layout\n @layout\n end",
"def layout(name=:layout, &block)\n return super(name, &block) if block_given?\n @_layout = name\n end",
"def layout(value = nil)\n if value\n @layout = value\n else\n @layout\n end\n end",
"def layout(method = nil)\n @layout = method || @layout\n end",
"def render_all_layouts(layouts, payload, info)\n renderer.layouts = layouts\n self.output = renderer.place_in_layouts(output, payload, info)\n ensure\n @renderer = nil # this will allow the modifications above to disappear\n end",
"def layout\n yield(layout_for) if block_given?\n layout_for\n end",
"def layout; end",
"def layouts=(_arg0); end",
"def layouts=(_arg0); end",
"def layout\n @layout\n end",
"def layout(&block)\n layout = Layout.new\n layout.instance_eval(&block)\n # return the layout descriptor\n layout\n end",
"def layout(model)\n #Rfm.layout(model.storage_name, options.symbolize_keys) #query.repository.adapter.options.symbolize_keys)\n model.layout\n end",
"def layout\n @current_layout ||= :default_layout\n send(\"#{@current_layout}\"){ yield }\n end",
"def layout\n properties[:layout]\n end",
"def getLayoutData\n @layoutData\n end",
"def set_layout\n @layoutme = 1\n end",
"def do_layout\n _init_layout\n r = @top_margin\n c = @left_margin\n #\n # determine fixed widths and how much is left to share with others,\n # and how many variable width components there are.\n ht = 0 # accumulate fixed height\n fixed_ctr = 0 # how many items have a fixed wt\n var_ctr = 0\n var_wt = 0.0\n @components.each do |e|\n $log.debug \" looping 1 #{e.name} \"\n _tmpwt = cget(e, :weight) || 0\n # what of field and button placed side by side\n if e.is_a? Field or e.is_a? Button or e.is_a? Label\n # what to do here ?\n @wts[e] ||= 1\n ht += @wts[e] || 1\n fixed_ctr += 1\n elsif _tmpwt >= 1\n ht += _tmpwt || 0\n fixed_ctr += 1\n elsif _tmpwt > 0 and _tmpwt <= 1\n # FIXME how to specify 100 % ???\n var_ctr += 1\n var_wt += _tmpwt\n end\n end\n unaccounted = @components.count - (fixed_ctr + var_ctr)\n $log.debug \" unacc #{unaccounted} , fixed #{fixed_ctr} , var : #{var_ctr} , ht #{ht} height #{@height} \"\n balance_ht = @width - ht # use this for those who have specified a %\n balance_ht1 = balance_ht * (1 - var_wt )\n average_ht = (balance_ht1 / unaccounted).floor # give this to those who have not specified ht\n average_ht = (balance_ht1 / unaccounted) # give this to those who have not specified ht\n $log.debug \" #{balance_ht} , #{balance_ht1} , #{average_ht} \"\n # not accounted for gap in heights\n rem = 0 # remainder to be carried over\n @components.each do |e|\n $log.debug \" looping 2 #{e.name} #{e.class.to_s.downcase} \"\n next if @ignore_list.include? e.class.to_s.downcase\n $log.debug \" looping 3 #{e.name} \"\n e.row = r\n e.col = c\n wt = cget(e, :weight)\n if wt\n if wt.is_a? Integer\n e.width = wt\n elsif wt.is_a? Float\n e.width = (wt * balance_ht).floor\n end\n else\n # no wt specified, give average of balance wt\n e.width = average_ht\n hround = e.width.floor\n\n rem += e.width - hround\n e.width = hround\n # see comment in prev block regarding remaininder\n if rem >= 1\n e.width += 1\n rem = 0\n end\n end\n $log.debug \" layout #{e.name} , w: #{e.width} r: #{e.row} , c = #{e.col} \"\n\n e.height = @height\n c += e.width.floor\n c += @gap\n end\n $log.debug \" layout finished \"\n end",
"def update!(**args)\n @layout = args[:layout] if args.key?(:layout)\n @padding = args[:padding] if args.key?(:padding)\n end",
"def layout\n return @layout if @layout\n\n bad_tiles = [] # The set of tile names that didn't work!\n @layout = [] # The 2D array of tiles\n for row in layout_text\n @layout.push(r = [])\n for tile_name in row\n tile = Tile.find_by_name(tile_name)\n r.push(tile)\n # Handle an error by remembering the tile name\n unless tile\n bad_tiles.push(tile_name) unless bad_tiles.include?(tile_name)\n end\n end\n end\n\n # If there was a problem raise the Error.\n unless bad_tiles.empty?\n @layout = nil\n raise Error(\"Bad tiles: %s\" % bad_tiles.join(\", \"))\n end\n @layout\n end",
"def layout\n return @layout if @layout\n\n bad_tiles = [] # The set of tile names that didn't work!\n @layout = [] # The 2D array of tiles\n for row in layout_text\n @layout.push(r = [])\n for tile_name in row\n tile = Tile.find_by_name(tile_name)\n r.push(tile)\n # Handle an error by remembering the tile name\n unless tile\n bad_tiles.push(tile_name) unless bad_tiles.include?(tile_name)\n end\n end\n end\n\n # If there was a problem raise the Error.\n unless bad_tiles.empty?\n @layout = nil\n raise Error(\"Bad tiles: %s\" % bad_tiles.join(\", \"))\n end\n @layout\n end",
"def layout\n lookup_layout\n end",
"def read_layouts\n self.layouts = []\n layouts_dir = File.join(source_path, \"layouts\")\n entries = Dir.entries(layouts_dir).reject{|f| File.directory?(f)}\n entries.each do |name|\n self.layouts << Layout.new(layouts_dir, name)\n end\n end",
"def do_layout\n $log.debug \" inside do_layout\"\n _init_layout\n raise \"please implement this in your subclass \"\n c = @left_margin\n # determine fixed widths and how much is left to share with others,\n # and how many variable width components there are.\n ht = 0 # accumulate fixed height\n fixed_ctr = 0 # how many items have a fixed wt\n var_ctr = 0\n var_wt = 0.0\n @components.each do |e|\n $log.debug \" looping 1 #{e.name} \"\n _tmpwt = @wts[e] || 0\n # what of field and button placed side by side\n if e.is_a? Field or e.is_a? Button or e.is_a? Label\n @wts[e] ||= 1\n ht += @wts[e] || 1\n fixed_ctr += 1\n elsif _tmpwt >= 1\n ht += @wts[e] || 0\n fixed_ctr += 1\n elsif _tmpwt > 0 and _tmpwt <= 1\n # FIXME how to specify 100 % ???\n var_ctr += 1\n var_wt += @wts[e]\n end\n end\n unaccounted = @components.count - (fixed_ctr + var_ctr)\n $log.debug \" unacc #{unaccounted} , fixed #{fixed_ctr} , var : #{var_ctr} , ht #{ht} height #{@height} \"\n balance_ht = @height - ht # use this for those who have specified a %\n balance_ht1 = balance_ht * (1 - var_wt )\n average_ht = (balance_ht1 / unaccounted).floor # give this to those who have not specified ht\n average_ht = (balance_ht1 / unaccounted) # give this to those who have not specified ht\n $log.debug \" #{balance_ht} , #{balance_ht1} , #{average_ht} \"\n # not accounted for gap in heights\n rem = 0 # remainder to be carried over\n @components.each do |e|\n $log.debug \" looping 2 #{e.name} #{e.class.to_s.downcase} \"\n next if @ignore_list.include? e.class.to_s.downcase\n $log.debug \" looping 3 #{e.name} \"\n e.row = r\n e.col = c\n wt = @wts[e]\n if wt\n if wt.is_a? Integer\n e.height = wt\n elsif wt.is_a? Float\n e.height = (wt * balance_ht).floor\n end\n else\n # no wt specified, give average of balance wt\n e.height = average_ht\n hround = e.height.floor\n\n rem += e.height - hround\n e.height = hround\n # see comment in prev block regarding remaininder\n if rem >= 1\n e.height += 1\n rem = 0\n end\n end\n $log.debug \" layout #{e.name} , h: #{e.height} r: #{e.row} , c = #{e.col} \"\n\n e.width = @width\n r += e.height.floor\n r += @gap\n end\n $log.debug \" layout finished \"\n end",
"def layoutify(opts)\n unless opts[:layout].respond_to?(:each)\n opts[:layout] = [opts[:layout]] * @cards.size\n end\n opts[:layout].each_with_index do |layout, i|\n unless layout.nil?\n entry = @layout[layout.to_s]\n unless entry.nil?\n entry.each do |key, value|\n opts[key.to_sym] = [] if opts[key.to_sym].nil?\n opts[key.to_sym][i] ||= entry[key] #don't override if it's already there\n end\n else\n Squib.logger.warn (\"Layout entry '#{layout}' does not exist.\" )\n end\n end\n end\n Squib.logger.debug {\"After layoutify: #{opts}\"}\n opts\n end",
"def process\n self.reset\n self.read_layouts\n\n self.zones = self.read_zones\n # pp self.zones\n\n self.transform_pages\n end",
"def build_layout\n year = Time.now.year\n add_call('Notification des abonnements électroniques', ->() { notifier })\n add_call(\"Extension des abonnements gratuits et d'échange de l'année #{year - 1}\", ->() { freesubs(year - 1) })\n add_call(\"Extension des abonnements gratuits et d'échange de l'année #{year}\", ->() { freesubs(year) })\n add_call('Création d\\'un abonnement collectif', ->() { collective_manager })\n add_call('Exploitation des abonnements collectifs', ->() { collective_exploitation })\n add_call('Recherche des tiers par facture', ->() { billing_manager })\n add_call('(Pour développeur) Fichiers de requête', ->() { sql_files })\n @layout.add_stretch\n end",
"def create_layout_info\n self.piece_layout ||= PieceLayout.create(layout: ImageLayout.create)\n self.part_layout ||= PartLayout.create(layout: ImageLayout.create)\n save\n end",
"def setLayoutData(layoutData)\n @layoutData = layoutData\n end",
"def print_layout # rubocop:disable Metrics/MethodLength\n [{ code: :property_details, # section code\n divider: true, # should we have a section divider\n key: :title, # key for the title translation\n key_scope: %i[returns lbtt_properties about_the_property], # scope for the title translation\n display_title: true, # Is the title to be displayed\n type: :list, # type list = the list of attributes to follow\n list_items: [{ code: :lau_code, lookup: true },\n { code: :full_title_number, action_name: :print },\n { code: :full_parent_title_number },\n { code: :ads_due_ind, lookup: true, when: :flbt_type, is: ['CONVEY'] }] },\n { code: :address,\n key: :title, # key for the title translation\n key_scope: %i[returns lbtt_properties property_address], # scope for the title translation\n type: :object }]\n end",
"def print_layout\n [print_layout_application,\n print_layout_landfill_operator, print_layout_waste_producer,\n print_layout_waste_water_details, print_layout_banned_from_landfill,\n print_layout_about_the_waste, print_layout_about_water_content, print_layout_water_treatment,\n print_layout_start_date,\n { code: :sites,\n type: :object },\n print_layout_supporting_document,\n print_layout_declaration]\n end",
"def layout(layout_width)\n idx, str = 0, ''\n\n #layout_width = 4\n layout_length = object.length - (layout_remainder = object.length % layout_width)\n\n while idx < layout_length - 1 do\n generate_division(layout_width).each do | val |\n # [5, 5].each do | val |\n str += h.render partial: \"layouts/layout_#{val}\", locals: { posts: object.slice(idx, val)}\n idx += val\n end\n end\n\n if layout_remainder > 0\n str += h.render partial: \"layouts/layout_#{layout_remainder}\", locals: { posts: object.slice(idx, layout_remainder)}\n end\n\n str.html_safe\n end",
"def layout\n nil\n end",
"def _init_layout\n # when user gives a negative value, we recalc and overwrite so the need to save, for a redraw.\n @saved_width ||= @width\n @saved_height ||= @height\n\n lines = Ncurses.LINES - 1\n columns = Ncurses.COLS - 1\n if @height_pc\n @height = ((lines - @top_margin - @bottom_margin) * @height_pc).floor\n elsif @saved_height <= 0\n @height = lines - @saved_height - @top_margin - @bottom_margin\n end\n $log.debug \" layout height = #{@height} \"\n if @width_pc\n @width = ((columns - @left_margin - @right_margin) * width_pc).floor\n elsif @saved_width <= 0\n # if width was -1 we have overwritten it so now we cannot recalc it. it remains the same\n @width = columns - @saved_width - @left_margin - @right_margin\n end\n $log.debug \" layout wid = #{@width} \"\n # if user has not specified, then get all the objects\n @components ||= @form.widgets.select do |w| w.visible != false && !@ignore_list.include?(w.class.to_s.downcase); end\n $log.debug \" components #{@components.count} \"\n end",
"def layout_fields\n \n end",
"def place_in_layouts(content, payload, info); end",
"def layout \n return @layout\n end",
"def transition_layout_using(cmd,\n from: self.layout,\n to:,\n src_queue_family: nil,\n dst_queue_family: nil,\n base_mip_level: 0,\n level_count: mip_levels - base_mip_level,\n base_array_layer: 0,\n layer_count: array_layers - base_array_layer,\n aspects: :color)\n access_opts = detect_transition_access_and_stage_flags(from, to)\n cmd.pipeline_image_barrier from_layout: from,\n to_layout: to,\n src_queue_family: src_queue_family,\n dst_queue_family: dst_queue_family,\n image: self,\n aspects: aspects,\n base_mip_level: base_mip_level,\n level_count: level_count,\n base_array_layer: base_array_layer,\n layer_count: layer_count,\n **access_opts\n @layout = to\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 set_layout h,w,t,l\n set_pad_dimensions t,l,h,w\n end",
"def layout=(layout)\n @layout = layout.to_sym\n case @layout\n when :horizontal\n @default_align = :right\n when :vertical\n @default_align = :left\n else\n raise 'Unsupported layout'\n end\n end",
"def layout\n @layout ||= layout_class.new(@rack_context)\n end",
"def _layout_for(name = nil)\n name ||= :layout\n view_flow.get(name).html_safe\n end",
"def layout\n return @layout if @layout\n return if no_layout?\n\n @layout = site.layouts[data.layout].tap do |layout|\n unless layout\n Bridgetown.logger.warn \"Generated Page:\", \"Layout '#{data.layout}' \" \\\n \"requested via #{relative_path} does not exist.\"\n end\n end\n end",
"def layout layout = nil, *actions\n if (layout || layout == false) && configurable?\n @layouts ||= Hash.new\n layout = layout.to_s unless layout == false\n if actions.size == 0\n actions = ['*']\n @master_layout = layout\n end\n actions.each { |a| @layouts[a] = layout }\n end\n @setup[:layouts] ||= @layouts ||\n (@controller.ctrl.slice.view.layout if @controller) || {}\n end",
"def layout_children\n \n end",
"def render_layout(output, layout, info)\n payload[\"content\"] = output\n payload[\"layout\"] = Utils.deep_merge_hashes(layout.data, payload[\"layout\"] || {})\n\n render_liquid(\n layout.content,\n payload,\n info,\n layout.path\n )\n end",
"def initialize(name, cube, extract, layout, options = {})\n super(cube.log)\n @name = name\n @cube = cube\n @extract = extract.is_a?(Extract) ? extract :\n MdxExtract.new(cube, extract, options)\n\n @include_names = options.fetch(:include_names, false)\n @include_aliases = options.fetch(:include_aliases, false)\n @suppress_missing = options.fetch(:suppress_missing, true)\n @suppress_zero = !options.fetch(:suppress_zero, true)\n @filter = options[:filter]\n all_maps = options.fetch(:maps, {})\n\n # Create columns for output/layout\n idx = 0\n @columns = []\n errors = []\n layout.each do |col|\n begin\n ci = Column.new(self, col, all_maps, idx)\n if ci.axis == :row\n if @include_names\n ci_tc = Column.new(self, col, nil, idx)\n @columns << ci_tc\n idx += 1\n end\n if @include_aliases\n ci_al = Column.new(self, col, :alias, idx)\n @columns << ci_al\n idx += 1\n end\n end\n @columns << ci\n @sort_required ||= ci.sort_order\n @filter_required ||= ci.filter_key?\n rescue ArgumentError => ex\n errors << ex.message\n end\n idx += 1\n end\n unless errors.empty?\n raise ArgumentError, \"There are #{errors.size} errors in the report layout:\\n- \" +\n errors.join(\"\\n- \")\n end\n @filter_count = @filter_required && spec.filter\n @row_count = 0\n end",
"def layout=(value)\n return if @default_layout == value && @layout == value\n @default_layout = value\n @layout = value\n refresh\n end",
"def parse_layout(layout)\n layout.collect do |map|\n size = map[:size]\n key = map[:key]\n raise(ArgumentError, \"Missing required :key and :size in: #{map.inspect}\") unless size && key\n\n FixedLayout.new(key, size)\n end\n end",
"def layout_fields\n @options.controls.each do | control |\n label = Label.new(control.name)\n label.rect.topleft = [@fieldX, @fieldY]\n \n button = Button.new(control.to_s) { self.capture_event(control) }\n button.rect.topleft = [ label.rect.right + @spacing, @fieldY ]\n \n # TODO: Like in the original, there's no column creation\n @fieldY = label.rect.bottom + @spacing\n \n self << label\n self << button\n end\n end",
"def render(opts = {}, locs = {}, &block)\n unless opts.key?(:layout)\n\n opts[:layout] = metadata[:options][:layout]\n opts[:layout] = blog_options.layout if opts[:layout].nil? || opts[:layout] == :_auto_layout\n\n # Convert to a string unless it's a boolean\n opts[:layout] = opts[:layout].to_s if opts[:layout].is_a? Symbol\n\n end\n\n content = super(opts, locs, &block)\n\n content.sub!(blog_options.summary_separator, '') unless opts[:keep_separator]\n\n content\n end",
"def print_layout\n [print_layout_header,\n print_layout_ads_date_of_sale, print_layout_ads_main_address,\n print_layout_non_ads_claiming_amount, print_layout_ads_claiming_amount,\n { code: :taxpayers,\n type: :object },\n print_layout_bank_details,\n print_layout_authenticated_declarations,\n print_layout_unauthenticated_declarations]\n end",
"def set_layout\n @layout = Layout.find(params[:id])\n end",
"def wrap_in_layout #:nodoc:\n if @options[:layout]\n ERB.new(@options[:layout]).result(binding)\n else\n yield\n end\n end",
"def layouts; end",
"def layouts; end",
"def render_all_layouts(layouts, payload, info); end",
"def layout\n nil\n end",
"def layout(sugar)\n # otherwise use standard layout for non moved residues?\n remove_layout(sugar)\n do_initial_layout(sugar)\n setup_scaling(sugar)\n seen_residues = do_chain_layout(sugar)\n seen_residues += do_stubs(sugar,seen_residues)\n do_basic_layout(sugar,seen_residues)\n do_box_layout(sugar)\n do_sibling_bunching(sugar)\n do_center_boxes_more(sugar)\n do_sibling_bunching(sugar)\n do_multi_residue_widening(sugar)\n class << sugar\n alias_method :uncondensed_box, :box\n def box\n box_block = lambda { |r|\n ! r.is_stub?\n }\n return uncondensed_box(&box_block)\n end\n end\n \n end",
"def to_html\n @binding = get_binding #use the same binding throughout\n do_include(@layout)\n end",
"def layout(name=:layout, &b)\n template(name, &b)\n end",
"def prototype(*args)\n opts = args.extract_options!\n klass = args.shift || Layout\n\n if klass == Layout\n opts[:parent] ||= self.parent || self\n opts[:image_spec] ||= self.image_spec.try(:clone)\n opts[:name] ||= generate_copy_of_field(:name)\n opts[:template] ||= template\n opts[:region_types] ||= region_types\n else\n opts[:layout] ||= self\n end\n\n opts[:regions] ||= regions.map(&:copy)\n\n klass.new(opts).tap do |object|\n if klass.reflect_on_association(:images)\n object.images = image_specs.map do |image_spec|\n image_spec.image_mounts.build(:owner => object)\n end\n end\n\n if klass.reflect_on_association(:placements)\n object.placements = placeholders.map do |ph| \n ph.placements.build(:owner => object)\n end\n end\n end\n end",
"def _write_layout_method\n case @_layout\n when String\n self.class_eval %{def _layout() #{@_layout.inspect} end}\n when Symbol\n self.class_eval %{def _layout() #{@_layout} end}\n when false\n self.class_eval %{def _layout() end}\n else\n self.class_eval %{\n def _layout\n if view_paths.find_by_parts?(\"#{_implied_layout_name}\", {:formats => formats}, \"layouts\")\n \"#{_implied_layout_name}\"\n else\n super\n end\n end\n }\n end\n end",
"def reformat\n\t\t\tif self.r < self.l\n\t\t\t\t# swap r and l\n\t\t\t\tswap = self.r\n\t\t\t\tself.r = self.l\n\t\t\t\tself.l = swap\n\t\t\tend\n\t\t\tif self.t < self.b\n\t\t\t\t# swap top and bottom\n\t\t\t\tswap = self.t\n\t\t\t\tself.t = self.b\n\t\t\t\tself.b = swap\n\t\t\tend\n\t\tend",
"def place_in_layout?; end",
"def place_in_layout?; end",
"def changes_from(other_layout, node)\n Woodhouse::Layout::Changes.new(self, other_layout, node)\n end",
"def initialize(x, y, w, h, layout = QuestData::DATA_LAYOUT)\n @dest_scroll_oy = 0\n super(x, y, w, h)\n @dest_scroll_oy = self.oy\n self.layout = layout\n end",
"def pre_render\n super\n @selected_indices = @source.selected_indices\n @left_margin = @source.left_margin\n @bg = @source.bgcolor\n @fg = @source.color\n @attr = NORMAL\n @row_focussed_attr ||= $row_focussed_attr\n end",
"def validate_layout(layout); end",
"def default_layout(width=@width, height=@height)\n if @nodes.length > 0\n set_static_nodes(width,height)\n static_wheel_nodes(width,height)\n fruchterman_reingold(100,width,height) #fast, little bit of layout for now\n normalize_graph(width,height)\n #do_kamada_kawai\n else\n @notice = NO_ITEM_ERROR\n end\n end",
"def set_layout(layout)\n case layout\n when Array\n $log.error \"NIL in window constructor\" if layout.include? nil\n raise ArgumentError, \"Nil in window constructor\" if layout.include? nil\n # NOTE this is just setting, and not replacing zero with max values\n @height, @width, @top, @left = *layout\n raise ArgumentError, \"Nil in window constructor\" if @top.nil? || @left.nil?\n\n @layout = { :height => @height, :width => @width, :top => @top, :left => @left }\n when Hash\n @layout = layout\n\n [:height, :width, :top, :left].each do |name|\n instance_variable_set(\"@#{name}\", @layout[name])\n end\n end\n end",
"def load_layouts\n @layouts = []\n data_sources.each do |ds|\n layouts_in_ds = ds.layouts\n layouts_in_ds.each { |i| i.identifier = File.join(ds.layouts_root, i.identifier) }\n @layouts += layouts_in_ds\n end\n\n @layouts_loaded = true\n end",
"def print_layout # rubocop:disable Metrics/MethodLength\n [{ code: :linked_transactions, # section code\n divider: false, # should we have a section divider\n display_title: false, # Is the title to be displayed\n type: :list, # type list = the list of attributes to follow\n list_items: [{ code: :return_reference,\n key_scope: %i[returns lbtt_transactions linked_transactions] },\n { code: :consideration_amount, format: :money, when: :convey, is: [true],\n key_scope: %i[returns lbtt_transactions linked_transactions] },\n { code: :npv_inc, format: :money, when: :convey, is: [false],\n key_scope: %i[returns lbtt_transactions linked_transactions] },\n { code: :premium_inc, format: :money, when: :convey, is: [false],\n key_scope: %i[returns lbtt_transactions linked_transactions] }] }]\n end",
"def show\n\t\tchangeset = @version.changeset.to_h.transform_values{ |values| values.last }#.transform_keys(&:to_sym)\n\t\tversion = @version.reify || @source.class.new\n\t\tversion.assign_attributes( changeset ) unless @version.event == \"destroy\"\n\t\tinstance_variable_set(\"@#{@source.class.name.underscore}\", version )\n\t\tif @source.class == Archiving\n\t\t\t# @documents = @archiving.documents # Deep Copy PaperTrail ?\n\t\t\trender template: 'archivings/show'\n\t\tend\n\t\tif @source.class == Document\n\t\t\t@article = @source.article\n\t\t\trender template: 'documents/show'\n\t\tend\n\tend",
"def configure_layout\n contributable = (@workflow || @pack || @blob)\n layout = nil\n\n # For testing skins\n if params[\"layout_preview\"]\n layout = Conf.layouts[params[\"layout_preview\"]]\n # Skins on resources\n elsif contributable && contributable.contribution && contributable.contribution.policy\n if contributable.contribution.policy.layout\n layout = Conf.layouts[contributable.contribution.policy.layout]\n if layout.nil?\n logger.error(\"Missing layout for #{contributable.class.name} #{contributable.id}: \"+\n \"#{contributable.contribution.policy.layout}\")\n end\n end\n # Skins on groups, or when in a group context\n elsif (network = @network) || (@context.is_a?(Network) && (network = @context))\n layout = network.layout\n end\n\n # Check skin exists\n if layout && layout[\"layout\"] && !File.exists?(\"#{RAILS_ROOT}/app/views/layouts/#{layout[\"layout\"]}.html.erb\")\n logger.error(\"Missing layout #{RAILS_ROOT}/app/views/layouts/#{layout[\"layout\"]}.html.erb\")\n layout = nil\n end\n\n # Use default skin if all else fails\n if layout.nil?\n @layout = {\"layout\" => 'application', \"stylesheets\" => [Conf.stylesheet]}\n else\n @layout = layout\n end\n\n @layout[\"layout\"]\n end",
"def lay_out\n layout = []\n @move_list.each do |move|\n end_point = layout.empty? ? ORIGIN : layout.last.end_point\n layout << Vector.new(end_point, end_point.extend(move))\n end\n layout\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 layout_for(page_range = :all)\n yield(@layout_for[page_range]) if block_given?\n @layout_for[page_range]\n end",
"def inside_layout(layout, &block)\n binding = block.binding if BINDING_REQUIRED\n\n layout = Dir.entries('app/views/layouts').detect { |a| /#{layout}/.match(a) }\n @template.instance_variable_set('@content_for_layout', capture(&block))\n concat(\n @template.render(:file => \"#{RAILS_ROOT}/app/views/layouts/#{layout}\", :user_full_path => true),\n binding\n )\n end",
"def print_layout # rubocop:disable Metrics/MethodLength\n [{ code: :address, # section code\n divider: false, # should we have a section divider\n display_title: true, # Is the title to be displayed\n type: :list, # type list = the list of attributes to follow\n list_items: [{ code: :address_line1 },\n { code: :address_line2, label: false, when: :address_line2, is_not: :nil? },\n { code: :address_line3, label: false, when: :address_line3, is_not: :nil? },\n { code: :address_line4, label: false, when: :address_line4, is_not: :nil? },\n { code: :town },\n { code: :county },\n { code: :postcode }] }]\n end",
"def to_liquid(attrs = nil)\n data['layout'] ||= config.layout(:list)\n super(attrs)\n end",
"def postload\n if @current_layout && @current_layout.length > 0\n @content_for_layout = @body\n @body = \"\"\n render_rhtml(@current_layout)\n end\n end",
"def reapply!\n root ||= self.view\n @layout_state = :reapply\n run_reapply_blocks\n\n @child_layouts.each do |child_layout|\n child_layout.reapply!\n end\n\n @layout_state = :initial\n\n return self\n end",
"def align\n [:owner, :group, :size].each do |field|\n current = @alignment[field]\n @buffer.each do |line|\n new = line[field].length\n current = new if current < new\n end\n @alignment[field] = current\n end\n end",
"def call\n compiled_query = compile_query\n wrap_data(compiled_query ? layout.find(*compiled_query) : layout.all(DEFAULT_REQUEST_OPTIONS))\n end",
"def layout(value = nil)\n if value.nil?\n @layout ||= nil\n @_layout ||= Rendering::LayoutFinder.find(@layout || configuration.layout, configuration.namespace)\n elsif !value\n @layout = Hanami::View::Rendering::NullLayout\n else\n @layout = value\n end\n end"
] |
[
"0.6186296",
"0.6185601",
"0.6100133",
"0.5952073",
"0.57825565",
"0.5782418",
"0.57714653",
"0.5703565",
"0.5666437",
"0.56112254",
"0.55494964",
"0.54733807",
"0.546586",
"0.5426156",
"0.5421659",
"0.535804",
"0.533002",
"0.53151804",
"0.53135353",
"0.5311427",
"0.5254293",
"0.5254293",
"0.52539086",
"0.52485853",
"0.5234335",
"0.520348",
"0.5196775",
"0.5190157",
"0.5145291",
"0.50904876",
"0.5090368",
"0.50769055",
"0.50769055",
"0.50499475",
"0.5036483",
"0.5015659",
"0.50109017",
"0.4995316",
"0.49777976",
"0.4920785",
"0.49059767",
"0.4883965",
"0.4882798",
"0.48580456",
"0.48483306",
"0.484205",
"0.48399764",
"0.48164865",
"0.48126808",
"0.48119137",
"0.47966242",
"0.47926193",
"0.47909656",
"0.4764919",
"0.47620404",
"0.47551242",
"0.4754359",
"0.47510052",
"0.47505128",
"0.47502983",
"0.47498333",
"0.4732387",
"0.47318912",
"0.4730359",
"0.47261116",
"0.47234398",
"0.47220817",
"0.46998477",
"0.46998477",
"0.46922016",
"0.46837538",
"0.467763",
"0.46745747",
"0.4650663",
"0.46413353",
"0.46318355",
"0.46077278",
"0.45964372",
"0.45964372",
"0.459082",
"0.45882332",
"0.45827317",
"0.45816338",
"0.45788807",
"0.45672482",
"0.4565051",
"0.4562113",
"0.45569944",
"0.4550298",
"0.45502624",
"0.4541902",
"0.45303944",
"0.45289257",
"0.45264894",
"0.451916",
"0.4512828",
"0.45110404",
"0.4508738",
"0.44955415",
"0.44912487"
] |
0.614691
|
2
|
Fill billing address on payment tab
|
def fill_billing_address(billing_address)
add_credit_card_form.bl_street_addr_input.set billing_address[:street]
add_credit_card_form.bl_city_input.set billing_address[:city]
# display state option
if page.has_css?('.stateSelect', wait: TimeOut::WAIT_SMALL_CONST)
page.execute_script("$('#stateSelect').css('display','block')")
add_credit_card_form.bl_state_opt.find("option[value='#{billing_address[:state]}']").select_option
end
add_credit_card_form.bl_zip_code_input.set billing_address[:postal]
add_credit_card_form.bl_phone_input.set billing_address[:phone_number]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fill_in_buyer_stripe_form(obj = billing_address_example_data)\n fill_in('account[billing_address][name]', with: obj[:first_name])\n fill_in('account[billing_address][address1]', with: obj[:street_address])\n fill_in('account[billing_address][address2]', with: obj[:extra_address])\n fill_in('account[billing_address][city]', with: obj[:locality])\n find_field('account[billing_address][country]').find(:option, obj[:country_name]).select_option\n fill_in('account[billing_address][state]', with: obj[:region])\n fill_in('account[billing_address][phone]', with: obj[:phone])\n fill_in('account[billing_address][zip]', with: obj[:postal_code])\nend",
"def copy_billing_address\n @fields.select { |k, _| k.start_with? 'HPP_BILLING_' }\n .each do |k, v|\n add_field(\"HPP_SHIPPING_#{k.split('HPP_BILLING_')[1]}\", v)\n end\n end",
"def billing_address(params={})\n add_field(mappings[:billing_address][:zip], params[:zip])\n add_field(mappings[:billing_address][:country], lookup_country_code(params[:country]))\n \n address = [params[:address1], params[:address2], params[:city], params[:state]].compact\n add_field('address', address.join(' '))\n end",
"def populate_billing_address!(options)\n options['contract.default'].billing_address ||= Address.new\n end",
"def copy_billing_address(address)\n self.email_address = address.email_address\n copy_address(:billing, address)\n end",
"def fill_in_checkout_address!\n expect(page).to have_content(IDENTITY)\n\n fill_in 'address[fname]', with: '薇'\n fill_in 'address[lname]', with: '李'\n fill_in 'address[mobile]', with: '13802049742'\n fill_in 'address[pid]', with: '11000019790225207X'\n\n # loop until page.all(:css, '#address_province option')[1]\n # page.all(:css, '#address_province option')[1].select_option\n # loop until page.all(:css, '#address_city option')[1]\n # page.all(:css, '#address_city option')[1].select_option\n # loop until page.all(:css, '#address_district option')[1]\n # page.all(:css, '#address_district option')[1].select_option\n\n fill_in 'address[full_address]', with: STREET\n\n # fill_in 'address[zip]', with: '300222'\n\n page.first('input[type=submit]').trigger('click')\n\n expect(page).to have_content(CHOOSE_EXISTING)\n end",
"def fill_in_address_personal_order\n # if not on the cart page, go there\n (URI.parse(current_url).path == '/cart') ? nil : (visit '/cart')\n # click checkout to start address process\n all(:xpath, '//button[@id=\"checkout-link\"]')[0].click # \"Checkout\"\n #select personal order\n choose 'order_retail_staff_order_detail_attributes__destroy_1'\n # fill in billing/contact info\n fill_in_billing_info_macro(FactoryGirl.create(:bill_address))\n #use same shipping as billing address\n check 'order_use_billing'\n # continue to shipping\n click_button I18n.t('actions.save_and_continue_to_delivery') # \"Continue to Shipping\"\nend",
"def billing_address\n Address.new(\n email_address: email_address,\n company: billing_company,\n full_name: billing_full_name,\n address_line_1: billing_address_line_1,\n address_line_2: billing_address_line_2,\n address_line_3: billing_address_line_3,\n town_city: billing_town_city,\n county: billing_county,\n postcode: billing_postcode,\n country_id: billing_country_id,\n phone_number: billing_phone_number\n )\n end",
"def billing_address_post\n params[:address][:country] = params[:address][:state].split(\"-\")[0]\n params[:address][:state] = params[:address][:state].split(\"-\")[1]\n @address = Address.new(params[:address])\n @address.customer = @customer\n if @address.save\n @cart.billing_address = @address\n @cart.save\n redirect_to build_url_options_for_checkout\n return\n else\n flash[:error] = @address.errors.full_messages.join('<br/>')\n render :action => 'billing_address'\n end\n end",
"def billing_address=(address)\n @billing_address = ensure_type(Address, address)\n end",
"def default_billing_address(options={})\n unless self.billing_address\n self.build_billing_address(options.merge({\n :company_name => self.company_name, :academic_title_id => self.academic_title_id, :gender => self.gender,\n :first_name => self.first_name, :last_name => self.last_name,\n :street => self.business_address.street, :street_number => self.business_address.street_number,\n :note => self.business_address.note, :postal_code => self.business_address.postal_code,\n :city => self.business_address.city, :country_code => self.business_address.country_code,\n :email => self.email}))\n else\n self.billing_address\n end\n end",
"def clone_billing_address\n self.ship_address = self.bill_address if self.bill_address\n end",
"def fill_in_address_non_apartment_order\n # if not on the cart page, go there\n (URI.parse(current_url).path == '/cart') ? nil : (visit '/cart')\n # click checkout to start address process\n all(:xpath, '//button[@id=\"checkout-link\"]')[0].click # \"Checkout\"\n #check for absence of apartment order form\n apartment_order_form_not_present?\n # fill in billing/contact info\n fill_in_billing_info_macro(FactoryGirl.create(:bill_address))\n #use same shipping as billing address\n check 'order_use_billing'\n # continue to shipping\n click_button I18n.t('actions.save_and_continue_to_delivery') # \"Continue to Shipping\"\nend",
"def billing_address\n all = {}\n for key_out in [:fax, :city, :company, :last_name, :country, :zip, :first_name, :address, :email, :state]\n all[key_out] = unescape params['x_' + key_out.to_s]\n end\n all\n end",
"def set_billing_info\n @billing_info = BillingInfo.find(params[:id])\n end",
"def set_billing_info\n @billing_info = BillingInfo.find(params[:id])\n end",
"def set_billing\n @billing = Billing.find(params[:id])\n end",
"def set_billing\n @billing = Billing.find(params[:id])\n end",
"def set_billing\n @billing = Billing.find(params[:id])\n end",
"def billing_address=(billing_address)\n @billing_address = ensure_type(Address, billing_address)\n end",
"def build_billing_address(person=@person)\n if person.billing_address\n person.billing_address.attributes = {\n :country_code => (person.business_address || person.personal_address).country_code,\n :country => (person.business_address || person.personal_address).country,\n }\n else\n person.build_billing_address({\n :academic_title_id => person.academic_title ? person.academic_title_id : nil,\n :gender => person.gender,\n :first_name => person.first_name,\n :last_name => person.last_name,\n :country_code => (person.business_address || person.personal_address).country_code,\n :country => (person.business_address || person.personal_address).country,\n :province_code => (person.business_address || person.personal_address).province_code,\n :province => (person.business_address || person.personal_address).province,\n }.merge((person.business_address || person.personal_address).content_attributes))\n end\n end",
"def billing_address\n all = {}\n [:fax, :city, :company, :last_name, :country, :zip, :first_name, :address, :email, :state].each do |key_out|\n all[key_out] = unescape params['x_' + key_out.to_s]\n end\n all\n end",
"def update_order_addresses\n order = current_order\n if order.bill_address.blank? || order.shipping_address.blank?\n order.bill_address ||= build_bill_address(payment_details_response)\n order.shipping_address ||= build_shipping_address(payment_details_response)\n\n complete_order_step(order, 'address')\n end\n end",
"def enter_billing_address_plus_email(first_name, last_name, address1, city, state_province, zip_postal_code, phone_number, email_address)\n enter_address(first_name, last_name, address1, city, state_province, zip_postal_code, phone_number)\n chkout_email_address_field.value = email_address\n chkout_billing_confirm_email_address_field.value = email_address\n end",
"def enter_billship_address_plus_country(country, first_name, last_name, address1, city, state_province, zip_postal_code, phone_number)\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n chkout_country_selector.value = country\n chkout_first_name_field.value = first_name\n chkout_last_name_field.value = last_name\n chkout_address_1_field.value = address1\n chkout_city_field.value = city\n chkout_select_state.value = state_province\n chkout_zip_code_field.value = zip_postal_code\n chkout_phone_number_field.value = phone_number\n end",
"def billing_address\n default_billing_address ? default_billing_address : shipping_address\n end",
"def billing_address\n default_billing_address ? default_billing_address : shipping_address\n end",
"def billing_info_edit\n result = ChargeBee::Customer.retrieve(@customer_id)\n @customer = result.customer\n @billing_address = result.customer.billing_address\n @country_codes = get_country_codes\n end",
"def billing_person\n build_billing_person\n end",
"def business_details_page_change_business_address(postcode: 'BS1 5AH',\n address: 'HARMSEN GROUP, TRIODOS BANK, DEANERY ROAD, BRISTOL, BS1 5AH')\n\n fill_in 'sPostcode', with: postcode\n click_button 'find_address'\n select address\n business_details_page_submit_business_details_page\n end",
"def payment_address!\n return unless currency.coin?\n record = payment_address\n\n # The address generation process is in progress.\n if record.address.blank?\n record\n else\n # allows user to have multiple addresses.\n payment_addresses.create!(currency: currency)\n end\n end",
"def billing_address=( address ) \n return unless address and address.is_a? Address\n \n duplicate_address = Address.where( frame_id: address.frame_id,\n first_name: address.first_name,\n last_name: address.last_name,\n address_1: address.address_1,\n address_2: address.address_2,\n city: address.city,\n province: address.province,\n country: address.country,\n postal_code: address.postal_code ).first\n \n if duplicate_address\n self.billing_address_id = duplicate_address.id\n else\n address.save\n self.billing_address_id = address.id\n end\n end",
"def billing_address\n @billing_addresses = BillingAddress.all.order('id DESC')\n render :template => \"backend/BillingAddress/billing_address\"\n end",
"def billing_params\n params.require(:billing).permit(:firstname, :lastname, :address, :phone, :city, :state, :country, :email)\n end",
"def add_address(options)\n address = options[:billing_address]\n\n post = {}\n post['Address 1'] = address[:address1] unless empty?(address[:address1])\n post['Address 2'] = address[:address2] unless empty?(address[:address2])\n post['City'] = address[:city] unless empty?(address[:city])\n post['State or Province'] = address[:state] unless empty?(\n address[:state]\n )\n post['ZIP or Postal Code'] = address[:zip] unless empty?(address[:zip])\n post['Country'] = address[:country] unless empty?(address[:country])\n\n post\n end",
"def initialize_billing_addr_params\n #billing address information\n @bill_email = @params[\"BillEmail\"]\n @bill_phone = @params[\"BillPhone\"]\n @bill_city = @params[\"BillCity\"]\n @bill_country_code = @params[\"BillCountryCode\"]\n @bill_line1 = @params[\"BillLine1\"]\n @bill_line2 = @params[\"BillLine2\"]\n @bill_postal_code = @params[\"BillPostalCode\"]\n @bill_state = @params[\"BillState\"]\n @bill_first_name = @params[\"BillFirstName\"]\n @bill_last_name = @params[\"BillLastName\"]\n @bill_address_id = generate_guid\n end",
"def before_payment\n #remove any payments if you are updatind\n # current_order.payments.destroy_all if request.put?\n if current_user\n @order.bill_address ||= Address.default\n @order.bill_address.user = current_user\n else\n @order.bill_address ||= Address.default\n end\n end",
"def set_billing_option\n @billing_option = BillingOption.find(params[:id])\n end",
"def vault_billing_address\n return nil if billing_details.id.nil?\n @gateway.address.find(customer_details.id, billing_details.id)\n end",
"def before_address\n @order.bill_address ||= current_user.try(:bill_address).try(:clone) || Address.new(:country => default_country)\n @order.ship_address ||= current_user.try(:ship_address).try(:clone) || Address.new(:country => default_country)\n end",
"def business_details_page_enter_business_or_organisation_details_manual_postcode_and_submit(companyName: 'Test Company',\n houseNumber: '12', line1: 'Deanery Road',\n line2: 'EA Building', townCity: 'Bristol', postcode: 'BS1 5AH')\n\n click_link 'manual_uk_address'\n fill_in 'registration_companyName', with: companyName\n fill_in 'address_houseNumber', with: houseNumber\n fill_in 'address_addressLine1', with: line1\n fill_in 'address_addressLine2', with: line2\n fill_in 'address_townCity', with: townCity\n fill_in 'address_postcode', with: postcode\n business_details_page_submit_business_details_page\n end",
"def create_order_billing_information(order, new_order, opts={})\n opts[:use_shipping_if_missing_info] ||= true # todo, actually use this value\n\n shipping_country = Country.find_by_iso(order.billing_country || order.shipping_country) || Country.find(Spree::Config[:default_country_id])\n state = State.find_by_name(order.billing_state || order.shipping_state) || # todo this is getting uglier by the minute\n State.find_by_abbr(order.billing_state || order.shipping_state) ||\n State.find_by_name_normalized(order.billing_state ? order.billing_state.gsub(/\\W/, '').downcase : order.shipping_state ? order.shipping_state.gsub(/\\W/, '').downcase : nil) \n\n # add billing information\n first, last = order.billing_name.split(/ /, 2)\n last = first unless last # some people just give a single name\n billing = Address.create(:firstname => first,\n :lastname => last,\n :phone => order.billing_phone_number,\n :email => order.billing_email,\n :country_id => shipping_country.id,\n :address1 => order.billing_address_one || order.shipping_address_one,\n :address2 => order.billing_address_two || order.shipping_address_two,\n :city => order.billing_city || order.shipping_city,\n :state_id => state.id,\n :zipcode => order.billing_zip || order.shipping_zip)\n \n\n # attr_at_xpath :billing_email, \"/BillingData/BuyerEmailAddress\"\n # new_order.bill_address = billing\n billing.addressable = new_order.creditcard_payment\n billing.save_without_validation\n end",
"def payment_address\n return unless currency.coin?\n payment_addresses.last&.enqueue_address_generation || payment_addresses.create!(currency: currency)\n end",
"def update_billing_info\n Validation.validateParameters(params)\n billing_address = params['billing_address']\n begin \n ChargeBee::Customer.update_billing_info(@customer_id, \n :billing_address => billing_address)\n render json: {\n :forward => \"/ssp/subscription\"\n } \n rescue ChargeBee::InvalidRequestError => e\n ErrorHandler.handle_invalid_request_errors(e, self)\n rescue Exception => e\n ErrorHandler.handle_general_errors(e, self)\n end\n\n end",
"def set_billing_plan\n @billing_plan = BillingPlan.find(params[:id])\n end",
"def purchase_options\n {\n :billing_address => {\n :address1 => @address,\n :city => @city,\n :state => @state,\n :country => \"US\",\n :zip => @zip\n }\n }\n end",
"def business_details_page_enter_ltd_business_details_manual_postcode_and_submit(companyNo: '10926928',\n companyName: 'Test Company', houseNumber: '12', line1: 'Deanery Road',\n line2: 'EA Building', townCity: 'Bristol', postcode: 'BS1 5AH')\n\n click_link 'manual_uk_address'\n fill_in 'registration_company_no', with: companyNo\n fill_in 'registration_companyName', with: companyName\n fill_in 'address_houseNumber', with: houseNumber\n fill_in 'address_addressLine1', with: line1\n fill_in 'address_addressLine2', with: line2\n fill_in 'address_townCity', with: townCity\n fill_in 'address_postcode', with: postcode\n business_details_page_submit_business_details_page\n end",
"def billing\n authorize current_user.organization\n if request.get?\n load_receipts\n if current_user.organization.stripe_customer.present?\n @default_card = current_user.organization.default_card\n\n if @default_card.present?\n @masked_card_number = \"**** **** **** #{@default_card.last4}\"\n @button_label = \"Update Credit Card\"\n else\n @button_label = \"Add Credit Card\"\n end\n else\n @button_label = \"Add Credit Card\"\n end\n else\n #{\"stripeToken\"=>\"tok_1DMMCKBtjjIyBvbaLqcBqsD4\", \"stripeTokenType\"=>\"card\", \"stripeEmail\"=>\"user@gmail.com\", \"controller\"=>\"home\", \"action\"=>\"stripe\"}\n if current_user.organization.stripe_customer_id.blank?\n #You do not have to assign a source to create a customer.\n # However, if you set the customer up on a subscription, they will require a source to be available, and the charges will be made to the customer's default_source.\n # If a customer has only one source, it is automatically the default_source.\n customer = Stripe::Customer.create(\n source: params.fetch(:stripeToken),\n email: params.fetch(:stripeEmail)\n )\n organization = current_user.organization\n organization.stripe_customer_id = customer.id\n organization.save!\n else\n #you can also add a new card to an existing customer, using a token:\n customer = Stripe::Customer.retrieve(current_user.organization.stripe_customer_id)\n stripe_card = customer.sources.create(source: params.fetch(:stripeToken))\n\n #Once you have a card assigned to the customer, you can make it the default_source, using this:\n customer.default_source = customer.sources.retrieve(stripe_card.id)\n customer.save\n end\n\n # so that you can't simulate same POST request multiple times(stripeToken must be unique)\n redirect_to profile_billing_path\n end\n end",
"def payment_format_address(payment)\n address = ''\n return address.html_safe if payment.nil?\n address << \"<address><strong>#{payment.firstname} #{payment.lastname}</strong><br />\"\n address << \"#{payment.unit} - \" if payment.unit && payment.unit.length > 0\n address << \"#{payment.address1}<br />\"\n address << \"#{payment.address2}<br />\" if payment.address2 && payment.address2.length > 0\n address << \"#{payment.city}, #{payment.province}, #{Carmen::Country.coded(payment.country).name}<br />#{payment.postal_code}</address>\"\n address.html_safe\n end",
"def shipping_address_edit\n @shipping_address = retrieve_shipping_address(@subscription_id)\n @country_codes = get_country_codes\n end",
"def fill_location_data(user)\n puts \"Inputing address 1: '#{adr1 = user.pay_card.adress_1}'\"\n get_elem_and_fill(:id, 'sa.nameAddressLine1', adr1)\n puts \"Inputing address 2: '#{adr2 = user.pay_card.adress_2}'\"\n get_elem_and_fill(:id, 'sa.nameAddressLine2', adr2)\n # fills city\n get_elem_and_fill(:id, 'sa.nameCity', user.pay_card.city)\n puts \"Inputing zip: '#{zip = user.pay_card.zip}'\"\n get_elem_and_fill(:id, 'sa.namePostcode', zip)\n puts \"Selecting country: '#{country = user.pay_card.country}'\"\n select_item_from_list(:xpath, \"//select[@id='sa.nameCountry']\", country)\n end",
"def set_address\n @address = Address.find_by(id: params[:id], user_profile_id: current_user.user_profile_id)\n end",
"def customer_billing_address(address)\n address_str=\"\"\n unless address.blank?\n address_str+=\"<p></p><p>#{address.address_line1}</p>\" unless address.address_line1.blank?\n address_str+=\"<p>City-#{address.city}</p>\" unless address.city.blank?\n address_str+=\"<p>State-#{address.state}</p>\" unless address.state.blank?\n address_str+=\"<p>Country-#{address.country}</p>\" unless address.country.blank?\n address_str+=\"<p>Postal code-#{address.postal_code}</p>\" unless address.postal_code.blank?\n end\n address_str.html_safe\n end",
"def set_address\n end",
"def payment_params\n params.require(:payment).permit(:customer_id, :visit_id, :method, :credit_card_no, :paid, :paid_at, billing_address_attributes: [ :street1, :street2, :city, :state, :zip, :name_on_card ])\n end",
"def business_details_page_enter_ltd_business_details_postcode_lookup_and_submit(companyNo: '10926928',\n companyName: 'Test Company', postcode: 'BS1 5AH',\n address: 'NATURAL ENGLAND, HORIZON HOUSE, DEANERY ROAD, BRISTOL, BS1 5AH')\n\n fill_in 'registration_company_no', with: companyNo\n fill_in 'registration_companyName', with: companyName\n fill_in 'sPostcode', with: postcode\n click_button 'find_address'\n select address\n business_details_page_submit_business_details_page\n end",
"def filling_address_info\n\t#find and select address type=House\n find(:id, 'Address_Type_Select').click\n find(\"option[value='House']\").click\n\t#find and fill out Street Address\n find(:id, 'Street').click\n fill_in('Street Address', :with => '9750 Jones Branch Dr')\n\t#find and fill out City\n\tfind(:id, 'City').click\n\tfill_in('City', :with => 'McLean')\n\t#find and select State=VA\n\tselect('VA', from: 'Region')\n\tfind(:id, 'Postal_Code').click\n\tfill_in('Zip Code', :with => '22107-0002')\nend",
"def set_shipping_address(address)\n @fields.merge!(address.to_hash)\n end",
"def setup_address_hash(options)\n default_address = {\n address1: 'Unspecified',\n city: 'Unspecified',\n state: 'NC',\n zip: '00000',\n country: 'US'\n }\n\n submitted_address = options[:billing_address] || options[:address] || default_address\n options[:billing_address] = default_address.merge(submitted_address.symbolize_keys) { |_k, default, submitted| check_billing_field_value(default, submitted) }\n options[:shipping_address] = options[:shipping_address] || {}\n end",
"def set_completed_address\n if self.street && self.number\n address = \"#{ self.street }, #{ self.number }\"\n\n unless self.complement.blank?\n address += \", #{ self.complement }\"\n end\n\n if self.neighborhood\n address += \", #{ self.neighborhood }\"\n end\n\n if self.city && self.city.state\n address += \", #{ self.city.name } - #{ self.city.state.name }\"\n end\n\n address += \" - Brasil\"\n\n self.completed = address\n end\n end",
"def set_address\n @customer_ship_address = CustomerShipAddress.find(params[:id])\n end",
"def change_address_payment_page_link\n $tracer.trace(__method__)\n #unit_test_no_generate: change_address_payment_page_link, a.className(create_ats_regex_string(\"ats-editbillingaddr\"))\n return ToolTag.new(a.className(create_ats_regex_string(\"ats-editbillingaddr\")), __method__, self)\n end",
"def shipping_address_post\n params[:address][:country] = params[:address][:state].split(\"-\")[0]\n params[:address][:state] = params[:address][:state].split(\"-\")[1]\n @address = Address.new(params[:address])\n @address.customer = @customer\n if @address.save\n @cart.shipping_address = @address\n unless @cart.billing_address\n @cart.billing_address = @address\n end\n if @cart.save\n redirect_to build_url_options_for_checkout\n return\n end\n else\n flash[:error] = @address.errors.full_messages.join('<br/>')\n render :action => 'shipping_address'\n end\n end",
"def set_billing_site\r\n @billing_site = BillingSite.find(params[:id])\r\n end",
"def account_address(address_details)\n self.address = Address.new(\n address_line1: address_details[:address_line1], address_line2: address_details[:address_line2],\n address_line3: address_details[:address_line3], address_line4: address_details[:address_line4],\n town: address_details[:address_town_or_city], county: address_details[:address_county_or_region],\n postcode: address_details[:address_postcode_or_zip], country: address_details[:address_country_code]\n )\n end",
"def set_for_postcode_search\n @show_manual_address = false\n @address_read_only = false\n @address_summary.postcode = ''\n @address_detail = Address.new(default_country: params[:address][:default_country])\n end",
"def new\n \t@order = current_order\n @shipping_address = ShippingAddress.new\n @order.update(status: \"filling in shipping address\")\n end",
"def billing\n request('billing', :get)\n end",
"def create\n @billing_address = BillingAddress.new(params[:billing_address])\n\n respond_to do |format|\n if @billing_address.save\n format.html { redirect_to @billing_address, notice: 'Billing address was successfully created.' }\n format.json { render json: @billing_address, status: :created, location: @billing_address }\n else\n format.html { render action: \"new\" }\n format.json { render json: @billing_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def fill_in_with_multiple_addresses!\n expect(page).to have_content(CHOOSE_EXISTING)\n page.first('#button-new-address').trigger('click')\n fill_in_checkout_address!\n page.first('.addresses__address-use a').trigger('click')\n end",
"def full_address\n merchant.street + \", \" + merchant.city + \", \" + merchant.state + \" \" + merchant.zip\n end",
"def get_billing_information(data)\n {\n :first_name => data[:first_name],\n :last_name => data[:last_name],\n :email_address => data[:email_address],\n\n :street_address => data[:address][:street_address],\n :secondary_address => data[:address][:secondary_address],\n :city => data[:address][:city],\n :state => data[:address][:state],\n :zip => data[:address][:zip_code],\n :country => data[:address][:country],\n :phone_number => data[:phone_number]\n }\n end",
"def set_BillingPeriod(value)\n set_input(\"BillingPeriod\", value)\n end",
"def set_account_address\n @account_address = AccountAddress.find(params[:id])\n end",
"def billing\n @data[:billing]\n end",
"def billing_params\n params.require(:billing).permit(:accounted_at, :client_id, :payment_method_id)\n end",
"def paid(order)\n @order = order\n\n mail :to => order.billing_address.email\n end",
"def add_address(post, options)\n if address = options[:billing_address] || options[:address]\n post[:ci_billaddr1] = address[:address1]\n post[:ci_billaddr2] = address[:address2] if address[:address2]\n post[:ci_billcity] = address[:city]\n post[:ci_billstate] = address[:state]\n post[:ci_billzip] = address[:zip]\n post[:ci_billcountry] = address[:country]\n end\n\n if address = options[:shipping_address]\n post[:ci_shipaddr1] = address[:address1]\n post[:ci_shipaddr2] = address[:address2] if address[:address2]\n post[:ci_shipcity] = address[:city]\n post[:ci_shipstate] = address[:state]\n post[:ci_shipzip] = address[:zip]\n post[:ci_shipcountry] = address[:country]\n end\n end",
"def set_street_address_1_save\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:street_address_1, @customer.street_address_1)\n end",
"def enter_address(first_name, last_name, address1, city, state_province, zip_postal_code, phone_number)\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n chkout_first_name_field.value = first_name\n chkout_last_name_field.value = last_name\n chkout_address_1_field.value = address1\n chkout_city_field.value = city\n chkout_select_state.value = state_province\n chkout_zip_code_field.value = zip_postal_code\n chkout_phone_number_field.value = phone_number\n end",
"def update!(**args)\n @billing_account = args[:billing_account] if args.key?(:billing_account)\n end",
"def order_billing_address_lines\n order.bill_address.try(:full_address_array)\n end",
"def set_address\n\t\t@address = Contact.find(params[:contact_id]).address\n\tend",
"def set_street_address_1_update\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:street_address_1, @customer.street_address_1)\n end",
"def associate_address\n order = Spree::Order.where(\"email = ?\", @user.email).order(\"created_at\").last\n if order.present?\n @user.update_attributes(bill_address_id: order.billing_address.id, ship_address_id: order.shipping_address.id)\n end\n end",
"def purchase_options\n {\n :ip => ip_address,\n :billing_address => {\n :name => name,\n :address1 => address,\n :city => city,\n :state => state,\n :country => country,\n :zip => zip\n }\n }\n end",
"def add_address(request, address)\r\n return if address.nil?\r\n request.Set(RocketGate::GatewayRequest::BILLING_ADDRESS, address[:address1])\r\n request.Set(RocketGate::GatewayRequest::BILLING_CITY, address[:city])\r\n request.Set(RocketGate::GatewayRequest::BILLING_ZIPCODE, address[:zip])\r\n request.Set(RocketGate::GatewayRequest::BILLING_COUNTRY, address[:country])\r\n\r\n#\r\n#\tOnly add the state if the country is the US or Canada.\r\n#\t \r\n if address[:state] =~ /[A-Za-z]{2}/ && address[:country] =~ /^(us|ca)$/i\r\n request.Set(RocketGate::GatewayRequest::BILLING_STATE, address[:state].upcase)\r\n end\r\n end",
"def new\n # customer creates a new shipping address\n end",
"def postfill!(customer)\n self.price = customer.subscription.plan.amount / 100\n self.stripe_id = customer.id\n self.exp_month = customer.active_card.exp_month\n self.exp_year = customer.active_card.exp_year\n self.last4 = customer.active_card.last4\n self.status = \"active\"\n self.save!\n self\n end",
"def address\n load_step # Need to load the account to make the decision\n if AccountType.other_organisation?(@account.account_type)\n # Uses overrides as the address is at address.company not at company\n wizard_address_step(STEPS, address_attribute: :org_address,\n next_step: :address_next_step)\n elsif AccountType.registered_organisation?(@account.account_type)\n wizard_address_step(STEPS, address_not_required: :reg_company_contact_address_yes_no,\n next_step: :address_next_step)\n else # must be individual\n wizard_address_step(STEPS, next_step: :address_next_step)\n end\n end",
"def billing!\n ready! && save!\n end",
"def billing_info_params\n params.require(:billing_info).permit(:active, :contact, :name, :rut, :address, :sector, :email, :phone, :accept, :company_id)\n end",
"def enter_int_address(country, first_name, last_name, address1, city, zip_postal_code, phone_number, email_address)\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n chkout_country_selector.value = country\n chkout_first_name_field.value = first_name\n chkout_last_name_field.value = last_name\n chkout_address_1_field.value = address1\n chkout_city_field.value = city\n chkout_zip_code_field.value = zip_postal_code\n chkout_phone_number_field.value = phone_number\n chkout_email_address_field.value = email_address\n chkout_confirm_email_address_field.value = email_address\n end",
"def fake_address\n {\n first_name: 'Jack',\n last_name: 'Macdowall',\n company_name: 'Macdowalls',\n line_1: '1225 Invention Avenue',\n line_2: 'Birmingham',\n postcode: 'B21 9AF',\n county: 'West Midlands',\n country: 'UK'\n }\n end",
"def payment_customer_address\n\t\t\t\t\tif self.billing_address.is_a?(String)\n\t\t\t\t\t\tparsed_address = self.class.parse_address(self.billing_address)\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tstreet: parsed_address[3],\n\t\t\t\t\t\t\tnumber: parsed_address[4],\n\t\t\t\t\t\t\tcity: parsed_address[2],\n\t\t\t\t\t\t\tzipcode: parsed_address[1]\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\treturn self.billing_address # We expect hash containing :street, :number, :city and :zipcode keys\n\t\t\t\t\tend\n\t\t\t\tend",
"def create\n @address = @company.addresses.build(address_params) \n\n respond_to do |format|\n if @address.save\n # If this is first address, set as bill and ship address\n @company.billaddress ||= @address.id\n @company.shipaddress ||= @address.id\n @company.save!\n\n format.html { redirect_to edit_company_path(@company), notice: 'Address was successfully created.' }\n format.json { render :show, status: :created, location: @address }\n else\n format.html { render :new }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def clone_shipping_address\n if Spree::AddressBook::Config[:show_bill_address_on_cc_form] == false\n if self.ship_address\n self.bill_address = self.ship_address\n end\n else\n if self.bill_address_id == nil\n self.bill_address = self.ship_address\n end\n end\n true\n end",
"def create_frontend_address(user, expect_success, values, default_bill=nil, default_ship=nil)\n visit spree.account_path\n click_link I18n.t(:add_new_address, :scope => :address_book)\n expect(current_path).to eq(spree.new_address_path)\n\n fill_in_address(values)\n check_frontend_defaults(default_bill, default_ship)\n\n click_button Spree.t(:create)\n\n if expect_success\n expect(page).to have_content(Spree.t(:successfully_created, :resource => Spree.t(:address1)))\n expect(current_path).to eq(spree.account_path)\n expect_frontend_addresses(user)\n else\n expect(page).to have_no_content(Spree.t(:successfully_created, :resource => Spree.t(:address1)))\n end\n end",
"def bill_to_existing\n address = Address.find params[:id]\n unless address.customer_id.eql?(@customer.id)\n redirect_to :controller=>'cart', :action=>'billing_address'\n return\n end\n @cart.billing_address = address\n @cart.save\n redirect_to build_url_options_for_checkout\n end",
"def enter_cust_info(first_name,last_name,address_line1,address_line2,city,zip_code,phone_no)\n sleep 5\n @browser.text_field(id: 'rc-shipping-firstName').set(first_name)\n sleep 5\n @browser.text_field(id: 'rc-shipping-lastName').set(last_name)\n sleep 5\n @browser.text_field(id: 'rc-shipping-line1').set(address_line1)\n sleep 5\n @browser.text_field(id: 'rc-shipping-line2').set(address_line2)\n sleep 5\n @browser.text_field(id: 'rc-shipping-city').set(city)\n sleep 5\n @browser.option(value: 'AK').click\n sleep 5\n @browser.text_field(id: 'rc-shipping-postal-code').set(zip_code)\n sleep 5\n @browser.text_field(id: 'rc-shipping-phone').set(phone_no)\nend"
] |
[
"0.7463737",
"0.73818403",
"0.7241998",
"0.723517",
"0.7148776",
"0.71184134",
"0.7043155",
"0.6992645",
"0.68744665",
"0.6874304",
"0.6826245",
"0.6780723",
"0.6763353",
"0.6748353",
"0.6735298",
"0.6735298",
"0.6727876",
"0.6727876",
"0.6727876",
"0.67195237",
"0.6714171",
"0.6711898",
"0.6680552",
"0.66355014",
"0.66240406",
"0.6616094",
"0.6616094",
"0.65739524",
"0.65708244",
"0.6527935",
"0.65260655",
"0.6496429",
"0.6400594",
"0.63808846",
"0.6371485",
"0.63529277",
"0.6301162",
"0.62882507",
"0.6237873",
"0.6235859",
"0.62355053",
"0.61969084",
"0.6184728",
"0.61748755",
"0.61471975",
"0.6133213",
"0.6126213",
"0.61216116",
"0.6112493",
"0.6072824",
"0.6070021",
"0.6054216",
"0.605315",
"0.6046094",
"0.60341287",
"0.60311097",
"0.60300785",
"0.6012835",
"0.6008014",
"0.60021573",
"0.59924144",
"0.59860253",
"0.5973519",
"0.5968155",
"0.59611315",
"0.59610224",
"0.5953137",
"0.59325266",
"0.59270346",
"0.59257275",
"0.5925041",
"0.5916443",
"0.59121495",
"0.59089863",
"0.59089106",
"0.58997273",
"0.5896058",
"0.5887899",
"0.5887111",
"0.5875886",
"0.58737296",
"0.5863958",
"0.5857583",
"0.5854196",
"0.58359",
"0.58262193",
"0.58240026",
"0.5811004",
"0.58086234",
"0.57977337",
"0.5797386",
"0.57954687",
"0.57894534",
"0.5771103",
"0.5770964",
"0.5768053",
"0.57678145",
"0.5766666",
"0.57660365",
"0.57622063"
] |
0.80183905
|
0
|
Add credit card on payment tab Return review tab
|
def add_credit_card(credit_card, billing_address = nil)
add_credit_card_form.card_number_input.set credit_card[:card_number]
add_credit_card_form.name_on_card_input.set credit_card[:card_name]
# display expiration month option
page.execute_script("$('#vin_PaymentMethod_creditCard_expirationDate_Month').css('display','block')")
add_credit_card_form.expiration_month_opt.select credit_card[:exp_month]
# display expiration year option
page.execute_script("$('#vin_PaymentMethod_creditCard_expirationDate_Year').css('display','block')")
add_credit_card_form.expiration_year_opt.select credit_card[:exp_year]
add_credit_card_form.security_code_input.set credit_card[:security_code]
if billing_address.nil?
if add_credit_card_form.has_shipping_checked_chk?
add_credit_card_form.use_shipping_address_chk.click
else
add_credit_card_form.use_shipping_address_as_billing_address.click
end
else
fill_billing_address(billing_address)
end
# submit info
add_credit_card_form.continue_btn.click
AtgCheckOutReviewPage.new
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_new_credit_card(name = 'LTRC DN', cardnumber = '5111005111051128', exp_month = '01', exp_year = '2017', cvv = '123', country = 'US')\n wait_for_ajax\n # open add new credit card popup\n billing_section.add_new_credit_card_lnk.click\n\n wait_for_ajax\n # fill information\n add_new_credit_cart_popup.card_holder_name_input.set name\n add_new_credit_cart_popup.card_number_input.set cardnumber\n add_new_credit_cart_popup.exp_month_input.set exp_month\n add_new_credit_cart_popup.exp_year_input.set exp_year\n add_new_credit_cart_popup.cvv_input.set cvv\n add_new_credit_cart_popup.country_input.set country\n\n # fill billing info\n add_new_credit_cart_popup.address_input.set Data::ADDRESS1_CONST\n add_new_credit_cart_popup.city_input.set Data::CITY_CONST\n add_new_credit_cart_popup.state_input.set Generate.state_name(Data::STATE_CODE_CONST)\n add_new_credit_cart_popup.zip_input.set Data::ZIP_CONST\n add_new_credit_cart_popup.phone_input.set Data::PHONE_CONST\n\n # submit information\n add_new_credit_cart_popup.submit_btn.click\n\n # sleep to work around with problem at popup cannot close after submiting info\n sleep 5\n execute_script(\"document.getElementById('myCsrAddCreditCardFloatingPane').removeAttribute('style');\")\n wait_for_add_new_credit_cart_popup(TimeOut::WAIT_MID_CONST)\n execute_script(\"document.getElementsByClassName('dijitDialogUnderlayWrapper')[0].setAttribute('style','display:none');\")\n execute_script(\"document.getElementsByClassName('dijitDialogUnderlayWrapper')[1].setAttribute('style','display:none');\")\n wait_for_ajax\n finalize_btn.click\n wait_for_ajax\n end",
"def add_creditcard(post, creditcard)\n post[:ccname] = \"#{creditcard.first_name} #{creditcard.last_name}\"\n post[:ccnum] = creditcard.number\n post[:cvv2] = creditcard.verification_value if creditcard.verification_value?\n post[:expmon] = creditcard.month\n post[:expyear] = creditcard.year\n end",
"def add_creditcard(request, creditcard)\r\n\r\n cardNo = creditcard.number\r\n cardNo.strip!\r\n if ((cardNo.length == 44) || (cardNo =~ /[A-Z]/i) || (cardNo =~ /\\+/) || (cardNo =~ /\\=/))\r\n request.Set(RocketGate::GatewayRequest::CARD_HASH, creditcard.number)\r\n else\r\n request.Set(RocketGate::GatewayRequest::CARDNO, creditcard.number)\r\n request.Set(RocketGate::GatewayRequest::CVV2, creditcard.verification_value)\r\n request.Set(RocketGate::GatewayRequest::EXPIRE_MONTH, creditcard.month)\r\n request.Set(RocketGate::GatewayRequest::EXPIRE_YEAR, creditcard.year)\r\n request.Set(RocketGate::GatewayRequest::CUSTOMER_FIRSTNAME, creditcard.first_name)\r\n request.Set(RocketGate::GatewayRequest::CUSTOMER_LASTNAME, creditcard.last_name)\r\n end\r\n end",
"def select_credit_card\n chooses \"credit card\"\n clicks_button \"Continue\"\n end",
"def add_credit_card(xml, creditcard)\n xml.tag!(\"CARD\") do\n xml.tag! 'CARDCODE', creditcard.verification_value if creditcard.verification_value?\n xml.tag! 'CARDNUMBER', creditcard.number\n xml.tag! 'EXPDATE', expdate(creditcard)\n end\n end",
"def get_credit_card\n end",
"def payment_type\n :credit_card\n end",
"def new_credit_card\n # populate new card with some saved values\n ActiveMerchant::Billing::CreditCard.new(\n :first_name => user.first_name,\n :last_name => user.last_name,\n # :address etc too if we have it\n :brand => cc_type\n )\n end",
"def payment\n {\n :credit_card => credit_card\n }\n end",
"def payment_type\n :credit_card\n end",
"def credit_details\n wrap_with :div, class: \"d-flex\" do\n [\n nest(card.value_card, view: :credit),\n link_to_card(card, menu_icon, path: { view: :edit }, class: \"text-dark ml-auto\")\n ]\n end\n end",
"def add_credit_card\n\n get_balanced_key\n card_uri = params[:card_uri]\n\n company_name = \"Mindfire Solutions\"\n customer = Balanced::Customer.new({name: company_name}).save\n customer_uri = customer.href\n get_customer = Balanced::Customer.fetch(customer_uri)\n card = Balanced::Card.fetch(card_uri)\n card.associate_to_customer(customer_uri)\n \n\n amount_in_dollars = params[:amount].to_i\n #amount_in_dollars * 100 convert into cents\n\n debit = card.debit(:amount => amount_in_dollars * 100, appears_on_statement_as: \"Debit Amount\")\n \n ##You can save the response in your db for future use\n #debit.transaction_number\n #debit.amount\n #debit.statusdebit.created_at\n \n #get the balanced market place\n marketplace = Balanced::Marketplace.my_marketplace\n \n credit = get_marketplace_bank_account.credit(:amount => debit.amount, appears_on_statement_as: \"Credit Amount\")\n\n\n return render json: {success: [\"Debit Transaction:: #{debit.attributes}\", \"Credit Transaction:: #{credit.attributes}\"] }\n\n end",
"def set_credit_card\n @credit_card = current_user.credit_cards.find(params[:id])\n end",
"def create\n creditcard = @payment_presenter.creditcard\n creditcard.address = @payment_presenter.address\n creditcard.order = @order\n \n begin\n creditcard.authorize(@order.total)\n rescue Spree::GatewayError => ge\n flash.now[:error] = \"Authorization Error: #{ge.message}\"\n render :action => \"new\" and return \n end\n creditcard.save\n @order.next!\n redirect_to checkout_order_url(@order)\n end",
"def add_account(xml, credit_card)\n xml.Account do\n xml.Holder credit_card.name\n xml.Number credit_card.number\n xml.Brand credit_card.brand.upcase\n xml.Expiry(:month => credit_card.month, :year => credit_card.year)\n xml.Verification credit_card.verification_value\n end\n end",
"def fill_credit_card_data\n fill_in 'Name on card', with: 'Spree Commerce'\n # set the fields with javascript\n page.execute_script \"$('#cielo_card_number').val('4111111111111111');\"\n page.execute_script \"$('#card_expiry').val('04 / 20');\"\n # javascript para executar a funcao que faz a requisicao a api\n # trazendo o numero de parcelas de acordo com o tipo de cartao\n page.execute_script \"obj = new window.CieloCredit({param_prefix: 'payment_source[1]', total_order: '10.0', currency: 'usd'}); obj.setCreditCard();\"\n fill_in 'Card Code', with: '123'\n choose '1x of $10.00'\n # confirm payment method\n click_button 'Save and Continue'\nend",
"def set_credit_card\n @credit_card = CreditCard.find(params[:id])\n end",
"def set_credit_card\n @credit_card = CreditCard.find(params[:id])\n end",
"def credit(money, creditcard_or_credit_card_id, options = {})\n post = {}\n add_address(post, options)\n add_custom(post, options)\n add_invoice(post, options)\n add_payment_source(post, creditcard_or_credit_card_id, options)\n\n commit(post[:userprofileid] ? :profile_credit : :ns_credit, money, post)\n end",
"def set_credit_card\n @credit_card = CreditCard.find(params[:id])\n end",
"def set_creditcard\n @creditcard = Creditcard.find(params[:id])\n end",
"def process_card(card_data) # card_dat --> hash con toda la informacion de l tarjeta de credito\n\t\toptions = payment_options #options es todo el hash \n\t\toptions[:payer][:payment_method] = \"credit_card\"\n\t\toptions[:payer][:funding_instruments] = [{\n\t\t\tcredit_card: {\n\t\t\t\ttype: CreditCardValidator::Validator.card_type(card_data[:number]), #visa, mastercard\n\t\t\t\tnumber: card_data[:number], #numero de la cuenta\n\t\t\t\texpire_month: card_data[:expire_month],\n\t\t\t\texpire_year: card_data[:expire_year],\n\t\t\t\tcvv2: card_data[:cvv2]\n\t\t\t}\n\t\t}]\n\t\tself.payment = Payment.new(options)\n\t\tself.payment\n\tend",
"def credit_card(params = {})\n brand = params[:brand].to_sym\n params.delete(:brand)\n\n exp_month = sprintf(\"%.2i\", Integer(params[:expiry_month], 10))\n exp_year = sprintf(\"%.4i\", Integer(params[:expiry_year], 10))\n params.delete(:expiry_month)\n params.delete(:expiry_year)\n\n method_missing(:credit_card, params)\n\n # The expiration data needs to be combined together\n exp = \"#{exp_year[-2..-1]}#{exp_month}\"\n add_field(mappings[:credit_card][:expiry_month], exp)\n\n # Map the card type to what Migs is expecting\n if params[:number] =~ ELECTRON\n brand_name = 'VisaDebit'\n else\n brand_name = {\n :visa => 'Visa',\n :master => 'Mastercard',\n :american_express => 'Amex',\n :diners_club => 'Dinersclub',\n :jcb => 'JCB',\n :solo => 'Solo'\n }[brand]\n end\n\n add_field(mappings[:credit_card][:brand], brand_name)\n end",
"def billing\n authorize current_user.organization\n if request.get?\n load_receipts\n if current_user.organization.stripe_customer.present?\n @default_card = current_user.organization.default_card\n\n if @default_card.present?\n @masked_card_number = \"**** **** **** #{@default_card.last4}\"\n @button_label = \"Update Credit Card\"\n else\n @button_label = \"Add Credit Card\"\n end\n else\n @button_label = \"Add Credit Card\"\n end\n else\n #{\"stripeToken\"=>\"tok_1DMMCKBtjjIyBvbaLqcBqsD4\", \"stripeTokenType\"=>\"card\", \"stripeEmail\"=>\"user@gmail.com\", \"controller\"=>\"home\", \"action\"=>\"stripe\"}\n if current_user.organization.stripe_customer_id.blank?\n #You do not have to assign a source to create a customer.\n # However, if you set the customer up on a subscription, they will require a source to be available, and the charges will be made to the customer's default_source.\n # If a customer has only one source, it is automatically the default_source.\n customer = Stripe::Customer.create(\n source: params.fetch(:stripeToken),\n email: params.fetch(:stripeEmail)\n )\n organization = current_user.organization\n organization.stripe_customer_id = customer.id\n organization.save!\n else\n #you can also add a new card to an existing customer, using a token:\n customer = Stripe::Customer.retrieve(current_user.organization.stripe_customer_id)\n stripe_card = customer.sources.create(source: params.fetch(:stripeToken))\n\n #Once you have a card assigned to the customer, you can make it the default_source, using this:\n customer.default_source = customer.sources.retrieve(stripe_card.id)\n customer.save\n end\n\n # so that you can't simulate same POST request multiple times(stripeToken must be unique)\n redirect_to profile_billing_path\n end\n end",
"def set_credit_card\n @credit_card = CreditCard.find(params[:id])\n end",
"def assign_default_credit_card\n true\n end",
"def show\n @payment = Payment.new\n @creditcard = ActiveMerchant::Billing::CreditCard.new\n \n end",
"def new\n @credit_card = ActiveMerchant::Billing::CreditCard.new\n end",
"def add_creditcard(parameters, creditcard)\n parameters[:CardNo] = creditcard.number\n parameters[:Expire] = expdate(creditcard)\n parameters[:SecurityCode] = creditcard.verification_value\n\n # The GMO API doesn't have name fields, so we add them to the client field\n parameters[:ClientField1] = \"#{creditcard.first_name} #{creditcard.last_name} #{parameters[:ClientField1]}\".strip\n end",
"def credit_card\n @card ||= card.credit_card(store, cvv) if card && store\n logger.debug \"credit card: #{@card.inspect}\"\n logger.debug \"card: #{card.inspect}\"\n @card\n end",
"def add_payment_source(post, credit_card_or_card_id, options)\n if credit_card_or_card_id.is_a?(ActiveMerchant::Billing::CreditCard)\n add_creditcard(post, credit_card_or_card_id)\n else\n post[:userprofileid] = credit_card_or_card_id[0...-4]\n post[:last4digits] = credit_card_or_card_id[-4..-1]\n end\n end",
"def credit! amount, options\n if hpp_payment? || adyen_cc_payment?\n process { payment_method.credit(amount, response_code, options) }\n else\n fail NotImplementedError, \"Spree::Payment does not implement credit!\"\n end\n end",
"def credit! amount, options\n if hpp_payment? || adyen_cc_payment?\n process { payment_method.credit(amount, response_code, options) }\n else\n fail NotImplementedError, \"Spree::Payment does not implement credit!\"\n end\n end",
"def save_payment_card(card_name, token, exp)\n card = user.payment_cards.where(kind: payment_kind, last4: last4, name: card_name, exp: exp).first_or_create!(customer_id: token)\n self.payment_card = card\n start_recurring_payment if save\n end",
"def authorize_recurring_and_store_card_details(encrypted_card, options = {})\n @authorize_response = authorize_with_encrypted_card(encrypted_card, options)\n @authorize_response.success? && store_credit_card_details\n end",
"def save_creditcard\n \n save_data = params[:creditcards]\n \n save_data[:user_id] = current_user.id\n Stripe.api_key = STRIPE_SECRET_KEY\n @stripe_customer = Stripe::Customer.create(\n :card => params[:creditcards][:stripe_token],\n :description => 'Customer for test ' + current_user.email\n )\n save_data[:stripe_customer_id] = @stripe_customer.id\n @creditcard = Creditcards.new(save_data)\n \n respond_to do |format|\n if @creditcard.save\n format.html { redirect_to view_creditcards_path, notice: 'Your credit card information has been registered to Stripe' }\n # if params[:project][:image].blank?\n # redirect_to @project\n # else\n # render :action => \"crop\"\n # end\n\n format.json { render json: @creditcard, status: :created, location: @creditcard }\n else \n format.html { render action: \"index\" }\n format.json { render json: @creditcard.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_rate_card_select\n @payment_profile = @project.payment_profiles.new\n authorize @payment_profile, :update?\n @payment_profile.rate_card_payment_profiles.build\n \n respond_to do |format|\n format.js\n end\n end",
"def credit_card\n\t\t@credit_card ||= ActiveMerchant::Billing::CreditCard.new(\n\t\t\t:type => card_type,\n\t\t\t:number => card_number,\n\t\t\t:verification_value => card_cvv,\n\t\t\t:month => card_exp_month,\n\t\t\t:year => card_exp_year,\n\t\t\t:first_name => self.billing_address.name.split(' ').first,\n\t\t\t:last_name => self.billing_address.name.split(' ').last\n\t\t\t)\n\tend",
"def create\n @credit_card = current_user.credit_cards.new(credit_card_params)\n\n current_user._create_stripe_customer_id\n # We want to retrieve the customer from Stripe\n # Then add the new card to the customer\n begin\n customer = Stripe::Customer.retrieve(current_user.stripe_customer_id)\n card = customer.sources.create(:source => params[:stripeToken])\n rescue Stripe::CardError => e\n # Since it's a decline, Stripe::CardError will be caught\n body = e.json_body\n err = body[:error][:message]\n redirect_to :back, notice: \"#{err}\"\n else\n customer.default_source = card.id\n customer.save\n @credit_card.stripe_card_id = card.id\n @credit_card.last_four = card.last4\n\n if @credit_card.save\n unless session[:pending_session_counselor_id].present?\n redirect_to user_dashboard_path, notice: 'Credit card was successfully created.'\n else\n redirect_to new_counseling_session_path, notice: 'You are almost done. Now you can finalize your session.'\n end\n else\n render :new\n end\n end\n end",
"def credit_card_number; end",
"def pay\n @card = Creditcard.new(creditcard_params)\n\n user = current_user\n\n if @card.valid?\n result = Creditcard.create_only_creditcard_over_braintree(user.braintree_customer_id, @card)\n @braintree_cc_return = result.success? ? result.credit_card : nil\n end\n\n\n if @braintree_cc_return.present?\n @card.save\n @card.update_attributes(user_id: user.id)\n @card = Creditcard.update_creditcard(@braintree_cc_return, user.id)\n end\n\n end",
"def credit(money, credit_card, options = {})\n standard_response\n end",
"def add_card(access_token,payment_method)\n begin\n if Rails.env.production?\n @url =\"https://#{APP_CONFIG.auth_api_key}/billing/addCard\"\n @authKey = APP_CONFIG.auth_api_key\n else\n @url = \"https://dev-#{APP_CONFIG.auth_api_key}:3018/billing/addCard\"\n @authKey = APP_CONFIG.auth_api_key\n end\n uri = URI(@url)\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl = true\n req = Net::HTTP::Post.new(uri.path, {'Content-Type' =>'application/json'});\n # debugger\n req.body ={\t\t\t\n :access_token => access_token,\n :user_id => user_id,\n :auth_key => @authKey,\n :offering => 2,\n :payment_method => payment_method\n }.to_json\n res1 = https.request(req)\n @authBody = JSON.parse(res1.body)\n raise @authBody[\"message\"] if @authBody[\"status\"] == 201\n return @authBody\n rescue Exception => e\n puts \"add_card exception\"\n puts e\n raise e\n end\n end",
"def authorize_credit_card\n main_body = {\n createTransactionRequest: {\n merchantAuthentication: merchant_authentication,\n transactionRequest: {\n transactionType: 'authOnlyTransaction',\n amount: '8.75',\n payment: {\n creditCard: {\n cardNumber: '5424000000000015',\n expirationDate: '1220',\n cardCode: '900'\n }\n }\n }\n }\n }\n\n response = self.class.post('', basic_auth: @auth, body: main_body.to_json,\n headers: { 'Content-Type' => 'application/json' })\n JSON.parse(response.body.delete(''))\n end",
"def add_card_complete_payment\n @billing_id = params[:billing_address_id]\n @shipping_id = params[:shipping_id]\n billing_address = Spree::Address.where(:id => @billing_id).first\n shipping_address = Spree::Address.where(:id => @shipping_id).first\n user = current_user\n\n @card = Creditcard.new(creditcard_params)\n if @card.valid? #checking @card validation before pushing it over braintree for validation.\n result = Creditcard.create_only_creditcard_over_braintree(user.braintree_customer_id, @card)\n @braintree_cc_return = result.success? ? result.credit_card : nil\n\n if @braintree_cc_return.present?\n @card.save\n @card.update_attributes(:user_id => user.id)\n @card = Creditcard.update_creditcard(@braintree_cc_return, user.id)\n billing_address.update_attributes(is_complete: true)\n shipping_address.update_attributes(is_complete: true)\n end\n else\n logger.info @card.errors.messages\n end\n\n end",
"def credit amount, description=nil, meta={}\n self.account.credit(amount, description, meta, self.uri)\n end",
"def creditcard=(creditcard)\n @creditcard = creditcard\n self.cc_type = ActiveMerchant::Billing::CreditCard.type?(creditcard.number)\n self.number = creditcard.number if Spree::Config[:store_cc]\n self.display_number = creditcard.display_number \n self.month = creditcard.month\n self.year = creditcard.year\n self.first_name = creditcard.first_name\n self.last_name = creditcard.last_name\n end",
"def store_credit_card?\n paid?\n end",
"def add_customer_credit_card(customer, credit_card, options = {})\n credit_card = credit_card.to_vaulted_billing\n\n authorization = authorize(customer, credit_card, 1.00, options)\n void = void(authorization.id, options) if authorization.success?\n\n respond_with(credit_card, authorization.response, { \n :success => authorization.success?, \n :transactions => { :void => void, :authorization => authorization }\n }) do |cc|\n cc.vault_id = authorization.response.body['PaymentAccountDataToken'].presence\n end\n end",
"def buy_credits\n if request.post? || params[:PayerID]\n payment = params[:PayerID] ? current_user.credit_payments.where(payment_token: params[:token]).take : current_user.credit_payments.new(amount: params[:amount])\n make_payment_helper(payment, paypal_cancel_url: url_for(action: :index), success_msg: 'Credits successfully purchased!') do\n current_user.add_credits(payment.amount)\n end\n end\n end",
"def credit_with_payment_profiles(amount, payment, response_code, option)\n provider.credit(amount, payment)\n end",
"def card\n if request.post?\n # Save information in DB\n # Update attributes of credit card \n @credit_card = CreditCard.new(params[:credit_card])\n @credit_card.type = \"\"\n @credit_card.i_account = $uid\n\n # Override a state\n if params[:state].blank?\n @credit_card.state = \"--\"\n end\n\n # Convert a date expired\n expired_date = params[:expires_date_months].[](0..1).strip.concat(params[:expires_date_years].[](2..3))\n if expired_date.length == 3\n expired_date = \"0\".concat(expired_date)\n end\n\n cc_expired = expired_date.[](0..1) + \"/\" + expired_date.[](2..3)\n @credit_card.cc_expired = cc_expired\n\n # Validation a credit card\n unless @credit_card.valid?\n flash_error = \"<ul>\"\n @credit_card.errors.full_messages.each do |curr_error|\n flash_error << \"<li>\" << curr_error.to_s << \"</li>\"\n end\n flash_error << \"</ul>\"\n\n flash[:error_card] = flash_error\n\n redirect_to :controller => 'subs', :tab => \"subscriber\"\n return false\n end\n\n # Encode values\n @credit_card.first_name = encode_value(@credit_card.first_name).to_s.strip\n @credit_card.last_name = encode_value(@credit_card.last_name).to_s.strip\n @credit_card.cc_number = encode_value(@credit_card.cc_number).to_s.strip\n @credit_card.address = encode_value(@credit_card.address).to_s.strip\n @credit_card.cc_expired = encode_value(@credit_card.cc_expired).to_s.strip\n #@credit_card.address1 = encode_value(@credit_card.address1)\n\n # First, check by Luhn-algoritm\n # Checks cc by luhn alrogithm\n unless check_luhn(params[:credit_card][:cc_number])\n redirect_to :controller => 'subs', :tab => \"subscriber\"\n return false\n end\n\n # Checks, is ip blocked\n unless check_blocked_ip\n redirect_to :controller => 'subs', :tab => \"subscriber\"\n return false\n end\n\n # Checks cc by authorize.net\n unless authorize_net_valid(params[:credit_card])\n redirect_to :controller => 'subs', :tab => \"subscriber\"\n return false\n end\n\n # Clear cvv of credit card\n @credit_card.cvv = \"\"\n\n # Save the credit card\n if @credit_card.save \n # Update a card_id in the Account\n @account.attributes = {:i_cc => @credit_card.i_cc}\n @account.save\n\n # Generate user message\n if @response_code.to_i == 1 && @response_reason_code.to_i == 1\n user_message = \"Billing information changed\"\n else\n user_message = get_user_message(@response_code, @response_reason_code)\n end\n\n # Add transaction\n add_transaction(:i_account => @account.i_account,\n :i_cc => @credit_card.i_cc,\n :type => \"cc_changed\",\n :transaction_id => @authorize_transaction_id,\n :gw_string => @authorize_gateway,\n :user_message => user_message,\n :ip => request.remote_ip.to_s,\n :authorization_code => @authorize_code)\n\n # Clear session\n session[:count_card_validation] = nil\n\n flash[:notice] = 'Credit card saved successfully'\n\n # Check, if account is blocked, then try to make a purchase and unblock account\n # Find a account\n @account = Account.find($uid)\n\n if @account.active == 0 && (Time.now.to_i-@account.endtime.to_i) > (60*60*24*3)\n bil_circle = @account.i_bilcircle\n @bil_circle = BillingCircle.find_by_i_bilcircle(bil_circle) if bil_circle > 0\n\n # Credit of user\n #credit = (@account.credit > 0) ? @account.credit : 0\n\n @plan = PlanCC.find_by_i_plan(@account.i_plan)\n\n # Count months of subscription\n count_months = (bil_circle == 0) ? 1 : @bil_circle.bilcircle\n # Discount of subscription\n discount = (bil_circle == 0) ? 0 : @bil_circle.discount.to_f/100\n\n # Find a credit card\n @credit_card = CreditCard.find_by_i_cc(@account.i_cc)\n # Result sum of payment\n sum_purchase = (@plan.price*count_months) - (@plan.price*count_months*discount) - @account.credit\n\n if sum_purchase > 0\n # Make a payment\n payment_result = authorize_net_purchase(sum_purchase)\n\n # Generate user message\n if @response_code.to_i == 1 && @response_reason_code.to_i == 1\n user_message = \"Billing information changed\"\n else\n user_message = get_user_message(@response_code, @response_reason_code)\n end\n\n if payment_result\n # Enable account\n @account.active = 1\n @account.credit = 0\n @account.endtime = (count_months.months).since(Time.now) #@account.endtime)\n\n @account.save\n\n add_transaction(:i_account => @account.i_account,\n :i_cc => @credit_card.i_cc,\n :amount => sum_purchase,\n :type => \"payment_received\",\n :transaction_id => @authorize_transaction_id,\n :gw_string => @authorize_gateway,\n :plan => @plan.i_plan,\n :new_plan => @plan.i_plan,\n :user_message => user_message,\n :ip => request.remote_ip.to_s,\n :authorization_code => @authorize_code)\n\n flash[:notice] = 'Credit card saved, account activated'\n else\n add_transaction(:i_account => @account.i_account,\n :i_cc => @credit_card.i_cc,\n :amount => sum_purchase,\n :type => \"payment_failed\",\n :transaction_id => @authorize_transaction_id,\n :gw_string => @authorize_gateway,\n :plan => @plan.i_plan,\n :new_plan => @plan.i_plan,\n :user_message => user_message,\n :ip => request.remote_ip.to_s,\n :authorization_code => @authorize_code)\n\n flash[:error_card] = 'Payment failed'\n end\n else\n # Sum purchase is less than 0\n sum_purchase = (@plan.price*count_months) - (@plan.price*count_months*discount)\n\n # Enable account\n @account.active = 1\n @account.endtime = (count_months.months).since(Time.now) #@account.endtime)\n @account.credit = @account.credit - sum_purchase\n\n @account.save\n\n add_transaction(:i_account => @account.i_account,\n :i_cc => @credit_card.i_cc,\n :amount => sum_purchase,\n :type => \"payment_received\",\n :plan => @plan.i_plan,\n :new_plan => @plan.i_plan,\n :user_message => \"Billing information changed\",\n :ip => request.remote_ip.to_s)\n\n flash[:notice] = 'Credit card saved, account activated'\n end\n end\n else\n flash[:error_card] = @credit_card.errors.full_messages.to_sentence\n end\n\n redirect_to :controller => 'subs', :tab => \"subscriber\"\n else\n redirect_to :controller => 'subs'\n end\n end",
"def credit(description, amount)\n\t\tadd_transaction(description, amount)\n\tend",
"def credit(amount, description)\n super(amount, description) # Call and pass data to the original methods of the BankAccount\n charge_fee # And also charge a fee, add another transaction\n end",
"def update_customer_credit_card(customer, credit_card, options = {})\n add_customer_credit_card(customer, credit_card, options)\n end",
"def enter_credit_card_info (credit_card_type, credit_card_number, exp_month, exp_year, sec_code)\n if credit_card_type != \"PowerUp Rewards Credit Card\"\n chkout_credit_card_selector.value = credit_card_type\n chkout_credit_card_number_field.value = credit_card_number\n chkout_credit_card_month_selector.value = exp_month\n chkout_credit_card_year_selector.value = exp_year\n chkout_security_code_number_field.value = sec_code\n else\n chkout_credit_card_selector.value = credit_card_type\n chkout_credit_card_number_field.value = credit_card_number\n chkout_credit_card_month_selector.is_visible.should be_false\n chkout_credit_card_year_selector.is_visible.should be_false\n chkout_security_code_number_field.is_visible.should be_false\n end\n\n end",
"def add_payment_details(post, amount, payment, options)\n txn = {\n 'donationAmt': amount(amount),\n 'recurrpay': empty?(options[:recurrfreq]) ? 'N' : 'Y',\n 'recurrfreq': options[:recurrfreq],\n 'othamt4': options[:othamt4]\n }\n payment_details =\n if payment.respond_to?(:routing_number)\n { 'paymenttype': options[:payment_type].presence || 'ACH' }\n else\n options = {\n 'paymenttype': CARD_BRAND[payment.brand.to_sym],\n 'ccnumber': payment.number,\n 'ccexpire':\n \"#{format(payment.month, :two_digits)}#{format(payment.year, :two_digits)}\"\n }\n if payment.verification_value\n options['ccvv'] = payment.verification_value\n end\n options\n end\n\n # if we are processing a creditcard payment, we need to insert\n # the cardholder name in the supporter hash\n unless payment.respond_to?(:routing_number)\n post['supporter'].merge!('Credit Card Holder Name': payment.name)\n end\n post['transaction'] =\n txn.merge(payment_details).delete_if { |_, v| v.blank? }\n end",
"def credit_card\n @credit_card ||= ActiveMerchant::Billing::CreditCard.new(\n :number => card_number,\n :verification_value => card_verification,\n :month => card_expires_on.month,\n :year => card_expires_on.year,\n :first_name => first_name,\n :last_name => last_name\n )\n end",
"def update_credit_card\n authenticate_request!\n current_customer.assign_attributes(credit_card: customer_credit_card_param)\n\n if current_customer.save!\n json_response(current_customer)\n else\n json_response({ errors: customer.errors.full_messages }, status: :bad_request)\n end\n end",
"def charge_credit_card(amount)\n true\n end",
"def charge_credit_card(amount)\n true\n end",
"def card_buy\n @page_title = _('Buy_Card')\n @page_icon = 'money.png'\n\n @email = params[:email]\n @real_price = @card.balance + @cg.get_tax.count_tax_amount(@card.balance)\n @send_invoice = params[:send_invoice]\n @total_tax_name = Confline.get_value('Total_tax_name')\n @description = params[:description].to_s\n end",
"def add_credit_card(xml, credit_card, address)\n\n xml.tag! :Card do\n\n # DataCash calls the CC number 'pan'\n xml.tag! :pan, credit_card.number\n xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)\n\n # optional values - for Solo etc\n if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s)\n\n xml.tag! :issuenumber, credit_card.issue_number unless credit_card.issue_number.blank?\n\n if !credit_card.start_month.blank? && !credit_card.start_year.blank?\n xml.tag! :startdate, format_date(credit_card.start_month, credit_card.start_year)\n end\n end\n\n xml.tag! :Cv2Avs do\n xml.tag! :cv2, credit_card.verification_value if credit_card.verification_value?\n xml.tag! :cv2_present, '1' if credit_card.verification_value?\n\n if address\n xml.tag! :street_address1, address[:address1] unless address[:address1].blank?\n xml.tag! :street_address2, address[:address2] unless address[:address2].blank?\n xml.tag! :street_address3, address[:city] unless address[:city].blank?\n xml.tag! :street_address4, address[:state] unless address[:state].blank?\n xml.tag! :postcode, address[:zip] unless address[:zip].blank?\n xml.tag! :country, address[:country] unless address[:country].blank?\n end\n\n # The ExtendedPolicy defines what to do when the passed data\n # matches, or not...\n #\n # All of the following elements MUST be present for the\n # xml to be valid (or can drop the ExtendedPolicy and use\n # a predefined one\n # xml.tag! :ExtendedPolicy do\n # xml.tag! :cv2_policy,\n # :notprovided => POLICY_REJECT, # REJ\n # :notchecked => POLICY_REJECT, # REJ\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_REJECT\n # xml.tag! :postcode_policy,\n # :notprovided => POLICY_ACCEPT,\n # :notchecked => POLICY_ACCEPT,\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_ACCEPT\n # xml.tag! :address_policy,\n # :notprovided => POLICY_ACCEPT,\n # :notchecked => POLICY_ACCEPT,\n # :matched => POLICY_ACCEPT,\n # :notmatched => POLICY_REJECT, # REJ\n # :partialmatch => POLICY_ACCEPT\n # end\n end\n end\n end",
"def apply_freshbooks_credit!\n credit = [ self.organization.accounting_gateway.available_credits[:USD], self.invoice_balance ].min\n response = FreshBooks.account.payment.create({ payment: {\n invoice_id: self.freshbooks_invoice_id,\n client_id: self.organization.accounting_gateway.freshbooks_id,\n amount: credit,\n type: 'Credit'\n }})\n end",
"def authorize_payment(credit_card, options = {})\n\n # this is the major function that interacts with the credit card company\n options[:order_id] = number # currently just loading a date\n # options[:email] = 'developer@fitwit.com'\n # options[:billing_address] = {\n # :name => 'Cody Fauser',\n # :address1 => '1234 Shady Brook Lane',\n # :address2 => 'Apartment 1',\n # :city => 'Ottawa',\n # :state => 'ON',\n # :country => 'CA',\n # :zip => 'K3P5N5',\n # :phone => '999-999-9999'}\n\n authorization = OrderTransaction.authorize(amount, credit_card, options)\n self.save!\n self.order_transactions << authorization\n\n if authorization.success?\n self.payment_authorized!\n else\n self.transaction_declined!\n end\n\n authorization\n #end\n end",
"def set_payment_card\n @payment_card = PaymentCard.find(params[:id])\n end",
"def card\n @data[:credit_card]\n end",
"def activate \n # credit card numbers should always be stored in the case of offline processing (no other option makes sense)\n #Spree::Config.set(:store_cc => true) \n \n Creditcard.class_eval do \n require 'openssl'\n require 'base64'\n \n # overrides filter_sensitive to make sure the stored values are encrypted.\n private\n def filter_sensitive \n # don't encrypt again, this way we can clone an order and its creditcard and keep text encrypted\n return unless encrypted_text.blank?\n gnupg = GnuPG.new :recipient => Spree::Pgp::Config[:email]\n public_key_text = Rails.cache.fetch('public_key') do\n File.read(\"#{RAILS_ROOT}/#{Spree::Pgp::Config[:public_key]}\")\n end\n gnupg.load_public_key public_key_text \n text = \"Number: #{number} Code: #{verification_value}\"\n self[:encrypted_text] = gnupg.encrypt(text)\n self[:number] = \"\"\n self[:verification_value] = \"\"\n end\n end\n \n # register Creditcards tab\n Admin::BaseController.class_eval do\n before_filter :add_creditcard_tab\n\n private\n def add_creditcard_tab\n @order_admin_tabs ||= []\n @order_admin_tabs << {:name => t('credit_cards'), :url => \"admin_order_creditcards_url\"} \n end\n end \n \n end",
"def credit(payment)\n payment_gateway = payment.payment_method\n check_environment(payment_gateway)\n\n amount = payment.credit_allowed >= payment.order.outstanding_balance.abs ? payment.order.outstanding_balance.abs : payment.credit_allowed.abs\n if payment_gateway.payment_profiles_supported?\n response = payment_gateway.credit((amount * 100).round, self, payment.response_code, minimal_gateway_options(payment, false))\n else\n options = {:card_number => payment.source.last_digits}.merge(minimal_gateway_options(payment, false))\n response = payment_gateway.credit((amount * 100).round, payment.response_code, options)\n end\n\n ## Thomas: add action here, until we update to a later version of active merchant\n response.params['action'] = \"CREDIT\" unless response.params['action']\n record_log payment, response\n\n if response.success?\n Spree::Payment.create(:order => payment.order,\n :source => payment,\n :payment_method => payment.payment_method,\n :amount => amount.abs * -1,\n :response_code => response.authorization,\n :state => 'completed')\n else\n gateway_error(response)\n end\n rescue ActiveMerchant::ConnectionError => e\n gateway_error e\n end",
"def create\n build_object\n creditcard = @creditcard_presenter.creditcard\n creditcard.address = @creditcard_presenter.address\n creditcard.order = @order\n \n # TODO - refactor the spree code so that creditcard name can be read from the address\n creditcard.first_name = creditcard.address.firstname\n creditcard.last_name = creditcard.address.lastname\n\n unless @creditcard_presenter.valid? and creditcard.save\n render :action => \"new\" and return\n end\n\n flash[:notice] = t(\"credit_card_added.\")\n redirect_to collection_url\n end",
"def credit_card(options = {})\n ActiveMerchant::Billing::CreditCard.new( credit_card_hash(options) )\n end",
"def credit_card_params\n params.require(:credit_card).permit(:customer_profile_id, :customer_payment_profile_id)\n end",
"def create_payment_card(params)\n c_r Lokalise::Resources::PaymentCard, :create, nil, params\n end",
"def update_credit_card\n json_response({ message: 'NOT IMPLEMENTED' })\n end",
"def add_credit_card(xml, credit_card, address)\n xml.tag! :Card do\n \n # DataCash calls the CC number 'pan'\n xml.tag! :pan, credit_card.number\n xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)\n \n # optional values - for Solo etc\n if [ 'switch', 'solo' ].include?(credit_card.type.to_s)\n \n xml.tag! :issuenumber, credit_card.issue_number unless credit_card.issue_number.blank?\n \n if !credit_card.start_month.blank? && !credit_card.start_year.blank?\n xml.tag! :startdate, format_date(credit_card.start_month, credit_card.start_year)\n end\n end\n \n xml.tag! :Cv2Avs do\n xml.tag! :cv2, credit_card.verification_value if credit_card.verification_value?\n xml.tag! :street_address1, address[:address1] unless address[:address1].blank?\n xml.tag! :street_address2, address[:address2] unless address[:address2].blank?\n xml.tag! :street_address3, address[:address3] unless address[:address3].blank?\n xml.tag! :street_address4, address[:address4] unless address[:address4].blank?\n xml.tag! :postcode, address[:zip] unless address[:zip].blank?\n \n # The ExtendedPolicy defines what to do when the passed data \n # matches, or not...\n # \n # All of the following elements MUST be present for the\n # xml to be valid (or can drop the ExtendedPolicy and use\n # a predefined one\n xml.tag! :ExtendedPolicy do\n xml.tag! :cv2_policy, \n :notprovided => POLICY_REJECT,\n :notchecked => POLICY_REJECT,\n :matched => POLICY_ACCEPT,\n :notmatched => POLICY_REJECT,\n :partialmatch => POLICY_REJECT\n xml.tag! :postcode_policy,\n :notprovided => POLICY_ACCEPT,\n :notchecked => POLICY_ACCEPT,\n :matched => POLICY_ACCEPT,\n :notmatched => POLICY_REJECT,\n :partialmatch => POLICY_ACCEPT\n xml.tag! :address_policy, \n :notprovided => POLICY_ACCEPT,\n :notchecked => POLICY_ACCEPT,\n :matched => POLICY_ACCEPT,\n :notmatched => POLICY_REJECT,\n :partialmatch => POLICY_ACCEPT\n end\n end\n end\n end",
"def purchase(money, creditcard, options = {})\n post = {}\n add_invoice(post, options)\n add_creditcard(post, creditcard)\n add_address(post, options)\n add_customer_data(post, options)\n add_duplicate_window(post)\n\n commit('AUTH_CAPTURE', money, post)\n end",
"def credit(money, creditcard, options = {})\n if creditcard.is_a?(String)\n raise ArgumentError, \"Reference credits are not supported. Please supply the original credit card or use the #refund method.\"\n end\n\n form = {}\n add_invoice(form, options)\n add_creditcard(form, creditcard)\n add_address(form, options)\n add_customer_data(form, options)\n add_test_mode(form, options)\n commit(:credit, money, form)\n end",
"def credit_card_type; end",
"def credit(postive_amount)\n Credit.create!(team: team,\n room_type: room_type,\n amount: postive_amount)\n end",
"def validate_card\n\t\tif paypal_express_token.blank? && !credit_card.valid?\n\t\t\tcredit_card.errors.full_messages.each do |message|\n\t\t\t\terrors.add_to_base message\n\t\t\tend\n\t\tend\n\tend",
"def add_payment(xml, options)\n return unless options[:credit_card] || options[:bank_account]\n\n xml.tag!('payment') do\n # Contains the customer’s credit card information\n add_credit_card(xml, options)\n # Contains the customer’s bank account information\n add_bank_account(xml, options)\n end\n end",
"def credit?\n (payment_method == CREDIT)\n end",
"def update_credit_card_info(credit_card)\n wait_until_bus_section_load\n wait_until {modify_credit_card_cb.visible?}\n modify_credit_card_cb.check\n cc_name_tb.type_text(credit_card.full_name) unless credit_card.full_name.nil?\n cc_no_tb.type_text(credit_card.number) unless credit_card.number.nil?\n cvv_tb.type_text(credit_card.cvv) unless credit_card.cvv.nil?\n cc_exp_mm_select.select(credit_card.expire_month) unless credit_card.expire_month.nil?\n cc_exp_yyyy_select.select(credit_card.expire_year) unless credit_card.expire_year.nil?\n end",
"def post_billing(req)\n with_stripe_error_handlers do\n customer = Stripe::Customer.retrieve(@dealership.customer_id)\n customer.card = posted['stripeToken']\n customer.save\n req.session['billing_flash_msg'] = \"Card updated successfully.\"\n redirect \"/admin/#{@dealership.slug}/billing\"\n end\n end",
"def create\n @invoice.attributes = params[:invoice]\n @credit_card = ActiveMerchant::Billing::CreditCard.new(params[:active_merchant_billing_credit_card])\n\n respond_to do |wants| \n wants.html do\n if (!@invoice.paying_with_credit_card? || @credit_card.valid?) && @invoice.save then \n \n @survey.billing_info_received!(current_association)\n\n redirect_to survey_path(@survey)\n else\n render :action => :new\n end\n end \n end\n end",
"def store(creditcard, options = {})\n post = {}\n post[:accttype] = 1\n add_address(post, options)\n add_custom(post, options)\n add_creditcard(post, creditcard)\n\n commit(:profile_add, nil, post)\n end",
"def prepare_credit_card\n @card = ActiveMerchant::Billing::CreditCard.new({\n :number => card_number,\n :month => card_month,\n :year => card_year,\n :first_name => card_first_name,\n :last_name => card_last_name,\n :verification_value => card_verification,\n :type => card_type\n })\n \n if @card.valid?\n @result[:card] = true\n else\n @result[:card] = false\n end\n @result[:card]\n end",
"def cc_payment_option\n\t\t$tracer.trace(__method__)\n\t\treturn ToolTag.new(section.id(\"payment_options\").find.p.id(\"/creditcardselected/\"), __method__, self)\n\tend",
"def set_cc_information(account, expire, cvv='')\n @PARAM_HASH['PAYMENT_TYPE'] = 'CREDIT'\n @PARAM_HASH['CC_NUM'] = account\n @PARAM_HASH['CC_EXPIRES'] = expire\n @PARAM_HASH['CVCVV2'] = cvv\n end",
"def postfill!(customer)\n self.price = customer.subscription.plan.amount / 100\n self.stripe_id = customer.id\n self.exp_month = customer.active_card.exp_month\n self.exp_year = customer.active_card.exp_year\n self.last4 = customer.active_card.last4\n self.status = \"active\"\n self.save!\n self\n end",
"def process_add!(result)\n self.payment = OrderPayment.new(\n :name => result.credit_card.name,\n :number => result.credit_card.number,\n :expiration_month => result.credit_card.expiration_month,\n :expiration_year => result.credit_card.expiration_year,\n :provider_name => IslayShop::Engine.config.payments.provider,\n :provider_token => result.transaction.id,\n :status => result.transaction.status,\n :card_type => result.credit_card.card_type\n )\n\n skus = Hash[*sku_items.map {|i| [i.sku_id, i.quantity]}.flatten]\n Sku.purchase_stock!(skus)\n next!(\"Authorizing #{formatted_total}\")\n end",
"def enter_credit_card_info (credit_card_type, credit_card_number, exp_month, exp_year, sec_code)\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n chkout_credit_card_selector.value = credit_card_type\n chkout_credit_card_number_field.value = credit_card_number\n chkout_credit_card_month_selector.value = exp_month\n chkout_credit_card_year_selector.value = exp_year\n chkout_security_code_number_field.value = sec_code\n end",
"def registerCard\n parameters={user_id: (@current_user[\"id\"]).to_i, number: (params[:number]).to_i, amount: (params[:amount]).to_i, expiration_month: (params[:expiration_month]).to_i, expiration_year: (params[:expiration_year]).to_i}\n puts (parameters)\n options = {\n :body => parameters.to_json,\n :headers => {\n 'Content-Type' => 'application/json'\n }\n }\n results = HTTParty.post(\"http://192.168.99.104:3003/credit_cards\", options)\n if results.code == 201\n head 201\n else\n render json: results.parsed_response, status: results.code\n end\n end",
"def mgs_chkout_pay_add_payment\n\t\t$tracer.trace(__method__)\n\t\treturn ToolTag.new(a.className(create_ats_regex_string(\"ats-addNewCard\")), __method__)\n\tend",
"def create_cardless\n if current_user.go_cardless_mandate.present? && current_user.go_cardless_customer.present?\n create_gocardless_subscription\n flash[:success] = 'Your payment has been successfully completed and subscription added to existing bank account.'\n redirect_to root_path\n else\n redirect_flow = GO_CARDLESS_CLIENT.redirect_flows.create(\n gocardless_redirect_params\n )\n redirect_to redirect_flow.redirect_url\n end\n end",
"def create_creditcard\n \n @creditcard = Creditcards.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @creditcard }\n end\n end",
"def set_credit_card_charge\n @credit_card_charge = CreditCardCharge.find(params[:id])\n end",
"def credit amount, description=nil, meta={}, destination_uri=nil\n credit = Credit.new(\n :uri => self.credits_uri,\n :amount => amount,\n :meta => meta,\n :description => description,\n :destination_uri => destination_uri,\n )\n credit.save\n end",
"def create\n @credit = Credit.new(params[:credit])\n \n @credit.amount = 0 if params[:credit][:amount].empty?\n current_credit = Credit.find_by_customer_id(session[:cust_id])\n \n authorise_amount @credit.amount\n\n if current_credit \n current_credit.amount += @credit.amount\n @credit = current_credit\n else\n @credit.customer_id = session[:cust_id]\n # @credit.save\n end\n\n\n\n\n respond_to do |format|\n if @credit.save\n format.html { redirect_to credits_url, notice: 'Credit was successfully created.' }\n format.json { render json: @credit, status: :created, location: @credit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @credit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def payment_card(card_id)\n c_r Lokalise::Resources::PaymentCard, :find, card_id\n end"
] |
[
"0.6897703",
"0.68912905",
"0.68727607",
"0.67950857",
"0.67049307",
"0.66833454",
"0.656524",
"0.6540334",
"0.6536022",
"0.65015244",
"0.6495551",
"0.64735353",
"0.64356935",
"0.64125687",
"0.6409902",
"0.6390594",
"0.6376964",
"0.6376964",
"0.63540894",
"0.6342632",
"0.6334938",
"0.63300616",
"0.632791",
"0.6321552",
"0.6321052",
"0.6317239",
"0.6288909",
"0.6264167",
"0.62524426",
"0.6245721",
"0.6229947",
"0.62175614",
"0.62175614",
"0.62145615",
"0.6208183",
"0.61966217",
"0.61866385",
"0.61828774",
"0.6168644",
"0.615529",
"0.61491436",
"0.61373436",
"0.613371",
"0.6129333",
"0.61214584",
"0.6118979",
"0.61157113",
"0.6114573",
"0.61105835",
"0.6084307",
"0.6065932",
"0.60586923",
"0.60382336",
"0.60349363",
"0.601854",
"0.6012194",
"0.6007497",
"0.5999446",
"0.5981504",
"0.59794116",
"0.59794116",
"0.5977937",
"0.5971768",
"0.59628814",
"0.5956192",
"0.59529567",
"0.5944238",
"0.593402",
"0.5930599",
"0.5929984",
"0.59275013",
"0.59253716",
"0.5914055",
"0.58822995",
"0.58758426",
"0.58746904",
"0.5871637",
"0.5870254",
"0.58667046",
"0.5843286",
"0.58398515",
"0.5836646",
"0.5830534",
"0.5821291",
"0.5819183",
"0.5815552",
"0.58130354",
"0.5812071",
"0.58109987",
"0.58070874",
"0.58067715",
"0.5790554",
"0.5790241",
"0.5790185",
"0.5789895",
"0.5785835",
"0.577844",
"0.5776123",
"0.5770529",
"0.57664603"
] |
0.7846991
|
0
|
Order jobs by: their stage number their allow_failure status their original order
|
def apply
jobs.sort_by.with_index { |job, ix| order(job, ix) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sort_checks_on_new_jobs\n @total_jobs_hash = @total_jobs.index_by(&:id)\n @checks.sort_by! do |check|\n if check.job.split_parent_job_id.present? || check.job.parent_job_id.present?\n split_image_values = check.job.initial_image_name.split('.').first.split('_').from(1)\n @compare_job = check.job\n split_image_values.length.times do |t|\n if check.job.split_parent_job_id.present?\n @compare_job = @total_jobs_hash[@compare_job.split_parent_job_id]\n elsif check.job.parent_job_id.present?\n @compare_job = @total_jobs_hash[@compare_job.parent_job_id]\n end\n end\n \"#{@compare_job.id}.#{split_image_values.present? ? split_image_values.join() : '0'}\".to_f\n else\n check.job_id.to_f\n end\n end\n end",
"def sort_jobs(result, circular_error, dependecy_error)\n job_order = result.keys\n if circular_error.zero? && dependecy_error.zero?\n result.each { |key, val| switch_jobs(key, val, job_order) }\n job_order.join\n else\n print_errors(circular_error, dependecy_error)\n end\n end",
"def ordered_executions\n return self.test_executions.sort! {|e1, e2| e2.execution_date <=> e1.execution_date}\n end",
"def tag_with_job_status(job)\n # Find all run actions associated to this run\n all_job_actions_sorted_by_id = job.actions.order('id ASC')\n\n # Browse actions and sort by status\n # FIXME: the latest action on a specific step overrides the data for the same previous instance of this step\n all_job_actions_sorted_by_id.each do |action|\n if action.errno.to_i >0\n border_color = COLOR_FAILED\n elsif action.completed_at.nil?\n border_color = COLOR_RUNNING\n else\n border_color = COLOR_COMPLETED\n end\n\n # Set attributes for thiss step\n self.step_attributes(action.step_id, {\n :border_color => border_color,\n :errno => action.errno,\n })\n end\n end",
"def sort\n sorted_stack = []\n jobs = @jobs.clone\n while !jobs.empty?\n job, related_job = jobs.first\n\n # basing on the current job, search the its related free job and add in the sorted stack\n sorted_stack << next_available_job(jobs, sorted_stack, job, related_job)\n jobs.delete(sorted_stack.last) # delete from temp queue last added job\n end\n sorted_stack\n end",
"def active_job_requests\n self.job_requests.joins(:project).where( :is_canceled => false, :project => {\n :is_finished => false ,\n :is_deleted => false \n } ).order(\"deadline_date ASC, is_finished ASC, created_at DESC\")\n end",
"def sort_popular_jobs\n Application.group(:job).count.sort_by do |job|\n job[1]\n end.reverse\n end",
"def failed_jobs\n @failed_jobs ||= []\n end",
"def jobs_in_stage(stage)\n array_for_stage(@stages[stage])\n end",
"def sort_jobs(job_list)\n sorted_and_filtered = []\n [\"red\", \"yellow\", \"grey\"].each do |color|\n job_list.select {|j| j.color == color}.each { |j| sorted_and_filtered << j }\n end\n sorted_and_filtered\nend",
"def cap_runs!\n runs_count = self.runs.count\n if runs_count > max_run_per_job\n runs.sort_by(:started_at, order: 'ALPHA ASC', limit: [0, runs_count - max_run_per_job]).each do |run|\n if run.status == :failed || run.status == :success\n run.delete\n end\n end\n end\n end",
"def process_job\n result = array.map do |x|\n x = x.split('=>')\n y = ret_y(x)\n Hash[x.first, y]\n end\n result = result.reduce(:merge)\n circular_error = check_circular(result)\n dependecy_error = result.select { |k, v| k == v }.count\n sort_jobs(result, circular_error, dependecy_error)\n end",
"def test_retuns_ordered_jobs_considering_all_dependecies\n sequence = Sequence.new()\n sequence.add(\"a =>\n b => c\n c => f\n d => a\n e => b\n f =>\")\n sequence.ordered.each do |job|\n assert (%w[a b c d e f].include?(job))\n end\n assert sequence.ordered.index(\"f\") < sequence.ordered.index(\"c\")\n assert sequence.ordered.index(\"c\") < sequence.ordered.index(\"b\")\n assert sequence.ordered.index(\"b\") < sequence.ordered.index(\"e\")\n assert sequence.ordered.index(\"a\") < sequence.ordered.index(\"d\")\n end",
"def sort_by_dependencies\n visited = Hash[dependencies.keys.map {|k| [k, false]}]\n in_call_stack = {}\n dependencies.each_pair do |job, dependency|\n return if error\n helper(visited, in_call_stack, job) unless visited[job]\n end\n result\n end",
"def inspect_jobs(index = nil)\n return empty_msg if empty?\n desc = []\n puts \"\\n\"\n @jobs.each_with_index do |j, i|\n unless index.nil?\n next unless i == index\n end\n desc << '| Job: ' + \" #{i + 1} \".rjust(8) + '|' + 'Pattern/AIV:'.rjust(18) + \" #{j.pattern.basename}\".ljust(125) + '|'\n desc << '| |' + 'Compiler ID:'.rjust(18) + \" #{j.id} \".ljust(125) + '|'\n desc << '| |' + 'AVC Files:'.rjust(18) + \" #{j.count} \".ljust(125) + '|'\n desc << '| |' + 'Output Directory:'.rjust(18) + \" #{j.output_directory} \".ljust(125) + '|'\n desc << '| |' + '.avc directory:'.rjust(18) + \" #{j.avc_dir} \".ljust(125) + '|'\n desc << '| |' + '.binl directory:'.rjust(18) + \" #{j.binl_dir} \".ljust(125) + '|'\n desc << '| |' + 'LSF:'.rjust(18) + \" #{j.location == :lsf ? true : false} \".ljust(125) + '|'\n desc << '| |' + 'Delete log files:'.rjust(18) + \" #{j.clean} \".ljust(125) + '|'\n desc << '| |' + 'Verbose:'.rjust(18) + \" #{j.verbose} \".ljust(125) + '|'\n if j.aiv2b_opts && j.aiv2b_opts.is_a?(String)\n aiv2b_opts = j.aiv2b_opts.gsub('AI_V2B_OPTIONS ', '')\n else\n aiv2b_opts = render_aiv2b_options_line.gsub('AI_V2B_OPTIONS', '')\n end\n desc << '| |' + 'AI_V2B Options:'.rjust(18) + \" #{aiv2b_opts} \".ljust(125) + '|'\n desc << '-' * desc.first.size\n end\n puts desc.flatten.join(\"\\n\")\n end",
"def all_games\n return self.stages\n .map{ |stage| stage.games }\n .flatten\n .sort do |game0, game1|\n if game0.starts_at.nil?\n -1\n elsif game1.starts_at.nil?\n 1\n else\n game0.starts_at <=> game1.starts_at\n end\n end\n end",
"def stage\n if status == \"Staging\" # ActiveJob being retried could cause this state\n transaction do\n core_records_fields.delete_all\n dataset_records.delete_all\n end\n end\n\n update!(status: \"Staging\") if status == \"Uploaded\"\n\n if status != \"Ready\"\n perform_staging\n update!(status: \"Ready\")\n end\n end",
"def sort_cyclists_race_stage(race, current_stage)\n sorted_cyclists = []\n nil_cyclists = []\n stage_max_points = Array.new(race.stages.count, 0)\n\n race.stages.each_with_index do |stage, index|\n race.cyclists.each do |cyclist| \n stage_effort = cyclist.stage_efforts.find_by(stage_id: stage)\n stage_max_points[index] = stage_max_points[index] + 1 if stage_effort\n end\n break if stage == current_stage # condition to determine which stage is \n end\n\n race.cyclists.each_with_index do |cyclist, index| \n total_time = 0\n total_points = 0\n stage_effort = nil\n stage_count = 0\n\n race.stages.each_with_index do |stage, ix_stage|\n today = Time.now.to_date # race.stages.last.close_date\n # if race.stages.last.close_date >= today\n stage_effort = cyclist.stage_efforts.find_by(stage_id: stage)\n if stage_effort\n total_time = total_time + stage_effort.elapsed_time.to_i\n total_points = total_points + stage_effort.points.to_i\n stage_count -= 1 \n else\n #break\n total_points = total_points + stage_max_points[ix_stage] + 1\n end\n # end\n break if stage == current_stage # condition to determine which stage is \n end\n\n if total_time > 0\n sorted_cyclists << { 'cyclist' => cyclist, 'total_time' => total_time, 'total_points' => total_points, 'stage_count' => stage_count} \n else\n nil_cyclists << { 'cyclist' => cyclist, 'total_time' => 'DNF', 'total_points' => total_points, 'stage_count' => stage_count} \n end\n end\n\n nil_cyclists.sort_by!{|a| a['total_points']}\n\n #sorted_cyclists.sort_by!{|k| k['total_points'].to_i}.reverse!\n sorted_cyclists.sort! do |a, b|\n [a['total_points'], a['stage_count'], a['total_time']] <=> [b['total_points'], b['stage_count'], b['total_time']]\n end\n\n return sorted_cyclists + nil_cyclists\n end",
"def failed\n jobs_index(Job.failed)\n end",
"def complex_sort( task_a, task_b, options )\n\n # Implement grouping by billable and/or active flags by using these as\n # sort paramneters. The order of the checks means that if grouping by both\n # flags we'll get a sort order of billable/active, billable/inactive,\n # non-billable/active, non-billable/inactive.\n\n if ( options[ :group_by_billable ] )\n return -1 if ( task_a.billable && ! task_b.billable )\n return 1 if ( task_b.billable && ! task_a.billable )\n end\n\n if ( options[ :group_by_active ] )\n return -1 if ( task_a.active && ! task_b.active )\n return 1 if ( task_b.active && ! task_a.active )\n end\n\n # More conventional sorting - we group by customer, then by project, then\n # finally sort by the task itself. The field used for the sorting of each\n # of the three object types is configurable and usually one of :title,\n # :code or :created_at.\n #\n # Liberal use of 'try' to deal with unassigned items - tasks with no\n # project, projects with no customer. Any \"<=>\" comparison with 'nil' will\n # result in 'nil' and a failed sort, so return '0' for such cases to treat\n # any nil comparison as 'same' (the \"|| 0\" at the end of comparison lines).\n\n if ( task_a.project.try( :customer_id ) != task_b.project.try( :customer_id ) )\n method = options[ :customer_sort_field ] || :title\n return ( task_a.project.try( :customer ).try( method ) <=> task_b.project.try( :customer ).try( method ) ) || 0\n elsif ( task_a.project_id != task_b.project_id )\n method = options[ :project_sort_field ] || :title\n return ( task_a.project.try( method ) <=> task_b.project.try( method ) ) || 0\n else\n method = options[ :task_sort_field ] || :title\n return ( task_a.send( method ) <=> task_b.send( method ) ) || 0\n end\n end",
"def sort_ops\n operations.running.sort_by { |op| sort_array(op) }.extend(OperationList)\n end",
"def sort_findings\n # findings are sorted by severity status order and then by number of items found descending\n status_order = [:danger, :warning, :info, :success]\n @findings = @findings.flatten.sort_by {|f| [status_order.index(f[:status]), -f[:items].to_a.size]}.each do |i|\n @summary[i[:status]] += 1 unless i[:items].blank?\n @summary['success'] += 1 if i[:status] == :success\n end\n end",
"def sort_all_incomplete\n @due_date_task_list.sort! { |duedatetask1, duedatetask2| duedatetask1.due_date <=> duedatetask2.due_date }\n @combined_list = @due_date_task_list + @task_list\n @combined_list.select { |duedatetask| (duedatetask.status == \"incomplete\") }\n end",
"def test_waiting_list_order\n # @todo don't know yet how to list waiting list\n # @todo original plan was just to have a waitinglist queue and only next is available to view\n puts \"Test under construction: waiting_list_order\"\n end",
"def sort_floor_plans\n if presentable.available_floor_plans.in_group(group).map(&:position).any?{ |e| e.nil? }\n @plans = presentable.available_floor_plans.in_group(group).\n sort{|a,b| NaturalSort.comparator(a.name, b.name)}\n else\n @plans = presentable.available_floor_plans.in_group(group).order(:position)\n end\n end",
"def compared_stages\n @compared_stages ||= project.stages.ordered.each_cons(2).map do |ahead, behind|\n comparison = snapshot&.comparisons&.detect { |c| c.behind_stage_id == behind.id && c.ahead_stage_id == ahead.id }\n {\n stages: [ahead, behind],\n snapshot: comparison,\n diff: diff_commits(comparison),\n blame: diff_blame(comparison),\n score: (ComparisonService.comparison_score(comparison) if comparison)\n }\n end\n end",
"def report(jobs)\n # <Most Interesting Man in the World>\n # I don't always write method chains, but when I do, they're Enumerable\n # calls or ActiveRecord scopes and they're arranged to look like an Elixir\n # pipeline.\n jobs\n .sort_by(&:title)\n .each_with_object(\"All Opportunities\\n\") do |job, string|\n string << job.to_s << \"\\n\"\n end\n end",
"def sort\n params[:backlog_entry].each_with_index do |id, index|\n BacklogEntry.update_all({position: index+1}, {id: id})\n end\n render nothing: true\n end",
"def index\n @stage_orders = [] # 初期化\n @groups.each { |group|\n @stage_orders += StageOrder.where( group_id: group.id ).order('id')\n }\n end",
"def order_by_label(builds)\n if source_control.creates_ordered_build_labels?\n builds.sort_by do |build|\n number, rebuild = build.label.split('.')\n # when a label only has build number, rebuild = nil, nil.to_i = 0, and this code still works\n [number.to_i, rebuild.to_i]\n end\n else\n builds.sort_by(&:time)\n end\n end",
"def task_steps_simple\n # this is a read-only display of workflow steps needed or completed\n # D - C - P - B - S\n # maybe it'll contain a id of the related item\n steps = Task.find_all_by_job_id(self).sort { |a, b| (a.order || 1) <=> (b.order || 1) } \n \n #puts steps.class\n end",
"def workflow_run_attempt_jobs(repo, run_id, attempt_number, options = {})\n paginate \"#{Repository.path repo}/actions/runs/#{run_id}/attempts/#{attempt_number}/jobs\", options do |data, last_response|\n data.jobs.concat last_response.data.jobs\n end\n end",
"def sorted_with_order\n # Identify groups of nodes that can be executed concurrently\n groups = tsort_each.slice_when { |a, b| parents(a) != parents(b) }\n\n # Assign order to each node\n i = 0\n groups.flat_map do |group|\n group_with_order = group.product([i])\n i += group.size\n group_with_order\n end\n end",
"def last_20_jobs(project_id)\n api(\"projects/#{project_id}/jobs\").sort_by { |j| -j['id'] }\nend",
"def retry_failing_jobs\n projects.each do |project|\n project_id = project['id']\n @logger.info \"Checking Project ##{project_id} \\\"#{project['name']}\\\"...\"\n\n unpassing_jobs = latest_unpassing_jobs(project_id)\n unpassing_pipelines = latest_unpassing_pipelines(project_id)\n\n if unpassing_pipelines.empty?\n @all_pipelines_passing[project_id] = true\n @logger.info '- All pipelines passing'\n else\n @all_pipelines_passing[project_id] = false\n end\n\n if !unpassing_jobs.empty? && !unpassing_pipelines.empty?\n unpassing_jobs.each do |job|\n message = \"- Job ##{job['id']} ('#{job['name']}') \"\\\n \"on branch '#{job['ref']}' has status %s\"\n if ['failed', 'canceled', 'manual'].include?(job['status'])\n # Rerun individual jobs\n @logger.info format(message, \"'#{job['status']}'. Retrying...\")\n api(\"projects/#{project_id}/jobs/#{job['id']}/retry\", :post)\n else\n @logger.info format(message, \"'#{job['status']}'. Skipping retry.\")\n end\n end\n else\n unpassing_pipelines.each do |pipeline|\n message = \"- Pipeline ##{pipeline['id']} on branch \"\\\n \"'#{pipeline['ref']}' has status %s\"\n if ['failed', 'canceled', 'manual'].include?(pipeline['status'])\n # Rerun the whole pipeline\n @logger.info format(message, \"'#{pipeline['status']}'. Retrying...\")\n api(\"projects/#{project_id}/pipelines/#{pipeline['id']}/retry\", :post)\n else\n @logger.info format(message, \"'#{pipeline['status']}'. Skipping retry.\")\n end\n end\n end\n end\n\n exit_if_all_pipelines_passing\nend",
"def test_update_status\n batch = batches(:batch4)\n job_one = Job.create(:batch=>batch,:tiff_number=>1234,:check_number=>12131,:count=>12, :job_status => 'Complete', :estimated_eob => 12)\n job_two = Job.create(:batch=>batch,:tiff_number=>1231,:check_number=>12135,:count=>12, :job_status => 'Allocated', :estimated_eob => 12)\n\n # Check for complete\n job_two.job_status = 'Complete'\n job_two.update\n\n batch.update_status\n assert_equal 'Complete', batch.status\n assert_in_delta(batch.completion_time.to_i, Time.now.to_i,1)\n\n # Check for processing\n job_one.job_status = 'Processing'\n job_one.update\n batch.update_status\n assert_equal('Processing', batch.status)\n assert_nil batch.completion_time\n\n # Check for new\n job_one.job_status = 'New'\n job_one.update\n job_two.job_status = 'New'\n job_two.update\n batch.update_status\n assert_equal 'New', batch.status\n assert_nil batch.completion_time\n\n # one new and one complete\n job_one.job_status = 'New'\n job_one.update\n job_two.job_status = 'Complete'\n job_two.update\n batch.update_status\n assert_equal 'Processing', batch.status\n assert_nil batch.completion_time\n\n # QA Rejected\n job_one.job_status = 'QA Rejected'\n job_one.update\n job_two.job_status = 'Complete'\n job_two.update\n batch.update_status\n assert_equal 'Processing', batch.status\n assert_nil batch.completion_time\n\n # one HLSC Rejected and the other Complete\n job_one.job_status = 'HLSC Rejected'\n job_one.update\n job_two.job_status = 'Complete'\n job_two.update\n batch.update_status\n assert_equal 'HLSC Rejected', batch.status\n job_one.job_status = 'Complete'\n job_one.update\n batch.update_status\n assert_equal 'Complete', batch.status\n\n # All HLSC Verified\n job_one.job_status = 'HLSC Verified'\n job_one.update\n job_two.job_status = 'HLSC Verified'\n job_two.update\n batch.update_status\n assert_equal 'HLSC Verified', batch.status\n\n # One HLSC Rejected and one processor allocated\n job_one.job_status = 'HLSC Rejected'\n job_one.update\n job_two.job_status = 'Complete'\n job_two.update\n batch.update_status\n assert_equal 'HLSC Rejected', batch.status\n end",
"def array_for_stage(jobs)\n jobs, _ = jobs.to_a.first if jobs.is_a? Hash\n\n jobs.inject([]) do |arr, job|\n arr << if job.is_a? Hash\n # Take just the job class, without any dependents\n job.keys[0]\n else\n job\n end\n end\n end",
"def job_completed(operation)\n jobs = operation.jobs.sort_by(&:updated_at)\n jobs.last.updated_at\n end",
"def sort\n if (defined? params[:moved] and defined? params[:test_case])\n # moved will look like 'test_case_3.0', make it '3.0' instead\n params[:moved].gsub!(/.*_(\\d+\\.\\d+)$/, '\\1')\n # find the new position for this item\n pos = params[:test_case].index(params[:moved]) + 1\n tc_id, tc_pos = params[:moved].split('.', 2)\n if (defined? pos and pos != tc_pos.to_i)\n stc = SuiteTestCase.where(:suite_id => params[:id], :test_case_id => tc_id).first\n if stc.insert_at(pos) != false\n flash[:notice] = \"Successfully saved sort order.\"\n end\n end\n end\n @suite = Suite.find(params[:id])\n # must redraw list with updated id #'s\n @current_cases = @suite.test_cases\n respond_with @suite do |format|\n format.js { render 'sort.js' }\n end\n end",
"def sort_groups!\n dashboard[:panel_groups] = dashboard[:panel_groups].sort_by { |group| -group[:priority].to_i }\n end",
"def priority_sort(result_list, free_bandwidth)\n priority_list = result_list.sort\n new_results = []\n priority_index = 0\n priority_list.each_index do |i|\n result = \"PASSED\"\n priority_index = priority_list[i].slice!(/^\\d+/).to_i\n bc = priority_list[i].split(\"|\")[0].unpack(\"a2a2a2\")\n if bc[2] == \"BF\"\n # fails if minimum failed and it's the top priority stream\n result = \"FAILED\" if bc[0] == \"YM\" && i == 0\n # fails if minimum failed and there was free bandwidth\n result = \"FAILED\" if bc[0] == \"YM\" && free_bandwidth > 0\n # fails if the bandwidth is over maximum specified\n result = \"FAILED\" if bc[1] == \"YN\"\n end\n new_results << priority_list[i].split(\"|\")[1].insert(0, \"[#{priority_index >= 0 ? sprintf(\"%d\", priority_index) : \"NONE\"}] [#{result}] \")\n end\n return new_results\nend",
"def in_progress_build\n active_states = [\"deploying\", \"testing\", \"monitoring\", \"awaiting_confirmation\"]\n builds_dataset.reverse_order(:id).filter(:state => active_states).first\n end",
"def test_retuns_job_in_a_specific_order_if_only_one_has_dependency\n sequence = Sequence.new()\n sequence.add(\"a =>\n b => c\n c =>\")\n sequence.ordered.each do |job|\n assert (%w[a b c].include?(job))\n end\n assert sequence.ordered.index(\"c\") < sequence.ordered.index(\"b\")\n end",
"def parse_input(params)\n puts \"============ Job will execute with following order =================\"\n puts Parser.sort_jobs!(Parser.parse_params(params))\n puts \"============ ************************************* =================\"\n Parser.sort_jobs!(Parser.parse_params(params))\n end",
"def render_jobs_list(jobs)\n workflow_with_jobs = []\n workflow_batch = {}\n\n jobs.each do |job|\n analysis = job&.analysis\n job.current_user = current_user\n workflow = analysis&.workflow\n slot = workflow_with_jobs.last\n\n if slot.nil? || slot[:analysis_dxid] != analysis&.dxid ||\n slot[:workflow]&.dxid != workflow&.dxid\n workflow_with_jobs << { analysis_dxid: analysis&.dxid,\n batch_id: analysis&.batch_id,\n workflow: workflow, jobs: [job] }\n fill_batch_with_workflows(workflow_batch, workflow, analysis)\n else\n slot[:jobs] << job\n end\n end\n\n workflow_with_jobs.map! do |slot|\n if slot[:workflow].nil?\n slot[:jobs].map do |job|\n job_serialized = JobSerializer.new(job)\n job_serialized.launched_on = job.analysis&.created_at || job.created_at\n job_serialized\n end\n else\n slot[:workflow].current_user = current_user\n\n workflow_serialized = WorkflowSerializer.new(slot[:workflow])\n number_workflows_in_batch(workflow_batch[slot[:batch_id]],\n workflow_serialized, slot[:analysis_dxid])\n workflow_serialized.jobs = slot[:jobs].map do |job|\n job_serialized = JobSerializer.new(job)\n\n launched_on = job.analysis&.created_at || job.created_at\n job_serialized.launched_on = launched_on\n if workflow_serialized.launched_on.nil? ||\n launched_on < workflow_serialized.launched_on\n workflow_serialized.launched_on = launched_on\n end\n\n job_serialized\n end\n\n workflow_serialized.launched_on ||= Time.current\n workflow_serialized\n end\n end.flatten!\n\n page_array = paginate_array(sort_array_by_fields(workflow_with_jobs))\n page_meta = pagination_meta(workflow_with_jobs.count)\n page_meta[:count] = page_meta.dig(:pagination, :total_count)\n\n render json: { jobs: page_array, meta: page_meta }, adapter: :json\n end",
"def latest_unpassing_jobs(project_id)\n latest_jobs(project_id).each_with_object([]) do |(branch, job_names), unpassing_jobs|\n job_names.each do |job_name, job|\n unpassing_jobs << job unless job['status'] == 'success'\n end\n end\nend",
"def orders_completed\n result = Array.new\n self.job_applications.each do |j|\n j.orders.each do |order|\n if !order.blank? and !order.workspace.blank?\n result << order if order.workspace.completed?\n end\n end\n end\n result\n end",
"def consecutive_failed_backup_jobs\n count = 0\n backup_source_jobs.descend_by_created_at.each do |job|\n break if job.successful?\n count += 1\n end\n count\n end",
"def job_priority\n case params[:queue]\n when 'high'\n 0\n when 'medium'\n 1\n when 'low'\n 2\n end\n end",
"def sort_and_group\n @customer_sort_field = validate_sort_field( @customer_sort_field )\n @project_sort_field = validate_sort_field( @project_sort_field )\n @task_sort_field = validate_sort_field( @task_sort_field )\n\n @filtered_tasks.sort! do | task_a, task_b |\n complex_sort(\n task_a,\n task_b,\n {\n :group_by_billable => ( @task_grouping == 'billable' || @task_grouping == 'both' ),\n :group_by_active => ( @task_grouping == 'active' || @task_grouping == 'both' ),\n :customer_sort_field => @customer_sort_field,\n :project_sort_field => @project_sort_field,\n :task_sort_field => @task_sort_field\n }\n )\n end\n end",
"def statuses_ordered\n statuses.all(:order => 'position ASC')\n end",
"def sort_due_date_incomplete\n @due_date_task_list.sort! { |duedatetask1, duedatetask2| duedatetask1.due_date <=> duedatetask2.due_date }\n @due_date_task_list.select { |duedatetask| (duedatetask.status == \"incomplete\") }\n end",
"def check_for_stuck_jobs\n Job.incomplete.each do |job|\n if job.stuck_chunks?\n job.priority = 50\n job.save!\n job.resend_stuck_chunks \n elsif job.stuck_packing?\n job.send_pack_request\n end\n end\n end",
"def sort_if_needed(deliverables)\n if session[@sort_name] && %w(score spent progress labor_budget).include?(session[@sort_name][:key])\n case session[@sort_name][:key]\n when \"score\" then\n sorted = deliverables.sort {|a,b| a.score <=> b.score}\n when \"spent\" then\n sorted = deliverables.sort {|a,b| a.spent <=> b.spent}\n when \"progress\" then\n sorted = deliverables.sort {|a,b| a.progress <=> b.progress}\n when \"labor_budget\" then\n sorted = deliverables.sort {|a,b| a.labor_budget <=> b.labor_budget}\n end\n\n return sorted if session[@sort_name][:order] == 'asc'\n return sorted.reverse! if session[@sort_name][:order] == 'desc'\n else\n return deliverables\n end\n end",
"def orders\n super.complete.order('completed_at DESC, id DESC')\n end",
"def get_status(job)\n (job.status == 'done' and !job.successful) ? 'Failed' : job.status.capitalize\n end",
"def tasks_uncompleted\n tasks_uncompleted = assigned_tasks.uncompleted.order(\"deadline DESC\")\n tasks_uncompleted += executed_tasks.uncompleted.order(\"deadline DESC\")\n tasks_uncompleted.sort_by { |h| h[:deadline] }.reverse!\n end",
"def sorted(tasks)\r\n tasks.sort_by {|task| task[\"priority\"]}\r\nend",
"def sort\n activity = nil\n params[:activity_in_sequence].each_with_index do |id, index|\n activity = Activity.find_by_id(id)\n Activity.update_all(['act_seq_order=?', index+1], ['id=?', id]) unless activity.user_id != current_user.id\n end\n activity.activity_sequence.set_current(activity.activity_sequence.first)\n render :nothing => true\n end",
"def completed_jobs\n @completed_jobs = Job.where(status: 'done').order(:deadline).paginate(page: params[:page], per_page: 15)\n end",
"def stages_with_resolved_dependencies\n # Looping over all stages...\n @stages.inject({}) do |resolved_stages, (name, jobs)|\n # If it's defined with a stage dependency\n jobs, _ = jobs.to_a.first if jobs.is_a? Hash\n\n # Looping over all jobs...\n resolved_stages[name] = jobs.inject([]) do |resolved_stage, job|\n job = job.keys[0] if job.is_a? Hash\n # Normalze to new hash form\n resolved_stage << {job => @dependencies[job]}\n end\n resolved_stages\n end\n end",
"def process_stages(stages)\n current_stage = stages.shift\n\n unless current_stage.nil?\n add_requests = merge_operations(current_stage).values.find_all { |op| op[0] == :+ }\n remove_requests = merge_operations(current_stage).values.find_all { |op| op[0] == :- }\n\n remove_requests.each do |remove_request|\n current_service = @service_registry.find_by_id(remove_request[1])\n\n unless current_service.nil?\n stop_service(current_service)\n end\n end\n\n remove_requests.each do |remove_request|\n current_service = @service_registry.find_by_id(remove_request[1])\n\n dependants(current_service.service)[:required].each do |dependant|\n if dependant.service.state? RunState::ACTIVE\n puts \"This really shouldn't be happening\"\n elsif dependant.service.state? RunState::RESOLVED\n dependant.service.set_state_installed\n end\n end\n\n @service_registry.unregister_service(remove_request[1])\n current_service.service.set_state_uninstalled\n\n end\n\n satisfied_dependencies = []\n\n registrations = add_requests.map do |add_request|\n @service_registry.register_service(*(add_request.drop(1))) { |registration|\n if has_required_dependencies? registration.service\n registration.service.set_state_resolved\n else\n registration.service.set_state_installed(\"Couldn't satisfy required dependencies: #{missing_dependencies(registration.service)}\")\n end\n\n dependants(registration.service)[:required].each do |dependant|\n if has_required_dependencies? dependant.service and dependant.service.state? RunState::INSTALLED\n dependant.service.set_state_resolved\n\n satisfied_dependencies << dependant\n end\n end\n }\n end\n\n registrations.each do |registration|\n start_service registration\n end\n\n satisfied_dependencies.each do |dependant|\n start_service dependant\n end\n\n # Process the remaining stages\n process_stages stages\n end\n end",
"def sort_cyclists_race_stage_list(race)\n sorted_cyclists_stage = [] \n race.stages.each do |stage|\n item = sort_cyclists_race_stage(race, stage)\n sorted_cyclists_stage << item\n end\n return sorted_cyclists_stage\n end",
"def inspect_jobs(index = nil)\n return empty_msg if empty?\n desc = []\n puts \"\\n\"\n @jobs.each_with_index do |j, i|\n unless index.nil?\n next unless i == index\n end\n desc << '| Job: ' + \"#{i + 1} \".rjust(8) + '|' + 'Pattern:'.rjust(18) + \" #{j.pattern.basename}\".ljust(120) + '|'\n desc << '| |' + 'Compiler ID:'.rjust(18) + \" #{j.id} \".ljust(120) + '|'\n desc << '| |' + 'Pinmap:'.rjust(18) + \" #{j.pinmap_workbook} \".ljust(120) + '|'\n desc << '| |' + '.atp directory:'.rjust(18) + \" #{j.pattern.dirname} \".ljust(120) + '|'\n desc << '| |' + '.pat directory:'.rjust(18) + \" #{j.output_directory} \".ljust(120) + '|'\n desc << '| |' + 'LSF:'.rjust(18) + \" #{j.location == :lsf ? true : false} \".ljust(120) + '|'\n desc << '| |' + 'Delete log files:'.rjust(18) + \" #{j.clean} \".ljust(120) + '|'\n desc << '| |' + 'Verbose:'.rjust(18) + \" #{j.verbose} \".ljust(120) + '|'\n fragment = '| |' + 'Compiler args:'.rjust(18)\n overflow_fragment = '| |' + ' '.rjust(18)\n compiler_args = []\n compiler_fragment = ''\n j.compiler_options.each_key do |k|\n if compiler_fragment.size + \" -#{k}\".size >= 120\n compiler_args << compiler_fragment\n compiler_fragment = nil\n end\n compiler_fragment += \" -#{k}\"\n end\n compiler_args << compiler_fragment unless compiler_fragment.nil?\n compiler_fragment = ''\n j.compiler_options_with_args.each_pair do |k, v|\n if compiler_fragment.size + \" -#{k}:#{v}\".size >= 120\n compiler_args << compiler_fragment\n compiler_fragment = nil\n end\n compiler_fragment += \" -#{k}:#{v}\"\n end\n compiler_args << compiler_fragment unless compiler_fragment.nil?\n if compiler_args.join.length <= 120\n desc << fragment + \"#{compiler_args.join}\".ljust(120) + '|'\n else\n # Need to cycle through compiler args and build a fragment <= 100 characters\n # and print it. Keep going until the remaining args is <= 100 and print again\n char_cnt = 0\n line_cnt = 0\n args = []\n compiler_args = compiler_args.join.strip.split(/\\s+/)\n until compiler_args.empty?\n args = compiler_args.select { |e| (char_cnt += e.length + 1) < 120 }\n # remove the args that fit on the first line\n compiler_args -= args\n if line_cnt == 0\n desc << fragment + \" #{args.join(' ')}\".ljust(120) + '|'\n else\n desc << overflow_fragment + \" #{args.join(' ')}\".ljust(120) + '|'\n end\n args = []\n line_cnt += 1\n char_cnt = 0\n end\n end\n desc << '-' * desc.first.size\n end\n puts desc.flatten.join(\"\\n\")\n end",
"def execution_state\n return :pending if self.test_executions.empty?\n\n self.test_executions.ordered_by_date.first.state\n end",
"def change_order_status_on_lazada(mp)\n @res = []\n orders = Spree::Order.where(\"market_place_id=? AND fulflmnt_state IN (?) AND market_place_order_status IN (?)\", mp.id, ['packup', 'completed', 'assign_for_repicking', 'delivery', 'assign_for_packup', \"picked_delivery\", \"dispatch_queue\", \"no_show\"], ['pending'])\n orders.each do |order|\n smp = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=?\", order.seller.id, mp.id) rescue nil\n if smp.present?\n @res << ApiJob.order_state_to_rts_lazada(order.id)\n end\n return @res.present? ? @res.join(\"; \") : \"Success\"\n end\n end",
"def sorted(tasks)\n tasks.sort_by {|task| task[:priority]}\nend",
"def success\n jobs_index(Job.success)\n end",
"def handle_failure(job,e)\n puts \"!\"\n puts \"! \\t FAIL\"\n puts \"! \\t \\t #{job.inspect}\"\n puts \"! \\t \\t #{e.inspect}\"\n puts \"!\"\n end",
"def handle_failure(job,e)\n puts \"!\"\n puts \"! \\t FAIL\"\n puts \"! \\t \\t #{job.inspect}\"\n puts \"! \\t \\t #{e.inspect}\"\n puts \"!\"\n end",
"def apply_sorting(chain)\n chain\n end",
"def failed_executions order = nil\n connection.failed_executions_for_user id, order\n end",
"def status()\n return [true, [], [], []] if not self.jobids.any?\n \n statuses = GridVid.query(@_keys.merge({:jobids => self.jobids}))\n passed = []\n running = [] \n failed = [] \n \n statuses.each_pair {|jobid, val|\n case val['status']\n when \"PASS\"\n passed << val['jobid'] \n when \"FAILED\" \n failed << val['jobid'] \n else\n running << val['jobid'] \n end \n }\n \n return [running.length == 0, passed, failed, running] \n end",
"def dependents_for_stage(stage_name)\n stage = array_for_stage(@stages[stage_name.to_sym])\n\n stage.inject([]) do |jobs, job|\n # Does the job have dependents?\n if job.is_a? Hash\n job, dependents = job.to_a.first\n jobs << job\n jobs << dependencies_for_job(dependents)\n else\n # Defined job is a simple class (eg Publisher)\n jobs << [job] + dependents_for(job)\n end\n end.flatten.uniq\n end",
"def complete_tasks\n sublist { |task| task.complete? }.sort_by { |task| task.completed_at }\n end",
"def test_return_multiple_idenpendent_jobs_in_any_order\n sequence = Sequence.new()\n sequence.add(\"a =>\n b =>\n c =>\")\n sequence.ordered.each do |job|\n assert (%w[a b c].include?(job))\n end\n end",
"def sort_operations\n operations.sort! { |a, b| sort_list(b, a) <=> sort_list(a, b) }\n end",
"def candidate_events_sorted\n # TODO: rewrite using event states\n candidate_events.sort do |ce1, ce2|\n # in order for this to work due_dates should not be nil.\n # if they are move them to the top so admin can give them\n # one.\n if ce1.due_date.nil?\n if ce2.due_date.nil?\n ce1.event_key <=> ce2.event_key\n else\n -1\n end\n elsif ce2.due_date.nil?\n 1\n elsif ce1.completed_date.nil?\n # due_dates filled in.\n if ce2.completed_date.nil?\n # if neither completed then the first to come\n # due is first\n due_date = ce1.due_date <=> ce2.due_date\n if due_date.zero?\n ce1.event_key <=> ce2.event_key\n else\n due_date\n end\n else\n # non completed goes on top.\n -1\n end\n elsif ce2.completed_date.nil?\n # non completed goes on top.\n 1\n else\n # if both are completed then the first to come\n # due is on top\n due_date = ce1.due_date <=> ce2.due_date\n if due_date.zero?\n ce1.event_key <=> ce2.event_key\n else\n due_date\n end\n end\n end\n end",
"def run_order\n max_quality < 100 ? -1 : 0\n end",
"def manager_list_by_status\n \n @sort_order = get_sort_order\n @sort_order[:status] = params[:order] == 'ASC' ? 'DESC' : 'ASC'\n flash[:sort_order] = @sort_order\n \n design_reviews = get_active_reviews\n @active_reviews = design_reviews[:active].sort_by { |dr| [dr[:review].review_status.name, dr[:review].age] }\n @inactive_reviews = design_reviews[:inactive].sort_by { |dr| [dr[:review].review_status.name, dr[:review].age] }\n @active_reviews.reverse! if params[:order] == 'DESC'\n @inactive_reviews.reverse! if params[:order] == 'DESC'\n \n @submissions = BoardDesignEntry.submission_count\n session[:return_to] = {:controller => 'tracker',\n :action => 'manager_list_by_date',\n :order => params[:order]}\n render( :action => 'manager_home' )\n\n end",
"def test_order(worker_name = 1)\n\n # if running on isolated UI, ignore priority and run only isolated tests\n if(worker_name.to_s.include?(\"isolate\"))\n return {\"isolated\" => 1}\n end\n\n # initialize hash\n order = {}\n\n begin\n # get record\n record = Worker.where(name: worker_name).first\n\n # pulling relevant fields into hash, unless they are ranked 0\n order['pixel'] = record.pixel if record.pixel != 0\n order['scheduled'] = record.scheduled if record.scheduled != 0\n order['buyflow'] = record.buyflow if record.buyflow != 0\n\n # sort into sorted array\n order_array = order.sort_by{|k, v| v}\n\n #convert back to hash for reading\n test_priority = Hash[order_array]\n rescue => e\n\n # catch and handle error\n Rails.logger.info \"Error - #{e.message}\"\n Rails.logger.info \"Could not find record for worker - using default order\"\n\n # use default hash\n test_priority = {\"scheduled\" =>1, \"buyflow\" => 2, \"pixel\" => 3}\n end\n\n # return to user\n return test_priority\n end",
"def index\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY CASE status\n WHEN '' THEN 1\n WHEN 'in progress' THEN 2\n WHEN 'reviewing' THEN 3\n WHEN 'done' THEN 4 END\")\n @sortType = params[:sort]\n\n if @sortType == \"title\"\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY title ASC\")\n end\n\n if @sortType == \"status\"\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY CASE status\n WHEN '' THEN 1\n WHEN 'in progress' THEN 2\n WHEN 'reviewing' THEN 3\n WHEN 'done' THEN 4 END\")\n end\n\n if @sortType == \"description\"\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY description ASC\")\n end\n\n if @sortType == \"deadline\"\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY deadline ASC\")\n end\n\n\n if @sortType == \"story_points\"\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY story_points ASC\")\n end\n\n if @sortType == \"priority\"\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY CASE priority\n WHEN '' THEN 1\n WHEN 'high' THEN 2\n WHEN 'medium' THEN 3\n WHEN 'low' THEN 4 END\")\n end\n @project = Project.find(params[:project_id])\n @sprint = Sprint.find(params[:sprint_id])\n end",
"def index\n # @customer_jobs = CustomerJob.where(depth: 0).order('job_name ASC')\n @customer_jobs = CustomerJob.all.order('job_name ASC')\n end",
"def order\n\n\t\t\t\ttestimonies = params.require(:testimonies)\n\n\t\t\t\torder = {}\n\t\t\t\ttestimonies.each_with_index do |id,i|\n\n\t\t\t\t\torder.merge! id => {sort: i}\n\n\t\t\t\tend\n\n\t\t\t\tif Testimony.update(order.keys,order.values)\n\n\t\t\t\t\trender json: nil,status: 200\n\n\t\t\t\telse\n\n\t\t\t\t\trender json: nil,status: 422\n\n\t\t\t\tend\n\n\t\t\tend",
"def cases_grouped_by_status(options = {}) \n options.delete_if { |key,value| value.blank? }\n options = {:sort => 'sfcase.last_modified_date', :order => 'DESC', :all_at_company => false}.merge(options)\n sort_sql = options[:sort] + ' ' + options[:order]\n \n if options[:all_at_company] and company\n # owner sort is handled thru Ruby...could be \n # either a Sfgroup or a Sfuser\n if options[:sort] == 'sfuser.last_name'\n cases = Sfcase.find(:all, :include => [:contact], \n :conditions => [\"sfcase.contact_id IN (?)\",company.associated_contacts.map { |c| c.id }])\n cases = sort_cases_by_owner(cases,options)\n else \n cases = Sfcase.find(:all, :include => [:contact], \n :conditions => [\"sfcase.contact_id IN (?)\",company.associated_contacts.map { |c| c.id }], \n :order => sort_sql).group_by(&:status)\n end\n else\n if options[:sort] == 'sfuser.last_name'\n cases = Sfcase.find(:all, \n :include => [:contact], \n :conditions => \"sfcase.contact_id = '#{id}'\")\n cases = sort_cases_by_owner(cases,options)\n else\n cases = Sfcase.find(:all, \n :include => [:contact], \n :conditions => \"sfcase.contact_id = '#{id}'\", \n :order => sort_sql).group_by(&:status)\n end\n end\n # cases = self.cases.find(:all, :order => sort_sql ).group_by(&:status)\n # cases = cases.group_by(&:status)\n ordered_cases = []\n AppConstants::CASE_SORT_ORDER.each do |status|\n cases.keys.each do |key|\n if key == status\n ordered_cases << [key,cases[key]]\n cases.delete(key)\n end\n end\n end\n # add in cases that aren't of any of the specified groups\n ordered_cases\n # now add in other case statuses\n cases.keys.each do |key|\n ordered_cases << [key, cases[key]]\n end\n ordered_cases\n end",
"def run_order\n 0\n end",
"def run_order\n 0\n end",
"def add_stages_to_transaction\n org_stages = self.organization.deal_statuses.where(\"name NOT IN (?)\", ['Won', 'Lost']).order(\"original_id\") \n org_stages.each do |stage|\n if stage.id == self.deal_status_id\n break\n else\n stage = self.organization.deal_statuses.where(\"id=?\",stage.id).first\n if stage.present? && stage.name.downcase != \"won\"\n begin\n DealTransaction.create({:organization_id => self.organization_id, :deal_id => self.id, :deal_status_id => stage.id, :user => User.current, :is_activity_display => false, :assigned_to => self.assigned_to.present? ? self.assigned_to : User.current.id})\n rescue\n end\n end\n end\n end\n end",
"def sort_by_algo(state_list)\n state_list.sort_by(&:algie_check)\n end",
"def active_jobs\n result = Array.new\n self.jobs.each do |j|\n if j.private?\n result << j\n elsif j.active?\n result << j\n end\n end\n result\n end",
"def collect_compare_priority\n @compare_quque = []\n @compare_quque = ComparisonTable.sort_by{|k, dar|\n DisplayOrder[StringTable[dar.first]] ? DisplayOrder[StringTable[dar.first]] : DisplayOrder[MISC_text]\n }.collect{|p| p[0]}\n end",
"def sort\n params[:skill].each do |key, value|\n Skill.find(value[:id]).update!(orderno: value[:orderno])\n end\n end",
"def sort\n raise l(:priority_sort_no_project_error) if !parent_object\n \n @priorities = parent_object.priorities\n \n params.keys.select{|k| k.include? UL_ID }.each do |key|\n Priority.sort_priorities(@priorities, params[key])\n end\n \n render :nothing => true\n end",
"def sort_project_build_phase\n puts \"Reordering build phase...\"\n\n project = Xcodeproj::Project.open(\"Traveloka.xcodeproj\")\n\n project.native_targets.each { |target|\n\n if target.name == \"Traveloka\" || target.name == \"Traveloka Staging\"\n # Take the native embed frameworks phase and pods build phases.\n native_embed_phase = target.build_phases.select { | build_phase |\n build_phase.to_s == \"Embed Frameworks\"\n }.first\n pods_embed_phase = target.build_phases.select { | build_phase |\n build_phase.to_s == \"[CP] Embed Pods Frameworks\"\n }.first\n pods_copy_phase = target.build_phases.select { | build_phase |\n build_phase.to_s == \"[CP] Copy Pods Resources\"\n }.first\n\n index_native_embed_phase = target.build_phases.index(native_embed_phase)\n\n # Shift the phase to below embed frameworks phase in native build phase.\n if index_native_embed_phase < target.build_phases.length && (pods_embed_phase != nil && pods_copy_phase != nil)\n target.build_phases.delete(pods_embed_phase)\n target.build_phases.delete(pods_copy_phase)\n target.build_phases.insert(index_native_embed_phase + 1, pods_copy_phase)\n target.build_phases.insert(index_native_embed_phase + 1, pods_embed_phase)\n end\n end\n }\n\n project.save\n\n puts \"\\e[32m√ Build phase reorder complete!\\e[0m\"\nend",
"def placings\n score_ordering = low? ? :asc : :desc\n\n scores.order(disqualified: :asc)\n .order(participated: :desc)\n .order(tier: :asc)\n .order(score: score_ordering)\n .order(tiebreaker_place: :asc)\n end",
"def processing\n jobs_index(Job.processing)\n end",
"def ja_sort\n [{ :created_at => :desc }]\n end",
"def sort_requirement\n find_user\n if !@user.nil?\n assign_project\n\n if params[:name]==\"created_at\"\n @requirements=Requirement.find(:all, :conditions=>[\"project_id=?\", session[:project_id]], :order => \"#{params[:name]} desc\")\n else\n @requirements=Requirement.find(:all, :conditions=>[\"project_id=?\", session[:project_id]], :order => \"#{params[:name]}\")\n end\n @attr=Attribute.find_by_project_id(session[:project_id])\n end\n end",
"def possible_builds\n commits = [@job.commit]\n\n if defined?(SamsonKubernetes) && @job.deploy.kubernetes_reuse_build\n previous_scope = @job.deploy.stage.deploys.prior_to(@job.deploy).where(kubernetes_reuse_build: false)\n previous = previous_scope.first&.job&.commit\n commits.unshift previous if previous\n end\n\n Build.where(git_sha: commits).sort_by { |build| [commits.index(build.git_sha), -build.updated_at.to_i] }\n end",
"def sort_if_needed\n @rules.sort! unless @sorted\n @sorted = true\n end"
] |
[
"0.62496305",
"0.61569655",
"0.6081873",
"0.5985731",
"0.5839663",
"0.56682956",
"0.5542638",
"0.54588515",
"0.54560703",
"0.54460883",
"0.5430229",
"0.54204166",
"0.5398697",
"0.5327998",
"0.52838296",
"0.5238117",
"0.52352196",
"0.52217776",
"0.5207978",
"0.52036643",
"0.5203209",
"0.5158789",
"0.5139889",
"0.5135203",
"0.5133683",
"0.51061213",
"0.50891554",
"0.5086599",
"0.50840044",
"0.50464404",
"0.50404304",
"0.5036418",
"0.50278836",
"0.50266117",
"0.5024133",
"0.5017173",
"0.5016102",
"0.5008549",
"0.50049174",
"0.5003215",
"0.49847472",
"0.49719915",
"0.49713373",
"0.49678317",
"0.4942178",
"0.49288353",
"0.4924396",
"0.49139026",
"0.49125353",
"0.49048647",
"0.48999912",
"0.48998934",
"0.4896376",
"0.48776126",
"0.4874028",
"0.48622864",
"0.48490426",
"0.4848523",
"0.48441917",
"0.48422295",
"0.48385864",
"0.4834913",
"0.48274335",
"0.48262608",
"0.48255995",
"0.48204815",
"0.48176026",
"0.48057237",
"0.48036724",
"0.48036724",
"0.48003843",
"0.47951517",
"0.47845086",
"0.47738773",
"0.47726637",
"0.4771184",
"0.4761265",
"0.47469905",
"0.47363967",
"0.4731618",
"0.47308686",
"0.4728054",
"0.47277355",
"0.47120225",
"0.47111714",
"0.4709486",
"0.4709486",
"0.4696725",
"0.46865708",
"0.46861574",
"0.46849474",
"0.46795222",
"0.46771172",
"0.46761227",
"0.4672155",
"0.46681982",
"0.4660529",
"0.46601757",
"0.46483546",
"0.4647852"
] |
0.67354697
|
0
|
Showcases a specific project.
|
def spotlight
@project = Project.find_by_guid(params[:guid])
@main_heading = spanitize(@project.name)+" <span class=\"punctuation\">#{@project.completed_on.strftime("%Y")}</span>"
@assets = @project.assets
@assets.shift
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @project = Project.find params[:id]\n @page_title = \"Project #{@project.name}\"\n end",
"def pick_demo_project(dir)\n projs = projects_in_dir(dir)\n if projs.count == 0\n raise Informative, 'Unable to find any project in the source files' \\\n \" of the Pod: `#{dir}`\"\n elsif projs.count == 1\n projs.first\n elsif (workspaces = projs.grep(/(demo|example|sample).*\\.xcworkspace$/i)).count == 1\n workspaces.first\n elsif (projects = projs.grep(/demo|example|sample/i)).count == 1\n projects.first\n else\n message = 'Which project would you like to open'\n selection_array = projs.map do |p|\n Pathname.new(p).relative_path_from(dir).to_s\n end\n index = UI.choose_from_array(selection_array, message)\n projs[index]\n end\n end",
"def show\n @project = Project.find(@perk.project_id)\n add_breadcrumb @project.name.to_s, '/projects/' + @project.id.to_s\n end",
"def show\n @page_title = \"Voluntips | Projekt: \" + @project.title\n set_show_keywords\n end",
"def show\n @project = Project.find(params[:id])\n @page_title = \"Project: \" + @project.title\n end",
"def show\n set_project_stat\n end",
"def show\n set_project_stat\n end",
"def show\n\t\tif @project = Project.find_by(id: params[:id])\n\t\t\trender 'show'\n\t\telse\n\t\t\trender 'no_projects_found'\n\t\tend\n\tend",
"def should_see_project_named(name)\n expect(page).to have_content name\n expect(page).to have_content \"STATUS UNDERWAY\"\n end",
"def show\n if params[:name]\n @project = Project.where(name: \"#{params[:name]}\").first\n else\n set_project\n end\n end",
"def show\n @project = @integrant.project\n end",
"def show\n @projects = @zabydovnuk.projects\n end",
"def show\n @project = Project.find(params[:project_id])\n end",
"def show\n @projects = find_projects\n end",
"def project; end",
"def projects ; end",
"def find_project(name)\n get(\"/projects/#{name}\")\n end",
"def find_project(name)\n get(\"/projects/#{name}\")\n end",
"def ask_for_project(message)\n ask_for(message,projects)\n end",
"def set_project\n @project = Project.includes(cases: :tester_user, suites: {cases: :tester_user}).find(params[:id])\n end",
"def run!\n begin\n found = Project.find(@dir)\n rescue MissingProject\n ask_questions!\n make_directories!\n create_config!\n copy_sources!\n say color(\"Your project was created\", :green)\n say Montage::Commands::BLANK\n else\n raise Montage::ProjectExists, <<-ERROR.compress_lines\n A Montage project exists in a parent directory at\n `#{found.paths.root}'\n ERROR\n end\n end",
"def set_project\n\n end",
"def set_project\n\n end",
"def show(project_token = @project_token, id = @id, user = @@default_user)\n @attributes = send_request(\"test_cases/#{id}\", :get) do |req|\n req.params = {\n token: project_token,\n auth_token: user.auth_token\n }\n end\n end",
"def project_new\n new_project.click\n end",
"def project(project_id)\n resource \"projects/#{project_id}\"\n end",
"def show\n @project = Project.find(params[:id])\n end",
"def show\n @project = Project.find(params[:id])\n end",
"def show\n @project = Project.find(params[:id])\n end",
"def show\n @project = Project.find(params[:id])\n end",
"def show\n @project = Project.find(params[:id])\n end",
"def show\n @project = Project.find(params[:id])\n end",
"def show\n @project = Project.find(params[:id])\n end",
"def show\n @project = Project.find(params[:id])\n end",
"def show\n @project = Project.find(params[:id])\n end",
"def listprojects()\n #loading array of all projects\n projects = Array.new(GoodData::Project.all)\n\n puts \"\"\n puts \"\"\n puts \"Listing GoodData projects available under provided credentials\"\n puts \"\"\n\n counter = 0\n #loop through projects and print their title and PID\n projects.each do |pr|\n counter += 1\n puts \"#{counter}. \"+pr.title+\" - \"+pr.pid\n end\n puts \"\"\n puts \"\"\n\n #get the number of the project from the user\n print \"Choose project:\"\n\n pnum = gets.chomp.to_i - 1\n\n wrkproj = projects[pnum]\n project_detail(wrkproj)\nend",
"def show\n add_breadcrumb \"Project: #{@project.name}\", project_path(@project)\n add_breadcrumb \"Phase #{@phase.sequence + 1}: #{@phase.name}\", project_phase_path(@project, @phase)\n add_breadcrumb \"Experiment: #{@experiment.name}\"\n end",
"def open_project(path)\n UI.puts \"Opening '#{path}'\"\n `open \"#{path}\"`\n end",
"def searchProject(project_name)\n\t\n\t$story_name = project_name\n\tputs \"************** START: Search PROJECT ****************\"\n\t$browser.click \"//strong\"\n\t$browser.wait_for_page_to_load\n\t$browser.click \"orgScope\"\n\tsleep 2\n\t$browser.click \"widgetScope\"\n\tsleep 2\n\tputs \"Step 1 : Type #{$story_name} in the Search Field\"\n\t$browser.type \"parametricKeyword\", project_name\n\t$browser.click \"//button[@type='submit']\"\n\tsleep 5\n\tputs \"Step 2 : Click on #{$story_name} link\"\n\t$browser.click \"link=#{$story_name}\"\n\t$browser.wait_for_page_to_load\n\tbegin\n\t\tassert_equal \"#{$story_name} - Razoo\", $browser.get_title\n\t\tputs \"Step 3 : Passed. User reached #{$story_name} Story Page successfully!!\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 3 : Failed. Problem in reaching the Project Story page.\"\n\tend\n\tputs \"************** END : Search PROJECT ****************\"\nend",
"def searchProject(project_name)\n\t\n\t$story_name = project_name\n\tputs \"************** START: Search PROJECT ****************\"\n\t$browser.click \"//strong\"\n\t$browser.wait_for_page_to_load\n\t$browser.click \"orgScope\"\n\tsleep 2\n\t$browser.click \"widgetScope\"\n\tsleep 2\n\tputs \"Step 1 : Type #{$story_name} in the Search Field\"\n\t$browser.type \"parametricKeyword\", project_name\n\t$browser.click \"//button[@type='submit']\"\n\tsleep 5\n\tputs \"Step 2 : Click on #{$story_name} link\"\n\t$browser.click \"link=#{$story_name}\"\n\t$browser.wait_for_page_to_load\n\tbegin\n\t\tassert_equal \"#{$story_name} - Razoo\", $browser.get_title\n\t\tputs \"Step 3 : Passed. User reached #{$story_name} Story Page successfully!!\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 3 : Failed. Problem in reaching the Project Story page.\"\n\tend\n\tputs \"************** END : Search PROJECT ****************\"\nend",
"def project\n end",
"def test_checklist_for_project\n login\n project = projects(:one_genus_two_species_project)\n expect = Name.joins(observations: :project_observations).\n where({ observations: { project_observations:\n { project_id: project.id } } }).\n with_rank(\"Species\").distinct\n\n get(:show, params: { project_id: project.id })\n assert_match(/Checklist for #{project.title}/, css_select(\"title\").text,\n \"Wrong page\")\n\n prove_checklist_content(expect)\n end",
"def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html\n end\n end",
"def show\n @projects = @dataset.experiments.collect { |experiment| experiment.project }.uniq\n end",
"def run_all\n \n projects.each do |project|\n project.targets.each do |target|\n config = target.config('Debug')\n UI.info((\"*\" * 80))\n UI.info \"Building #{project.name} - #{target.name} - #{config.name}\"\n UI.info((\"*\" * 80))\n config.builder.build\n end\n end\n \n end",
"def active_project_select(project)\n project_link = active_project_table.find('a', :text => /\\A#{project}\\z/)\n project_link.native.send_keys(:enter)\n end",
"def show\n @project = @pds_project\n end",
"def show\n @projects = @setting.experiments.collect { |experiment| experiment.project }.uniq\n end",
"def show\n @project = @model.project\n end",
"def project_switch(project_name)\n # Check if project exists\n if project_list.include?(project_name)\n print_line(\"Switching to #{project_name}\")\n # Disable spooling for current\n driver.init_ui(driver.input, Rex::Ui::Text::Output::Stdio.new)\n\n # Switch workspace\n workspace = framework.db.find_workspace(project_name)\n framework.db.workspace = workspace\n print_line(\"Workspace: #{workspace.name}\")\n\n # Spool\n spool_path = ::File.join(Msf::Config.log_directory, 'projects', framework.db.workspace.name)\n spool_file = ::File.join(spool_path, \"#{project_name}_spool.log\")\n\n # Start spooling for new workspace\n driver.init_ui(driver.input, Rex::Ui::Text::Output::Tee.new(spool_file))\n\n # Restore the prompt so we don't get \"msf > >\".\n #prompt = framework.datastore['Prompt'] || Msf::Ui::Console::Driver::DefaultPrompt\n #prompt_char = framework.datastore['PromptChar'] || Msf::Ui::Console::Driver::DefaultPromptChar\n #if active_module # if there is an active module, give them the fanciness they have come to expect\n # driver.update_prompt(\"#{prompt} #{mod.type}(%bld%red#{mod.shortname}%clr) \", prompt_char, true)\n #else\n # driver.update_prompt(\"#{prompt} \", prompt_char, true)\n #end\n\n print_line(\"Spooling to file #{spool_file}...\")\n print_line(\"Successfully migrated to #{project_name}\")\n else\n print_error('Project was not found on list of projects!')\n end\n return true\n end",
"def project(name)\n @projects.find { |p| p.name == name }\n end",
"def select_project( options )\n index = nil\n \n if(options[:index] ) \n index = options[:index] if @projects.size > options[:index]\n elsif(options[:name])\n index = @project_list.index(options[:name])\n end\n\n puts \"IN AdamModel - select_project found index : #{index}\"\n \n if( index )\n @selected_project_index = index\n @selected_asset_index = 0\n load_assets_and_filter\n return true\n end\n\n return false\n end",
"def test_project\n project\n @browser.find_element(:id, 'tab-versions').click\n sleep (2)\n @browser.find_element(:xpath, \"//*[@id='tab-content-versions']/p[2]/a\").click\n version = rand(999).to_s + 'version'\n @browser.find_element(:id, 'version_name').send_keys version\n @browser.find_element(:name, 'commit').click\n #expected = 'Successful creation.'\n expected = 'Создание успешно.'\n assert_equal(expected, @browser.find_element(:id, 'flash_notice').text)\n end",
"def show_all_projects\r\n json = GoodData.get GoodData.profile.projects\r\n puts \"You have this project available:\"\r\n json[\"projects\"].map do |project|\r\n pid = project[\"project\"][\"links\"][\"roles\"].to_s\r\n puts \"Project name: #{project[\"project\"][\"meta\"][\"title\"].bright} Project PID: #{pid.match(\"[^\\/]{32}\").to_s.bright}\"\r\n end\r\n end",
"def show_selected_projects(query, args = {})\n args = {\n action: :index,\n letters: \"projects.title\",\n num_per_page: 50,\n include: :user\n }.merge(args)\n\n show_index_of_objects(query, args)\n end",
"def get(project_name)\n response = get_request(\"/projects/#{project_name}/\")\n TheShiningSource::Project.new(response)\n end",
"def run_on_project\n @target_dir = @params[:target_dir]\n zones = @project.get_element('zones')\n\n # iterates all zones, descend into zone\n run_on_project_zones(zones)\n\n # use the specwrite class to write a complete\n # serverspec example in a subdirectory(serverspec)\n target_specdir = File.join(@target_dir, 'serverspec')\n\n begin\n spec_writer = SpecWriter.new(target_specdir, @spec_code)\n spec_writer.write\n\n outputs 'SPEC', \"Serverspecs written to #{target_specdir}. Run:\"\n outputs 'SPEC', \"( cd #{target_specdir}; sudo rake spec )\"\n outputs 'SPEC', 'To run automatically, use --run'\n rescue => exception\n $log.error \"Error writing serverspec files, #{exception}\"\n STDERR.puts exception.inspect\n end\n\n run_serverspec(target_specdir) if @params[:auto_run]\n end",
"def create_valid_project\n create_project_with 'Some test project'\n end",
"def select_project_id(test_data)\n hide_notifications_bar\n logger.info \"Entering project ID '#{test_data[CoreUseOfCollectionsData::PROJECT_ID.name]}'\"\n wait_for_options_and_select(project_id_input, project_id_options, test_data[CoreUseOfCollectionsData::PROJECT_ID.name])\n end",
"def project\n return \"fake-project\" if ENV[\"LAKA_TEST\"]\n `gcloud config get-value project`.strip\n end",
"def fake_out_xcode_project_loading\n fake_result = <<-EOS\nInformation about project \"Example\":\n Targets:\n Example\n ExampleUITests\n ExampleMacOS\n ExampleMacOSUITests\n Build Configurations:\n Debug\n Release\n If no build configuration is specified and -scheme is not passed then \"Release\" is used.\n Schemes:\n Example\n ExampleUITests\n ExampleMacOS\nEOS\n allow_any_instance_of(FastlaneCore::Project).to receive(:raw_info).and_return(fake_result)\nend",
"def new\n @project = Project.new\n @title = \"New Project\"\n end",
"def show_project # :nologin: :prefetch:\n store_location\n pass_query_params\n if @project = find_or_goto_index(Project, params[:id].to_s)\n @is_member = @project.is_member?(@user)\n @is_admin = @project.is_admin?(@user)\n\n @draft_data = Project.connection.select_all %(\n SELECT n.display_name, nd.id, nd.user_id\n FROM names n, name_descriptions nd, name_descriptions_admins nda\n WHERE nda.user_group_id = #{@project.admin_group_id}\n AND nd.id = nda.name_description_id\n AND n.id = nd.name_id\n ORDER BY n.sort_name ASC, n.author ASC\n )\n end\n end",
"def details\n get(\"project/details\")[\"project\"]\n end",
"def select_project_id(test_data)\n hide_notifications_bar\n wait_for_options_and_select(project_id_input, project_id_options, test_data[UseOfCollections::PROJECT_ID.name])\n end",
"def enter_project_desc(test_data)\n hide_notifications_bar\n logger.info \"Entering project description '#{test_data[CoreUseOfCollectionsData::PROJECT_DESC.name]}'\"\n wait_for_element_and_type(project_desc_text_area, test_data[CoreUseOfCollectionsData::PROJECT_DESC.name])\n end",
"def list_projects # :nologin:\n query = create_query(:Project, :all, :by => :title)\n show_selected_projects(query)\n end",
"def url_for_project_named(name)\n eval project_path\n end",
"def show\n @project = @project_issue.project\n end",
"def project(project_id, params = {})\n make_get_request(\"/projects/#{project_id}\", params)\n end",
"def show\n\n \n @projects = Project.select(\"all\").where(:project_id => params[:id]);\n \n end",
"def show\n @content = @project.content\n end",
"def run_project(args)\n cmd = \"run #{args.join(' ')} 2>&1 | tee -a #{log}\"\n system %{trap 'killall -9 \"iPhone Simulator\"' INT ; #{bin} #{cmd}}\n end",
"def index\n @projects_briefcases = ProjectsBriefcase.all\n end",
"def show\n # turn ruby database into json\n # route to the project 3 page with this json\n # id = 1\n end",
"def project(options = {})\n raise Unfuddled::Error.new(\"No options given for project, cannot query\") if options == {}\n \n raise Unfuddled::Error.new(\"Can only supply one of :id and :name\") if options.keys.include?([:id , :name])\n \n url = \"/api/v1/projects/#{options[:id]}.json\" if options.keys.include?(:id)\n url = \"/api/v1/projects/by_short_name/#{options[:name]}.json\" if options.keys.include?(:name)\n\n Unfuddled::Project.from_response( send(:get , url)[:body] , self)\n end",
"def show\n @project = Project.find(params[:id])\n set_current_project\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def open_project(widget)\n # Filter for the file chooser\n filter = Gtk::FileFilter.new\n filter.name = '.cproj'\n filter.add_pattern('*.cproj')\n\n # File chooser dialog\n chooser = create_chooser filter, Gtk::Stock::OPEN,\"Choose a .cproj file\" \n\n # Check the user input\n chooser.run do |r|\n if r == Gtk::Dialog::RESPONSE_ACCEPT\n @project.open chooser.filename\n @treeView.create_tree @project\n end\n chooser.destroy\n end\n end",
"def show\n @projects = Project.all\n end",
"def show\n if @project\n if ProjectUser.verify_role(current_user.id, @project, 'client')\n render json: Project.build_project_object(@project, current_user.id), status: 200\n else\n render json: { error: 'You must be a member of a project to see its content' }, status: :unauthorized\n end\n else\n render json: { error: \"no project found with id of #{params[:id]}\" }, status: 404\n end\n end",
"def set_project\n @project = Project.friendly.find(params[:id])\n @title = @project.title\n @content = @project.title + ' started at ' + @project.start_date.to_s + ' for ' + @project.client_name.to_s +\n ' with ' + @project.contract_type + ' contract type ' + 'and lasted '+ @project.duration.to_s + ' month, located at ' + @project.location + ', ' + @project.design_capacity + ' design capacity and ' + @project.construction_man_hour.to_s + ' construction man hour.'\n end",
"def select_project_to_monitor_post_production\n @projects = current_user.assigned_projects_for( PROJECT_ROLE[:account_executive] )\n \n add_breadcrumb \"Select Project\", 'select_project_to_monitor_post_production_url'\n render :file => \"projects/project_management/select_project_to_monitor_post_production\"\n end",
"def project\n @client.project(:id => project_id)\n end",
"def index\n prepare_projects_display\n \n end",
"def show_project\r\n @project = Project.find(params[:id])\r\n @id = @project.id\r\n respond_to do |format|\r\n format.html { render 'project_control/view' }\r\n format.json { render json: @project }\r\n end\r\n end",
"def show\n @project = Project.find(params[:id])\n @tcs = @project.test_cases.where(\"status != 'deleted'\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @project }\n end\n end",
"def test_info(project_name, plan_name, test_case_name)\n test_plan_id = test_plan_id(project_name, plan_name)\n test_cases = test_cases_for_test_plan(test_plan_id)\n\n test_cases.values.find do |test_case|\n test_case[:name] == test_case_name\n end\n end",
"def set_target_project\n @project = Project.find(params[:id])\n end",
"def name\n 'Project'\n end",
"def show\r\n @project = Project.find params[:project_id] if params[:project_id]\r\n @project ||= @round.projects.first\r\n @issue = Issue.find params[:issue_id] if params[:issue_id]\r\n @scenario = Scenario.find params[:scenario_id] if params[:scenario_id]\r\n\r\n @label = Label.find params[:label_id] if params[:label_id]\r\n @no_label = params[:no_label]\r\n @unexecuted = params[:unexecuted]\r\n @execution_result = params[:execution_result]\r\n\r\n conditions = {}\r\n conditions[:issue_id] = @issue.id if @issue\r\n\r\n @scenario_folders = @project.requirements\r\n\r\n @scenarios_grid = ScenarioGrid.new do |scope|\r\n r = scope.where(conditions)\r\n r = r.label(@label) if @label\r\n r = r.no_label if @no_label\r\n r = r.unexecuted(@round) if @unexecuted\r\n r = r.execution_result(@round, @execution_result) if @execution_result\r\n r.page(params[:page]).per(20)\r\n end\r\n @scenarios_grid.column_names = [:execution_title, :defects, :labels, \"execution_buttons project-actions\"]\r\n\r\n @defects = Defect.current_scenario(@scenario) if @scenario\r\n end",
"def show\n @project = Project.find(params[:project_id])\n @subproject = Subproject.find(params[:id])\n end",
"def show\n @project = Project.find(params[:id])\n @pads = Pad.find_all_by_p_name(@project.name)\n #@frames = Frame.find_all_by_p_name(@project.name)\n respond_to do |format|\n set_current_project(@project)\n format.html # show.html.erb\n format.json { render :json => @project }\n end\n end",
"def run_project(options={}, *package_names)\n options = {\n 'ssh_config_file' => ssh_config_file,\n 'project_dir' => method_dir,\n 'remote_dir' => remote_dir,\n 'quiet' => true,\n }.merge(options)\n \n linecook('run', options, *package_names)\n end",
"def setup_projects\n # noop\n end",
"def new\n @test = Project.new\n end",
"def project(project_id, query_params = nil)\n get(\"/projects/#{project_id}\", query_params)\n end",
"def start_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'StartProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :project_name\n\t\t\targs[:query]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def set_project\n begin\n @project = current_institute.projects.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n redirect_to projects_path\n end\n end",
"def project(options)\n ARGV << '--help' if ARGV.length == 0\n begin\n OptionParser.new do |opts|\n opts.banner = 'Usage: tm -p PROVIDER [options] project [project_options]'\n opts.separator ''\n opts.separator 'Options:'\n \n opts.on('-C', '--create ATTRIBUTES', 'Create a new project') do |attribute|\n options[:project_attributes] = {attribute => ARGV.shift}.merge(attributes_hash(ARGV))\n options[:subcommand] = 'create'\n end\n \n opts.on('-R', '--read [PROJECT]', 'Read out project and its attributes') do |id|\n options[:project] = id if id\n options[:subcommand] = 'read'\n end\n \n opts.on('-U', '--update ATTRIBUTES', 'Update project information') do |attribute|\n options[:project_attributes] = {attribute => ARGV.shift}.merge(attributes_hash(ARGV))\n options[:subcommand] = 'update'\n end\n \n opts.on('-D', '--destroy [PROJECT]', 'Destroy the project. Not reversible!') do |id|\n options[:project] = id if id\n options[:subcommand] = 'destroy'\n end\n \n opts.on('-I', '--info [PROJECT_ID]', 'Get project info. Same as --read. ') do |id|\n options[:project] = id if id\n options[:subcommand] = 'read'\n end\n \n opts.on('-S', '--search [ATTRIBUTES]', 'Search for a project based on attributes') do |attribute|\n options[:project_attributes] = attribute ? {attribute => ARGV.shift}.merge(attributes_hash(ARGV)) : {}\n options[:subcommand] = 'search'\n end\n \n opts.on('-L', '--list-all', 'List all projects. Same as --search without any parameters') do\n options[:project_attributes] = {}\n options[:subcommand] = 'search'\n end\n \n opts.on('-P', '--project [PROJECT_ID]', 'Set the project id') do |id|\n options[:project] = id\n end\n \n opts.separator ''\n opts.separator 'Other options:'\n \n opts.on_tail('-h', '--help', 'Show this message') do\n puts opts\n exit\n end\n end.order!\n rescue OptionParser::MissingArgument => exception\n puts \"tm #{options[:original_argv].join(' ')}\\n\\n\"\n puts \"Error: An option was called that requires an argument, but was not given one\"\n puts exception.message\n end\n parse_config!(options)\n begin\n require 'ticketmaster'\n require \"ticketmaster-#{options[:provider]}\"\n rescue\n require options[:provider]\n end\n send(options[:subcommand], options)\nend",
"def set_project\n @project = Project.friendly.find(params[:project_id])\n end",
"def index\n\t @title = \"Miradi Data Server\"\n\t \"<html>Welcome to the Miradi Data Server!<br/>\" +\n\t\t\"<form action='projects' method='post' accept-charset='utf8'>\" + \n\t\t\"Project Name: <input type='text' name='name'></input>\" +\n\t\t\"<input type='submit' value='Create Project'></input>\" + \n\t\t\"</form>\"\n\tend"
] |
[
"0.63962287",
"0.6232627",
"0.62316436",
"0.621612",
"0.62108773",
"0.61737895",
"0.61737895",
"0.61718553",
"0.6095874",
"0.6070048",
"0.6066141",
"0.60609514",
"0.6023641",
"0.60217977",
"0.60068315",
"0.6003659",
"0.5989172",
"0.5989172",
"0.59808344",
"0.59803337",
"0.5979686",
"0.59784806",
"0.59784806",
"0.5976331",
"0.59741366",
"0.5943092",
"0.5919998",
"0.5919998",
"0.5919998",
"0.5919998",
"0.5919998",
"0.5919998",
"0.5919998",
"0.5919998",
"0.5919998",
"0.59180754",
"0.59133255",
"0.59086514",
"0.59034973",
"0.59034973",
"0.59015054",
"0.5869207",
"0.5857515",
"0.583345",
"0.5826456",
"0.58197415",
"0.58155954",
"0.5815448",
"0.5796279",
"0.57945704",
"0.5785511",
"0.57841974",
"0.57718617",
"0.577171",
"0.57613176",
"0.575854",
"0.5754032",
"0.5747568",
"0.572894",
"0.57246196",
"0.57232565",
"0.570286",
"0.5690839",
"0.56903595",
"0.5688762",
"0.56740373",
"0.5673455",
"0.56619436",
"0.5658893",
"0.5654351",
"0.56541693",
"0.5648818",
"0.56445384",
"0.5635958",
"0.5634534",
"0.56338096",
"0.5626941",
"0.5625062",
"0.5621252",
"0.56176454",
"0.5611321",
"0.5610201",
"0.56098527",
"0.5605279",
"0.560506",
"0.5601601",
"0.56013244",
"0.5598869",
"0.559564",
"0.55809647",
"0.55635214",
"0.55577654",
"0.55566055",
"0.55542475",
"0.5553776",
"0.5552685",
"0.5551525",
"0.5551138",
"0.55359423",
"0.55308175",
"0.5529457"
] |
0.0
|
-1
|
Displays about me page.
|
def about
@main_heading='<span>Hello</span> <span>my</span> <span>name</span> <span>is</span> <span>Jim</span><span class="punctuation">.</span>'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def about\r\n end",
"def about; render; end",
"def about\n end",
"def about\n\t\t@user = current_user\n\tend",
"def about\n\n end",
"def about\n\tend",
"def about\n\tend",
"def about\n \n end",
"def about_me\n\tend",
"def about\n\n \tend",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n\n end",
"def about\n\n end",
"def about\n\n end",
"def about; end",
"def about; end",
"def about_me\n @breadcrumbs << [I18n.t('pages.about.breadcrumb'), about_path]\n @breadcrumbs << [I18n.t('pages.about.me.breadcrumb')]\n end",
"def about\n # Static Page\n end",
"def about_us\n # it's deliberate that there's no code in here... but we should have a helpful error when we request the URL again\n end",
"def about_us\n\n\tend",
"def about_command(stem, sender, reply_to, msg)\n # This method renders the file \"about.txt.erb\"\n end",
"def about\n # STUB\n end",
"def set_about_me\n @about_me = AboutMe.find(params[:id])\n end",
"def command_about(m)\n m.user.send \"Showbot was created by Jeremy Mack (@mutewinter) and some awesome contributors on github. The project page is located at https://github.com/mutewinter/Showbot\"\n m.user.send \"Type !help for a list of showbot's commands\"\n end",
"def about\n @current_nav_identifier = :about\n params[:name] = @current_nav_identifier\n set_page\n render 'show'\n end",
"def about(widget)\n puts \"about\"\n Gnome::About.new(TITLE, VERSION ,\n \"Copyright (C) 2008 Universidad EAFIT\",\n \"Colatio Builder\",\n [\"Juan Guillermo Lalinde\",\"Federico Builes\",\"Alejandro Peláez\",\"Nicolás Hock\"],\n [\"Juan Guillermo Lalinde\",\"Federico Builes\",\"Alejandro Peláez\",\"Nicolás Hock\"],\n nil).show\n end",
"def set_admin_about\n @about = Admin::AboutMe.find(params[:id])\n end",
"def about_us\n end",
"def about_us\n end",
"def about\n\t\tabout_post = Post.of_type(Post::POST_TYPE_ABOUT)\n\t\tif about_post.present?\n\t\t\tgon.post = about_post.as_json\n\t\t\trender :show\n\t\telse\n\t\t\tredirect_to :root\n\t\tend\n\tend",
"def show_about_window_for app\n app.show_about_window\n end",
"def about\n puts \"Name: #{@name}\"\n end",
"def set_aboutme\n @aboutme = Aboutme.find(params[:id])\n end",
"def me\n @user = current_user\n render \"show\"\n end",
"def about_us; end",
"def show_about\n @metadata_profile = @unit.effective_metadata_profile\n @num_downloads = MonthlyUnitItemDownloadCount.sum_for_unit(unit: @unit)\n @num_submitted_items = @unit.submitted_item_count\n @collections = Collection.search.\n institution(@unit.institution).\n filter(Collection::IndexFields::PRIMARY_UNIT, @unit.id).\n order(\"#{Collection::IndexFields::TITLE}.sort\").\n limit(999)\n @subunits = Unit.search.\n institution(@unit.institution).\n parent_unit(@unit).\n order(\"#{Unit::IndexFields::TITLE}.sort\").\n limit(999)\n render partial: \"show_about_tab\"\n end",
"def about\n\t\t\tputs \"Here is our potential Santa for the season.\"\n\t\t\tputs \"They have changed their name to #{@name}.\"\n\t\t\tputs \"They identify themself as #{@gender}\"\n\t\t\tputs \"They are #{age} years young\"\n\t\t\tputs \"Soon they will be celebrating their #{celebrate_birthday(100)}th birthday,\"\n\t\tend",
"def about\n @about_object = instance_variable_get(\"@#{controller_name.singularize}\")\n render template: \"/dash/base/about\"\n end",
"def about_us\r\n\t@title = \"About Us\"\r\n end",
"def app_about\n end",
"def about_us\n render(:about_us, layout:false) and return\n end",
"def about\n Qt::MessageBox.about(self, 'Jacinthe Reports', ABOUT.join(\"\\n\"))\n end",
"def about\n Qt::MessageBox.about(self, 'Jacinthe Reports', ABOUT.join(\"\\n\"))\n end",
"def about\n @title = \"about\"\n end",
"def about_me\r\n puts \"I'm #{@name} and I'm #{@age} years old!\"\r\n end",
"def about\n @toc_id = 'about'\n end",
"def about\n\t\tunless params[:result].nil?\n\t\t\t@result = params[:result]\n\t\tend\n\n\t\t@about = Static.where(\"title = ?\", \"about\").first\n\tend",
"def profile\n\t@user = current_user\n\t@title = \"This is your profile page\"\n end",
"def set_about\n @about = About.find(params[:id])\n end",
"def set_about\n @about = About.find(params[:id])\n end",
"def about\n\t\tputs \"Make: \" + @make\n\t\tputs \"Model: \" + @model\n\t\tputs \"Miles: \" + @miles.to_s\n\t\tputs \"Type: \" + @type\n\t\tputs \"Color: \" + @color\n\t\tputs \"Year: \" + @year.to_s\n\t\tif @used\n\t\t\tputs \"The #{@make} #{@model} is used.\"\n\t\telse\n\t\t\tputs \"The #{@make} #{@model} is new\"\n\t\tend\n\tend",
"def about\n render :template =>\"bodysize/about\"\n end",
"def about\n @about_html = current_institution&.about_html\n end",
"def about\n respond_to do |format|\n format.html { render :about }\n end\n end",
"def show\n @editable = @page\n @title = PageTitle.new I18n.t(\"page_titles.about.#{@page.slug}\")\n\n # no layout\n render html: @page.content.html_safe, layout: false if @page.content_in_html?\n end",
"def about_me\n puts \"I'm #{@name} and I'm #{@age} years old!\"\n end",
"def about_me\n puts \"I'm #{@name} and I'm #{@age} years old!\"\n end",
"def about_me\n puts \"I'm #{@name} and I'm #{@age} years old!\"\n end",
"def about_me\n puts \"I'm #{@name} and I'm #{@age} years old!\"\n end",
"def show\n @page_title = 'Profile for ' + @person.full_name\n end",
"def set_about_u\n @about_u = AboutU.find(params[:id])\n end",
"def about\n @user = current_user\n @content = UserContent.find_by_user_id(@user.id) # Originally created on 'User' creation. Check 'User' Model.\n # @content = current_user.user_contents\n \n respond_to do |format| \n if params[:ajax] == \"true\" # Request came from ajax. Respond without layout.\n format.html { render :layout => false } # about.html.erb\n else\n format.html # about.html.erb WITH layout\n end\n end\n end",
"def about\n Qt::MessageBox.information(self, tr(\"About\"), tr(\"This is a simple DICOM Viewer made with QtRuby.\"))\n end",
"def about\n require \"github/markup\"\n @readme = GitHub::Markup.render(\"README.md\", File.read(\"README.md\")).html_safe\n end",
"def about\n respond_to do |format|\n format.html # about.html.erb\n format.xml { render :xml => nil }\n end\n end",
"def set_about\n @about = About.first\n end",
"def set_about\n @about = About.first\n end",
"def set_about\n @about = about.find(params[:id])\n end",
"def show\n @aboutu = Aboutu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aboutu }\n end\n end",
"def create\n @about_me = AboutMe.new(about_me_params)\n\n if @about_me.save\n redirect_to [:admin, @about_me], notice: 'About me was successfully created.'\n else\n render :new\n end\n end",
"def index\n @about_mes = AboutMe.all\n end",
"def about\n\t\tputs \"Your gender is #{@gender}!\"\n\t\tputs \"Your ethnicity is #{@ethnicity}!\"\n\t\tputs \"Here is the #{@reindeer_ranking}!\"\n\t\tputs \"Santa is #{age} year(s) old!\"\n\tend",
"def about\r\n\t\tputs \"Gender: #{@gender}\"\r\n\t\tputs \"ethnicity: #{@ethnicity}\"\r\n\t\tputs \"reindeer_ranking: #{@reindeer_ranking}\"\r\n\t\tputs \"age: #{@age}\"\r\n\tend",
"def set_about\n @about = About.find(params[:id])\n end",
"def update\n if @about_me.update(about_me_params)\n redirect_to [:admin, @about_me], notice: 'About me was successfully updated.'\n else\n render :edit\n end\n end",
"def about\n\t\tcontent = Content.first.about_content\n\t\tif content.present?\n\t\t# response to the JSON\n \t render json: { success: true, response: {about_content: content.as_json} },:status=> 200\n\t else\n\t render :json=> { success: false, message: \"About Content is not present\" },:status=> 203\n\t end \n\tend",
"def show\n @admin_about = About.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_about }\n end\n end",
"def about\n\t\tputs \"Gender: #{@gender}\"\n\t\tputs \"Ethnicity: #{@ethnicity}\"\n\t\tputs \"Age: #{@age}\"\n\t\tp \"Reindeer Ranking: #{@reindeer_ranking}\"\n\tend",
"def show\n @me = current_user\n end",
"def show\n @about_page = AboutPage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @about_page }\n end\n end",
"def show\n # Not showing hacker info right now, perhaps this will be a profile page in the future.\n redirect_to entries_path\n end",
"def set_about\n if params[:id].to_i >0\n @adminabout = About.find(params[:id])\n end\n end",
"def user_information\n @current_user = current_user\n\n render :partial => 'home/user_info'\n end"
] |
[
"0.7451907",
"0.73669726",
"0.7351496",
"0.73436224",
"0.73277146",
"0.72607416",
"0.72607416",
"0.7220392",
"0.72112465",
"0.718813",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.71365947",
"0.71365947",
"0.71365947",
"0.703458",
"0.703458",
"0.6970587",
"0.69121397",
"0.6901819",
"0.68292654",
"0.6794614",
"0.6751307",
"0.67260885",
"0.6697472",
"0.6682818",
"0.66627055",
"0.66451734",
"0.66335076",
"0.66335076",
"0.6567441",
"0.6537827",
"0.6507957",
"0.64835197",
"0.6428372",
"0.6419567",
"0.6416757",
"0.6357404",
"0.6341491",
"0.6336738",
"0.6297117",
"0.62732387",
"0.62674296",
"0.62674296",
"0.6175684",
"0.61406237",
"0.6138466",
"0.6125629",
"0.6089556",
"0.6073829",
"0.6073829",
"0.6061611",
"0.6057171",
"0.60014105",
"0.59873235",
"0.5973917",
"0.5942423",
"0.5942423",
"0.5942423",
"0.5942423",
"0.5940464",
"0.59379923",
"0.5934237",
"0.59121174",
"0.5884604",
"0.58438766",
"0.58306515",
"0.58306515",
"0.58251923",
"0.58187246",
"0.57851017",
"0.57771224",
"0.5776718",
"0.57730347",
"0.57499003",
"0.5740652",
"0.57150376",
"0.5714967",
"0.57095647",
"0.56998986",
"0.56899285",
"0.56898415",
"0.5680187",
"0.5674589"
] |
0.0
|
-1
|
Wraps content words in individual spans.
|
def spanitize(content)
content.split(" ").map { |s| "<span>#{s}</span>" }.join(" ")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def wrap_in_spans(**options)\n safe_join(options.fetch(:value, []).map { |v| content_tag(:span, html_escape(v)) })\n end",
"def wrap( content )\n content\n end",
"def span_wrap tag, text\n \"<span class='#{tag}' markdown='1'>#{text}</span>\"\nend",
"def wrap\n @text\n end",
"def words\n grid.words.map {|word| decorate_word(word) }\n end",
"def wrap(content)\n [\"<#{@wrap_tag}>\", content, \"</#{@wrap_tag}>\"].join\n end",
"def wrap(body)\n separator = \" \"\n words = body.split(separator)\n sentences = []\n sentence = []\n words.each do |word|\n sentence.push(word)\n if (sentence).join(separator).length > 75\n sentence.pop\n sentences.push(sentence.join(separator))\n sentence = [word]\n end\n end\n if sentence.length > 0\n sentences.push(sentence.join(separator))\n end\n sentences.join(\"\\n\")\nend",
"def wrap_list(list, width)\n list.map do |text|\n wrap_text(text, width)\n end.flatten\n end",
"def highlight_words(t, words, html = true)\n if html\n t = h(t)\n end\n if html\n t = highlight(t, words, '<span class=\"highlight\">\\1</span>')\n else\n t = highlight(t, words, '*\\1*')\n end\n return t\n end",
"def wrap(width=nil)\n if width.nil? or width < 0\n term_width, _ = Term.size\n\n if width and width < 0\n width = (term_width - 1) + width\n else\n width = term_width - 1\n end\n end\n\n return self if size <= width\n\n strings = []\n start_pos = 0\n end_pos = width\n\n loop do\n split_pos = rindex(/\\s/, end_pos) || end_pos\n\n strings << self[start_pos...split_pos]\n\n start_pos = index(/\\S/, split_pos)\n break if start_pos == nil\n end_pos = start_pos + width\n\n if end_pos > size\n strings << self[start_pos..-1]\n break\n end\n end\n\n if block_given?\n strings.each { |s| yield s }\n else\n strings.join(\"\\n\")\n end\n end",
"def insert_tag(tagname, cssclass, words)\n wrapped = false\n\n loop do\n break if words.empty?\n\n if words.first.standalone_tag?\n tag_words = words.extract_consecutive_words! do |word|\n word.standalone_tag?\n end\n @content << wrap_text_in_diff_tag(tag_words.join, tagname, cssclass)\n elsif words.first.iframe_tag?\n tag_words = words.extract_consecutive_words! { |word| word.iframe_tag? }\n @content << wrap_text_in_diff_tag(tag_words.join, tagname, cssclass)\n elsif words.first.block_tag?\n tag_words = words.extract_consecutive_words! { |word| word.block_tag? }\n @content << wrap_text_in_diff_tag(tag_words.join, tagname, cssclass)\n elsif words.first.tag?\n\n # If this chunk of text contains unclosed tags, then wrapping it will\n # cause weirdness. This would be the case if we have e.g. a style\n # applied to a paragraph tag, which will change the opening tag, but\n # not the closing tag.\n #\n #\n\n if !wrapped && !words.contains_unclosed_tag?\n @content << diff_tag_start(tagname, cssclass)\n wrapped = true\n end\n @content += words.extract_consecutive_words! do |word|\n word.tag? && !word.standalone_tag? && !word.iframe_tag?\n end\n else\n non_tags = words.extract_consecutive_words! do |word|\n (word.standalone_tag? || !word.tag?)\n end\n unless non_tags.join.empty?\n @content << wrap_text_in_diff_tag(non_tags.join, tagname, cssclass)\n end\n\n break if words.empty?\n end\n end\n\n @content << diff_tag_end(tagname) if wrapped\n end",
"def wordwrap(text, width=120, string='<wbr />')\n wrapped = ''\n\n # Get array of words and loop through them.\n (text).scan(/\\w+/).each do |word|\n\n new_word = ''\n if word.length > width\n ((word.length / width)+1).times do |i|\n range = (width*i)..((width*(i+1))-1)\n new_word += word[range] + string\n end\n end\n new_word = word unless word.length > width\n\n wrapped += new_word + ' ' + string\n end\n\n wrapped\n end",
"def wrap(num_lines)\n cleaned = gsub(/\\s+/, ' ').strip\n\n chars_per_line = cleaned.size / num_lines.to_f\n\n lines = []\n cleaned.split.each do |word|\n if lines.empty?\n lines << word\n else\n if (lines[-1].size + 1 + word.size) <= chars_per_line ||\n lines.size >= num_lines\n lines[-1] << ' ' unless lines[-1].empty?\n lines[-1] << word\n else\n lines << word\n end\n end\n end\n\n Caption.new(lines.join(\"\\n\"))\n end",
"def wrap_text\n return @wrap_text\n end",
"def wrap_with_paragraphs(env, nodes); end",
"def html_breaking_wrap(html, col=80)\n # Breakup the string by html tags\n tag_regex = /<\\/?[^>]*>/\n if html && html =~ tag_regex\n # Breakup the string by html tags\n ss = StringScanner.new( html )\n a = []\n while ( ss.scan_until(tag_regex) )\n a << ss.pre_match if !ss.pre_match.blank?\n a << ss.matched \n ss = StringScanner.new( ss.rest ) \n end\n a << ss.rest if ss.rest?\n \n # For each non-tag break long words\n a.collect{ |s| s[0..0]=='<' ? s : text_breaking_wrap(s, col) }.join\n else\n text_breaking_wrap(html, col) \n end\n end",
"def wrap(text, length)\n cur_page.wrap(text, length)\n end",
"def word_wrap(width=60)\n lines = []\n line = \"\"\n self.split(/\\s+/).each do |word|\n if line.size + word.size >= width\n lines << line\n line = word\n elsif line.empty?\n line = word\n else\n line << \" \" << word\n end\n end\n lines << line if line\n return lines.join \"\\n\"\n end",
"def word_wrap(text, line_width: T.unsafe(nil), break_sequence: T.unsafe(nil)); end",
"def wrap(html); end",
"def wrap(html); end",
"def wrap_text(s, width=78) # {{{\n return nil unless s\n\ts.gsub(/(.{1,#{width}})(\\s+|\\Z)/, \"\\\\1\\n\").split(\"\\n\")\nend",
"def wrap(text)\n @proxy.wrap(text)\n end",
"def wrap text = nil, prefix = \"<nowiki>\", suffix = \"</nowiki>\"\n result = \"\"\n text = (yield(text)) || text if block_given?\n when_not_empty(text) { result = \"#{prefix}#{text}#{suffix}\" }\n result\n end",
"def wrap_text(text, size)\n text = text.split(\" \")\n wrapped_text = \"\"\n current_line_size = 0\n text.each { |word|\n if (word.length + 1 + current_line_size > size)\n wrapped_text += \"\\n\"\n wrapped_text += word\n current_line_size = word.length\n else\n wrapped_text += \" \" unless current_line_size == 0\n wrapped_text += \"#{word}\"\n current_line_size += word.length\n end\n }\n wrapped_text\nend",
"def wrap_words(s, limit)\n result = []\n words = s.split(\" \")\n\n line = []\n j = 0\n\n while j < words.size\n line << words[j]\n\n # Use join(\" \") to add space to the string\n if line.join(\" \").size > limit && line.size == 1 # When the word length is longer than the limit\n result << line.join(\" \")\n line = []\n elsif line.join(\" \").size > limit\n line.pop\n result << line.join(\" \")\n line = []\n next\n end\n\n if j == words.size - 1 && line != []# When we reach the end of the array\n result << line.join(\" \")\n end\n\n j += 1\n end\n\n p result\nend",
"def wrap_tag text, tag = \"nowiki\", &block\n wrap(text, \"<#{tag}>\", \"</#{tag}>\", &block)\n end",
"def add_tool_tip_span(text)\n text_array = text.split(' ')\n p text_array\n words_to_replace = {}\n text_array.each do |word|\n search_word = word.chomp(',').chomp('.').chomp(')').chomp(';').downcase\n if Glossary.where(word: search_word)[0]\n words_to_replace[word] = search_word\n elsif Glossary.where(word: search_word.chomp('s'))[0]\n words_to_replace[word] = search_word.chomp('s')\n end\n end\n words_to_replace.each do |word , search_word|\n entry = Glossary.find_by(word: search_word)\n text_array.each_with_index do |array_word, index|\n if array_word == word\n text_array[index] = \"<a href='' data-toggle='tooltip' title='#{entry.definition}'>#{word}</a>\"\n end\n end\n end\n return text_array.join(\" \")\nend",
"def in_words_group\n if self < 100\n self.in_words_under_100\n else\n self.in_words_3_digits\n end\n end",
"def wrap_text(txt, col = 75)\n txt.wrap_text(col)\n end",
"def breaking_word_wrap(txt, col = 80)\n txt.gsub(/(.{1,#{col}})( +|$\\n?)|(.{1,#{col}})/,\n \"\\\\1\\\\3\\n\")\n end",
"def words\n @content.split\n end",
"def words\n @content.split\n end",
"def widont(text)\n text.gsub(%r/\n (\\s+) # some whitespace group 1\n ( # capture group 2\n (?:<(?:a|em|span|strong|i|b)[^>]*?>\\s*)? # an optional opening tag\n [^<>\\s]+ # the matched word itself\n (?:<\\/(?:a|em|span|strong|i|b)[^>]*?>\\s*)? # optional inline closing tags\n (?:\\s*?<\\/(?:p|h[1-6]|li|dt|dd)>) # a closing element\n )/x, ' \\2')\n end",
"def wrapped_text *args\n options = {\n :line_width => columns\n }.merge args.extract_options!\n\n line = args.shift\n\n word_wrap(line, options)\n end",
"def wrapped_by_paragraph; end",
"def word_wrap( s,width=10 )\n\tret=[]\n\tline=\"\"\n\ts.split.map { |x|\n\t\tword=x\n\t\tif line.size + x.size + 1 <= width\n\t\t\tline += x + \" \"\n\t\telse\n\t\t\tif word.size > width\n\t\t\t\tret << line\n\t\t\t\tline = \"\"\n\t\t\t\tw = word.clone\n\t\t\t\twhile w.size > width\n\t\t\t\t\tret << w[0..(width-1)]\n\t\t\t\t\tw = w[width.to_i..-1]\n\t\t\t\tend\n\t\t\t\tret << w unless w.size == 0\n\t\t\telse\n\t\t\t\tret << line\n\t\t\t\tline = x + \" \"\n\t\t\tend\n\t\tend\t\t\n \t}\n\tret << line unless line.empty?\n\n\tret\nend",
"def word_wrap(txt, maxlen, word_pattern = DEFAULT_WORD_PATTERN)\n words = txt.scan(word_pattern)\n\n words.each_with_object(['']) do |word, lines|\n last = lines.last\n wordlen = word.rstrip.length\n\n if wordlen > maxlen\n lines.concat(word.scan(/.{1,#{maxlen}}/))\n elsif last != '' && last.length + wordlen > maxlen\n lines << word\n else\n lines.last << word\n end\n end.delete_if(&:empty?).each(&:strip!)\n end",
"def wrapped_text *args\n options = {\n :line_width => columns\n }.merge args.extract_options!\n\n line = args.shift\n\n word_wrap(line, options)\n end",
"def whisper_words(words)\n\nend",
"def find_words \n # breaks the story_template into keywords using .split, which inherently splits at spaces\n keywords = @story_template.split()\n # Using a for loop, looks at each word in the story_template and identifies if it is not empty and has a staple []\n keywords.each do |word|\n if (word != \"\") && (word[0] == \"[\")\n @story_keywords << word[1..-2] # This line takes every char from after the [ until the ]\n end\n end\n @story_keywords \n end",
"def each_word opts = {}, &block\n {:whitespace => :attach_before, :delemiters => :attach_before}.merge! opts\n \n # First, we create a two-dimensional array of words with any whitespace or\n # delemiters that should attach to them.\n mapped = []\n attach_before_next = []\n \n self.enumerate do |item|\n case item\n when Delimiter\n case opts[:delemiters]\n when :standalone\n mapped << [item]\n when :attach_after\n attach_before_next << item\n else\n if attach_before_next.empty?\n if mapped.last\n mapped.last << item\n else\n attach_before_next << item\n end\n else\n attach_before_next << item\n end\n end\n \n when Whitespace\n case opts[:whitespace]\n when :standalone\n mapped << [item]\n when :attach_after\n attach_before_next << item\n else\n if attach_before_next.empty?\n if mapped.last\n mapped.last << item\n else\n attach_before_next << item\n end\n else\n attach_before_next << item\n end\n end\n \n when Word\n if not attach_before_next.empty?\n mapped << [attach_before_next, item].flatten\n attach_before_next = []\n else\n mapped << [item]\n end\n \n end\n end\n \n if not attach_before_next.empty?\n mapped << [Word.new] unless mapped.last\n (mapped.last << attach_before_next).flatten!\n end\n \n # Next, we yield each group of (word plus delimiters and whitespace) as a\n # normal string to the block\n mapped.each do |arr|\n yield arr.map{|w|w.to_s}.join\n end\n end",
"def output_words\n if @number <= self.class.total_included_words\n convert_paragraphs_to_words(self.class.included_paragraphs_joined)\n else\n repeat = (@number / self.class.total_included_words.to_f).ceil\n convert_paragraphs_to_words((PARAGRAPHS * repeat).join(\"\\n\\n\"))\n end\n end",
"def with_span(span)\n Context.with(CONTEXT_SPAN_KEY, span) { |s| yield s }\n end",
"def break_words(stuff)\n words = stuff.split(' ')\nend",
"def word_wrap(input, max_width)\n # List of lines, where each line is a list of words.\n lines = [[]]\n\n # Add words to the last line until it would go over the max\n # width, in which case start a new line.\n input.split(/ +/).each do |word|\n if (lines + [word]).join(' ').size < max_width\n lines.last << word\n else\n lines << [word]\n end\n end\n\n # We're done, just turn the lists of words into actual lines.\n return lines.map { |l| l.join(' ') }\n end",
"def build_contained_spans\n contained_span_builders.find_all(&:finished?).map(&:to_span)\n end",
"def word_wrap(text, line_width=40)\n text.split(\"\\n\").collect do |line|\n line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\\s+|$)/, \"\\\\1\\n\").strip : line\n end * \"\\n\"\n end",
"def reformat_wrapped(s, width = Config::Gui::MSG_WIDTH - 1)\n \t lines = []\n \t line = \"\"\n \t s.split(/\\s+/).each do |word|\n \t if line.size + word.size >= width\n \t lines << line\n \t line = word\n \t elsif line.empty?\n \t line = word\n \t else\n \t line << \" \" << word\n \t end\n \t end\n \t lines << line if line\n \t return lines\n \tend",
"def with_span(span)\n Context.with_value(CURRENT_SPAN_KEY, span) { |c, s| yield s, c }\n end",
"def split_text(text)\n if @wrap == :word\n text, skip = text.split(/\\s/), -1\n cc = /(\\\\\\w\\[\\w+\\])(.+)/\n text.each_with_index do |w,i|\n next if i < skip\n w << ' ' unless w[-1] == ' '\n rarr = []\n w.sub!(cc) do\n vals = [$1, $2]\n $2 =~ /^(\\s*)$/ ? rarr.concat(['', vals[0]]) : rarr << vals[0]\n \"SpLiThErE#{vals[1]}\"\n end while w =~ cc\n unless rarr.empty?\n w.sub!(/^SpLiThErE/) { '' }\n warr = w.split('SpLiThErE') and text.delete_at(i)\n until rarr.empty? && warr.empty?\n t = '' << (rarr[0] ? rarr.shift : '') << (warr[0] ? warr.shift : '')\n text.insert(i, t) and i += 1\n end\n skip = i\n end\n end\n else text = text.split(//) end\n return text\n end",
"def with_span(span)\n Context.with_value(CURRENT_SPAN_KEY, span) { |c, s| yield s, c }\n end",
"def apply_template_to_words_or_texts_in (word_list, &render)\n\n sentence_pattern = self.word_template.split(//) # reduce the template to just characters\n\n output_sentence = [] # the outputted sentence as an array (join before return)\n\n sentence_pattern.each do |pattern_character|\n\n if pattern_character !~ /^[xCc]$/ # if matching the formatting characters, convert\n output_sentence << pattern_character\n\n else # otherwise just output directly (because it's punctuation)\n output_sentence << render.yield(pattern_character, word_list)\n end\n\n end\n\n output_sentence.join(\"\")\n end",
"def word_wrap(text, line_width = 80)\n text.split(\"\\n\").collect do |line|\n line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\\s+|$)/, \"\\\\1\\n\").strip : line\n end * \"\\n\"\n end",
"def break_words(stuff)\r\n words = stuff.split(' ')\r\n return words\r\nend",
"def format_text(text, wrap, indent=0)\n result = []\n work = clean_text(text)\n\n while work.length > wrap do\n if work =~ /^(.{0,#{wrap}})[ \\n]/\n result << $1.rstrip\n work.slice!(0, $&.length)\n else\n result << work.slice!(0, wrap)\n end\n end\n\n result << work if work.length.nonzero?\n result.join(\"\\n\").gsub(/^/, \" \" * indent)\n end",
"def format_text(text, wrap, indent=0)\n result = []\n work = clean_text(text)\n\n while work.length > wrap do\n if work =~ /^(.{0,#{wrap}})[ \\n]/\n result << $1.rstrip\n work.slice!(0, $&.length)\n else\n result << work.slice!(0, wrap)\n end\n end\n\n result << work if work.length.nonzero?\n result.join(\"\\n\").gsub(/^/, \" \" * indent)\n end",
"def word_wrap(text, line_width = 80)\n text.split(\"\\n\").collect do |line|\n line.length > line_width ?\n line.gsub(/(.{1,#{line_width}})(\\s+|$)/, \"\\\\1\\n\").strip :\n line\n end * \"\\n\"\nend",
"def snippet(text, wordcount, omission)\n return '' if text.blank?\n text.split[0..(wordcount-1)].join(\" \") + (text.split.size > wordcount ? \" \" + omission : \"\")\n end",
"def span(stylename, content)\n %Q(<text:span text:style-name=\"#{stylename}\">#{ERB::Util.h(content)}</text:span>)\n end",
"def wrap(text)\n return text if @done\n\n text = \"#{@pre_wrap.values}#{text}\" if @pre_wrap\n\n if dyn_params[:id]\n @tag ||= 'div'\n end\n\n if @tag\n if text.blank? && EMPTY_TAGS.include?(@tag)\n res = \"#{@pre_wrap}<#{@tag}#{params_to_html}#{@append}/>\"\n else\n res = \"<#{@tag}#{params_to_html}#{@append}>#{text}</#{@tag}>\"\n end\n else\n res = text\n end\n @done = true\n\n (@space_before || '') + res + (@space_after || '')\n end",
"def wrap text\n return unless text && !text.empty?\n\n text_len = @width - @indent\n\n text_len = 20 if text_len < 20\n\n re = /^(.{0,#{text_len}})[ \\n]/\n next_prefix = ' ' * @indent\n\n prefix = @prefix || next_prefix\n @prefix = nil\n\n @res << prefix\n\n while text.length > text_len\n if text =~ re then\n @res << $1\n text.slice!(0, $&.length)\n else\n @res << text.slice!(0, text_len)\n end\n\n @res << \"\\n\" << next_prefix\n end\n\n if text.empty? then\n @res.pop\n @res.pop\n else\n @res << text\n @res << \"\\n\"\n end\n end",
"def whisper_words(words)\nreturn words.map{ |elem| elem.downcase + \"...\"}\nend",
"def format_as_span_html(name, attr, body); end",
"def wrap(width)\n width ||= 80\n output = []\n indent = ''\n\n text = gsub(/\\t/, ' ')\n\n text.lines do |line|\n line.chomp! \"\\n\"\n if line.length > width\n indent = if line.uncolor =~ /^(\\s*(?:[+\\-*]|\\d+\\.) )/\n ' ' * Regexp.last_match[1].length\n else\n ''\n end\n new_lines = line.split_line(width)\n\n while new_lines.length > 1 && new_lines[1].length + indent.length > width\n output.push new_lines[0]\n\n new_lines = new_lines[1].split_line(width, indent)\n end\n output += [new_lines[0], indent + new_lines[1]]\n else\n output.push line\n end\n end\n output.map!(&:rstrip)\n output.join(\"\\n\")\n end",
"def interesting_words(sentence, stop_word_array=['a', 'the', 'on'])\n # TODO\nend",
"def highlight(html, words)\n tokenizer = HTML::Tokenizer.new(html)\n tokens = []\n \n while token = tokenizer.next\n tokens << token unless token[0, 1] == \"<\" or token.delete(\"\\r\\n\\t\").empty?\n end\n\n sections = []\n pattern = /(#{words.join('|')})/i\n i = 0\n\n while i < tokens.size\n if tokens[i].downcase =~ pattern\n sections << tokens[ [0, i - 5].max .. i + 5].to_a.join(' ') \n i += 4\n end\n \n i += 1\n end\n\n sections.map do |section|\n section.gsub(pattern, '<span class=\"highlight\">\\1</span>')\n end\n end",
"def wrap_text(txt, col = 80)\n txt.gsub(/(.{1,#{col}})( +|$\\n?)|(.{1,#{col}})/,\n \"\\\\1\\\\3\\n\")\n end",
"def wrap_entry(entry_name, content); end",
"def break_words(stuff)\n words = stuff.split(' ')\n words # removed the return command\nend",
"def wrap(node_or_tags); end",
"def word_wrap(text, options = {})\n line_width = options.fetch(:line_width, 80)\n whitespace = options.fetch(:whitespace, 0)\n text.split(\"\\n\").collect! do |line|\n line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\\s+|$)/, \"\\\\1\\n#{\" \"*whitespace}\").strip : line\n end * \"\\n\"\n end",
"def apply_span_transforms( str, rs )\n\t\t\t@log.debug \"Applying span transforms to:\\n %p\" % str\n\n\t\t\tstr = transform_code_spans( str, rs )\n\t\t\tstr = transform_auto_links( str, rs )\n\t\t\tstr = encode_html( str )\n\t\t\tstr = transform_images( str, rs )\n\t\t\tstr = transform_anchors( str, rs )\n\t\t\tstr = transform_italic_and_bold( str, rs )\n\n\t\t\t# Hard breaks\n\t\t\tstr.gsub!( / {2,}\\n/, \"<br#{EmptyElementSuffix}\\n\" )\n\n\t\t\t@log.debug \"Done with span transforms:\\n %p\" % str\n\t\t\treturn str\n\t\tend",
"def line_wrap(strs, first_indent, rest_indent, max_len)\n\n # First, tokenize the strings\n words = []\n strs.each do |str|\n if str =~ /\\A</\n # String is a tag; treat as atomic unit and don't split\n words << str\n else\n # String of white and non-white tokens.\n # Tokenize into white and non-white tokens.\n str.scan(/\\S+|\\s+/).each { |word| words << word }\n end\n end\n\n # Now merge tokens that are not separated by whitespace tokens. For\n # example, \"<i>\", \"word\", \"</i>\" gets merged to \"<i>word</i>\". But\n # \"<i>\", \" \", \"word\", \" \", \"</i>\" gets left as separate tokens.\n\n words2 = []\n words.each do |word|\n # If there is a previous word that does not end with whitespace,\n # and the currrent word does not begin with whitespace, concatenate\n # current word to previous word. Otherwise append current word to\n # end of list of words.\n if words2.last && words2.last !~ /\\s\\z/ && word !~ /\\A\\s/\n words2.last << word\n else\n words2 << word\n end\n end\n\n lines = [ ]\n line = \"\"\n llen = 0\n # set the indent for the first line\n indent = first_indent\n # saved-up whitespace to put before next non-white word\n white = \"\"\n \n words2.each do |word| # ... while words remain to wrap\n # If word is whitespace, save it. It gets added before next\n # word if no line-break occurs.\n if word =~ /\\A\\s/\n white << word\n next\n end\n wlen = word.size\n if llen == 0\n # New output line; it gets at least one word (discard any\n # saved whitespace)\n line = \" \" * indent + word\n llen = indent + wlen\n indent = rest_indent\n white = \"\"\n next\n end\n if llen + white.length + wlen > max_len\n # Word (plus saved whitespace) won't fit on current line.\n # Begin new line (discard any saved whitespace).\n lines << line\n line = \" \" * indent + word\n llen = indent + wlen\n indent = rest_indent\n white = \"\"\n next\n end\n # add word to current line with saved whitespace between\n line << white + word\n llen += white.length + wlen\n white = \"\"\n end\n \n # push remaining line, if any\n lines << line unless line.empty?\n \n return lines\n end",
"def each(&block)\n @words.each(&block)\n end",
"def convert_to_words(text)\n convert_to_paragraph(text).join(\" \").split(\" \")\n end",
"def div_wrap tag, text\n \"<div class='#{tag}' markdown='1'>#{text}</div>\"\nend",
"def wrap_text(txt, col = 80)\n txt.gsub(/(.{1,#{col}})( +|$\\n?)|(.{1,#{col}})/, \"\\\\1\\\\3\\n\") \nend",
"def wrap_text(txt, col)\n txt.gsub(/(.{1,#{col}})( +|$)\\n?|(.{#{col}})/,\"\\\\1\\\\3\\n\")\n end",
"def whisper_words(words)\n\twhisper = words.map { |word| word.downcase + \"...\"}\n \treturn whisper\nend",
"def get_words(qty = 30)\n raise \"Error on quantity of words.\" if qty < 1\n\n words = []\n\n qty.times do\n words += [apply_replacements(@evaluated_expression.sample)]\n end \n\n words\n end",
"def goHighlight (h, s)\n # if (!h) return\n # hLen = h.size\n #\n # for (var i=0; i<hLen; i++) {\n # var para = this.paragraphList().list[h[i]-1] || false;\n # if (para) {\n # var sntns = s[h[i].toString()] || false;\n # var multi = !sntns || sntns.length==0; #// Individual sentences, or whole paragraphy?\n # var lines = this.getSentences(para);\n # var jLen = lines.length;\n #\n # /* First pass. Add SPAN tags to all lines. */\n # for (var j=0; j<jLen; j++) {\n # var k = (multi) ? j : sntns[j]-1;\n # lines[j] = \"<span data-num='\" + (j+1) + \"'>\" + lines[j] + \"</span>\";\n # # // lines[j] = \"<a name='\" + (j+1) + \"' /><span data-num='\" + (j+1) + \"'>\" + lines[j] + \"</span>\";\n # }\n #\n # /* Second pass, update span to Highlight selected lines */\n # for (var j=0; j<jLen; j++) {\n # var k = (multi) ? j : sntns[j]-1;\n # var line = lines[k] || false;\n # if (line) {\n # lines[k] = lines[k].replace(\"<span\", \"<span class='\" + this.classHighlight + \"'\");\n # # // trying to create absolute links for sentences here\n # # // lines[k] = lines[k].replace(\"<span\", \"<a name='\" + + \"'><span class='\" + this.classHighlight + \"'\");\n # }\n # }\n #\n # para.setAttribute(\"data-sentences\", jLen);\n # para.innerHTML = lines.join('. ').replace(/__DOT__/g, \".\").replace(/<\\/span>\\./g, \".<\\/span>\");\n # para.addClassName('emReady'); /* Mark the paragraph as having SPANs */\n # }\n # }\n end",
"def get_words\n @sentences.each_index do |i|\n s = @sentences[i]\n words = s.split(' ')\n words.each do |w|\n word = w.gsub(WORD_SANITIZE, '').downcase\n if belongs_to_known_abbreviations? word\n add_word_to_result(word, i)\n else\n add_word_to_result(word.gsub(DOT_SANITIZE, ''), i)\n end\n end\n end\n end",
"def wraps\n by_type(Wrap)\n end",
"def break_words(sentence)\n sentence.scan /\\w+-\\w+|\\w+/\nend",
"def truncate_words(options = {})\n stripped = ActionController::Base.helpers.strip_tags(self)\n\n max_length = options[:max_chars] || 100\n omission = options[:omission] || \"...\"\n center = options[:center]\n highlight = [options[:highlight]].flatten.compact\n highlight_class = options[:highlight_class] || \"highlight\"\n\n if max_length < stripped.length\n if center\n r_limit = stripped.index(center) + center.length + ((max_length - center.length) / 2) - 1 - omission.length\n l_limit = stripped.index(center) - ((max_length - center.length) / 2) + omission.length\n\n if l_limit < 0\n r_limit -= l_limit\n r_limit += omission.length\n l_limit = 0\n end\n if r_limit > stripped.length\n l_limit -= r_limit - stripped.length\n l_limit -= omission.length\n r_limit = stripped.length\n end\n result = stripped[l_limit..r_limit]\n if l_limit >0 && stripped[l_limit-1,1] != \" \"\n result = result[result.index(\" \")+1..-1]\n end\n if r_limit < stripped.length && stripped[r_limit + 1,1] != \" \"\n result = result[0..(result.rindex(\" \")-1)]\n end\n\n result = omission + result + omission\n else\n limit = max_length - 1 - omission.length\n result = stripped[0..limit]\n if stripped[limit + 1,1] != \" \"\n if result.rindex(\" \")\n result = result[0..(result.rindex(\" \")-1)]\n else\n result = \"\"\n end\n end\n result += omission\n end\n else\n result = stripped\n end\n\n highlight.each do |h|\n result = result.gsub(h, \"<span class=\\\"#{highlight_class}\\\">#{h}</span>\")\n end\n result\n\n\n end",
"def build_spans on_range\n # TODO: rewrite in terms of each_row\n @spans = Array.new @size[1]\n\n @size[1].times do |y|\n spans = []\n left = (@size[1]-y-1)*@size[0]\n start = nil\n\n @size[0].times do |x|\n d = on_range.include?(@pixels[left+x])\n\n if !start && d\n start = x\n elsif start && !d\n spans << [start, x]\n start = nil\n end\n end\n\n spans << [start, @size[0]] if start\n @spans[y] = spans\n end\n end",
"def wrap_text=(value)\n @wrap_text = value\n end",
"def split_span(span)\n span[0] += self.length if span[0] < 0\n span\n end",
"def mltify_text text\n \n coder = HTMLEntities.new\n text = coder.decode text\n text = sanitize( text, okTags = \"\" )\n text = coder.encode text\n words = text.downcase.gsub( /[^A-za-z0-9\\s'\\-#]/, \" \" ).split( /\\s/ )\n \n final_words = []\n words.each do |w|\n unless stop_words.include? w\n final_words << w\n end\n end\n RAILS_DEFAULT_LOGGER.info final_words.join( ' ' ).squish\n final_words.join( ' ' ).squish\n end",
"def prepare_span(key, data, span)\n end",
"def word_break(word)\n if word.length > 10\n content_tag :abbr, truncate(word, :length => 10), :title => word\n else\n word\n end\n end",
"def wrap(range, insert_before, insert_after); end",
"def word_wrap(text, indent=0)\n chars = text.split(//)\n unless text.length < 80\n count = 1\n last_space = 80\n chars.each_with_index do |char, index|\n count += 1\n last_space = index if char.match(/ /)\n if char == \"\\n\"\n count = indent\n elsif count == 80\n chars[last_space] = \"\\n#{\" \" * indent}\"\n count = indent + index - last_space\n end\n end\n end\n chars.join\n end",
"def process_wikiwords(full_document)\n doc = full_document.dup\n doc.gsub!(/\\[\\[([A-Za-z0-9_\\-\\ ]+)\\]\\]/) do |match|\n name = $1\n link = name.gsub(/\\s+/, '-')\n if md = /^(\\d\\d\\d\\d-\\d\\d-\\d\\d-)/.match(link)\n date = md[1].gsub('-', '/')\n link = link.sub(md[1], date)\n end\n \"[#{name}](#{link}.html)\"\n end\n return doc\n end",
"def text\n add_spaces(@text, @chars_per_group)\n end",
"def _wrapped_spans(object_name,method,options={})\n\t\ts = \"<span class='label'>#{options[:label_text]||method}</span>\\n\"\n\t\tvalue = if options[:value]\n\t\t\toptions[:value]\n\t\telse\n\t\t\tobject = instance_variable_get(\"@#{object_name}\")\n\t\t\tvalue = object.send(method)\n\t\t\tvalue = (value.to_s.blank?)?' ':value\n\t\tend\n\t\ts << \"<span class='value'>#{value}</span>\"\n\tend",
"def break_long_words(length=75, break_char=\" \", &block)\n @modified_string.gsub!(/https?:\\/\\/\\S+|<a [^>]+>|<img [^>]+>|([^\\s^\\n^\\^^\\A^\\t^\\r<]{#{length},}?)|<\\/a>/) do |s|\n if $1\n ns = block_given? ? yield($1) : $1\n last_pos, result_string = 0, ''\n while string = ns[last_pos..(last_pos + length)]\n result_string += string + break_char\n last_pos += (length + 1)\n end\n result_string\n else\n s\n end\n end\n self\n end",
"def extract_html_wrappers!(source, wrappers, placeholder_map)\n default = ''\n nodes = Nokogiri::HTML.fragment(source).children\n nodes.each do |node|\n if node.is_a?(Nokogiri::XML::Text)\n default << node.content\n elsif text = extract_text(node)\n wrapper = node.to_s.sub(text, \"\\\\\\\\1\")\n wrapper = prepare_wrapper(wrapper, placeholder_map)\n pos = find_or_add_wrapper(wrapper, wrappers)\n default << wrap(text, pos + 1)\n else # no wrapped text (e.g. <input>)\n key = \"__I18NLINER_#{placeholder_map.size}__\"\n placeholder_map[key] = node.to_s.inspect << \".html_safe\"\n default << key\n end\n end\n default\n end",
"def wrap_text(hello, blank )\n return \"#{blank}#{hello}#{blank}\"\nend"
] |
[
"0.6453105",
"0.6385358",
"0.62999296",
"0.62721914",
"0.6076125",
"0.60640967",
"0.58964074",
"0.58885306",
"0.5692121",
"0.56615716",
"0.56406766",
"0.5631153",
"0.5605348",
"0.5601667",
"0.5601264",
"0.5580383",
"0.55583394",
"0.55454296",
"0.5544432",
"0.55317855",
"0.55317855",
"0.5514798",
"0.55114484",
"0.5488046",
"0.54459643",
"0.54337233",
"0.5423649",
"0.5418868",
"0.5395389",
"0.5365773",
"0.535796",
"0.53324974",
"0.53324974",
"0.53311145",
"0.5309104",
"0.5307274",
"0.53034705",
"0.5298522",
"0.5290255",
"0.52696764",
"0.5255528",
"0.52526855",
"0.524575",
"0.523688",
"0.52199626",
"0.5186558",
"0.51778454",
"0.5177721",
"0.5173636",
"0.5171774",
"0.5162627",
"0.51574045",
"0.5155616",
"0.5142758",
"0.5139665",
"0.5138179",
"0.5138179",
"0.5124517",
"0.5120407",
"0.5120128",
"0.5110866",
"0.51003915",
"0.50984466",
"0.5097219",
"0.5093697",
"0.5090252",
"0.50887704",
"0.50813144",
"0.50775015",
"0.50764346",
"0.5072293",
"0.5069028",
"0.50612384",
"0.505254",
"0.504391",
"0.50427806",
"0.5033425",
"0.5033256",
"0.5027996",
"0.5022397",
"0.5020837",
"0.50190675",
"0.5015666",
"0.5005615",
"0.4987497",
"0.49685624",
"0.49585325",
"0.494327",
"0.4943215",
"0.4941281",
"0.49332058",
"0.49323308",
"0.493096",
"0.4929141",
"0.4920475",
"0.4918876",
"0.49129376",
"0.49120277",
"0.49117738",
"0.4911192"
] |
0.65256125
|
0
|
READ CSV DATA Method to get the data from a csv in hash map
|
def get_csv_data(csv_data)
csv_file = nil
#Get the path and name of the CSV file
if csv_data.to_s.include? '.csv'
csv_file = File.join(File.dirname(__FILE__), "../venture/config/csv_data/#{csv_data}")
elsif (
csv_file = File.join(File.dirname(__FILE__), "../venture/config/csv_data/#{csv_data}.csv")
)
end
csv_arr = CSV.read( csv_file, {:headers => true, :header_converters => :symbol, :encoding => 'UTF-8'} )
keys = csv_arr.headers.to_a
# read attribute example => csv[index][:column1]
return csv_arr.to_a.map {|row| Hash[ keys.zip(row) ] }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def process_csv(file)\n data = CSV.read(file, {encoding: \"UTF-8\", headers: true, header_converters: :symbol, converters: :all})\n hashed_data = data.map { |d| d.to_hash } \n \n puts \"CSV Loaded...\"\n\n return hashed_data\n end",
"def get_csv_data(infile)\n csv_data = CSV.read infile\n headers = csv_data.shift.map {|i| i.to_s }\n string_data = csv_data.map {|row| row.map {|cell| cell.to_s } }\n return string_data.map {|row| Hash[*headers.zip(row).flatten] }\nend",
"def get_csv_data(infile)\n csv_data = CSV.read infile\n headers = csv_data.shift.map {|i| i.to_s }\n string_data = csv_data.map {|row| row.map {|cell| cell.to_s } }\n return string_data.map {|row| Hash[*headers.zip(row).flatten] }\nend",
"def read_csv(csv_file, data)\n logger.info \"Reading #{data.type} data from '#{csv_file} date column = #{@date_column} data starts at col #{@data_start_column} skipping #{@header_rows} header rows\"\n lines = File.readlines(csv_file)\n (@header_rows...lines.length).each do |i|\n reading = lines[i].split(',')\n begin\n date = Date.parse(reading[@date_column])\n rowdata = reading[@data_start_column, @data_start_column + 47].map(&:to_f)\n data.add(date, rowdata)\n rescue StandardError => e\n logger.warn e.message\n logger.warn e.backtrace.join(\"\\n\")\n logger.warn \"Unable to read data on line #{i} of file #{csv_file} date value #{reading[@date_column]}\"\n end\n end\n logger.info \"Read hash #{data.length} rows\"\n end",
"def load_csv()\n f = File.read(INPUT_CSV)\n CSV.parse(f, :headers => true, :col_sep => \",\").map do |row|\n as_hash = row.to_hash\n\n geom = { \n type: \"Point\",\n coordinates: as_hash['coordinates'].split.map { |num| num.to_f }\n }\n\n as_hash.delete('coordinates')\n as_hash['geom'] = geom\n\n if (as_hash['pic_url'].strip.length < 1)\n as_hash.delete('pic_url')\n end\n\n if (as_hash['place_image'].strip.length < 1)\n as_hash.delete('place_image')\n end\n\n as_hash\n end\nend",
"def load_data(csv)\n @hash.each do |sentence, count|\n csv << [sentence, count]\n end\n end",
"def get_references\n references_hash = {}\n FasterCSV.foreach(\"#{Source_path}/TbReference.csv\", :quote_char => '\"', :col_sep =>',', :row_sep =>:auto) do |row|\n references_hash[row[0]] = row[6]\n end\n return references_hash\nend",
"def load_csv(file) \n\t\thash = {}\n\t\tCSV.foreach(file) { |row| hash[row[0]] = row[1] } \n\t\thash\n\tend",
"def read_scores_from\n teams_data = []\n\n CSV.foreach('scores.csv', headers: true, header_converters: :symbol) do |row|\n teams_data << row.to_hash\n end\n teams_data\nend",
"def load_data(filename)\n return CSV.read(filename, headers: true).map { |line| line.to_h }\nend",
"def load_data(filename)\n data = CSV.open(filename, 'r', headers: true).map do |line|\n line.to_h\n end\n return data\nend",
"def get_csv_data(csv_file)\n\t\tcsv_file = File.read(csv_file)\n\t\tcsv = CSV.parse(csv_file, :headers => true)\t\n\t\tcsv\n\tend",
"def load_csv(csv_path)\n raise Error::InvalidCSV unless File.exist? csv_path\n begin\n vals = CSV.read(csv_path)\n rescue CSV::MalformedCSVError\n raise Error::InvalidCSV\n end \n\n raise Error::BlankCSV if vals.length == 0\n raise Error::InvalidCSV if vals[0].length != 3\n\n # remove optional header\n vals.shift if vals[0][0] == HEADER_VAL\n\n @data = vals.collect do |data|\n {\n \"image_path\" => data[0],\n \"id\" => data[1],\n \"label\" => data[2]\n }\n end\n end",
"def read_in_ownership(csv_file_name, temp_hash = Hash.new)\n\t CSV.foreach(csv_file_name, :headers => true) do |row|\n\t\t song_id, owner_data = row[0], row[1]\n\t \t unless (song_id =~ /#/)\n\t \t \t temp_hash[song_id] = owner_data\n\t \t end\n end\n temp_hash\n\tend",
"def csv_parsed\n transform_to_hash(@csv_array, @header)\n end",
"def read_in_ownership(csv_file_name, temp_hash = Hash.new)\n\t CSV.foreach(csv_file_name, :headers => true) do |row|\n\t\t song_id, owner_data = row[0], row[1]\n\t \t unless (song_id =~ /#/)\n\t \t \t temp_hash[song_id] = owner_data\n\t \t end\n end\n temp_hash\n\tend",
"def csv_data\n case\n when google_key || url then Curl::Easy.perform(uri).body_str\n when file then File.open(uri).read\n end\n end",
"def load_data\n @data ||= CSV.read(@file)\n end",
"def parse_csv(decoded_data)\n csv = CSV.parse(decoded_data)\n headers = csv.shift\n csv.to_a.map! { |row| Hash[headers.zip(row)] }\n end",
"def read_parameters_from_csv(csv)\r\n\t\tbegin\r\n\t\t\ttemp = CSV.read(csv)\r\n\t\trescue Exception\r\n\t\t\traise ArgumentError, \"It wasn't possible to read from #{csv} file.\"\r\n\t\tend\r\n\t\ttemp.each_with_index do |row,index|\r\n\t\t\t@actual_parameters[index] = row[0].split(';')\r\n\t\tend\r\n\tend",
"def import_from_csv(file_name)\r\n #implementation goes here\r\n csv_text = File.read(file_name)\r\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\r\n # #8 iterate over table rows, create hash for each, then convert to Entry using 'add_entry' method\r\n csv.each do |row|\r\n row_hash = row.to_hash\r\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\r\n end #end csv.each loop\r\n end",
"def parse_csv(csv_string)\n csv_data = FasterCSV.parse(csv_string)\n header = csv_data.shift\n [csv_data.map{|row| Hash[*header.zip(row).flatten] }, header]\n end",
"def parse_csv_file\n csv_data = CSV.read(\"../artists_for_seed_data.csv\")\n csv_data.shift\n # iterate over each element and send back a hash\n # need to shift again at the beginning to get rid of id on the row\n painter_object_array = []\n csv_data.each do |painter_row_arr|\n \n painter_row_arr.shift\n painter_object = {\n :name => painter_row_arr[0],\n :years => painter_row_arr[1],\n :genre => painter_row_arr[2],\n :nationality => painter_row_arr[3],\n :bio => painter_row_arr[4],\n :painter_num => painter_row_arr[6]\n }\n painter_object_array.push(painter_object)\n end\n painter_object_array.flatten\nend",
"def load_data(filename)\n data = CSV.read(filename, headers: true).map(&:to_h)\n return data\nend",
"def parse_csv(csv)\n objects = CSV.parse(csv)\n headers = objects.shift\n objects.to_a.map! { |row| Hash[headers.zip(row)] }\n end",
"def csv_row_to_map(row_values)\n {\n type: row_values[0],\n key: row_values[1],\n revision: row_values[2],\n last_modified: row_values[3],\n details: JSON.parse(row_values[4])\n }\n end",
"def readCSV pmdReportCSVFile\n\tfile = File.open(pmdReportCSVFile, \"rb\")\n\tcsv_contents = file.read\n\tkeys = [\"Problem\",\"Package\",\"File\",\"Priority\",\"Line\",\"Description\",\"Rule set\",\"Rule\"]\n\treturn CSV.parse(csv_contents).map {|a| Hash[ keys.zip(a) ] }\nend",
"def read_in_csv_data(csv_file_name)\n begin\n CSV.foreach(csv_file_name, headers: true) do |row|\n @songs << Song.new(row['name'], row['location'])\n end\n rescue Exception\n @songs = nil\n end\n @songs\n end",
"def read_data(options={})\n orig_data = CSV.read(@filename, :skip_blanks => true)\n num_lines = orig_data.length\n if num_lines % @num_lines_per_linegroup == 0\n num_line_groups = num_lines / @num_lines_per_linegroup\n else\n raise \"ERROR: Invalid number of lines in file!\"\n end\n \n# puts \"Num Lines: #{num_lines}\"\n# puts \"************************\\n\"\n \n # array for final data\n @final_data = []\n \n # go through each line group\n num_line_groups.times do |i|\n \n # init a temp hash\n temp_hashes = []\n @data_columns.each do |col|\n temp_hashes[col] = {}\n end\n \n # grab data per linegroup\n @num_lines_per_linegroup.times do |j|\n line = orig_data[i*@num_lines_per_linegroup + j]\n field_name = @input_data_rows[j]\n # parse columns within a line\n @data_columns.each do |col|\n data = line[col]\n temp_hashes[col][field_name] = data\n # puts \" #{line[col]}\" if !line[col].nil?\n end\n end\n \n # push grabbed data onto master hash array\n temp_hashes.each do |record|\n if !record.nil?\n @final_data << record\n end\n end\n \n end # per line groups\n \nend",
"def parse\n data = CSV.parse(@input_data)\n data.shift # remove header row\n headers = [:player_key, :birth_year, :first_name, :last_name]\n data.map {|row| Hash[ *(headers.zip(row).flatten) ] }\n end",
"def csv_data\n @csv_data ||= compute_csv_data\n end",
"def players(team)\n field= []\n CSV.foreach(\"teams.csv\", headers:true,header_converters: :symbol) do |row|\n if row[:team] == team\n field << row.to_hash\n end\n end\n field\nend",
"def parse_painter_csv_file\n csv_data = CSV.read(\"db/painter_seed_data.csv\")\n csv_data.shift\n # iterate over each element and send back a hash \n # need to shift again at the beginning to get rid of id on the row\n painter_object_array = []\n csv_data.each do |painter_row_arr|\n painter_row_arr.shift\n painter_object = {\n :name => painter_row_arr[0],\n :years => painter_row_arr[1],\n :genre => painter_row_arr[2],\n :nationality => painter_row_arr[3],\n :bio => painter_row_arr[4],\n :painting_num => painter_row_arr[6],\n :portrait => painter_row_arr[7]\n }\n painter_object_array.push(painter_object) \n end\n painter_object_array.flatten\nend",
"def read_from_roster(csv)\n players = []\n CSV.foreach(csv, headers: true, header_converters: :symbol) do |player|\n players << player.to_hash\n end\n players\nend",
"def prod_to_hash(csv_name)\n\tprod_array = CSV.read(csv_name)\n\tprod_array.each_with_index do |line, index|\n\t\tnext if line[0] == \"Opportunity ID\" \n\t\tbreak if line[0] == nil\n\t\t@current_opp_list[line[0]] = Opportunity.new(line[@prods_opp], line[@prods_prod], line[@prods_access], line[@prods_status], \"unknown\")\n\t\t\n\tend\n\t\nend",
"def parse_csv(csv_name, schema)\n CSV.read(csv_name).map {|row| map_row_to_entity(row, schema) }\nend",
"def load_students\n puts \"Loading file\"\n # Open the file with \"read\" privilages\n file = File.open(\"students.csv\", \"r\")\n # Go through each line of the file\n file.readlines.each do |line|\n # .. picking out the name and cohort columns\n name, cohort = line.chomp.split(',')\n # Add them to the student variable as a hash\n @students << {name: name, cohort: cohort.to_sym}\n end\n # Close the file\n file.close\nend",
"def loadCSVFile(filePath)\n data = []\n CSV.foreach(filePath, :headers => true) do |row|\n row = row.to_h\n row.each do |k, v|\n v = v.to_s\n row[k] = v\n end\n data << row\n end\n data\n end",
"def parse_to_load_file(csv)\n csv.each_with_index do |student, index|\n student = {month: csv[index][0] , name: csv[index][1], city: csv[index][2], hobby: csv[index][3]}\n @students << student\n end\nend",
"def process_file(path)\n CSV.open(path, {:headers => true}) do |csv|\n csv.each do |row|\n res = cached_lookup(row['X'].to_f, row['Y'].to_f)\n puts \"#{res[:lng]},#{res[:lat]},#{res[:neighborhood]}\"\n end\n end\n end",
"def initMetaData(csvfile,metamap,keyfield)\n\t\tallRows = CSV.read(csvfile,{:col_sep=>\";\"})\n\t\tif allRows and not allRows.empty?\n\t\t\ttitle = allRows[1]\n\t\t\tallRows.each_with_index do |row,i|\n\t\t\t\tif i > 1\n\t\t\t\t\tmetaData = Model::MetaData.new(title,row)\n\t\t\t\t\tkey = metaData.send(keyfield)\n\t\t\t\t\tmetamap[key] = metaData\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def gather_from_csv\n items = {}\n FasterCSV.foreach(@plucked_out_items_csv, FCSV_OPTS){|line|\n STDERR.puts \"ERROR: RMID not found for item_id #{line[:item_id].chomp} in CSV-file #{@plucked_out_items_csv}\" unless line[:rmid]\n items[ line[:item_id].chomp ] = {\n :handle => line[:item_hdl].chomp,\n :rmid => line[:rmid].chomp,\n #:collection_handle => line[:col_owner_hdl].chomp,\n }\n }\n items\n end",
"def read_data\n entities = Hash.new\n DATA.each_line.map(&:chomp).each do |entity|\n entities[entity.split(',').slice(0..-2).map { |n| n.to_i } ] = entity.split(',').slice(-1)\n end\n entities\nend",
"def parse\n data = CSV.parse(@input_data)\n data.shift # remove header row\n headers = [:player_key, :year, :team_id, :game, :at_bats, :runs, :hits, :doubles, :triples, :home_runs, :runs_batted_in, :stolen_bases, :caught_stealing]\n data.map {|row| Hash[ *(headers.zip(row).flatten) ] }\n end",
"def csv_import(the_file)\n import_list = []\n CSV.foreach(the_file, headers: true) do |row|\n import_list << row.to_hash\n end\n import_list\n end",
"def process_csv(path)\n res = {}\n CSV.foreach(path) do |row|\n (tag_str, _, dest_str, val_str) = row\n next unless $tags.has_key? tag_str\n tag, dest, val = $tags[tag_str], dest_str.to_i, val_str.to_i\n res[dest] = {} unless res.has_key?(dest)\n res[dest][tag] = 0 unless res[dest].has_key?(tag)\n res[dest][tag] += val\n end\n res\nend",
"def get_data(file_name)\n @all_data=[]\n\n CSV.foreach(file_name, :headers => true) do |row|\n first=row[\"first_name\"]\n last=row[\"last_name\"]\n position=(row[\"position\"]).tr(\" \",\"_\")\n team=(row[\"team\"]).tr(\" \",\"_\")\n\n @all_data.push( {:Team => team, :First_Name => first, :Last_Name => last, :Position => position} )\n end\n @all_data\nend",
"def load_places_CSV()\n puts \"loading CSV\"\n $places = {}\n File.open('places.csv').each do |line|\n place = line.split(\"\\t\") \n plat,plon,name = place\n if plat.to_f>14.04\n square = get_square(plat.to_f, plon.to_f)\n if $places[square].nil? \n p square\n $places[square] = []\n end\n $places[square] << place \n end\n end\n puts $places.size.to_s + \" places loaded\"\nend",
"def load_dspace_csv(csv_file, fields)\n final = {}\n table = CSV.parse(File.read(csv_file), headers: true)\n table.each do |row|\n values = {}\n fields.each do |hyrax_name, dspace_name|\n values[hyrax_name] = extract_single_value(row, dspace_name)\n end\n values['handle'] = extract_single_value(row, 'dc.identifier.uri')\n final[values['handle']] = values\n end\n final\n end",
"def parse_csv(file)\n\t\tdata = []\n\t\t# Break open CSV and go through rows\n\t\tbegin\n\t\t\tdata = CSV.read(file, :headers => true,:skip_blanks => true,:header_converters => :symbol, :encoding => 'UTF-8')\n\t\trescue\n\t\t\t# Convert to UTF-8 if necessary\n\t\t\tdata = CSV.read(file, :headers => true,:skip_blanks => true,:header_converters => :symbol, :encoding => 'Windows-1252:UTF-8')\n\t\tend\n\t\tdata\n\tend",
"def each\n CSV.foreach(@file, @options) do |row|\n yield row.to_hash\n end\n end",
"def read\n prev_hash = nil\n\n CSV.open(nmea_file, 'r').each do |row|\n timestamp = Time.strptime(\"#{row[9]} #{row[1]}\", '%d%m%y %H%M%S.%L')\n next if timestamp.year < 1990\n\n speed = (row[7].to_f * 1.852).round(2)\n bb = row[8].to_f\n\n lat, lon = geo_convert(\n lat_source: row[3],\n lon_source: row[5],\n sw: row[4],\n ww: row[6]\n )\n\n hash = {\n timestamp: timestamp.strftime(TIME_FORMAT),\n bb: bb,\n speed: speed,\n lat: lat,\n lon: lon\n }\n\n if prev_hash.nil? || hash != prev_hash\n check_bounds lat, lon if lat && lon\n yield hash\n end\n\n prev_hash = hash\n end\n end",
"def create_csv_for_LLR(csv_data)\n\n csv_string = CSV.open(\"#{$basefile}LLR.csv\", \"wb\") do |csv|\n\n csv << csv_data.first.keys\n csv_data.each do |hash|\n csv << hash.values\n end\n end\n end",
"def import_base\n CSV.foreach(@file.path, encoding: detect_encoding, headers: true) do |row|\n next if row.blank?\n yield ActiveSupport::HashWithIndifferentAccess.new(row)\n end\n end",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n # #8 iterate over the CSV::Table rows then create a hash for each row, convert each row_hash\n #to an Entry by using the add_entry method\n csv.each do |row|\n row_hash = row.to_hash\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n end",
"def parse_csv_row(csv_row)\n {\n s_no: csv_row['Sr. No'],\n ticket_no: csv_row['Ticket No'],\n email: csv_row['Email'],\n name: csv_row['Name'],\n new_eth_address: csv_row['New Ethereum Add']\n }\n end",
"def get_data(file_name)\n @all_data=[]\n\n CSV.foreach(file_name, :headers => true) do |row|\n id=row[\"id\"]\n title=(row[\"title\"]).tr(\" \",\"_\")\n year=row[\"year\"]\n synopsis=row[\"synopsis\"]\n rating=row[\"rating\"]\n genre=row[\"genre\"]\n studio=row[\"studio\"]\n\n @all_data.push( {:ID => id, :Title => title, :Year => year, :Synopsis => synopsis, :Rating => rating, :Genre => genre, :Studio => studio} )\n end\n @all_data\nend",
"def load_data(file_name)\n\t\tindata = []\n\t\t#csv reader as shown in class; typecasted because I ran into some weird bugs\n\t\tCSV.foreach(\"#{file_name}\", col_sep: \"\\t\") do |row| \n\t\t\tindata.push({\"user_id\"=>row[0].to_i, \"movie_id\"=>row[1].to_i, \"rating\" => row[2].to_i, \"timestamp\" => row[3].to_i})\n\t\tend\n\t\treturn indata\n\tend",
"def csvAccountDataParsing\n\taccounts = {}\n\n\tCSV.foreach(\"accounts.csv\", {headers: true, return_headers: false}) do |row|\n\t\taccountName = row[\"Account\"].chomp.capitalize\n\t\taccounts = set_initial_values(accounts, accountName, row)\n\t\taccounts[accountName].addData(row)\n\tend\n\n\taccounts.each_value do |value|\n\t\tvalue.calculateFinalAmounts\n\tend\n\n\treturn accounts\nend",
"def load_questions\n CSV.foreach(\"questions.csv\", { :col_sep => ' | ' }) do |row|\n key = row[0]\n value = row[1]\n RESPONSES[key] = value\n end\n puts \"Questions and responses loaded!\"\n puts \"\"\nend",
"def grab_lookup_table(csv_url)\n cmd = `curl #{csv_url} -s`\n csv = cmd.gsub(\"\\r\",\"\\n\").split(/\\n+/).map{ |x| x.split(\",\")}\n table = {}\n csv.each {|row| table[row[0]] = row[1]}\n return table\n end",
"def read_row\n @row ||= Row.new([nil] * @key_map.size, key_map: @key_map)\n\n # Need to read ahead by one record in order to get EOF flag\n @prev_read ||= @data_stream.readline\n\n self.eof_flag = @data_stream.eof?\n @row.last_row = self.eof_flag\n\n this_read = @data_stream.readline\n\n if @data_lib.csv_opt[:headers] && @data_lib.header_as_variables\n row_array = @prev_read.fields\n else\n row_array = @key_map.map.with_index do |v,i|\n variable_idx_to_csv_col(@prev_read.size)[i] && @prev_read[variable_idx_to_csv_col(@prev_read.size)[i]]\n end\n end\n\n @row.set_values(row_array)\n @prev_read = this_read\n\n @row\n end",
"def CSVHash arg, columns=nil\n if arg.is_a?(File)\n CSVHash.from_file(arg.path)\n elsif arg.is_a?(String)\n CSVHash.from_file(arg)\n elsif arg.is_a?(Array) && columns.is_a?(Array)\n CSVHash.to_string(arg,columns)\n end\nend",
"def load\n CSV.foreach(@csv_file, headers: :first_row, header_converters: :symbol) do |row|\n @data << Employee.new(row)\n end\n end",
"def read_and_hash\n $students = []\n file = File.open('grades.csv', 'r')\n files = file.readlines\n files = files.map(&:chomp)\n files = files.map { |line| line.split(/\\W+/) }\n file.close()\n files.each do |array|\n $students.push(name: array.shift, grades: array)\n end\nend",
"def read_csv_data file\n rows = []\n readerIn = CSV.open(file, 'r')\n row = readerIn.shift\n while row!= nil && !row.empty?\n rows << row\n row = readerIn.shift\n end\n readerIn.close\n \n return rows\nend",
"def loci\n CSV.read(@file).map do |row|\n {\n :name => row[@columns[:name]],\n :target => row[@columns[:target]],\n :strand => STRAND_TOKENS[row[@columns[:strand]]],\n :start => row[@columns[:start]].to_i - 1, # This arithmetic gives\n :stop => row[@columns[:stop]].to_i, # inclusive, one-indexed\n # slices\n }\n end\n end",
"def set_data_from_csv_file(csv_file)\n begin\n start_time = 0,\n end_time = 0,\n sum = 0, temp_sum = 0, index = 1,\n data = [],\n first_row = true\n \n if csv_file\n csv_data = FasterCSV.parse(csv_file)\n length = csv_data.length\n interval = 1\n until length/interval < 10000\n interval+=1\n end\n csv_data.each do |time,power_data|\n start_time = time if first_row\n end_time = time\n temp_sum = temp_sum + power_data.to_f\n \n if(index % interval == 0 )\n data << (temp_sum/interval).to_f.round(2)\n temp_sum = 0\n end\n sum = sum + power_data.to_f\n first_row = false\n index+=1\n end\n @analysis_data.csv_data = data.to_json()\n @analysis_data.test_duration = end_time.to_i - start_time.to_i\n @analysis_data.energy_consumed = sum/3600\n end\n rescue FasterCSV::MalformedCSVError\n @analysis.errors.add_to_base(INVALID_CSV_FILE_ERROR)\n @invalid_csv = true\n end\n end",
"def create_league(csv)\n league = []\n CSV.foreach(csv, headers: true, header_converters: :symbol) do |row|\n hash = Hash[row]\n league << hash\n end\n league\n\nend",
"def load_students (filename = \"students.csv\")\n #open the filename or students.csv as default\n File.open(filename, \"r\") do |file|\n #iterate over each line in the file\n file.readlines.each do |line|\n #split at the comma and parallel assign name to the first value, cohort to the second\n name, cohort = line.chomp.split(\",\")\n #create a hash and push to the @students array using method\n @students << {name: name, cohort: cohort}\n end\n end\nend",
"def parse_csv content, sep\n CSV.parse(content, :col_sep => sep,\n :converters => [:numeric],\n :headers => true,\n :skip_blanks => true).\n map{ |row| row.to_hash }\n end",
"def row_from_csv(csv, line:)\n row_args = %i[timestamp speaker settings content].each_with_object({}) do |key, args|\n args[key] = csv[@key_map[key]]\n args\n end\n\n Row.new(line_number: line, **row_args)\n end",
"def load_csv(filename)\n CSV::Converters[:blank_to_nil] = lambda do |field|\n field && field.empty? ? nil : field\n end\n CSV.new(File.read(filename), \n :headers => true, \n :header_converters => :symbol, \n :converters => [:all, :blank_to_nil]\n ).entries.map { |row| row.to_hash }\nend",
"def read_csv_file(csv_table_path)\r\n \r\n table_dimensions = detect_state_table_dim(csv_table_path)\r\n \r\n if table_dimensions==:one_d\r\n return read_1d_csv_file(csv_table_path)\r\n elsif table_dimensions==:two_d\r\n return read_2d_csv_file(csv_table_path)\r\n else\r\n raise \"Error: CSV File dimensions: #{table_dimensions}\"\r\n end # end if else \r\n \r\n end",
"def csv(handle, path = nil)\n @dsd = DataSourceDownload.get(handle)\n raise \"handle '#{handle}' does not exist\" if @dsd.nil? and handle != \"manual\"\n path = (handle == \"manual\") ? DataSourceDownload.flex(path) : @dsd.save_path_flex \n @handle = handle\n @csv ||= {}\n if @csv[path].nil? \n download_handle unless @dsd.nil?\n #puts path\n begin\n @csv[path] = CSV.read(path)\n @new_data = true\n rescue\n #resolve one ugly known file formatting problem with faster csv\n alternate_csv_load = alternate_fastercsv_read(path) #rescue condition if this fails\n #return \"READ_ERROR:CSV FORMAT OR FILE PROBLEM\" if alternate_csv_load.nil? \n @csv[path] = alternate_csv_load\n @new_data = true\n end\n end\n @csv[path]\n end",
"def recommendation_csv_inputs csv_path\n valid_inputs = []\n\n CSV.foreach(csv_path, {headers: true, header_converters: :symbol}) do |row|\n row = row.to_h\n valid_inputs << row if valid_recommendation_hash?(row)\n end\n\n valid_inputs\n\n rescue => e\n valid_inputs\n end",
"def csv\n @csv_table ||= begin\n csv_raw = File.read(CSV_PATH)\n CSV.parse(csv_raw, headers: true)\n end\n\nend",
"def load\n csv = csv_data\n @data = TableFu.new(csv_data, @table_opts[:column_options] || {})\n if @table_opts[:faceting]\n @data.col_opts[:ignored] = [@table_opts[:faceting][:facet_by]]\n @facets = @data.faceted_by @table_opts[:faceting][:facet_by]\n end\n @data.delete_rows! @table_opts[:dead_rows] if @table_opts[:dead_rows]\n end",
"def import_from_csv(file_name)\n # implementation\n csv_text = File.read(file_name)\n # the variable 'csv' is a table type object\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n \n # \n csv.each do |row|\n # create a hash type variable 'row_hash'\n row_hash = row.to_hash\n # use 'add_entry' to change 'row_hash' into 'Entry', also add the new Entry into AddressBook's entries\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n end",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n # Iterate over the CSV::Table object's rows. Then create a has for each row.\n # Convert each row_hash to an entry by using add_entry method.\n csv.each do |row|\n row_hash = row.to_hash\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n end",
"def read_users_from_file(filename)\n CSV.read(filename, :headers => true, :header_converters => :symbol).map { |row| row.to_hash }\nend",
"def lookup(row,col) #input file, put out rows\n @data.each do |row|\n\n row.each do |col|\n @parsed[row][col] = row[0][col].to_sym => col\n end\n end\n return @parsed\n end",
"def readCSV(filename)\n resultArray = Array.new\n\n # read csv file\n File.open(filename) { |file|\n while line = file.gets\n row = CSV.parse_line( Kconv::kconv(line, Kconv::UTF8, Kconv::SJIS) )\n resultArray.push( row )\n end\n }\n\n return resultArray\nend",
"def load_csv(csv_filepath)\n gifts = []\n CSV.foreach(csv_filepath) do |row|\n gifts << row[0] # Nosso csv só tem uma coluna\n end\n return gifts\nend",
"def parse(args={})\n csv_args = {:skip_blanks=>true,:col_sep=>\",\"}\n csv_args[:col_sep] = args[:col_sep] if args[:col_sep]\n args[:value_filter] ||= Csv2sql.method :default_value_filter\n i = 0\n CSV.foreach(@filename,csv_args) do |row|\n values = row\n #values_filter is for whole row\n #value_filter is for single value\n values = args[:values_filter].call(row, i) if args[:values_filter]\n if values\n if args[:value_filter]\n j = -1\n values = row.map do |value|\n j += 1\n args[:value_filter].call(value,i,j)\n end\n end\n yield values if values\n end\n i += 1\n end\n end",
"def parsed_data\n @parsed_data ||= begin\n CSV.read(full_filename, col_sep: col_sep, quote_char: quote_char, encoding: encoding)\n rescue => e #CSV::MalformedCSVError => er\n @parse_error = e.to_s\n rows = []\n #one more attempt. If BOM is present in the file.\n begin\n f = File.open(full_filename, \"rb:bom|utf-8\")\n rows = CSV.parse(f.read.force_encoding(\"ISO-8859-1\"))\n ensure\n return rows\n end\n end\n end",
"def csvReader(file, headers)\n begin\n csvTable = CSV.read(file, {col_sep:\"\\t\", quote_char:\"\\0\", headers:headers})\n rescue ArgumentError\n puts \"Error: Unsupported encoding, tabulated/CSV file must be in UTF-8 format.\"\n abort\n end\n parsedObj = OpenStruct.new()\n parsedObj.rowArray = []\n parsedObj.belArray = []\n csvTable.each do |row|\n unless row.length == 0\n current = OpenStruct.new()\n current.bel_id = row[0]\n current.bel_id.slice! \"BEL:\"\n current.bel = row[1]\n current.sentence = row[2]\n current.sentence_id = row[3]\n current.sentence_id.slice! \"SEN:\"\n current.pmid = row[4]\n parsedObj.rowArray << current\n parsedObj.belArray << row[1]\n end\n end\n parsedObj.linecount = csvTable.length\n return parsedObj\nend",
"def read_data\n\t\tindex = 0\n\t\torders = []\n\t\tCSV.parse(@data_file.read()) do |row|\n\t\t\tif index == 0\n\t\t\t\t#header row\n\t\t\t\t@columns = parse_columns(row[0])\n\t\t\t\t# p @columns\n\t\t\telse\n\t\t\t\t# p row[0]\n \t\t\tdata = row[0].split(\"\\t\")\n \t\t\torders << parse_order(data) \n\t\t\tend\n \t\tindex += 1\n\t\tend\n\t\treturn orders\n\tend",
"def load_students(filename = \"students.csv\")\n file = File.open(filename, \"r\")\n file.readlines.each do |line|\n name, cohort = line.chomp.split(',') \n @students << {name: name, cohort: cohort.to_sym}\n end\n file.close\nend",
"def initMetaDataFromCSV(csvfile)\n\t\tif not File.exist?(csvfile)\n\t\t\traise StandardError \"file not exist!\"\n\t\tend\n\t\tbasename = File.basename(csvfile, \".csv\")\n\t\tcase basename\n\t\t#处理角色名,用来随机用\n\t\twhen 'JiaoSeMing'\n\t\t\tinitPlayerNameMetaData(csvfile)\n\t\t#英雄配表\n\t\twhen 'WuJiang'\n\t\t\t@heroMetaMap = {}\n\t\t\tinitMetaData(csvfile,@heroMetaMap,\"generalID\")\n\t\t\t#自有兵法列表\n\t\t\t@selfBookList = []\n\t\t\t@heroMetaMap.each_value do |hero| \n\t\t\t\tselfBook = hero.gInitialWarcraft.to_i\n\t\t\t\tif selfBook > 0 and not @selfBookList.include?(selfBook)\n\t\t\t\t\t@selfBookList << selfBook\n\t\t\t\tend\n\t\t\tend #generalID \n\t\t#招募配表\n\t\twhen 'ZhaoMu'\n\t\t\t@recuriteMetaMap = {}\n\t\t\tinitMetaData(csvfile,@recuriteMetaMap,\"recruitName\")\n\t\t#情义(命运)\n\t\twhen 'MingYun'\n\t\t\t@fateMetaMap = {}\n\t\t\tinitMetaData(csvfile,@fateMetaMap,\"fateID\")\n\t\t#角色级别与经验值\n\t\twhen 'JiaoSeShengJiJingY'\n\t\t\t@playerLevelMetaMap = {}\n\t\t\tinitMetaData(csvfile, @playerLevelMetaMap ,\"characterLevel\")\n\t\t#英雄级别与经验值配表\n\t\twhen 'WuJiangDengJi'\n\t\t\t@heroLevelMetaMap = {}\n\t\t\tinitMetaData(csvfile, @heroLevelMetaMap ,\"levelGeneral\")\n\t\t#英雄进阶\n\t\twhen 'WuJiangJinJie'\n\t\t\t@heroAdancedLevelMetaMap = {}\n\t\t\tinitMetaData(csvfile, @heroAdancedLevelMetaMap ,\"advancedTime\")\n\t\t#装备-武器防具坐骑\n\t\twhen 'ZhuangBei'\n\t\t\t@equipmentMap = {}\n\t\t\tinitMetaData(csvfile, @equipmentMap ,\"equipmentID\")\n\t\t#兵法\n\t\twhen 'BingFa'\n\t\t\t@bookMap = {}\n\t\t\tinitMetaData(csvfile,@bookMap,\"bookID\")\n\t\t#宝物\n\t\twhen 'DaoJu'\t\n\t\t\t@propMap = {}\n\t\t\tinitMetaData(csvfile,@propMap,\"propID\")\n\t\twhen 'PeiYang'\n\t\t\tinitHeroBringupMetaData(csvfile)\n\t\t#VIP表\n\t\twhen 'Vip'\n\t\t\t@vipMap = {}\n\t\t\tinitMetaData(csvfile,@vipMap,\"vipLevel\")\n\t\t#强化表\n\t\twhen 'ZhuangBeiQiangHua'\n\t\t\t@strengthenMap = {}\n\t\t\tinitStrengthenMapMetaData(csvfile,@strengthenMap)\n\t\t#进阶表\n\t\twhen 'BingFaJinJie'\n\t\t\t@bookAdvancedMap = {}\n\t\t\tinitBookAdvancedMapMetaData(csvfile,@bookAdvancedMap)\n\t\t#兵法碎片\n\t\twhen 'BingFaSuiPian'\n\t\t\t@bookFragment = {}\n\t\t\tinitMetaData(csvfile,@bookFragment,\"fragmentID\")\n\t\t#flag , 游戏配置,标记 等表\n\t\twhen 'Flag'\n\t\t\t@flagMap = {}\n\t\t\tinitMetaData(csvfile,@flagMap,\"name\")\n\t\twhen 'ZhanYi'\n\t\t\tinitBattle(csvfile)\n\t\twhen 'NPC'\n\t\t\t@npcMetaMap = {}\n\t\t\tinitMetaData(csvfile, @npcMetaMap, \"npcID\")\n\t\twhen 'ChengZhangRenWu'\n\t\t\tinitTaskMetaData(csvfile)\n\t\telse\n\t\tend\n\tend",
"def load_student_file\n @student_records = {}\n open(@student_file) do |input_file|\n CSV::Reader.parse(input_file) do |csv_record|\n @student_records[csv_record[0].to_s] = create_student_record(csv_record)\n end\n puts \"#{@student_records.size} records loaded from student.csv\"\n puts \"record for 716012 => \" + @student_records['716012'].inspect\n puts \"record for 725311 => \" + @student_records['725311'].inspect\n end\n end",
"def parse_rows(data)\n csv_options = DEFAULT_OPTIONS.merge(:col_sep => inferred_separator)\n CSV.parse(data, csv_options).map(&:to_hash)\n end",
"def load_csv (csv_file)\n\tret = []\n\tFile.open(csv_file, \"r\") do |f|\n\t\tf.each_line do |line|\n\t\t\t#puts line\n\t\t\tret << line.split(';')\n\t\tend\n\tend\n\treturn ret\nend",
"def grades_to_hash(csv)\n csv.map { |r| r.to_hash }\n end",
"def csv_hash\n {\n vendor: self.vendor_name,\n name: self.name,\n url: self.url,\n enable_proxy: self.access == 2 ? 1 : 0,\n description: self.description,\n more_info: '',\n enable_new: self.new_database.to_i,\n enable_trial: self.trial_database.to_i,\n types: self.resources.pluck(:name).join(';'),\n keywords: '',\n target: 0,\n slug: '',\n best_bets: self.curated.pluck(:name).join(';'),\n subjects: self.subjects.pluck(:name).join(';'),\n desc_pos: 1,\n lib_note: 0,\n enable_popular: self.popular.to_i,\n enable_hidden: 0,\n internal_note: '',\n owner: '',\n resource_icons: '',\n thumbnail: '',\n content_id: self.libguides_id\n }\n end",
"def create_item_rows_from_csv \n item_rows = []\n CSV.foreach('./data/items.csv', headers: true, header_converters: :symbol) do |row|\n item_rows << row\n end \n return item_rows\n end",
"def each_row(batch = ETL::Batch.new)\n log.debug(\"Reading from CSV input file #{file_name}\")\n @rows_processed = 0\n ::CSV.foreach(file_name, csv_options) do |row_in|\n # Row that maps name => value\n row = {}\n\n # If we weren't given headers then we use what's in the file\n if headers.nil?\n # We have a hash - OK we'll use it\n if row_in.respond_to?(:to_hash)\n row = row_in.to_hash\n # We have an array - use numbers as the keys\n elsif row_in.respond_to?(:to_a)\n ary = row_in.to_a\n ary.each_index do |i|\n row[i] = ary[i]\n end\n # Error out since we don't know how to process this\n else\n raise ETL::InputError, \"Input row class #{row_in.class} needs to be a hash or array\"\n end\n # if we were given the headers to use then we just need to grab the\n # values out of whatever we have\n else\n values = row_in.kind_of?(::CSV::Row) ? row_in.fields : row_in.to_a\n\n if headers.length != values.length\n raise ETL::InputError, \"Must have the same number of headers #{headers.length} \" + \n \"and values #{values.length}\"\n end\n\n # match up headers and values\n (0...headers.length).each do |i|\n row[headers[i]] = values[i]\n end\n end\n\n # now we apply our header map if we have one\n @headers_map.each do |name, new_name|\n if row.has_key?(name)\n # remap old name to new name\n row[new_name] = row[name]\n row.delete(name)\n else\n raise ETL::InputError, \"Input row does not have expected column '#{name}'\"\n end\n end\n\n transform_row!(row)\n yield row\n @rows_processed += 1\n end\n end",
"def parse_csv(csv_file)\n\n # Loop through all entries in CSV file\n CSV.foreach(csv_file, :quote_char => \"\\\"\") do |row|\n next if row[0] == \"From\" && row[1] == \"To\"\n next if row[0].nil?\n\n # [0, 1] refers to the 2 addresses in the csv file\n [0, 1].each do |i|\n add_location(row[i])\n end\n\n add_journey(row)\n end\nend",
"def prep_hash_for_csv(data_hash)\n\tbig_array = []\n\tdata_hash.each do |key, ads|\n\t\tad_array = [].push(key)\n\t\tads.each do |ad|\n\t\t\tad_string = ad[0] + \"\\r\" + ad[1] + \"\\r\" + ad[2]\n\t\t\tad_array.push(ad_string)\n\t\tend\n\t\tbig_array.push(ad_array)\n\tend\n\toutput_array = big_array.safe_transpose\n\treturn output_array\nend",
"def row_to_hash(row, columns, key_map)\n hash = {}\n (0..columns.length - 1).each do |i|\n # First, convert the column name using the translation table\n key = key_map[columns[i]]\n\n # Only process column if it's name is included in translation table\n if key\n value = row[i]\n # For string values, convert carriage returns to newlines, since\n # EasyChair form-entered newlines appear to be stored as CRs in\n # the exported data. This is primarily for the abstract field,\n # but this code performs the mapping on all string-valued columns\n if value && value.is_a?(String)\n value.gsub!(/\\r/, \"\\n\")\n end\n\n # Now store the value in the hash we're building\n hash[key] = value\n end\n end\n # Return the hash created from the array representing a CSV row\n hash\nend"
] |
[
"0.7417968",
"0.72490907",
"0.72490907",
"0.7213275",
"0.71767604",
"0.7123355",
"0.70743215",
"0.7051665",
"0.697614",
"0.6874475",
"0.681373",
"0.67446506",
"0.67120284",
"0.67027617",
"0.6691012",
"0.6689355",
"0.66708124",
"0.6616215",
"0.6603404",
"0.653157",
"0.65192586",
"0.6515183",
"0.65127116",
"0.6505254",
"0.6498561",
"0.649761",
"0.64927506",
"0.6456217",
"0.6440115",
"0.6436542",
"0.63776916",
"0.63719606",
"0.63529474",
"0.63381296",
"0.63230944",
"0.63072085",
"0.6285785",
"0.6281138",
"0.6267308",
"0.62665814",
"0.62529397",
"0.62455904",
"0.6243318",
"0.6228828",
"0.6220018",
"0.6219659",
"0.61823785",
"0.6181187",
"0.616362",
"0.6154604",
"0.615348",
"0.61426777",
"0.6141356",
"0.6139445",
"0.6132944",
"0.6116782",
"0.61071074",
"0.6103571",
"0.61004233",
"0.6098196",
"0.60867065",
"0.60698366",
"0.6051385",
"0.6028935",
"0.6025826",
"0.60252726",
"0.6017519",
"0.60142535",
"0.6007786",
"0.6007165",
"0.60059947",
"0.59985065",
"0.59943044",
"0.5991795",
"0.5980125",
"0.5959187",
"0.59510076",
"0.5945271",
"0.59420663",
"0.59400964",
"0.59388036",
"0.5938442",
"0.59314466",
"0.59064686",
"0.5884457",
"0.588174",
"0.58784914",
"0.5865972",
"0.5861184",
"0.5852562",
"0.5845763",
"0.5844806",
"0.5840283",
"0.58373827",
"0.58351356",
"0.5835029",
"0.58241814",
"0.5813798",
"0.5803956",
"0.58005226"
] |
0.7975117
|
0
|
FILTER CSV DATA (HASH MAP FILTER) Allows you to filter a hash map from csv data
|
def get_data_by_filters(filters, csv)
filters_a = filters.to_s.split(',')
csv_tmp = Array.new
csv_tmp = csv
for i in 0..(filters_a.size - 1)
filter = filters_a[i].to_s.downcase.strip
filter_data = get_filter_data filter
#The array is cleaned
data_filtered = Array.new
csv_tmp.each_with_index do |(record), index|
#Add csv headers
if index == 0
#data_filtered.push(record)
end
case filter_data[:operador].to_s.strip
when '='
if record[filter_data[:key].to_s.to_sym] == filter_data[:value].to_s
data_filtered.push(record)
end
when '!='
if record[filter_data[:key].to_s.to_sym] != filter_data[:value].to_s
data_filtered.push(record)
end
when '>'
if record[filter_data[:key].to_s.to_sym].to_s.to_f > filter_data[:value].to_s.to_f
data_filtered.push(record)
end
when '>='
if record[filter_data[:key].to_s.to_sym].to_s.to_f >= filter_data[:value].to_s.to_f
data_filtered.push(record)
end
when '<'
if record[filter_data[:key].to_s.to_sym].to_s.to_f < filter_data[:value].to_s.to_f
data_filtered.push(record)
end
when '<='
if record[filter_data[:key].to_s.to_sym].to_s.to_f <= filter_data[:value].to_s.to_f
data_filtered.push(record)
end
when 'contains'
if record[filter_data[:key].to_s.to_sym].to_s.downcase.include? filter_data[:value].to_s.downcase
data_filtered.push(record)
end
end
end
#The data of the 1st filter is added to 'csv_tmp' to reduce the filtered records
csv_tmp = data_filtered
end
return data_filtered
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def prefilter_csv_data(raw_csv_data)\n # De-dup emails absolutely\n csv_data = raw_csv_data.uniq{|row| row[:email]}\n\n # Remove data with duplicate names scoped in company and address (parameterized)\n #csv_data.uniq{|row| \"#{row[:first_name]} #{row[:last_name]} #{row[:company]} #{row[:address]}\".try(:parameterize)}\n end",
"def read(filter = {})\n CSVFileTransaction.new(@path).read do |existing_data|\n existing_data.select do |row|\n filter.keys.all? do |key|\n row[key] == filter[key]\n end\n end\n end\n end",
"def process_csv(file)\n data = CSV.read(file, {encoding: \"UTF-8\", headers: true, header_converters: :symbol, converters: :all})\n hashed_data = data.map { |d| d.to_hash } \n \n puts \"CSV Loaded...\"\n\n return hashed_data\n end",
"def filter(*columns)\n # columns = [*columns].flatten #columns should accept either an array of strings or a variable number of strings\n raise ArgumentError unless (columns.respond_to?(:size) and columns.size < @num_columns)\n output = []\n @file.each_with_index do |line, i|\n #TODO: Decide wther to allow user to specify if header row exists. If so, this step will be conditional. Else, add proviso to the README that csv file must include a header line.\n next if i == 0 # skip header row\n row = {}\n line.chomp.split(@separator).each_with_index do |value, j|\n if filtered_column_positions(columns).include? j\n row[@header[j]] = value\n end\n end\n output << row\n end\n output\n end",
"def parse(args={})\n csv_args = {:skip_blanks=>true,:col_sep=>\",\"}\n csv_args[:col_sep] = args[:col_sep] if args[:col_sep]\n args[:value_filter] ||= Csv2sql.method :default_value_filter\n i = 0\n CSV.foreach(@filename,csv_args) do |row|\n values = row\n #values_filter is for whole row\n #value_filter is for single value\n values = args[:values_filter].call(row, i) if args[:values_filter]\n if values\n if args[:value_filter]\n j = -1\n values = row.map do |value|\n j += 1\n args[:value_filter].call(value,i,j)\n end\n end\n yield values if values\n end\n i += 1\n end\n end",
"def load_csv()\n f = File.read(INPUT_CSV)\n CSV.parse(f, :headers => true, :col_sep => \",\").map do |row|\n as_hash = row.to_hash\n\n geom = { \n type: \"Point\",\n coordinates: as_hash['coordinates'].split.map { |num| num.to_f }\n }\n\n as_hash.delete('coordinates')\n as_hash['geom'] = geom\n\n if (as_hash['pic_url'].strip.length < 1)\n as_hash.delete('pic_url')\n end\n\n if (as_hash['place_image'].strip.length < 1)\n as_hash.delete('place_image')\n end\n\n as_hash\n end\nend",
"def players(team)\n field= []\n CSV.foreach(\"teams.csv\", headers:true,header_converters: :symbol) do |row|\n if row[:team] == team\n field << row.to_hash\n end\n end\n field\nend",
"def filter_data_columns_csv(iterator)\n retval = []\n\n if iterator == nil\n return []\n end\n\n csv = CSV.parse(iterator, :headers => true, :skip_blanks => true)\n \n headers = csv.headers() \n #check for duplicate field names\n #dup_head = headers.detect {|e| headers.rindex(e) != headers.index(e)}\n dup_head = headers.detect do |e|\n if (!e.empty?) #For empty (e == \"\") header fields\n headers.rindex(e) != headers.index(e)\n end\n end\n \n if (headers.empty?)\n message = \"#### Error: header filtering failed.\\n\"\n return [message, nil]\n end\n \n if (dup_head != nil)\n message = \"### Error: document may contain duplicate column names.\\n\"\n message << \"# Source: \" << dup_head << \"\\n\"\n return [message, nil]\n end\n \n csv.each do |row|\n row_hash = (row.to_hash)\n retval << row_hash\n end\n\n return [message, retval]\n end",
"def preprocess_data\n # Remove things if needed\n if @filter_keys\n @input = @input.delete_if{|k, v| !@filter_keys.include?(k)}\n end\n end",
"def filter(values); end",
"def filter(values); end",
"def filter(values); end",
"def reprocess_csv(file)\n raw = open(file).read.force_encoding(\"UTF-8\")\n csv = CSV.parse(raw, headers: true, header_converters: :symbol)\n csv.each do |row|\n data = row.to_hash.each { |k, v| v = v.to_s.gsub(/[[:space:]]+/, ' ').strip }\n data[:area_id] = data[:area].downcase\n data[:gender] = data[:gender].downcase\n data[:term] = '2013'\n %i(num).each { |i| data.delete i }\n ScraperWiki.save_sqlite([:name, :name, :term], data)\n end\nend",
"def recommendation_csv_inputs csv_path\n valid_inputs = []\n\n CSV.foreach(csv_path, {headers: true, header_converters: :symbol}) do |row|\n row = row.to_h\n valid_inputs << row if valid_recommendation_hash?(row)\n end\n\n valid_inputs\n\n rescue => e\n valid_inputs\n end",
"def get_csv_data(csv_data)\r\n csv_file = nil\r\n\r\n #Get the path and name of the CSV file\r\n if csv_data.to_s.include? '.csv'\r\n csv_file = File.join(File.dirname(__FILE__), \"../venture/config/csv_data/#{csv_data}\")\r\n elsif (\r\n csv_file = File.join(File.dirname(__FILE__), \"../venture/config/csv_data/#{csv_data}.csv\")\r\n )\r\n end\r\n\r\n csv_arr = CSV.read( csv_file, {:headers => true, :header_converters => :symbol, :encoding => 'UTF-8'} )\r\n keys = csv_arr.headers.to_a\r\n # read attribute example => csv[index][:column1]\r\n return csv_arr.to_a.map {|row| Hash[ keys.zip(row) ] }\r\nend",
"def filter(hash)\n hash.keys.sort.each_with_object({}) do |key, hsh|\n value = hash[key]\n\n hsh[key] = if value.is_a?(Hash)\n filter(value)\n elsif value.is_a?(Array)\n value.map do |elem|\n filter(elem)\n end\n elsif FILTERED_FIELDS.include?(key)\n :filtered\n else\n value\n end\n end\n end",
"def filter_hash!(hsh)\n [[:timestamp, ->(t) { t.to_f }]].each do |k, f|\n hsh[k] = f.call(hsh[k])\n end\n hsh\n end",
"def clean_og(canvas_ex,hash)\n\tCSV.foreach(canvas_ex) do |row|\t\n\t\tif row[2] != nil \n\t\t\tif row[2].include? \"F\" \n\t\t\t\t#assign everyone a 0\n\t\t\t\thash[row[2]] = 0\n\t\t\tend\t\t\t\n\t\tend\n\tend\n\t\n\treturn hash\nend",
"def _output_dir_file_data_filter(hash, filter_key)\n hash.select { |key, _| key == filter_key }\n end",
"def filter_metadata(data, keys, values, filter_on=nil)\n\n filter_data = data\n\n # If filter_on is defined, iterate through the list and get the array\n # to filter\n if(filter_on)\n Array(filter_on).each do |f|\n filter_data = filter_data.try(:[],f)\n end\n end\n\n\n\n # Define a proc for filtering the array\n # +keys+:: The key(s) under which a value is stored in the array element\n # +v+:: Should contain the current element of the array we're testing\n # +values+:: The values which are valid and should cause the element to be included in the filtered array\n select_function = Proc.new { |keys,v, values|\n value = v\n Array(keys).each do |k|\n begin\n value = value.try(:[], k)\n rescue\n value = nil\n end\n end\n\n if(value.class == Array)\n (values & value).present?\n elsif(value.present?)\n Array(values).include?(value)\n else\n value.present?\n end\n\n }\n\n # Call the above proc\n if(filter_data.class==Hash)\n filter_data.select!{|hk,v|\n select_function.call(keys,v, values)\n }\n else\n filter_data.select!{|v|\n select_function.call(keys,v, values)\n\n }\n end\n\n\n\n\n\n return data\n end",
"def read_in_ownership(csv_file_name, temp_hash = Hash.new)\n\t CSV.foreach(csv_file_name, :headers => true) do |row|\n\t\t song_id, owner_data = row[0], row[1]\n\t \t unless (song_id =~ /#/)\n\t \t \t temp_hash[song_id] = owner_data\n\t \t end\n end\n temp_hash\n\tend",
"def filterhash\n @filter_hash\n end",
"def read_in_ownership(csv_file_name, temp_hash = Hash.new)\n\t CSV.foreach(csv_file_name, :headers => true) do |row|\n\t\t song_id, owner_data = row[0], row[1]\n\t \t unless (song_id =~ /#/)\n\t \t \t temp_hash[song_id] = owner_data\n\t \t end\n end\n temp_hash\n\tend",
"def filtered_poi_hash\n addr = @hash['address']\n {\n 'category_id' => @hash['category_id'],\n 'name' => @hash['name'],\n 'branch_store_name' => @hash['branch_store_name'],\n 'money' => @hash['money'],\n 'telephone' => @hash['telephone'],\n 'cover_img' => @hash['cover_image_url'],\n 'tags' => @hash['tags'],\n 'pixnet_rating' => @hash['rating']['avg'],\n 'city' => addr['city'],\n 'town' => addr['town'],\n 'open_hours' => open_hours,\n 'website' => website,\n 'address' => address\n }\n end",
"def filter_friends\n inname = DATA_DIR.join('unpacked', 'all-friends-ids.csv')\n rows = open(inname, 'r'){|i| i.readlines }\n hsh = rows.inject(Hash.new{|h, k| h[k] = 0}) do |h, row|\n uname, friend_id = row.strip.split(',')\n h[friend_id] += 1\n h\n end\n\n fhsh = hsh.select{|k, v| v >= MIN_FRIEND_COUNT }\n end",
"def csv_parsed\n transform_to_hash(@csv_array, @header)\n end",
"def load_data(csv)\n @hash.each do |sentence, count|\n csv << [sentence, count]\n end\n end",
"def filter_csv data\n data.select do |items|\n items.select! {|item| item.try(:strip).present? }\n if items.size != 3\n false\n else\n true\n end\n end\n end",
"def FilterHashArray array, filter = {}, include = true, &proc\n out = []\n array.each do |item|\n #puts \"item #{item.inspect}\"\n ok = true\n filter.each_pair do |k, v|\n #puts \"#{k} = #{v.inspect}\"\n if !item.has_key?(k) || \n v.is_a?(Array) && !v.map(&:to_s).include?(item[k].to_s) || \n !v.is_a?(Array) && v.to_s != item[k].to_s\n ok = false\n #puts \"False\"\n break\n end\n end\n if ok && include || !ok && !include\n #puts \"Ok\"\n out << item\n proc.call(item) unless proc.nil?\n end\n end\n out\n end",
"def load_csv(file) \n\t\thash = {}\n\t\tCSV.foreach(file) { |row| hash[row[0]] = row[1] } \n\t\thash\n\tend",
"def data_filter(data, filters)\n if not data.is_a?(Array) or not filters.is_a?(String)\n return data\n end\n data = data.clone\n for filter in array_filter(filters.split(\",\"))\n key, value = array_filter(filter.split(\":\"))\n # find unspecified fields\n if value == nil\n data.select!{|d| d[key] == nil}\n # find fields that match regex\n elsif value.is_a?(String)\n data.select!{|d| d[key].to_s =~ /#{value}/m}\n end\n end\n return data\n end",
"def filtered_entries; end",
"def read_scores_from\n teams_data = []\n\n CSV.foreach('scores.csv', headers: true, header_converters: :symbol) do |row|\n teams_data << row.to_hash\n end\n teams_data\nend",
"def filter(filter)\n filtered_height_map = HeightMap.new\n filtered_height_map.load(filter.filter(@data), @size_x)\n filtered_height_map\n end",
"def import_from_csv(file_name)\r\n #implementation goes here\r\n csv_text = File.read(file_name)\r\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\r\n # #8 iterate over table rows, create hash for each, then convert to Entry using 'add_entry' method\r\n csv.each do |row|\r\n row_hash = row.to_hash\r\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\r\n end #end csv.each loop\r\n end",
"def extract_countries_and_regions\n infile, result, *others = params\n out_file_name = \"countries_and_regions.csv\"\n\n puts; print \"Extracting countries and regions from #{infile}\"\n\n col_filter = \"COUNTRIES:4-6+REGIONS:18\"\n\n Sycsvpro::Collector.new(infile: infile,\n outfile: out_file_name,\n cols: col_filter).execute\n\n puts; puts \"You can find the collection result in #{out_file_name}\"\nend",
"def prepare_filters(input, setup = @valid_filters)\n input = input.keys_to_symbols\n (setup.keys & input.keys).inject({}) do |prepared, filter|\n # TODO if we ever do more complex filters (eg multiple ids, where logically they're stored as a list but go\n # back to a csv string for display), this is where we do it\n prepared.merge(filter => input[filter])\n end\n end",
"def get_references\n references_hash = {}\n FasterCSV.foreach(\"#{Source_path}/TbReference.csv\", :quote_char => '\"', :col_sep =>',', :row_sep =>:auto) do |row|\n references_hash[row[0]] = row[6]\n end\n return references_hash\nend",
"def csv_row_to_map(row_values)\n {\n type: row_values[0],\n key: row_values[1],\n revision: row_values[2],\n last_modified: row_values[3],\n details: JSON.parse(row_values[4])\n }\n end",
"def 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 process(csv_data)\n unless csv_data.headers == SOA_CSV_STRUCTURE\n LOGGER.error(\"Structure of #{csv_filename} does not match:\\nExpected: #{SOA_CSV_STRUCTURE.inspect}.\\nActual: #{csv_data.headers.inspect}.\\nContent: #{csv_file}\")\n abort('ABORTED!')\n end\n\n index = 0\n csv_data.delete_if do |row|\n index += 1\n retval = row[:buchungstag].nil? || row[:wertstellung].nil? || row[:umsatzart].nil?\n LOGGER.info(\"- Record nbr. #{index} not processed due to empty field(s): #{row.inspect}\") if retval\n retval\n end\n\n csv_data.sort_by { |row| DateTime.parse(row[:buchungstag]) }\n end",
"def apply_filters(entries, filters)\n filters.each{\n |filter|\n parts = filter.split(\"=\")\n \n # Determine if the filter is joined with a '=' or '!='\n last_char=parts[0][-1,1]\n if last_char == \"!\"\n test_equals = false\n key = parts[0][0, parts[0].length()-1]\n match = parts[1]\n else\n test_equals = true\n key = parts[0]\n match = parts[1]\n end\n \n entries.each{\n |e, entry|\n # Find the key value in entry, or nil if it doesn't exist\n value = find_entry_setting(entry, key)\n \n # Calculate if the returned value matches the filter value\n if value.is_a?(Array)\n is_equal = false\n value.each{\n |v|\n if is_value_match?(v, match)\n is_equal = true\n end\n }\n else\n is_equal = is_value_match?(value, match)\n end\n \n # Delete the entry if the result of the match check isn't what\n # the filter is looking for\n if is_equal != test_equals\n entries.delete(e)\n end\n }\n }\n \n return entries\n end",
"def parse\n data = CSV.parse(@input_data)\n data.shift # remove header row\n headers = [:player_key, :birth_year, :first_name, :last_name]\n data.map {|row| Hash[ *(headers.zip(row).flatten) ] }\n end",
"def process_csv_file(filename, no_of_unique,delimiter)\n @arr_unique = Array.new{hash.new}\n @arr_details = Array.new(@no_of_columns){{\"int\" => 0, \"float\" => 0, \"date\" => 0, \"datetime\" => 0, \"string\" => 0, \"max_value\" => 0, \"min_value\" => 0}}\n total_chunks = SmarterCSV.process(filename, {:col_sep => delimiter, :chunk_size => 200, :remove_empty_values => false, :remove_zero_values => false}) do |chunk|\n for i in 0..@headers.length-1\n arr = chunk.map{|x| x[@headers[i].to_sym]}\n if(@arr_unique[i].to_a.empty?)\n @arr_unique[i] = arr.uniq\n elsif(@arr_unique[i].size < no_of_unique.to_i+2)\n @arr_unique[i] |= arr.uniq\n elsif (arr.uniq.include?(nil) && !@arr_unique[i].include?(nil))\n @arr_unique[i].push(nil)\n elsif (arr.uniq.include?(\"NULL\") && !@arr_unique[i].include?(\"NULL\"))\n @arr_unique[i].push(\"NULL\")\n elsif (arr.uniq.include?(\"\\N\") && !@arr_unique[i].include?(\"\\N\"))\n @arr_unique[i].push(\"\\N\") \n elsif (arr.uniq.include?(\"\") && !@arr_unique[i].include?(\"\"))\n @arr_unique[i].push(\"\")\n elsif (arr.uniq.include?(\" \") && !@arr_unique[i].include?(\" \"))\n @arr_unique[i].push(\" \")\n end \n arr.each do |field|\n field_type = get_datatype(field)\n count = @arr_details[i][field_type]\n @arr_details[i][field_type] = count+1\n if(field != nil)\n begin\n if(@header_datatype[i] == \"int\" || @header_datatype[i] == \"float\") \n if(@arr_details[i][\"max_value\"] < field)\n @arr_details[i][\"max_value\"] = field\n end\n if(@arr_details[i][\"min_value\"] > field || @arr_details[i][\"min_value\"] == 0)\n @arr_details[i][\"min_value\"] = field\n end\n else\n if(@arr_details[i][\"max_value\"] < field.to_s.length)\n @arr_details[i][\"max_value\"] = field.to_s.length\n end\n if(@arr_details[i][\"min_value\"] > field.to_s.length || @arr_details[i][\"min_value\"] == 0)\n @arr_details[i][\"min_value\"] = field.to_s.length\n end\n end\n rescue Exception => e\n end\n end\n end\n end\n end\n end",
"def index_source\n @lines = {}\n @index = Hash.new{ |h, k| h[k] = [] }\n if @field_names\n index_fields\n include_filter = convert_filter(@include, @field_names)\n exclude_filter = convert_filter(@exclude, @field_names)\n end\n @line_count = 0\n @skip_count = 0\n @dup_count = 0\n line_num = 0\n @data.each do |row|\n line_num += 1\n next if line_num == 1 && @field_names && @ignore_header\n unless @field_names\n if row.class.name == 'CSV::Row'\n @field_names = row.headers.each_with_index.map{ |f, i| f || i.to_s }\n else\n @field_names = row.each_with_index.map{ |f, i| f || i.to_s }\n end\n index_fields\n include_filter = convert_filter(@include, @field_names)\n exclude_filter = convert_filter(@exclude, @field_names)\n next\n end\n field_vals = row\n line = {}\n filter = false\n @field_names.each_with_index do |field, i|\n val = field_vals[i]\n val = val.to_s.strip if val && @trim_whitespace\n line[field] = val\n if include_filter && f = include_filter[i]\n filter = !check_filter(f, line[field])\n end\n if exclude_filter && f = exclude_filter[i]\n filter = check_filter(f, line[field])\n end\n break if filter\n end\n if filter\n @skip_count += 1\n next\n end\n key_values = @key_field_indexes.map{ |kf| @case_sensitive ?\n field_vals[kf].to_s :\n field_vals[kf].to_s.upcase }\n key = key_values.join('~')\n parent_key = key_values[0...(@parent_fields.length)].join('~')\n if @lines[key]\n @warnings << \"Duplicate key '#{key}' encountered at line #{line_num}\"\n @dup_count += 1\n key += \"[#{@dup_count}]\"\n end\n @index[parent_key] << key\n @lines[key] = line\n @line_count += 1\n end\n end",
"def filter_hash(hsh)\n [[:timestamp, ->(t) { Time.at(t) }]].map do |k, f|\n hsh[k] = f.call(hsh[k])\n end\n hsh\n end",
"def filter(row)\n self.keys.each do |key|\n value = self.parameters.send(key)\n case value\n when Array\n return false unless value.include?(row[key])\n when Range\n return false unless value.include?(row[key])\n else\n return false unless value === row[key]\n end\n end\n return true\n end",
"def read_csv(csv_file, data)\n logger.info \"Reading #{data.type} data from '#{csv_file} date column = #{@date_column} data starts at col #{@data_start_column} skipping #{@header_rows} header rows\"\n lines = File.readlines(csv_file)\n (@header_rows...lines.length).each do |i|\n reading = lines[i].split(',')\n begin\n date = Date.parse(reading[@date_column])\n rowdata = reading[@data_start_column, @data_start_column + 47].map(&:to_f)\n data.add(date, rowdata)\n rescue StandardError => e\n logger.warn e.message\n logger.warn e.backtrace.join(\"\\n\")\n logger.warn \"Unable to read data on line #{i} of file #{csv_file} date value #{reading[@date_column]}\"\n end\n end\n logger.info \"Read hash #{data.length} rows\"\n end",
"def parse_csv(decoded_data)\n csv = CSV.parse(decoded_data)\n headers = csv.shift\n csv.to_a.map! { |row| Hash[headers.zip(row)] }\n end",
"def filter_hash(hash, filter, debug = false)\n fail 'Hash argument is not a Hash!' unless hash.is_a? Hash\n\n filtered_hash = {}\n select_logic = case filter\n when String then 'k.nil? ? false : k[Regexp.new(filter)] && k.length == filter.length'\n when (Fixnum || Integer || Float || Numeric) then \"k[Regexp.new('#{filter}')]\"\n when Regexp then 'k[filter]'\n when Symbol then\n 'k == filter'\n when NilClass then true # Return all specs if a filter is set to nil (i.e. user doesn't care about this filter)\n else true\n end\n filtered_hash = hash.select do |k, v|\n # binding.pry if filter == 'SubSection A'\n [TrueClass, FalseClass].include?(select_logic.class) ? select_logic : eval(select_logic)\n end\n filtered_hash\n end",
"def load\n csv = csv_data\n @data = TableFu.new(csv_data, @table_opts[:column_options] || {})\n if @table_opts[:faceting]\n @data.col_opts[:ignored] = [@table_opts[:faceting][:facet_by]]\n @facets = @data.faceted_by @table_opts[:faceting][:facet_by]\n end\n @data.delete_rows! @table_opts[:dead_rows] if @table_opts[:dead_rows]\n end",
"def get_csv_data(infile)\n csv_data = CSV.read infile\n headers = csv_data.shift.map {|i| i.to_s }\n string_data = csv_data.map {|row| row.map {|cell| cell.to_s } }\n return string_data.map {|row| Hash[*headers.zip(row).flatten] }\nend",
"def get_csv_data(infile)\n csv_data = CSV.read infile\n headers = csv_data.shift.map {|i| i.to_s }\n string_data = csv_data.map {|row| row.map {|cell| cell.to_s } }\n return string_data.map {|row| Hash[*headers.zip(row).flatten] }\nend",
"def prod_to_hash(csv_name)\n\tprod_array = CSV.read(csv_name)\n\tprod_array.each_with_index do |line, index|\n\t\tnext if line[0] == \"Opportunity ID\" \n\t\tbreak if line[0] == nil\n\t\t@current_opp_list[line[0]] = Opportunity.new(line[@prods_opp], line[@prods_prod], line[@prods_access], line[@prods_status], \"unknown\")\n\t\t\n\tend\n\t\nend",
"def process_file(path)\n CSV.open(path, {:headers => true}) do |csv|\n csv.each do |row|\n res = cached_lookup(row['X'].to_f, row['Y'].to_f)\n puts \"#{res[:lng]},#{res[:lat]},#{res[:neighborhood]}\"\n end\n end\n end",
"def gather_from_csv\n items = {}\n FasterCSV.foreach(@plucked_out_items_csv, FCSV_OPTS){|line|\n STDERR.puts \"ERROR: RMID not found for item_id #{line[:item_id].chomp} in CSV-file #{@plucked_out_items_csv}\" unless line[:rmid]\n items[ line[:item_id].chomp ] = {\n :handle => line[:item_hdl].chomp,\n :rmid => line[:rmid].chomp,\n #:collection_handle => line[:col_owner_hdl].chomp,\n }\n }\n items\n end",
"def parse\n data = CSV.parse(@input_data)\n data.shift # remove header row\n headers = [:player_key, :year, :team_id, :game, :at_bats, :runs, :hits, :doubles, :triples, :home_runs, :runs_batted_in, :stolen_bases, :caught_stealing]\n data.map {|row| Hash[ *(headers.zip(row).flatten) ] }\n end",
"def filter_data\n @data.map do |currency|\n currency.select { |attribute,_|\n selected_attributes.include? attribute.to_s\n }\n end\n end",
"def strip_metadata(f, iterator)\n if (f == nil or iterator == nil)\n return false\n end\n \n if iterator.class == String\n #spilt the iterator text by endlines, outputs array\n iterator = iterator.split(/$/)\n #else if iterator.class == File (or anything else), do nothing\n end\n \n if f != nil and iterator != nil\n i = 0\n\n f.get_ifilter_headers.each do |h|\n #metadata_col_hash = {}\n \n begin\n row = iterator[i]\n rescue\n row = []\n log_and_print \"WARN: filter_metadata_columns() is parsing empty data\"\n end\n \n #if row is a hash (i.e. from a Couchdb doc and not a Tempfile),\n # join it back into one string\n if row.is_a? Hash\n row = row.map {|k,v| v}.join\n end\n\n if ( f['regex'].include?(\"csv\") ) #if (f['regex'] == \"csv\")\n iterator = strip_header(h, iterator)\n end\n \n #If row is length of two, then we want to make a key => val pair out \n # of the row. Else, the user has matches an unknown amout of values,\n # and we can only number the keys.\n\n i = i + 1 \n end\n else\n #metadata_columns = []\n end\n \n if iterator.is_a? Array\n iterator = iterator.join('') #Converts back into string\n end\n iterator = iterator.lstrip #Removes leading whitespace between header and csv\n\n return iterator\n end",
"def clean(data)\n data.map{|line|\n Hash[line.map{ |col| \n col[1] = BOOL_MAP[col[1]] || col[1].to_s.strip.gsub(/^\\s+|\\s+$/, '').gsub(/\\n|\\r/,' ')\n col\n }]\n }\n end",
"def parse_csv(csv_string)\n csv_data = FasterCSV.parse(csv_string)\n header = csv_data.shift\n [csv_data.map{|row| Hash[*header.zip(row).flatten] }, header]\n end",
"def filterKeyPair(line=\"\", store={})\n\n temp = line.split(\"=\")\n left = temp[0].strip\n key_comb = left.split(/<|>/)\n key = key_comb[0].strip.to_sym\n\n if temp[1].include? \"\\\"\"\n value = temp[1].strip.split('\"')[1]\n elsif [\"yes\", \"true\", \"1\"].include? temp[1].strip # assumption yes, true , 1 => true; no false 0 => false\n value = true\n elsif [\"no\", \"false\", \"0\"].include? temp[1].strip\n value = false\n elsif temp[1].strip.split(\",\").length > 1\n value = temp[1].strip.split(\",\")\n else\n value = temp[1].strip\n end\n\n if key_comb.length == 1\n store[key]=value\n elsif @overrides.include? key_comb[1].strip\n store[key]=value\n elsif !store.include?(key)\n store[key]=value\n end\n\n end",
"def filter_data(params_list)\n filter_params = {}\n\n if params['data']\n params['data'].keys.each do |key|\n if params_list.map{|x| x.to_s}.include? key\n filter_params[key] = params['data'][key]\n end\n end\n end\n\n filter_params\n end",
"def read_from_roster(csv)\n players = []\n CSV.foreach(csv, headers: true, header_converters: :symbol) do |player|\n players << player.to_hash\n end\n players\nend",
"def parse_csv_file\n csv_data = CSV.read(\"../artists_for_seed_data.csv\")\n csv_data.shift\n # iterate over each element and send back a hash\n # need to shift again at the beginning to get rid of id on the row\n painter_object_array = []\n csv_data.each do |painter_row_arr|\n \n painter_row_arr.shift\n painter_object = {\n :name => painter_row_arr[0],\n :years => painter_row_arr[1],\n :genre => painter_row_arr[2],\n :nationality => painter_row_arr[3],\n :bio => painter_row_arr[4],\n :painter_num => painter_row_arr[6]\n }\n painter_object_array.push(painter_object)\n end\n painter_object_array.flatten\nend",
"def filter(options, headers, row) \n matches = []\n \n # No Tag(s)\n if row[headers.index(\"tags\")].size == 0\n matches.append(\"No Tags\")\n end\n\n # No Topic(s)\n if row[headers.index(\"topics\")].size == 0\n matches.append(\"No Topics\")\n end\n \n # No Description\n if row[headers.index(\"description\")].size == 0\n matches.append(\"No Description\")\n end\n\n # > 5000 words (potentially look at shortening)\n if row[headers.index(\"wordcount\")].to_i > 5000\n matches.append(\"> 5000 words\")\n end\n\n return matches\nend",
"def parse_painter_csv_file\n csv_data = CSV.read(\"db/painter_seed_data.csv\")\n csv_data.shift\n # iterate over each element and send back a hash \n # need to shift again at the beginning to get rid of id on the row\n painter_object_array = []\n csv_data.each do |painter_row_arr|\n painter_row_arr.shift\n painter_object = {\n :name => painter_row_arr[0],\n :years => painter_row_arr[1],\n :genre => painter_row_arr[2],\n :nationality => painter_row_arr[3],\n :bio => painter_row_arr[4],\n :painting_num => painter_row_arr[6],\n :portrait => painter_row_arr[7]\n }\n painter_object_array.push(painter_object) \n end\n painter_object_array.flatten\nend",
"def read_users_from_file(filename)\n CSV.read(filename, :headers => true, :header_converters => :symbol).map { |row| row.to_hash }\nend",
"def to_filter\n to_hash.to_filter\n end",
"def filter_by_kv h, k, v\n h.map {|h1| (h1[k] == v) && h1 || nil }.compact\n end",
"def process!\n if valid?\n # get the csv rows as an array of hashes\n setup_data\n raw_csv_data = compute_csv_data\n # remove duplicate rows in the csv file (by email or name)\n prefilterted_csv_data = prefilter_csv_data raw_csv_data\n # remove the rows that match emails in the database\n new_data = filter_data_through_db prefilterted_csv_data\n\n # crate a new users\n resolved_data = create_new_user_records new_data\n end\n @rejected_user_data\n end",
"def prep_hash_for_csv(data_hash)\n\tbig_array = []\n\tdata_hash.each do |key, ads|\n\t\tad_array = [].push(key)\n\t\tads.each do |ad|\n\t\t\tad_string = ad[0] + \"\\r\" + ad[1] + \"\\r\" + ad[2]\n\t\t\tad_array.push(ad_string)\n\t\tend\n\t\tbig_array.push(ad_array)\n\tend\n\toutput_array = big_array.safe_transpose\n\treturn output_array\nend",
"def grades_to_hash(csv)\n csv.map { |r| r.to_hash }\n end",
"def make_testdata_reworked_csv_file\n create_column_headers_index_hash \n create_row_headers_index_hash \n clear_testdata_reworked_file\n CSV.open('testdata_reworked.csv', \"wb\") do |csv|\n CSV.foreach('testdata.csv', {headers: true}) do |row| \n row[0] = @column_hash.key(row[0].to_i)\n row[1] = @row_hash.key(row[1].to_i)\n csv << row\n end\n end\nend",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n # #8 iterate over the CSV::Table rows then create a hash for each row, convert each row_hash\n #to an Entry by using the add_entry method\n csv.each do |row|\n row_hash = row.to_hash\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n end",
"def filter; end",
"def filter; end",
"def filter; end",
"def findBarcodeFromCSV()\n puts Dir.pwd\n sampleSheetPath = \"../../../SampleSheet.csv\"\n samplesDirPath = \"../../SamplesDirectories.csv\"\n barcodeHash = Hash.new\n\n if File::exist?(sampleSheetPath) &&\n File::exist?(samplesDirPath)\n\n lines1 = IO.readlines(sampleSheetPath)\n lines2 = IO.readlines(samplesDirPath)\n\n lines2.each do |line|\n tokens = line.split(\",\")\n \n if tokens[1].to_s.eql?(@analysisLane.to_s)\n # puts \"Adding : \" + tokens[4] + \" to hashtable\"\n barcodeHash.store(tokens[4], \"\")\n end\n end\n\n lines1.each do |line|\n tokens = line.split(\",\")\n\n if tokens[1].to_s.eql?(@analysisLane.to_s) &&\n !barcodeHash.has_key?(tokens[4])\n return tokens[4].to_s\n end\n end \n return \"\"\n else\n # The flowcell is not barcoded. Return an empty string\n return \"\"\n end\n end",
"def parse_csv(csv)\n objects = CSV.parse(csv)\n headers = objects.shift\n objects.to_a.map! { |row| Hash[headers.zip(row)] }\n end",
"def grep_csv(file)\n csv = CSV.read(file)\n csv.each do |row|\n if row[@opts[:col]] =~ @regex\n @matches.push(row)\n end\n end\n end",
"def readCSV pmdReportCSVFile\n\tfile = File.open(pmdReportCSVFile, \"rb\")\n\tcsv_contents = file.read\n\tkeys = [\"Problem\",\"Package\",\"File\",\"Priority\",\"Line\",\"Description\",\"Rule set\",\"Rule\"]\n\treturn CSV.parse(csv_contents).map {|a| Hash[ keys.zip(a) ] }\nend",
"def load_csv(filename)\n CSV::Converters[:blank_to_nil] = lambda do |field|\n field && field.empty? ? nil : field\n end\n CSV.new(File.read(filename), \n :headers => true, \n :header_converters => :symbol, \n :converters => [:all, :blank_to_nil]\n ).entries.map { |row| row.to_hash }\nend",
"def access_fav_movies_file\n # Access 'movies.csv' file to pull the saved favorite movie info;\n # And create a hash data set based on the existing list in the file\n f = File.new('movies.csv', 'r')\n\n # Parse the pipe-seperated data and organize them into one aggregated hash.\n saved_movie_info_set = {}\n f.each do |line|\n movie_info_array = line.split(\"|\")\n movie_info_hash = {}\n\n movie_info_hash[:title] = movie_info_array[0]\n movie_info_hash[:year] = movie_info_array[1]\n movie_info_hash[:company] = movie_info_array[2]\n movie_info_hash[:genres] = movie_info_array[3]\n movie_info_hash[:length] = movie_info_array[4]\n movie_info_hash[:director] = movie_info_array[5]\n movie_info_hash[:mpaa_rating] = movie_info_array[6]\n movie_info_hash[:tagline] = movie_info_array[7]\n movie_info_hash[:poster] = movie_info_array[8]\n movie_info_hash[:release_date] = movie_info_array[9]\n\n saved_movie_info_set[movie_info_array[0].split(\"(\")[0].split.join.downcase] = movie_info_hash\n end\n f.close\n return saved_movie_info_set\nend",
"def read_data(options={})\n orig_data = CSV.read(@filename, :skip_blanks => true)\n num_lines = orig_data.length\n if num_lines % @num_lines_per_linegroup == 0\n num_line_groups = num_lines / @num_lines_per_linegroup\n else\n raise \"ERROR: Invalid number of lines in file!\"\n end\n \n# puts \"Num Lines: #{num_lines}\"\n# puts \"************************\\n\"\n \n # array for final data\n @final_data = []\n \n # go through each line group\n num_line_groups.times do |i|\n \n # init a temp hash\n temp_hashes = []\n @data_columns.each do |col|\n temp_hashes[col] = {}\n end\n \n # grab data per linegroup\n @num_lines_per_linegroup.times do |j|\n line = orig_data[i*@num_lines_per_linegroup + j]\n field_name = @input_data_rows[j]\n # parse columns within a line\n @data_columns.each do |col|\n data = line[col]\n temp_hashes[col][field_name] = data\n # puts \" #{line[col]}\" if !line[col].nil?\n end\n end\n \n # push grabbed data onto master hash array\n temp_hashes.each do |record|\n if !record.nil?\n @final_data << record\n end\n end\n \n end # per line groups\n \nend",
"def whereable_deparse(hash)\n raise FilterInvalid, \"Invalid hash #{hash}\" if hash.size > 1\n\n key, value = hash.first\n\n case key\n when :and, :or\n arel = whereable_deparse(value.first)\n value[1..-1].each do |o|\n arel = arel.public_send(key, whereable_deparse(o))\n end\n arel\n when :eq, :not_eq, :gt, :gteq, :lt, :lteq\n column = whereable_valid_column(value[:column])\n literal = whereable_valid_literal(column, value[:literal])\n arel_table[column].public_send(key, literal)\n when :between\n column = whereable_valid_column(value[:column])\n literals = value[:literals]\n raise(FilterInvalid, \"Invalid operation for #{column}\") if defined_enums.key?(column)\n\n arel_table[column].between(literals)\n when :in\n column = whereable_valid_column(value[:column])\n literals = value[:literals].map { |l| whereable_valid_literal(column, l) }\n\n arel_table[column].in(literals)\n else\n raise FilterInvalid, \"Invalid hash #{hash}\"\n end\n end",
"def csv_filter_params\n params.require(:csv_filter).permit(:name, :csv_attribute_id, :before_value, :after_value, :compare_value, :csv_operator_id)\n end",
"def parse_line line,header,options,bedfilter,samples,template,stats=nil\n fields = VcfLine.parse(line)\n rec = VcfRecord.new(fields,header)\n r = rec # alias\n\n filter = options[:filter]\n sfilter = options[:sfilter]\n efilter = options[:efilter]\n ifilter = options[:ifilter]\n add_filter = options[:add_filter] # contains a filter name (soft filter)\n seval = options[:seval]\n ignore_missing = options[:ignore_missing]\n quiet = options[:quiet]\n set_filter_field = nil\n\n if sfilter or efilter or ifilter or seval\n # check for samples\n header_samples = header.column_names[9..-1]\n raise \"Empty sample list, can not execute query!\" if not header_samples\n end\n\n # --------------------------\n # Filtering and set analysis\n if bedfilter\n bed = bedfilter.contains(rec)\n return if not bed\n end\n\n skip = lambda { |&m|\n matched = m.call\n if add_filter\n set_filter_field = true if matched\n false # always continue processing with an add-filter\n else\n not matched\n end\n }\n\n if filter\n return if skip.call { rec.gfilter(filter,ignore_missing_data: ignore_missing,quiet: quiet) }\n end\n \n if sfilter # sample 'or' filter\n rec.each_sample(options[:sfilter_samples]) do | sample |\n return if skip.call { sample.sfilter(sfilter,ignore_missing_data: ignore_missing,quiet: quiet) }\n end\n end\n\n if ifilter # include sample filter\n found = false\n rec.each_sample(options[:ifilter_samples]) do | sample |\n if sample.ifilter(ifilter,ignore_missing_data: ignore_missing,quiet: quiet)\n found = true\n break\n end\n end\n # Skip if there are no matches\n return if skip.call {found}\n end\n\n if efilter # exclude sample filter\n rec.each_sample(options[:efilter_samples]) do | sample |\n return if skip.call{ sample.efilter(efilter,ignore_missing_data: ignore_missing,quiet: quiet) }\n end\n end\n\n stats.add(rec) if stats\n\n # -----------------------------\n # From here on decide on output\n \n rec.add_to_filter_field(add_filter) if set_filter_field\n\n if samples\n # Select certain samples for output\n newfields = fields[0..8]\n samples.each do |s|\n newfields << fields[s+9] \n end\n fields = newfields\n end\n if options[:eval] or seval\n begin\n results = nil # result string\n if options[:eval] \n res = rec.eval(options[:eval],ignore_missing_data: ignore_missing,quiet: quiet)\n results = res if res\n end\n if seval\n list = (results ? [] : [rec.chr,rec.pos])\n rec.each_sample(options[:sfilter_samples]) { | sample |\n list << sample.eval(seval,ignore_missing_data: ignore_missing,quiet: quiet)\n }\n results = (results ? results.to_s + \"\\t\" : \"\" ) + list.join(\"\\t\")\n end\n rescue => e\n $stderr.print \"\\nLine: \",line\n $stderr.print \"ERROR evaluating --eval <#{options[:eval]}> #{e.message}\\n\"\n raise if options[:verbose]\n exit 1\n end\n return results.to_s+\"\\n\" if results\n else\n if options[:rdf]\n # Output Turtle RDF\n VcfRdf::record(options[:id],rec,options[:tags])\n elsif options[:template]\n # Use ERB template\n begin\n template.body(binding)\n rescue Exception => e\n $stderr.print e,\": \",fields,\"\\n\"\n $stderr.print e.backtrace.inspect if options[:verbose]\n raise \n end\n elsif options[:rewrite]\n # Default behaviour prints VCF line, but rewrite info\n eval(options[:rewrite]) \n (fields[0..6]+[rec.info.to_s]+fields[8..-1]).join(\"\\t\")+\"\\n\"\n elsif stats\n # do nothing\n else\n # Default behaviour prints VCF line\n fields.join(\"\\t\")+\"\\n\"\n end\n end\nend",
"def scanCsvEntry(row)\n entry = SavsLogEntry.new() ;\n entry.scanCsvRow(row, RequiredKeyList, @colIndex) ;\n \n # drop the entry if no demandId.\n if(entry.isValid()) ;\n @entryList.push(entry) ;\n else\n entry = nil ;\n end\n \n return entry ;\n end",
"def parse_csv(csv_name, schema)\n CSV.read(csv_name).map {|row| map_row_to_entity(row, schema) }\nend",
"def create_csv_for_LLR(csv_data)\n\n csv_string = CSV.open(\"#{$basefile}LLR.csv\", \"wb\") do |csv|\n\n csv << csv_data.first.keys\n csv_data.each do |hash|\n csv << hash.values\n end\n end\n end",
"def compute_csv_data\n row_count = 0\n csv_row_number = 0\n csv_data = []\n CSV.foreach(self.file.path, headers: true) do |row|\n # Transform row to hash\n row = row.to_hash\n # Normalize it\n row = normalize_row(row)\n # Increment row number\n csv_row_number += 1\n\n # PRECOMPUTE\n row = precompute_row(row, csv_row_number) # row[:csv_row_number] = csv_row_number AND initialize errors and array fields as arrays\n\n # store the valid_row result\n valid_row = valid_row?(row)\n\n # tranform raw row hash into a intermediate (more concise) information OR put in rejected data\n if valid_row\n csv_data << compute_row(row)\n else\n @rejected_user_data << row\n end\n if !self.limit.zero? && valid_row\n row_count += 1\n if row_count >= self.limit\n break\n end\n end\n end\n # Save original CSV data for post-processing report\n @original_csv_data = csv_data\n end",
"def transform_csv_file(csv_file)\n @logger.info(\"Transforming CSV file\")\n transformed = []\n headers = csv_file.shift\n headers.map!(&method(:prepare_custom_headers))\n\n csv_file.each do |row|\n transformed << Hash[headers.zip row]\n end\n prefix_sf_attribute_names transformed\n end",
"def write_to_csv(data_hash)\n\tprint(\"Please enter the name of the csv file to be written: \")\n\t#example: BRCA1_Data\n\tfile = gets.strip.to_s\n\tCSV.open(\"#{file}.csv\", 'wb') do |csv|\n\t\tfor key in data_hash\n\t\tcsv << [key[0], key[1]]\n\t\tend\n\tend\n\tputs \"done!\"\nend",
"def filter!( *headers, &block )\n return to_enum( :filter!, headers ) unless block_given?\n data.filter!( *headers, &block ); self\n end",
"def csvlatread (filename)\n File.readlines(filename).each do |line|\n if line && !empty?(line)\n f1, f2, code, lat, rest = line.split(\"\\t\")\n\n code = clean(code)\n lat = clean(lat).downcase\n\n yield code, lat\n end\n end\nend",
"def solr_metadata_not_in_csv(csv_metadata, solr_metadata)\n not_in_csv = solr_metadata.reject { |s| csv_metadata.any? { |c| c.casecmp(s.strip).zero? } }\n log(\"ERROR: Found solr metadata that wasn't in the CSV, appending to the end of the list during migration => #{not_in_csv.join('; ')}\") unless not_in_csv.empty?\n not_in_csv\n end",
"def preprocess_csv\n concatenate_arrays(replace_blanks(parsed_csv))\n end",
"def map_answers(csv_data, question:)\n print \"Answered #{question.to_s.gsub('_', ' ')}?\\n\"\n print csv_data.group_by{ |row| row[question]&.empty? }[false]&.map{|x| [x.slice(:first_name, :last_name).values.join(' '), x[question]].join(': ') }&.join(\"\\n\")\n print \"\\n\\n\"\n end",
"def map_user(csv_user)\n user = {}\n\n user['active'] = true\n user['username'] = csv_user['LOGIN']\n user['firstName'] = csv_user['FIRST_NAME']\n user['middleName'] = csv_user['MIDDLE_NAME']\n user['lastName'] = csv_user['LAST_NAME']\n user['email'] = csv_user['EMAIL']\n\n # Incoming format is '11-FEB-20 07.51.57.521000000 PM', convert to epoch milli\n user['insertInstant'] = Date.parse(csv_user['REGISTRATION_DATE']).strftime(\"%Q\")\n user['lastLoginInstant'] = Date.parse(csv_user['LASTACTIVITY_DATE']).strftime(\"%Q\")\n\n # Register the user to an application\n user['registrations'] = [{\n 'applicationId': $fusionauth_application_id,\n 'insertInstant': Date.parse(csv_user['REGISTRATION_DATE']).strftime(\"%Q\"),\n 'lastLoginInstant': Date.parse(csv_user['LASTACTIVITY_DATE']).strftime(\"%Q\"),\n # Add any roles you would like added to this user, adding 'user' as an example.\n 'roles': [\n 'user'\n ]\n }]\n\n # Import the password, with specified encryption scheme, factor and salt\n user['encryptionScheme'] = 'salted-pbkdf2-hmac-sha256'\n user['factor'] = 10_000\n user['salt'] = csv_user['PASSWORD_SALT']\n user['password'] = csv_user['PASSWORD']\n user['verified'] = true\n\n return user\nend"
] |
[
"0.6322489",
"0.6280653",
"0.6217684",
"0.60133225",
"0.59794575",
"0.58892584",
"0.5803522",
"0.5799369",
"0.57303035",
"0.56759834",
"0.56759834",
"0.56759834",
"0.5597768",
"0.5558027",
"0.55175036",
"0.5508664",
"0.5507356",
"0.5499295",
"0.5477099",
"0.5471953",
"0.54608864",
"0.54562825",
"0.54536533",
"0.5432449",
"0.5427268",
"0.5417982",
"0.54059446",
"0.5396324",
"0.5386344",
"0.5385401",
"0.5364273",
"0.5338172",
"0.5329694",
"0.53296137",
"0.5286551",
"0.527953",
"0.5258861",
"0.52520514",
"0.524662",
"0.5233115",
"0.52306014",
"0.5223733",
"0.5221822",
"0.5219608",
"0.5207629",
"0.5201636",
"0.52011025",
"0.517896",
"0.5178428",
"0.51738274",
"0.51662743",
"0.5165698",
"0.5165698",
"0.5152518",
"0.5146244",
"0.5127505",
"0.5118715",
"0.50958693",
"0.5083578",
"0.507866",
"0.5075935",
"0.5073384",
"0.50646937",
"0.50637203",
"0.50629735",
"0.5061625",
"0.5056194",
"0.5043617",
"0.5037416",
"0.50324833",
"0.5032457",
"0.50271755",
"0.5027113",
"0.5026939",
"0.50211424",
"0.50106055",
"0.50106055",
"0.50106055",
"0.5006969",
"0.49974614",
"0.49916002",
"0.4990548",
"0.49832946",
"0.49695683",
"0.49685812",
"0.4959474",
"0.49358904",
"0.49275956",
"0.49275804",
"0.4926101",
"0.49214524",
"0.4921333",
"0.49183637",
"0.49160153",
"0.4907945",
"0.49030536",
"0.49001074",
"0.4883907",
"0.48807648",
"0.48724383"
] |
0.6452923
|
0
|
== Instance Methods =====================================================
|
def perform(operation_id)
operation = BackOps::Operation.find(operation_id)
process(operation)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def private; end",
"def initialize\n\t\t\n\tend",
"def initialize\n \n end",
"def initialize\n\n end",
"def initialize\n\n end",
"def initialize\r\n\r\n end",
"def implementation; end",
"def implementation; end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n \n end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def initialize()\r\n\r\n end",
"def initialize() end",
"def initialize\n \n end",
"def initialize\n \n end",
"def initialize()\n\t\tend",
"def initialize\n\n\tend",
"def initialize\n\n\tend",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; 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 init\n\n end",
"def initialize\n end",
"def initialize\n\n\n\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n 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 instance; end",
"def instance; end",
"def instance; end",
"def initialize()\n\n end",
"def initialize\n super()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def probers; end",
"def initialize\n\t\nend",
"def schubert; end",
"def refutal()\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\n super \n end",
"def initialize\n # nothing here for now\n end",
"def initialize\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def custom; end",
"def custom; end",
"def internal; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def init\n end"
] |
[
"0.84469724",
"0.7322652",
"0.73202515",
"0.7296683",
"0.7296683",
"0.72934824",
"0.7273197",
"0.7273197",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.71615446",
"0.71429765",
"0.71429765",
"0.71429765",
"0.71429765",
"0.71429765",
"0.71429765",
"0.71429765",
"0.71429765",
"0.71429765",
"0.71429765",
"0.71429765",
"0.7136003",
"0.7136003",
"0.7136003",
"0.7136003",
"0.7122059",
"0.7066795",
"0.7020107",
"0.7020107",
"0.6985094",
"0.69778824",
"0.69778824",
"0.6940928",
"0.6940928",
"0.6940928",
"0.6940928",
"0.6885821",
"0.6885821",
"0.6885821",
"0.6885821",
"0.6885821",
"0.6885821",
"0.6885821",
"0.6885821",
"0.6885821",
"0.6883464",
"0.6881493",
"0.68795836",
"0.6848611",
"0.6848611",
"0.6848611",
"0.6848611",
"0.6848611",
"0.6848611",
"0.68452036",
"0.68452036",
"0.68452036",
"0.6844915",
"0.6844915",
"0.6844915",
"0.6821352",
"0.6821352",
"0.6821352",
"0.6818892",
"0.6788733",
"0.67880726",
"0.6786791",
"0.6786791",
"0.6781984",
"0.6779979",
"0.67766005",
"0.6766175",
"0.67468494",
"0.67468494",
"0.67468494",
"0.67468494",
"0.67468494",
"0.67468494",
"0.67468494",
"0.6717077",
"0.671579",
"0.67143637",
"0.6707673",
"0.6707673",
"0.6690906",
"0.6690906",
"0.6686044",
"0.66806966",
"0.66806966",
"0.66806966",
"0.66806966",
"0.66667587"
] |
0.0
|
-1
|
tracking table remaining hours
|
def remaining(g, a)
goal = g.to_f
actual = a.to_f
if goal == 0 && actual == 0
""
else
r = goal - actual
if goal > actual
"<div class=\"act sum\"><div class=\"num\">#{r}</div></div>".html_safe
elsif goal <= actual
"<div class=\"act sum over\"><div class=\"num\">#{r}</div></div>".html_safe
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def remaining_hours\n \n end",
"def remaining_hours_by_day\n values_by_day(0, true) { |x| model.remaining_hours_for_day_number(x) }\n end",
"def hours\n \n end",
"def spent_hours\n @spent_hours ||= time_entries.sum(:hours) || 0\n end",
"def hours\n _nudge[0]\n end",
"def total_timesheet\n if self.shifts.any?\n hours = self.shifts.sum(:time_worked)\n if hours > 40\n self.reg_hours = 40\n self.ot_hours = hours - 40\n ot_rate = job.pay_rate * 1.5\n self.gross_pay = job.pay_rate * self.reg_hours + self.ot_hours * ot_rate\n else\n pay = job.pay_rate * hours\n self.reg_hours = hours\n self.ot_hours = 0\n self.gross_pay = pay\n self.total_bill = pay * job.mark_up\n \n end\n end\n end",
"def schedule_impact\n if self.time_added?\n self.hours\n elsif time_removed?\n self.hours * -1.0\n else\n 0.0\n end\n end",
"def hours ; Duration[self * 3600] ; end",
"def hours\n self.to_i * 3_600\n end",
"def uninvoiced_hours\n @uninvoiced_hours ||= uninvoiced_timers.map(&:hours).sum\n end",
"def hours_planned\n hours_planned = 0\n project_tasks.each do |project_task|\n hours_planned += project_task.hours_planned\n end\n hours_planned\n end",
"def update_time_worked\n\n time_entries = self.time_card.time_entry\n total_hours = 0\n # Ordering by time so the total hours can be calculated.\n # An odd array will have [start_time1, end_time1, start_time2]\n # and the total_hours_worked = start_time1 - end_time1\n # An even array will have [start_time1, end_time1, start_time2, end_time 2]\n # and the total_hours_worked = (start_time1 - end_time1) + (start_time2 - end_time2)\n\n time_entries = time_entries.order(time: :asc)\n time_entries_count = time_entries.count\n\n i = 0\n while i < time_entries_count and i+1 < time_entries_count\n start_time = time_entries[i].time\n end_time = time_entries[i+1].time\n i = i+2\n total_hours = total_hours + time_diff(start_time, end_time).to_i\n end\n\n if time_entries_count == 1\n self.time_card.update_attribute(:total_hours_worked, 0)\n else\n self.time_card.update(:total_hours_worked => total_hours)\n end\n\n end",
"def hours\n\n today = Date.today\n hours = {}\n #if @traveler.is_visitor? or @traveler.is_api_guest? #Return a wide range of hours\n if not @traveler or not @traveler.registered?\n (0..30).each do |n|\n hours[(today + n).to_s] = {open: \"07:00\", close: \"22:00\"}\n end\n\n else # This is not a guest, check to see if the traveler is registered with a service\n\n # NOTE(wilsonj806) For now this implementation does not let registered users\n #...book trips on weekends. Eventually we want to change that so they can do so\n\n if @traveler.booking_profiles.count > 0 #This user is registered with a service\n booking_profile = @traveler.booking_profiles.first\n service = booking_profile.service\n\n min_notice_days = (service.booking_details[:min_days] || 2).to_i\n max_notice_days = (service.booking_details[:max_days] || 14).to_i\n\n \n if service.booking_details[:trusted_users] and booking_profile.external_user_id.in? service.booking_details.try(:[], :trusted_users).split(',').map{ |x| x.strip }\n (1..21).each do |n|\n hours[(today + n).to_s] = {open: \"00:00\", close: \"23:59\"}\n end\n elsif service.schedules.count > 0 #This user's service has listed hours. This is the most common case.\n \n #Find out if we are past the cutoff for today. If so, start counting from tomorrow\n if service.booking_details[:cutoff_time] and (Time.now.in_time_zone.seconds_since_midnight > service.booking_details[:cutoff_time].to_i)\n day = Time.now + 1.days \n else\n day = Time.now\n end\n \n biz_days_count = 0\n (0..max_notice_days).each do |n|\n if service.open_on_day? day\n if biz_days_count >= min_notice_days\n schedule = service.schedules.where(day: day.wday).first\n if schedule\n hours[day.strftime('%Y-%m-%d')] = {open: schedule.schedule_time_to_military_string(schedule.start_time), \n close: schedule.schedule_time_to_military_string(schedule.end_time)}\n end\n end\n biz_days_count += 1\n end\n day = day + 1.days \n end\n\n else #This user is registered with a service, but that service has not entered any hours\n\n (min_notice_days..max_notice_days).each do |n|\n unless (today + n).saturday? or (today + n).sunday?\n hours[(today + n).to_s] = {open: \"08:00\", close: \"17:00\"}\n end\n end\n\n end\n\n else #This user is logged in but isn't registered with a service\n\n (1..14).each do |n|\n unless (today + n).saturday? or (today + n).sunday?\n hours[(today + n).to_s] = {open: \"08:00\", close: \"17:00\"}\n end\n end\n\n end # if #traveler.user_profile.user_services.count > 0\n end # if @travler.is_visitor\n\n render status: 200, json: hours\n\n end",
"def sum_hours\n @hours.each do |row|\n @cycling[0] += row[0].to_f\n @entertainment[0] += row[1].to_f\n @programming[0] += row[2].to_f\n @reading[0] += row[3].to_f\n @yoga[0] += row[4].to_f\n end\n end",
"def hours ; self * 60.minutes ; end",
"def article_age_in_hours title\n $_time_ ||= Time.now.to_i\n fullrow = get_full_row title\n return 10000 unless fullrow\n age = fullrow[6].to_i\n hours = (($_time_ - age)/3600).to_i\n return hours\nend",
"def hours_left\n remaining = WorkingTime::Interval.new(self, close_of_business)\n return remaining.duration\n end",
"def hours; self * HOUR; end",
"def hours; self * HOUR; end",
"def hours\n self * SECONDS_IN_HOUR\n end",
"def remaining_time()\n return @total_time_units - @done_time_units\n end",
"def get_working_hours_total\n @total_hours = 0.0\n unless @saved_time_entries.empty?\n @total_hours = @saved_time_entries.map(&:actual_duration).inject(0) do |total,duration|\n actual_duration = @dur_setng_is_one100th ? one_hundredth_timediffernce(duration) : one_tenth_timediffernce(duration)\n total.to_f.roundf2(2) + actual_duration.to_f\n end\n @total_hours = @total_hours.to_f.roundf2(2)\n end\n @total_hours || 0.0\n end",
"def hours\n\t\treturn self * 60.minutes\n\tend",
"def hours\n\t\treturn self * 60.minutes\n\tend",
"def get_time_remaining\n\n end",
"def hours_from_tasks(user)\n\t\t#time_range = set_time\n\t\ttotal_hours=0\n\t\tif Date.today.day <= 15\n\t\t\t#return first half of month\n\t\t\tuser.tasks.where(complete: true, created_at: Time.now.beginning_of_month..Time.now).each do |t|\n\t\t\t\ttotal_hours += t.hours_to_complete\n\t\t\tend\n\t\telse\n\t\t\t#return second half of month\n\t\t\tuser.tasks.where(complete: true, created_at: Date.today..Time.now.end_of_month).each do |t|\n\t\t\t\ttotal_hours += t.hours_to_complete\n\t\t\tend\n\t\tend \n\t\treturn total_hours\n\tend",
"def total_hours(start,finish)\n total=0\n start.upto(finish) {|day|\n total+=@values[day].total\n }\n return total\n end",
"def hourly_totals(emoji)\n hour_zero = self.last_hour.where(emoji: emoji).pluck(:created_at).size\n hour_one = self.last_hour_plus_one.where(emoji: emoji).pluck(:created_at).size\n hour_two = self.last_hour_plus_two.where(emoji: emoji).pluck(:created_at).size\n hour_three = self.last_hour_plus_three.where(emoji: emoji).pluck(:created_at).size\n hour_four = self.last_hour_plus_four.where(emoji: emoji).pluck(:created_at).size\n some_days = [hour_zero, hour_one, hour_two, hour_three, hour_four]\n end",
"def total_hours\n ('%.02f' % ((ends_at - starts_at) / 1.hour)).to_f\n end",
"def hours(ctx)\n return ctx.shift_hours if earning_tests.none?\n\n earning_tests.map { |test| test.hours(ctx) }.min\n end",
"def hours() 60 * minutes end",
"def get_hours()\n\n return self.hours\n\nend",
"def hours(user_id)\n return self.user_events.find_by(user_id: user_id).hours || 0\n end",
"def total_spent_hours\n @total_spent_hours ||= TimeEntry.where(:meeting_id => id).sum(:hours).to_f\n end",
"def table_time\n @table_time * 1000\n end",
"def wl_remaining_table_allocation\r\n\t\t\t\tproject_alloc = self.wl_table_allocation\r\n\t\t\t\ttotal_alloc = self.wl_global_table_allocation\r\n\t\t\t\toutput = total_alloc#self.wl_global_table_allocation\r\n\r\n\t\t\t\tproject_alloc.each do |e|\r\n\t\t\t\t\tperiod = e[:start_date]..e[:end_date]\r\n\t\t\t\t\ttotal_alloc.each_with_index do |ta, i|\r\n\t\t\t\t\t\tta_period = ta[:start_date]..ta[:end_date]\r\n\t\t\t\t\t\tif period.overlaps?(ta_period)\r\n\t\t\t\t\t\t\ttotal = (ta[:percent_alloc] - e[:percent_alloc])\r\n\t\t\t\t\t\t\ttotal = 100 if total > 100\r\n\t\t\t\t\t\t\toutput[i][:percent_alloc] = 100 - total\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\r\n\t\t\t\treturn output\r\n\t\t\tend",
"def get_remaining_hours(logged_hours, estimated_hours, logged_ratio, remaining_ratio)\n if logged_ratio > 0\n remaining_hours = Integer(logged_hours.to_f/logged_ratio.to_f*remaining_ratio)\n else\n remaining_hours = Integer(estimated_hours.to_f*remaining_ratio/100)\n end\n remaining_hours += 1 if remaining_hours == 0\n remaining_hours\n end",
"def total(entries)\n seconds = entries.inject(0) { |sum, entry| sum + (entry[:end] - entry[:start]) }\n hours = seconds / 3600\nend",
"def hrs\n self / 24.0\n end",
"def time_remaining\n\n end",
"def hours\n fail \"A value is required for #{__method__}\" unless @value\n return \"0/#{@value}:0:0\"\n end",
"def base(table, column, where='1=1')\n count = DB[\"SELECT COUNT(*) FROM #{table} WHERE #{column} IS NULL AND (#{where})\"].first[:count]\n $times[[table, column]] << [Time.now, count]\n t = $times[[table, column]]\n\n vel = 0\n time_remaining = 0\n interval = [10, t.size].min\n if t.size >= 2\n t0 = t[-interval]\n t1 = t[-1]\n vel = ((t1[1] - t0[1]).to_f / (t1[0] - t0[0]).to_f).abs\n time_remaining = count / vel if (vel > 0)\n end\n\n puts \"#{count} #{table}.#{column}, vel = %.2f, remaining: #{Time.at(time_remaining).gmtime.strftime('%U dias %R:%S')}\" % [vel]\n\nTime.at(7683).gmtime.strftime('%R:%S')\n\n\n return count\nend",
"def hours_spent\n \thours_spent = 0\n \tinputs.each do |input|\n \t\thours_spent += input.hours\n \tend\n \thours_spent\n end",
"def spent_hours_for_issue\n return @spent_hours_for_issue if defined?(@spent_hours_for_issue)\n\n @spent_hours_for_issue = nil\n\n return @spent_hours_for_issue if issue_id.blank?\n\n @spent_hours_for_issue = TimeEntry.\n where(:issue_id => self.issue_id).\n sum(:hours)\n end",
"def estimated_hours\n return @estimated_hours if defined?(@estimated_hours)\n\n @estimated_hours = nil\n\n @estimated_hours = issue.estimated_hours if issue\n end",
"def update_card_totalhours\n if timecard.time_entries.count == 2\n # yup there is a pair of entries\n # grab the times of each entry and calculate the difference to add to the time card\n times = timecard.time_entries.pluck(:time)\n timecard.totalhours = ((times[1] - times[0]) / 3600).round(TOTAL_HOURS_SCALE)\n else\n # not a pair\n # make sure the total hours is nil\n timecard.totalhours = nil\n end\n timecard.save\n end",
"def total_time; end",
"def hour_out\n @hour_out ||= time_out.hour\n end",
"def labor_hours\n font \"Helvetica\"\n fill_color \"555555\"\n text \"Hours Log\", align: :center, size: 12, style: :bold\n fill_color \"000000\"\n table([\n [\"Worked By\", \"Date\", \"Clock in\", \"Clock out\", \"Labor time\", \"Down time\"],\n [\"\",\"\",\"\",\"\",\"\",\"\"],\n [\"\",\"\",\"\",\"\",\"\",\"\"],\n [\"\",\"\",\"\",\"\",\"\",\"\"],\n [\"\",\"\",\"\",\"\",\"\",\"\"]\n ], :header => true,\n :position => :center,\n :column_widths => [187, 79, 79, 79, 53, 53],\n :cell_style => {:font => \"Helvetica\", :size => 12, :height => 35, :align => :center}\n )\n end",
"def number_of_blackout_hours\n graph.plugin(:merit).order.blackout.number_of_hours\n end",
"def calc_hours_till\n (calc_mins_till / 60.00).round(2)\n end",
"def total_hours\n approved_flights.sum(:duration)\n end",
"def time_remaining\n end",
"def hours_spent\n hours_spent = 0\n project_tasks.each do |project_task|\n hours_spent += project_task.hours_spent\n end\n hours_spent\n end",
"def hours_sold_for\n @project.hours_sold_for\n end",
"def real_effort_now(date = Date.today)\n return 0 unless !real_hours.blank? && real_hours > 0\n self.task_progresses.where(\"working_day <= ?\", date).sum(:effort)\n end",
"def calc_raw_hours(job, task_name, effort)\n if $op_cyclo\n ## The cyclo can be used instead of cyclo, the relationship depends on the coding style, but\n ## a linear seems to hold\n hour = 6*job.cyclo()\n else\n hour = job.each_loc()\n end\n\n hour = hour/effort.to_f\n\n ## Adjust to each product/company coding style (flatness)\n hour = hour * $op_coding_style\n\n hour = 1.5 if hour < 1.5 # .5 hour work is the min for each file\n\n return hour\n end",
"def hours\n return \"There are #{self * (60 * 60)} seconds in #{self} hours\"\n end",
"def test_hour\n assert_nil tasks(:explain_search).hours\n assert_equal 8, tasks(:today_shift).hours\n end",
"def hours_logged(user)\n\t\ttime_range = set_time\n\t\ttotal_hours = 0\n\t\tuser.log_hours.where(updated_at: time_range).each do |t|\n\t\t\ttotal_hours = total_hours + t.hours\n\t\tend\n\n\t\treturn total_hours\n\tend",
"def daily_thievery\r\n\t\t@inventory += (@thieves)*3\r\n\tend",
"def timeRemaining(t1)\n\t\treturn subtract(t1,getCurrentTime)\n\tend",
"def fuel_hours\n (fuel_blocks / fuel_per_hour).floor\n end",
"def remaining_time\n t = date.to_time - Time.now\n \"%2d Tage %2d h %2d Min.\" % [t/86400, t/3600%24 , t/60%60]\nend",
"def total_hours_per_week\n exsisting_shift_hour = Schedule.where(start_time: Date.today-7..Date.today, employee_id: self.employee_id).sum('shift_hour')\n current_shift_hour = self.id.present? ? 0 : (self.end_time - self.start_time)/3600\n if (current_shift_hour + exsisting_shift_hour) > 40\n errors.add(:start_time, 'must be less than equal to 40 per week')\n end\n end",
"def working_hours_balance\n @working_hours_balance\n end",
"def get_expiry_hours(event)\n \n hours_left = (event.event_date - event.created_at) / 60 / 60\n \n if hours_left >= 36\n #return 24.hours\n return 8.hours\n elsif hours_left < 24\n return 5.hours\n end\n\n return 12.hours\n\nend",
"def index\n @time_clocks = current_user.time_clocks\n @time_clock = TimeClock.new\n @test_clock = current_user.time_clocks.last\n unless @test_clock && @test_clock.clock_out.nil?\n @time = TimeClock.new(clock_in: (DateTime.now - 5.hours), user_id: current_user.id, date: Date.today.to_s)\n @time.save!\n end\n @total_hours = 0\n @unpaid_hours = 0\n @time_clocks.each do |time|\n if time.clock_out.nil?\n else\n time.hours = time_diff(time.clock_in, time.clock_out)\n time.save!\n @total_hours += time.hours\n end\n end\n @time_clocks.where(billed: false).each do |time|\n if time.hours.nil?\n else\n @unpaid_hours += time.hours\n end\n end\n end",
"def validate_time_total(hash, date)\n if hash.values.map(&:to_i).inject(:+) > (MINUTES_PER_HOUR * HOURS_IN_DAY)\n session[:message] = \"You cannot exceed 24 hours in a day. Please try again.\"\n redirect \"/edit_activities/\" + date\n end\n hash\n end",
"def hours_available_for(user)\n milestone_resource = milestone_resources.where(resource_id: user).first\n self.duration.to_f * milestone_resource.try(:available_hours_per_day).to_f\n end",
"def hours( calculator )\n a = []\n a << terse_hours( calculator.total ) if ( @report.include_totals )\n a << terse_hours( calculator.committed ) if ( @report.include_committed )\n a << terse_hours( calculator.not_committed ) if ( @report.include_not_committed )\n return a\n end",
"def has_hours?\n return ( total() > 0.0 )\n end",
"def time_rows\n rows = []\n (0..NUM_HALF_HOURS-1).each do |half_hour|\n cols = []\n row = content_tag :tr do\n cols << hour_cell(half_hour)\n cols << minute_cell(half_hour)\n (0..(num_days-1)).each do |day|\n cols << event_cells(half_hour,day)\n end\n cols.join.html_safe\n end\n rows << row\n end\n rows.join.html_safe\n end",
"def hours\n response[\"hours\"]\n end",
"def table\n @max_cols = []\n @col_width = []\n @col_event = []\n (0..(num_days-1)).each do |day|\n @max_cols[day] = calc_max_cols(0, NUM_HALF_HOURS,day)\n if @max_cols[day] == 0\n @max_cols[day] = 1\n end\n @col_width[day] = (100.0/(num_days*@max_cols[day]) + 0.5).to_i\n @col_event << {}\n end\n @all_day_max = calc_all_day_max\n calc_event_rows\n content_tag :div do\n all_day_table + hour_table\n end\n end",
"def report_time_spent(entry)\n if Setting.plugin_redmine_spent_time_in_issue_description['time_format'].eql? 'human'\n humanized_time(entry.hours)\n else\n entry.hours\n end\n end",
"def hour() end",
"def registro_inicio(vaca,num_horas)\n estim_reg = Time.now.advance(:hours => -num_horas.to_i).localtime\n estimate_time = estim_reg.change(:min => 0)\n return estimate_time \n end",
"def hour_table\n content_tag :div, :class => \"day_div\" do\n content_tag :table, :class => \"day_table\" do\n header + time_body\n end\n end\n end",
"def store_changes_for_estimated_hours!(result, old_value, new_value)\n \t\tchange = hash_for_ticket_change(old_value, new_value)\n \t\tresult[N_('Estimated hours')] = change if change\n \tend",
"def spent_hours_for_user\n return @spent_hours_for_user if defined?(@spent_hours_for_user)\n\n @spent_hours_for_user = nil\n\n return @spent_hours_for_user if user_id.blank?\n\n @spent_hours_for_user = TimeEntry.\n where(:project_id => self.project_id).\n where(:user_id => self.user_id).sum(:hours)\n end",
"def remaining_days\n self.paid_through - Date.today\n end",
"def past_hour\n \t\tresponse = self.where({created_at: (Time.now.utc - 1.hour)..Time.now.utc})\n\n\t \t#Empty Attributes Array\n\t \tattrib = []\n\n\t\t#Find all the attributes of the Active Record resultset\n\t\tresponse.accessible_attributes.each do |value|\n\t\t\tif value!=\"\"\n\t\t\t\tattrib << value\n\t\t\tend\n\t\tend\n\n\t\t#Now add the average of all the values to the 0th element of resultset\n\t\tattrib.each do |value|\n\t\t response[0][value]=(response[0][value])/response.length\n\t\tend\n\t\tfor i in 1..response.length-1\n\t\t\tattrib.each do |value|\n\t\t response[0][value]+=(response[i][value])/response.length\n\t\t end\n\t\tend\n\n\t\tjson_response = response[0].as_json\n\t\tjson_response['AbandonRate']=json_response['AbandonRate'].round(1)\n\t json_response['LongestQueueDur']=format_agent_time(json_response['LongestQueueDur'])\n\t json_response['AverageWrapTime']=format_agent_time(json_response['AverageWrapTime'])\n\t json_response['AverageSpeedToAnswer']=format_agent_time(json_response['AverageSpeedToAnswer'])\n\t json_response['AverageTalkTime']=format_agent_time(json_response['AverageTalkTime'])\n\n\t #Return Value\n\t json_response\n \tend",
"def spent_hours_for_issue_and_user\n return @spent_hours_for_issue_and_user if defined?(@spent_hours_for_issue_and_user)\n\n @spent_hours_for_issue_and_user = nil\n\n return @spent_hours_for_issue_and_user if issue_id.blank? || user_id.blank?\n\n @spent_hours_for_issue_and_user = TimeEntry.\n where(:issue_id => self.issue_id).\n where(:user_id => self.user_id).\n sum(:hours)\n end",
"def calculate_time\n if @event.present? && @event.ends != nil\n event_time = @event.ends - @event.starts\n \n if event_time < 3600\n difference = ((event_time / 60) % 60)\n @event_difference = \"#{difference.round(0)} minutes\"\n else\n difference = event_time / (60 * 60)\n if difference == 1 \n @event_difference = \"#{difference.round(0)} hour\"\n else\n @event_difference = \"#{difference.round(1)} hours\"\n end\n end\n end\n end",
"def weekly_hours\n worked_hours\n end",
"def row_sum()\n return self.work_packets.sum( :worked_hours )\n end",
"def historical_values(end_time, history_length, unit = DEFAULT_UNIT)\n unit = :hour if (1.send(unit) / 1.hours) < 1\n finish_time = unit == :hour ? floor_hour(end_time) : end_time.midnight\n hours = 1.send(unit) / 1.hours\n (0..(history_length-1)).map{|i| finish_time - i.send(unit)}.reverse.map do |hour|\n find_stats_for(hour, hours)\n end\n end",
"def effective_num_hours\n actual_hours = sessions.map(&:hours).reduce(&:+)\n [actual_hours, time_constraint(:max_hours)].compact.min\n end",
"def remaining_count\n raw_history['results_remaining']\n end",
"def lead_time\n 0\n end",
"def groups_total_hours(records, from, to, rows)\n groups_total_hours = []\n # days difference between rows\n days = ((to - from) / rows).to_i + 1\n (0..rows-1).each do |i|\n i_from = to - (i+1) * days\n i_to = to - i * days\n # break if time period of current row is out of time area delimited by from and to \n break if from > i_to\n date = i_to - days / 2\n total_hours = records.where(\"date(records.created_at) > ? and date(records.created_at) <= ?\", i_from, i_to).sum(\"hours\")\n groups_total_hours << {date: date, total_hours: total_hours}\n end\n groups_total_hours \n end",
"def hours\n fail \"A value is required for #{__method__}\" unless @value\n fail 'A value cannot be > 24' if @value > 24\n fail 'A value cannot be <= 0' if @value <= 0\n return 'daily' if @value == 24\n\n \"0/#{@value}:0:0\"\n end",
"def spent_hours_for_issue_and_user_previous_month\n return @spent_hours_for_issue_and_user_previous_month if defined?(@spent_hours_for_issue_and_user_previous_month)\n\n @spent_hours_for_issue_and_user_previous_month = nil\n\n return @spent_hours_for_issue_and_user_previous_month if issue_id.blank? || user_id.blank?\n\n date_filter = Date.today.prev_month\n\n @spent_hours_for_issue_and_user_previous_month = TimeEntry.\n where(:issue_id => self.issue_id).\n where(:user_id => self.user_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month).\n sum(:hours)\n end",
"def report_total_hours(all_entries)\n printf \"TOTAL %.2f\\n\", total(all_entries.flatten)\nend",
"def entry_duration(entry)\n (entry.scheduled_datetime - entry.completed_datetime) / 1.hour\n end",
"def slot_time\n 0\n end",
"def index\n @current_user ||= User.find_by_remember_token(cookies[:remember_token])\n @hours = Hour.where(user_id: @current_user.id).where.not(group_id: nil).order('created_at DESC').includes(:group)\n @time = @hours.to_a.map { |x| x[:amount] }.sum\n end",
"def total_working_hours_balance\n @total_working_hours_balance\n end",
"def full_row_seconds\n @full_row_seconds ||= compute_total_seconds\n end",
"def working_hours\n return @working_hours\n end"
] |
[
"0.7676171",
"0.7173557",
"0.6600199",
"0.65166014",
"0.6462451",
"0.64035916",
"0.6358075",
"0.6335529",
"0.6332385",
"0.63228506",
"0.6300982",
"0.62360656",
"0.62245053",
"0.6215398",
"0.62150073",
"0.62085503",
"0.6174296",
"0.6172661",
"0.6171145",
"0.61647373",
"0.61322415",
"0.61111933",
"0.6103687",
"0.6103687",
"0.6097587",
"0.60970694",
"0.60849637",
"0.60750884",
"0.6065071",
"0.6063494",
"0.6047048",
"0.6038275",
"0.6027139",
"0.60267633",
"0.60258704",
"0.6016929",
"0.5972673",
"0.594239",
"0.5925868",
"0.5922954",
"0.588629",
"0.5878012",
"0.5877972",
"0.5873711",
"0.586001",
"0.5855029",
"0.5853464",
"0.58533597",
"0.5852901",
"0.5852111",
"0.5849927",
"0.5844467",
"0.5841356",
"0.5839682",
"0.58343846",
"0.58312",
"0.58300656",
"0.58031756",
"0.5800161",
"0.57935417",
"0.57902807",
"0.57768255",
"0.57697743",
"0.5768311",
"0.5755272",
"0.5746497",
"0.5737744",
"0.5737377",
"0.5723716",
"0.5723257",
"0.57214075",
"0.57137793",
"0.56980896",
"0.56979835",
"0.5694619",
"0.5693868",
"0.5692802",
"0.56874615",
"0.5685323",
"0.56710964",
"0.5658021",
"0.5651769",
"0.56482404",
"0.564528",
"0.5639717",
"0.56347483",
"0.56326896",
"0.56285816",
"0.56283283",
"0.5618544",
"0.56175596",
"0.5613401",
"0.561195",
"0.56053036",
"0.5605232",
"0.56022453",
"0.5601989",
"0.5601361",
"0.56007034",
"0.5600527",
"0.5598153"
] |
0.0
|
-1
|
tracking table remaining currency
|
def remaining_currency(g, a)
goal = g.to_f
actual = a.to_f
if goal == 0 && actual == 0
""
else
r = goal - actual
number_to_currency(r, :precision => 0)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def currency; end",
"def currency; end",
"def dollar_total\n total / 100.0\n end",
"def charge\n subtotal * 0\n end",
"def remaining_total\n total\n end",
"def memo(_row)\n 'EUR'\n end",
"def amount; end",
"def currency\n nil\n end",
"def currency\n nil\n end",
"def total_debt\n self.amount\n end",
"def total\n currency(@total)\n puts @total\n end",
"def available_balance(cur)\n 1000\n end",
"def full_price_total(count)\n count * unit_price\n end",
"def total\n price - original_value\n end",
"def total\n price - original_value\n end",
"def total\n total = with_product_discounts\n total = with_basket_discounts(total)\n return \"£#{total}\"\n end",
"def acc_balance\n @page.css(\"span[data-semantic = 'header-available-balance-amount']\").text.to_money.to_f\n end",
"def collection_currency\n card_prices = []\n current_user.cards.each do |card|\n price = remove_dot(card.usd_price)\n card_prices << Money.new(price) * card.quantity \n end\n # call `format`\n card_prices.inject(:+) \n end",
"def get_cout_total\n return (self.prix)\n end",
"def unpaid_amount\n gross_amount - paid_amount\n end",
"def non_pending_balance_display\n number_to_currency(non_pending_balance)\n end",
"def current_subtotal\n debt_claim_items.reject(&:marked_for_destruction?).sum(&:current_debt)\n end",
"def money; end",
"def amount\n available_amount - blocked_amount\n end",
"def mark_up_amt\n rounder5(self.vehicle.price * 0.082)\n end",
"def total\n conv_price_single * conv_quantity\n end",
"def amount\n difference\n end",
"def total_value_cents\n total_benefits_value\n end",
"def amount\n price\n end",
"def get_cout_total\n if (self.comptable_null?)\n return (0)\n elsif (self.comptable_diff?)\n return (self.cout - self.sum_charges)\n elsif (self.comptable_total?)\n return (self.cout)\n end\n end",
"def total_value_usd\n @quantity * price_in_usd\n end",
"def balance_owed\n discounted_price - amount_paid\n end",
"def univ_fee_amount_to_charge()\n raise \"not a university\" if ! university\n payments.select(&:good?).empty? ? payments.first.amount : university.subscription_charge_for_n(univ_dvd_rate)\n end",
"def without_vat_original_currency()\n return invoice_goods_ammout.to_f + shipping.to_f\n end",
"def nouveau_prix\n nouveau_prix = 0\n if(!bouteille.nil?)\n nouveau_prix = bouteille.prix\n nouveau_prix = nouveau_prix * (1 - (rabais/100)) if rabais?\n end\n ActionController::Base.helpers.number_to_currency(nouveau_prix, unit: \"\", separator: \".\", delimiter: \"\", format: \"%n\")\n end",
"def void_last_transaction\n @total -= @prices #subtract prices from the total price\n end",
"def cf\n\t\tself.buy ? (-self.amount-self.fee) : (self.amount - self.fee)\n\tend",
"def investment\n if buy_price\n num_of_shares * buy_price\n end\n end",
"def amount_owed\n total_price - amount_paid\n end",
"def calc\n\n # get the amount (hrs or days)\n if self.rateType == 'Hour'\n\n std = self.hours.nil? ? 0 : TimeUtil.hours_to_numeric(self.hours)\n\n else\n\n std = dayValue.nil? ? 0 : dayValue\n \n end\n\n amt = 0\n \n amt = std * self.chargeRate unless self.chargeRate.nil? || self.chargeRate == 0\n self.netAmount = amt\n\n return amt\n \n end",
"def currency\n money.currency\n end",
"def total_price\n total = 0\n self.transactions.each do |t|\n total += t.price\n end\n total\n end",
"def effective_total\n total = effective_total_money\n \"#{total.currency} #{total.format}\"\n end",
"def balance\n self.all_benefits - self.all_pays\n end",
"def amount_charged\n\t\t@amount = 6000\n\tend",
"def amount_remaining\n @desired_amount - @bought_amount\n end",
"def calculate_total_in_cents\n total = 0\n self.subscriptions.each do |s|\n if s.duration.to_i == 30\n total += PriceConfig.pricing(30) * 100\n elsif s.duration.to_i == 60\n total += PriceConfig.pricing(60) * 100\n else\n total += PriceConfig.pricing(90) * 100\n end\n end\n total\n end",
"def money\n end",
"def total_debt\n Money.new(all_debts.sum { |_, debt| debt }, 'PLN')\n end",
"def change_for(amount)\n currency = $keys[$i]\n count = amount / $currencies[currency]\n remaing_amount = amount - (count * $currencies[currency])\n $output[currency] = count\n $i += 1\n change_for(remaing_amount) if remaing_amount > 0 \n\n $output.delete_if {|k,v| v == 0 } \nend",
"def total_amount\n self.tickets.inject(0) do |amount, ticket|\n amount += ticket.price_minus_discount\n end\n end",
"def net_expenditures\n return super - total_revenue\n end",
"def value\r\r\n @currency[:amount]\r\r\n end",
"def update_amount\n self.amount = purchase_entries\n .find_all(&:price?)\n .sum { |journal_entry| journal_entry.price * journal_entry.quantity }\n \n self.vat_amount = purchase_entries\n .find_all(&:vat_amount?)\n .sum { |journal_entry| journal_entry.vat_amount * journal_entry.quantity }\n end",
"def acc_currency\n @page.css(\"span[data-semantic = 'header-available-balance-amount']\").text.to_money.currency.to_s\n end",
"def currency_exchanges\n self.invoice.currency_exchanges\n end",
"def store_credit_maximum_amount\n item_total - 0.01\n end",
"def promo_total\n 0.0\n end",
"def us_dollar(cents); end",
"def total_price_te\n if object.open?\n I18n.t('admin.invoices.index.total_price_ati_will_be_computed')\n else\n formatted_price(object.computed_total_price_te)\n end\n end",
"def total_quantity\n cached_qty_bank.to_f + cached_qty_consigned.to_f\n end",
"def damt_paid\n\tamt_paid/100.0 rescue 0.0 \nend",
"def cumulative_total_after_tax\n amount = 0.0\n @products_in_cart.each do |product|\n amount += product.total\n end#each\n return amount\nend",
"def amount_owed\n invoice_total - total_amount_paid\n end",
"def cents; end",
"def get_btc_profit\n quantity - close_positions.sum(:quantity)\n end",
"def remaining_funds()\n films = self.find_films_for_each_customer()\n film_fees = films.map{|film| film.price}\n combined_fees = film_fees.sum\n return @funds - combined_fees\n end",
"def price_adjustment \n price_adjustment_fixed / 100.0 \n end",
"def calculate\n=begin\n self.net_amount = nil\n self.tax_amount = nil\n self.gross_amount = nil\n=end\n self.total\n end",
"def membership_fixed_total\n applied_subscriptions.select {|h| h[:type] == :fixed}.map {|h| h[:amount] }.flatten.reduce(:+).to_i || 0\n end",
"def get_currency_used(item)\r\r\n @currency.nil? ? item_currency(item) : @currency\r\r\n end",
"def pending_balance_display\n number_to_currency(pending_balance)\n end",
"def unadjusted_total\n total = Money.new( 0, 'USD' )\n \n for line_item in line_items\n total += ( line_item.price * line_item.quantity )\n end\n \n total\n end",
"def ot_voucher_amount\n end",
"def balance\n res = dollars\n\n fund_transactions.each do |tran|\n res += tran.dollars\n end\n\n return res\n end",
"def unpaid_amount\n draft ? nil : gross_amount - paid_amount\n end",
"def percent_val\n dollar_amt ? ((dollar_amt / Contract.sum(:dollar_amt)) * 100) : nil\n end",
"def total_value\n @quantity * @price_per_share\n end",
"def price\n total\n end",
"def fixed_price\n data.fixed_price\n end",
"def current_balance_display\n number_to_currency(current_balance)\n end",
"def available_currency\n # GROUP THE ORDER BY THE CURRENCY, AND TOTAL THE AMOUNT FOR THAT CURRENCY\n grouped_orders = orders.group_by(&:converted_currency)\n grouped_orders.map{|c| {c[0].denomination => c[1].map(&:purchase_amount).reduce(:+)}}\n end",
"def available_balance\n self.limit - self.sum_of_charges\n end",
"def currency_unit\n @currency_unit\n end",
"def get_total_expense\n\t\tbills.pluck(:amount).inject(:+) rescue 0\n\tend",
"def billing_record_total_amount(rows)\n rows.any? { |row| row.respond_to?(:billing_record_row) } ? number_to_currency(@entry.billing_record.try(&:total_amount)) : ''\n end",
"def balance\n credit = FineBalance.sum('AMOUNT', :conditions=>{:INCURRED_ID=>self.CHARGE_INCURRED_ID})\n return self.AMOUNT-credit\n end",
"def price_in_usd\n case @currency\n when :inr\n @price_per_share.to_i * 50\n when :gbp\n @price_per_share.to_i * 2\n else\n @price_per_share.to_i\n end\n end",
"def apply_clearance(cart)\n cart.each do |product_name, stats|\n stats[:price]-= stats[:price] * 0.2 if stats[:clearance]\n end\ncart\nend",
"def total\n Money.new(self.expense_entries.sum('unit_cost_pence * qty'))\n end",
"def host_fee\n (total - net_rate).round(2)\n end",
"def conv_exchange_rate\n currency_exchange.exchange_rate\n end",
"def cumulative_total_before_tax\n amount = 0.0\n @products_in_cart.each do |product|\n amount += product.price\n end#each\n return amount\nend",
"def damt_subm\n\tamt_subm/100.0 rescue 0.0 \nend",
"def current_price; self['CurrentPrice'].to_i; end",
"def final_price\n return if @result.result[:final_price].blank?\n (@result.result[:final_price]&.delete('^0-9').to_i/100) - savings\n end",
"def final_amount\n amount_paid - discount_value - discount_percent\n end",
"def profit\n \tself.bid - self.payout\n end",
"def total_base_price\n tickets.map(&:base_price).sum\n end",
"def current_amount\n items.reduce(0) do |sum, item|\n sum + item.current_amount * item.price\n end\n end"
] |
[
"0.68829226",
"0.68829226",
"0.6693771",
"0.6661102",
"0.6640936",
"0.66256446",
"0.6599034",
"0.6470488",
"0.6470488",
"0.6465763",
"0.64164734",
"0.6405326",
"0.6361261",
"0.63534707",
"0.63534707",
"0.6337433",
"0.63216555",
"0.631954",
"0.62777054",
"0.62714416",
"0.6224347",
"0.62189704",
"0.6217363",
"0.6208521",
"0.62017137",
"0.61992735",
"0.6196381",
"0.618221",
"0.61779094",
"0.61774236",
"0.6176016",
"0.6167301",
"0.6161303",
"0.6160042",
"0.6145896",
"0.6142676",
"0.6141254",
"0.61361504",
"0.61267126",
"0.6124667",
"0.611931",
"0.61159784",
"0.6110323",
"0.610465",
"0.6094667",
"0.609352",
"0.60912526",
"0.6072129",
"0.6070208",
"0.6063985",
"0.60636127",
"0.6057622",
"0.6055209",
"0.60531086",
"0.60456425",
"0.6045538",
"0.60453933",
"0.6041689",
"0.60386777",
"0.6037405",
"0.6037183",
"0.60326535",
"0.6031563",
"0.60314786",
"0.60311836",
"0.60296047",
"0.6029193",
"0.60274565",
"0.6025503",
"0.60241115",
"0.6022376",
"0.60155916",
"0.6012176",
"0.6008285",
"0.60052115",
"0.60001045",
"0.59996563",
"0.59980196",
"0.59957397",
"0.59940386",
"0.5992437",
"0.59866387",
"0.5986143",
"0.5985841",
"0.5985071",
"0.5982984",
"0.5980475",
"0.59770626",
"0.5967759",
"0.5966257",
"0.59618944",
"0.5960218",
"0.5959136",
"0.5957925",
"0.5957219",
"0.59508365",
"0.5946771",
"0.5946633",
"0.5946051",
"0.59454304"
] |
0.627164
|
19
|
Override ResourceController collection method
|
def collection
feature_id = nil
if params[:feature_id]
feature_id = params[:feature_id]
elsif params[:id]
feature_id = object.feature_id
end
if params[:filter].blank? && !feature_id.blank?
search_results = parent_object.definitions
elsif !params[:filter].blank?
search_results = Definition.search(params[:filter])
search_results = search_results.where(:feature_id => feature_id) if feature_id
else
search_results = []
end
@collection = search_results.empty? ? search_results : search_results.page(params[:page])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def decorated_collection\n @collection.map do |element|\n Resource.new(element, @controller)\n end\n end",
"def collection\n resource_class.all\n end",
"def make_collection\n @resource.make_collection\n end",
"def resource_collection\n @resource_collection ||= @run_context.resource_collection\n end",
"def base_collection\n @base_collection ||= resource_model.all\n end",
"def index\n build_resource({})\n respond_with self.resource\n end",
"def controller_resource\n Iteration\n end",
"def collection_url\n super_url(with_chain(resource_class))\n end",
"def index\n respond_with Collection.all\n end",
"def index\n respond_with Collection.all\n end",
"def resource_list\n self.resources\n end",
"def resources\n @pruned_resources || super\n end",
"def resource_collection\n run_context && run_context.resource_collection\n end",
"def new_resource\n base_collection.new\n end",
"def resource_type\n :collection if collection?\n end",
"def resource_type\n :collection if collection?\n end",
"def index\n authorize! :index, current_model_class\n yield if block_given? # after_index\n respond_with collection\n end",
"def resources()\n end",
"def collection; end",
"def collection; end",
"def resources; end",
"def resources; end",
"def index\n respond_with(@collection) do |format|\n format.json { render :json => @collection.to_json(collection_serialization_options) }\n end\n end",
"def resources\n self.collection.find({}, :sort => [:_id, :asc]).map do |hash|\n self.normalize hash\n end\n end",
"def collection_action(action)\n define_method(action) do\n if params[:ids].present?\n self.resources ||= resource_scope.where(id: params[:ids])\n end\n\n if effective_resource.scope?(action)\n self.resources ||= resource_scope.public_send(action)\n end\n\n self.resources ||= resource_scope.all\n\n EffectiveResources.authorize!(self, action, resource_klass)\n\n @page_title ||= \"#{action.to_s.titleize} #{resource_plural_name.titleize}\"\n\n collection_post_action(action) unless request.get?\n end\n end",
"def resources\n end",
"def index\n @resources = Resource.all\n end",
"def index\n @resources = Resource.all\n end",
"def index\n @resources = Resource.all\n end",
"def resource_collection\n client.run_status.run_context.resource_collection\n end",
"def collection_url\n send route_prefix_to_method_name(\"#{class_name.model_name.route_key}_url\")\n end",
"def collections_path; end",
"def collection_path\n send route_prefix_to_method_name(\"#{class_name.model_name.route_key}_path\")\n end",
"def collection(&block)\n unless resource_scope?\n raise ArgumentError, \"can't use collection outside resource(s) scope\"\n end\n\n with_scope_level(:collection) do\n path_scope(parent_resource.collection_scope, &block)\n end\n end",
"def method_for_association_chain #:nodoc:\n resource_collection_name\n end",
"def index\n @collections = Collection.all\n respond_with(@collections)\n end",
"def collect\n raise Errors::ActionMethodNotImplemented.new 'Collect actions must overwrite the collect method.'\n end",
"def render_collection( resources, presenter: nil, pagination: :auto, **context, &block )\n render json: json_collection( resources, presenter, pagination: pagination, **context, &block )\n end",
"def resource\n\n end",
"def collection\n self.class.collection\n end",
"def collection\n self.class.collection\n end",
"def collection\n klass.collection\n end",
"def resources\n @resources\n end",
"def index\n @resources = Resource.all\n end",
"def collection_representer_klass\n resource_module::Representer::Collection\n end",
"def index\n @resources = resource_class.send(:all)\n render json: @resources\n end",
"def set_resource_actions\n self.actions[:index] = Action.new(self.entity, :index, :collection, :resource => true)\n self.actions[:new] = Action.new(self.entity, :new, :collection, :resource => true)\n self.actions[:edit] = Action.new(self.entity, :edit, :member, :resource => true)\n self.actions[:show] = Action.new(self.entity, :show, :member, :resource => true)\n self.actions[:create] = Action.new(self.entity, :create, :collection, :method => :post, :resource => true)\n self.actions[:update] = Action.new(self.entity, :update, :member, :method => :put, :resource => true)\n self.actions[:delete] = Action.new(self.entity, :delete, :member, :method => :delete, :resource => true)\n end",
"def create\r\n super do |format|\r\n redirect_to collection_url and return if resource.valid?\r\n end\r\n end",
"def create\r\n super do |format|\r\n redirect_to collection_url and return if resource.valid?\r\n end\r\n end",
"def create\r\n super do |format|\r\n redirect_to collection_url and return if resource.valid?\r\n end\r\n end",
"def create\r\n super do |format|\r\n redirect_to collection_url and return if resource.valid?\r\n end\r\n end",
"def load_collection\n current_ability.scope_for(authorization_action, resource_class) do\n resource_base.accessible_by(current_ability, authorization_action)\n end\n end",
"def collection\n klass.collection\n end",
"def index\n @resources_customs = ResourcesCustom.all\n end",
"def has_many(resource_name, options = {}, block = nil)\n meta_def resource_name do |*params|\n path = (path_with_slash + (options[:path] || resource_name.to_s))\n filter = params.first || {}\n collection = @client.resource(:path => path, :parent => self, :block => block, :filter => filter, :extend => options[:extend])\n collection.extend(CollectionMethods) # unless?\n collection.extend(options[:extend]::CollectionMethods) if options[:extend] # unless?\n collection\n end\n end",
"def subresources\n if any?\n { collection_rel => self }\n else\n {}\n end\n end",
"def create\n super do |format|\n redirect_to collection_url and return if resource.valid?\n end\n end",
"def create\n super do |format|\n redirect_to collection_url and return if resource.valid?\n end\n end",
"def create\n super do |format|\n redirect_to collection_url and return if resource.valid?\n end\n end",
"def set_collection_instance\n instance_variable_set(:\"@#{model_type.to_s.gsub('/', '__').pluralize}\", @resources)\n end",
"def set_collection_instance\n instance_variable_set(:\"@#{model_type.to_s.gsub('/', '__').pluralize}\", @resources)\n end",
"def initialize_resources_class_accessors! #:nodoc:\n\n\n # First priority is the namespaced model, e.g. User::Group\n self.resource_class ||= begin\n namespaced_class = self.name.sub(/Controller/, '').singularize\n namespaced_class.constantize\n rescue NameError\n nil\n end\n\n\n\n # Second priority is the top namespace model, e.g. EngineName::Article for EngineName::Admin::ArticlesController\n self.resource_class ||= begin\n namespaced_classes = self.name.sub(/Controller/, '').split('::')\n namespaced_class = [namespaced_classes.first, namespaced_classes.last].join('::').singularize\n namespaced_class.constantize\n rescue NameError\n nil\n end\n\n\n\n # Third priority the camelcased c, i.e. UserGroup\n self.resource_class ||= begin\n camelcased_class = self.name.sub(/Controller/, '').gsub('::', '').singularize\n camelcased_class.constantize\n rescue NameError\n nil\n end\n\n\n\n # Otherwise use the Group class, or fail\n self.resource_class ||= begin\n class_name = self.controller_name.classify\n class_name.constantize\n rescue NameError => e\n raise unless e.message.include?(class_name)\n nil\n end\n\n\n\n self.resource_instance_name = self.controller_name.singularize.to_sym #test_name\n\n self.collection_name = self.controller_name.to_sym\n\n\n\t\tself.resource_name = resource_class.to_s\n\n end",
"def resources\n return @resources\n end",
"def resources\n return @resources\n end",
"def resources\n return @resources\n end",
"def collection\n action_name == 'show' ? @presenter : @collection\n end",
"def resource; end",
"def singular_resource\n super.decorate\n end",
"def collection_name\n :\"@#{controller_name}\"\n end",
"def present_collection(collection = resource); nil; end",
"def add_to_list_resource\n manage_list_resource(:add)\n end",
"def index\n @custom_collections = CustomCollection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @custom_collections }\n end\n end",
"def current_collection() instance_variable_get(\"@#{resource_plural}\") end",
"def show\n @custom_collection = get_collection\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @custom_collection }\n end\n end",
"def resource\n self\n end",
"def index\n new_i18n_key\n respond_with(collection)\n end",
"def restful(model: nil, route_prefix: nil, actions: :all)\n class_attribute :model_name, :class_name, :route_prefix,\n instance_writer: false\n\n self.model_name = model\n self.class_name = class_from_name\n self.route_prefix = route_prefix\n\n include InstanceMethods\n include Restful::Actions\n\n setup_actions actions unless actions == :all\n\n if respond_to?(:helper_method)\n helper_method :collection, :resource, :resource_class,\n :edit_resource_path, :edit_resource_url, :new_resource_path,\n :new_resource_url, :collection_path, :collection_url\n\n end\n end",
"def collections; end",
"def resource_scope\n resource_class.all\n end",
"def index\n @collections = Collection.all\n end",
"def index\n @collections = Collection.all\n end",
"def collection_uri\n super + uuid + '/'\n end",
"def authorize_collection! action, collection\n collection.map do |model|\n authorize! action, model\n end\n end",
"def index\n render jsonapi: authorized_collection, each_serializer: Connection::Serializer\n end",
"def collection(http_verb, action = nil, body = nil, options)\n actual_client(options).send(http_verb, path(action), body, options)\n end",
"def inherited(resource)\r\n resource.class_eval do\r\n self.versions ||= {}\r\n self.helper_object = Object.new\r\n\r\n begin\r\n plural = name.demodulize.tableize\r\n self.path = lambda { |format|\r\n begin\r\n new.polymorphic_path [:resources, plural], :format => format\r\n rescue => e\r\n nil\r\n end\r\n }\r\n self.query_template = DEFAULT_COLLECTION_QUERY_TEMPLATE.dup\r\n self.model = name.sub(/^Restful\\b/, '').constantize\r\n finder :find, :all, :first, :last\r\n helper ApplicationHelper\r\n rescue ArgumentError, NameError => e\r\n nil\r\n end\r\n\r\n Restful::Resource.classes << self\r\n end\r\n end",
"def collection_action(name, method, request_type)\n self.actions[name.to_sym] = Action.new(self.entity, name.to_sym, :collection, :method => method, :request_type => request_type)\n end",
"def enclosing_collection_resources\n @enclosing_collection_resources ||= []\n end",
"def show\n authorize! :show, params[:id]\n @collection = Collection.find(params[:id])\n respond_with(@collection)\n end",
"def index\n respond_with(@collection) do |format|\n format.html\n format.json { render :json => json_data }\n end\n end",
"def collection_scope; end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end"
] |
[
"0.75454414",
"0.75432986",
"0.7115129",
"0.68111414",
"0.6715225",
"0.6696003",
"0.66899097",
"0.6684242",
"0.66061133",
"0.66061133",
"0.6576192",
"0.6530712",
"0.65107936",
"0.65043175",
"0.6489149",
"0.6489149",
"0.64478284",
"0.643337",
"0.64229524",
"0.64229524",
"0.6407082",
"0.6407082",
"0.63823676",
"0.6374151",
"0.6359146",
"0.62685627",
"0.62652147",
"0.62652147",
"0.62652147",
"0.624685",
"0.6240009",
"0.6209122",
"0.6182468",
"0.61801416",
"0.6170415",
"0.61650574",
"0.6161965",
"0.61567223",
"0.61357486",
"0.61333185",
"0.61333185",
"0.6129694",
"0.61271363",
"0.61271256",
"0.6123301",
"0.6104474",
"0.6086582",
"0.60777354",
"0.60777354",
"0.60777354",
"0.60777354",
"0.60716426",
"0.6062388",
"0.6056083",
"0.5994464",
"0.59894884",
"0.59856874",
"0.59856874",
"0.59856874",
"0.59665555",
"0.59665555",
"0.59638387",
"0.59600407",
"0.59600407",
"0.59600407",
"0.5955113",
"0.59421504",
"0.5940569",
"0.5928604",
"0.5923087",
"0.59175754",
"0.5907301",
"0.5906818",
"0.59010094",
"0.5899434",
"0.58971596",
"0.5896699",
"0.5890797",
"0.5882814",
"0.587711",
"0.587711",
"0.5875769",
"0.58702457",
"0.5866666",
"0.58455086",
"0.5843031",
"0.58425206",
"0.5839309",
"0.5832246",
"0.5826932",
"0.5818386",
"0.58146465",
"0.58146465",
"0.58146465",
"0.58146465",
"0.58146465",
"0.58146465",
"0.58146465",
"0.58146465",
"0.58146465",
"0.58146465"
] |
0.0
|
-1
|
Only allow a trusted parameter "white list" through.
|
def definition_params
params.require(:definition).permit(:feature_id, :is_public, :is_primary, :ancestor_ids, :position, :content, :author_id, :language_id, :numerology, :tense)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"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 filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n 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 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 [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\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 filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params\n true\n end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; 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 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 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 paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def user_params\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def user_params\r\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"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 params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"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 get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\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 filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\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 argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\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 sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def parameters\n nil\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end",
"def special_device_list_params\n params.require(:special_device_list).permit(:name)\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 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"
] |
[
"0.71230334",
"0.70530915",
"0.69479465",
"0.6902122",
"0.67367256",
"0.67172784",
"0.6689043",
"0.66784793",
"0.6660117",
"0.6555213",
"0.6528485",
"0.6458438",
"0.6452378",
"0.6451654",
"0.64478326",
"0.6433326",
"0.6413599",
"0.6413599",
"0.63907677",
"0.63787645",
"0.63787645",
"0.6375229",
"0.63608277",
"0.635366",
"0.6283652",
"0.62798274",
"0.6245606",
"0.62283605",
"0.6224614",
"0.6223649",
"0.62118477",
"0.6207179",
"0.61780804",
"0.6173056",
"0.61674094",
"0.615996",
"0.6145132",
"0.613597",
"0.612235",
"0.6108622",
"0.6098955",
"0.60767287",
"0.6055062",
"0.60391796",
"0.60363555",
"0.6030472",
"0.6018476",
"0.60174584",
"0.60163116",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60159874",
"0.60052663",
"0.6003681",
"0.6001089",
"0.5996807",
"0.5994288",
"0.59942675",
"0.5984987",
"0.59827954",
"0.59777087",
"0.5975369",
"0.59706473",
"0.5966046",
"0.5965166",
"0.5965166",
"0.59577847",
"0.5952617",
"0.59503365",
"0.59480196",
"0.5943258",
"0.5931462",
"0.59299",
"0.5927073",
"0.5924737",
"0.5919184",
"0.5918459",
"0.591457",
"0.59142643",
"0.59062785",
"0.59054136",
"0.59047925",
"0.5902357",
"0.5900476",
"0.5898475",
"0.5898218",
"0.5895328"
] |
0.0
|
-1
|
for each hypothetical day. It should return a pair of days representing the best day to buy and the best day to sell. Days start at 0. You need to buy before you can sell Pay attention to edge cases like when the lowest day is the last day or the highest day is the first day.
|
def stock_picker(prices)
acc_profit = 0
acc_buy_date = 0
acc_sell_date = 0
profits = prices.map.with_index do |price, index|
remaining_days = prices[index..-1] # to create an array that becomes smaller each iteration from index 0
maximum = remaining_days.max # to identify the maximum number in that iteration's array
highest_value = maximum - price # price is at index 0, so maximum minus minimum for each one will help identify the best buy/sell dates
# create accumilator for index and value of highest profit
if highest_value > acc_profit
acc_profit = highest_value
acc_buy_date = prices.index(price)
acc_sell_date = prices.index(maximum)
end
end
p "Buy on day #{acc_buy_date} and sell on day #{acc_sell_date} for a profit of $#{acc_profit}."
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pick_best_day(optimized, days)\n\tbuy_day = 0\n\tsell_day = 0\n\tprofit = 0\n\tdays.each do |day|\n\t\tdaily_profit = days[optimized[days.index day]] - day\n\t\tif daily_profit > profit\n\t\t\tprofit = daily_profit\n\t\t\tbuy_day = days.index day\n\t\t\tsell_day = optimized[days.index day]\n\t\tend\n\tend\n\t[buy_day, sell_day]\nend",
"def stock_picker(prices) \n min_price = Float::INFINITY\n day_min_cost = 0\n max_price = -Float::INFINITY\n profit = -Float::INFINITY\n best_days = []\n\n prices.each_with_index do |price, day|\n if price < min_price \n min_price = price\n day_min_cost = day\n end\n \n if price - min_price > profit && day > day_min_cost\n max_price = price\n profit = price - min_price\n best_days = [day_min_cost, day]\n end\n end\n\n if best_days.empty?\n # In the case that the prices are decreasing order and there are no duplicates, the best days \n # to buy is the second to last day and the best day to sell is the last day\n best_days = [prices.length - 2, prices.length - 1]\n else\n best_days\n end\nend",
"def stock_picker daily_prices_array\n best_buy_day = 0\n best_sell_day = 0\n best_profit = 0\n for buy_day in 0...daily_prices_array.length\n for sell_day in buy_day...daily_prices_array.length\n if daily_prices_array[sell_day] - daily_prices_array[buy_day] > best_profit\n best_profit = daily_prices_array[sell_day] - daily_prices_array[buy_day]\n best_sell_day = sell_day\n best_buy_day = buy_day\n end\n end\n end\n [best_buy_day, best_sell_day]\nend",
"def stock_picker(array)\n best_buy = 0\n best_sell = 0\n max_profit = 0\n\n #first iterate through the array to find a buy day\n (0..(array.length-2)).each do |buy_date|\n\n #for each possible buy day, iterate through each sell day\n ((buy_date + 1)..array.length - 1).each do |sell_date|\n\n #check the price difference for those two days\n price_difference = array[sell_date] - array[buy_date]\n\n #if price diff is larger than the current max profit, store those days and max profit\n if price_difference > max_profit\n best_buy = buy_date\n best_sell = sell_date\n max_profit = price_difference\n end\n end\n end\n puts \"day #{best_buy}: buy at #{array[best_buy]}\"\n puts \"day #{best_sell}: sell at #{array[best_sell]}\"\n puts \"profit of #{max_profit}\"\n\n return [best_buy, best_sell]\nend",
"def optimize_days(days)\n\toptimized = {}\n\tdays.each do |day|\n\t\tprofit = 0\n\t\tfor i in (days.index(day)...days.length)\n\t\t\tif days[i]-day > profit\n\t\t\t\tprofit = days[i]-day\n\t\t\t\tbest_day_to_sell = i\n\t\t\tend\n\t\tend\n\t\tbest_day_to_sell = days.index day if best_day_to_sell.nil?\n\t\toptimized[days.index day] = best_day_to_sell\n\tend\n\toptimized\nend",
"def stock_picker(arr)\n \n max = 0\n day1 = 0\n day2 = 0\n\n arr.length.times do |buy|\n arr.length.times do |sell|\n if buy < sell && (arr[sell] - arr[buy] > max)\n day1 = buy\n day2 = sell\n max = arr[day2] - arr[day1]\n end\n end\n end\n\n return [day1, day2]\nend",
"def stock_picker(array)\n best_days = Hash.new(0)\n\n array.each_with_index do |buy_price, idx1|\n buy_day = idx1\n (idx1 + 1...array.length).each do |idx2|\n sell_day = idx2\n sell_price = array[idx2]\n if buy_price <= sell_price\n best_days[[buy_day, sell_day]] = sell_price - buy_price\n end\n end\n end\n result = greatest_value_in_hash(best_days)\n\n # Days start at 0, wchich is the very first day of the prices\n return \"Best day to buy: #{result[0]}\\nBest day to sell: #{result[1]}\\nProfit: $#{result[2]}\"\nend",
"def stock_picker(days)\n\tx = 0\n\tsets_of_two = days.permutation(2).to_a\n\tdifference = sets_of_two.map { |a,b| a-b }\n\tdiff_low_to_high = difference.sort\n\tbuy_sell = sets_of_two[difference.index(diff_low_to_high[0])]\n\n\twhile days.find_index(buy_sell[0]) > days.find_index(buy_sell[1])\n\t\tbuy_sell = sets_of_two[difference.index(diff_low_to_high[x])]\n\t\tx += 1\n\tend\n\n\tprint [days.find_index(buy_sell[0]), days.find_index(buy_sell[1])]\t\nend",
"def stock_picker(input)\n \n best_profit = 0\n buy_sell_days = [0,0]\n \n# Since we need to buy before we can sell, we should only consider\n# buying up until the second-to-last day:\n \n for x in 0..input.length-2\n \n# We'll always sell after we buy, so we use nested 'for' loops to\n# check our sell value against our buy value and store our max profit:\n \n for y in 1+x..input.length-1\n \n profit = (input[y] - input[x])\n \n if profit > best_profit\n best_profit = profit\n buy_sell_days = [x,y]\n end\n \n end\n \n end\n \n return buy_sell_days\n \nend",
"def stock_picker(stocks)\n buy_day, sell_day, max_profit = 0, 0, 0\n for i in (0...stocks.length - 1)\n buy, possible_sales = stocks[i], stocks[i+1..-1]\n best_sale = possible_sales.max # Find the best price we can still sell for\n current_profit = best_sale - buy\n if current_profit > max_profit\n max_profit = current_profit # New standard we'll have to beat\n buy_day = i + 1 # If i is 0, we should buy on day 1\n sell_day = sales.index(best_sale) + buy_day + 1 # Add 1 in both cases to correct for indexing\n end\n end\n print [buy_day,sell_day]\nend",
"def stock_picker(prices)\n\n\t# Best available [buy, sell] days for each buy day\n\tbest_days = []\n\tprices.each_index do |i|\n\t\tavailable_days = prices[i...prices.size] # only same day or after are valid sell days\n\t\tbest_days << [i, prices.index(available_days.max)]\n\tend\n\n\t# Calculates profit of each best day, same size and index as best_days\n\tprofits = []\n\tbest_days.each {|i| profits << prices[i[1]] - prices[i[0]] }\n\n\t# Returns [buy, sell] day pair matching index of highest profit\n\tbest_days[profits.index(profits.max)]\nend",
"def stock_picker(prices)\n\t# Initialize everything to 0\n\tmin = 0\t\t\t# Day with lowest price so far\t\t\t\t\t\n\tbuy = 0\t\t\t# Buy day with best max_diff so far\n\tsell = 0\t\t# Sell day with best max_diff so far\n\tmax_diff = 0\t# Best value of prices[sell]-prices[buy]\n\t(1...prices.length).each do |i|\n\t\t# Go through each day - not necessary to do the first\n\t\tif prices[i] < prices[min]\n\t\t\t# If current price is less than current min:\n\t\t\tmin = i\t\t\t\t\t\t# Set as current min\n\t\tend\n\t\tdiff = prices[i] - prices[min]\t# Compare difference to current min\n\t\tif diff > max_diff\n\t\t\t# If it's better:\n\t\t\tbuy = min\t\t\t\t\t# Record min as day to buy\n\t\t\tsell = i\t\t\t\t\t# Record current day as day to sell\n\t\t\tmax_diff = diff\t\t\t\t# Record new max difference\n\t\tend\n\tend\n\t[buy, sell]\nend",
"def stock_picker(data)\n #setup\n buy_day = 0\n sell_day = 0\n #algorithm\n for i in 0...data.length\n for j in (i+1)...data.length\n if (data[j]-data[i]) > (sell_day-buy_day)\n buy_day = i\n sell_day = j\n end\n end\n end\n #return\n [buy_day,sell_day]\nend",
"def stock_picker(prices)\n\tgreatest_profit = 0\n\tbuy_day, sell_day = nil, nil\n\n\t(prices.length - 1).times do |day|\n\t\t((day+1)..(prices.length - 1)).each do |day2|\n\t\t\tcurrent_profit = prices[day2] - prices[day]\n\n\t\t\tif current_profit > greatest_profit\n\t\t\t\tbuy_sell = [day,day2] \n\t\t\t\tgreatest_profit = profit\n\t\t\tend\n\t\tend\n\tend\n\n\treturn [buy_day, sell_day]\nend",
"def stock_picker prices\n max_profit = 0-Float::INFINITY\n buy_day = 0\n sell_day = 0\n\n prices.each.with_index do |first_price,first_index|\n profits_for_day = prices.map.with_index do |second_price,second_index|\n if first_index < second_index\n second_price - first_price\n else\n 0-Float::INFINITY\n end\n end\n max_profit_for_day = profits_for_day.max\n if max_profit_for_day > max_profit\n max_profit = max_profit_for_day\n buy_day = first_index\n sell_day = profits_for_day.index(max_profit_for_day)\n end\n end\n\n return [buy_day,sell_day]\nend",
"def stock_picker(prices)\n i = 0\n diff = 0\n best_days = []\n (i...prices.length).each do |index_one|\n (i + 1...prices.length).each do |index_two|\n if prices[index_two] - prices[index_one] > diff\n diff = prices[index_two] - prices[index_one]\n best_days = [index_one, index_two]\n end\n end\n end\n best_days\n end",
"def stock_picker(stocks)\n biggest_price = 0\n profitable_days = []\n (0...stocks.length).each do |i|\n (i + 1...stocks.length).each do |j|\n day = stocks[i][0]\n price = stocks[i][1]\n other_day = stocks[j][0]\n other_price = stocks[j][1]\n stock_price = price - other_price\n if stock_price.abs > biggest_price\n biggest_price = stock_price\n profitable_days = [day, other_day]\n end\n end\n end\n\n profitable_days\nend",
"def stock_picker(prices)\n buy_date = 0\n sell_date = 0\n max_profit = 0\n \n (0...prices.size).each do |buy|\n ((buy + 1)...prices.size).each do |sell|\n \n profit = prices[sell] - prices[buy] \n if max_profit < profit\n max_profit = profit\n buy_date = buy\n sell_date = sell\n end\n end\n end\n [buy_date, sell_date]\nend",
"def stock_picker prices\n\tbest_days = []\n\tbest_profit = 0\n\n\tprices.length.times do |i|\n\t\tj = i\n\t\tfor j in i...prices.length\n\t\t\tif prices[j] - prices[i] > best_profit\n\t\t\t\tbest_profit = prices[j] - prices[i]\n\t\t\t\tbest_days[0] = i\n\t\t\t\tbest_days[1] = j\n\t\t\tend\n\t\tend\n\tend\n\tbest_days\nend",
"def stockPicker(prices)\n pair = [0,0]\n profit = 0\n prices.each_with_index do |buy, i|\n # Find highest sell day\n sell = prices[i..-1].max\n if profit < (sell-buy)\n pair[0] = i\n pair[1] = prices[i..-1].index(sell)+i # Find index of that sell day\n profit = sell-buy\n end\n end\n pair\nend",
"def stock_picker(prices)\n index = 0\n lowest = 0\n best_value = []\n for i in prices\n for j in prices[index..prices.length-1]\n if i - j < lowest\n lowest = i - j # lowest will be equal to the greatest price difference (greatest negative number)\n min = prices.index(i) # index of buy date\n max = prices.index(j) # index of sell date\n end\n end\n index += 1 # increments each iteration to ensure sell dates cannot be past dates\n end \n best_value << min\n best_value << max\n puts \"#{best_value} If you buy on day #{min} and sell on day #{max},\n you will make $#{lowest.abs} profit.\"\nend",
"def stock_picker(stock_array)\n\n day_hash = Hash.new(0)\n day_index = 0\n stock_array.each { |day_number|\n day_hash[day_index] = day_number\n day_index += 1\n }\n\n day_hash_sell = day_hash.clone\n profit_best = Hash.new(0)\n profit_best_counter = nil\n day_hash.each do |key, value|\n\n buy = -value \n day_hash_sell.each do |key_sell, value_sell|\n\n #ensure day is only in futue\n if key_sell <= key then \n next\n end\n\n profit = buy + value_sell \n if profit_best_counter == nil || profit > profit_best_counter then \n #reset hash to ensure only 1 answer given\n profit_best = Hash.new(0)\n\n #track best days to buy/sell in array\n profit_best[key] = key_sell\n\n #keep track of best profit so far\n profit_best_counter = profit\n end \n end \n end\n puts profit_best\nend",
"def stock_picker(stock_values)\n n = stock_values.length\n max_profit = 0;\n start_day = nil\n end_day = nil\n\n for i in (0...n)\n for j in (i + 1...n)\n potential_profit = stock_values[j] - stock_values[i]\n if potential_profit > max_profit\n max_profit = potential_profit\n start_day = i\n end_day = j\n end\n end\n end\n\n [start_day, end_day]\nend",
"def computeBuySellToMaximizeProfit()\n currentStock = \"\"\n i = 0 # Loop counter\n while i < @days.size do # Traverse the data for each date to find price differences\n if i == @days.size - 1 # For the final week\n puts \"#{@days[i]} SELL #{currentStock}\"\n break\n end\n weeklyDifferences = [] # Stores the price differences between closing prices for all stocks in a particular week\n @data.each_with_index do |(key, value), index| # Traverse the data corresponding to current date for each key (stock)\n stockDifferences = {} # Stores the price difference between closing prices for a stock in a particular week\n stockDifferences[:stock] = key\n stockDifferences[:difference] = (value[i+1][:close].to_f - value[i][:close].to_f).round(5) # value[i+1] represents the next date for the stock data\n weeklyDifferences << stockDifferences\n end\n mostProfitableStock = getMostProfitableStock(weeklyDifferences)\n if i == 0 # For week 1\n puts \"#{@days[i]} BUY #{mostProfitableStock}\"\n currentStock = mostProfitableStock\n elsif mostProfitableStock == currentStock # If the stock already bought is more profitable\n puts \"#{@days[i]} HOLD #{mostProfitableStock}\"\n else\n puts \"#{@days[i]} SELL #{currentStock}, BUY #{mostProfitableStock}\"\n currentStock = mostProfitableStock \n end\n i = i + 1\n end\n end",
"def stock_picker(arr)\n\tbuy_day = 0\n\tsell_day = 0\n\told_profit = -999\n\n\tarr.each_with_index do |buy_price, buy_index|\n\t\tarr.each_with_index do |sell_price, sell_index|\n\t\t\tif sell_index <= buy_index\n\t\t\t\tnext\n\t\t\tend\n\t\t\tnew_profit = sell_price - buy_price\n\t\t\tif new_profit > old_profit\n\t\t\t\told_profit = new_profit\n\t\t\t\tbuy_day = buy_index\n\t\t\t\tsell_day = sell_index\n\t\t\tend\n\t\tend\n\tend\n\treturn [buy_day,sell_day]\nend",
"def stock_picker(array)\n max_profit = 0\n buy_sell_days = [0,0]\n array.each_with_index do |buy_price, buy_day|\n array.each_with_index do |sell_price, sell_day|\n if buy_day > sell_day\n next\n end\n if sell_price - buy_price > max_profit\n max_profit = sell_price - buy_price\n buy_sell_days = [buy_day, sell_day]\n end\n end \n end \n p buy_sell_days\nend",
"def stock_picker(data) \n\tday1 = 0\n\twhile day1 < data.length - 1\n\t\tday2 = day1 + 1\t\n\t\twhile day2 < data.length\n\t\t\tprofit ||= 0 #initialize profit at 0\n\t\t\tif data[day2] - data[day1] > profit\n\t\t\t\tprofit = data[day2] - data[day1] #update these variables if profit margin is larger than existing\n\t\t\t\tsellDate = day2\n\t\t\t\tbuyDate = day1\n\t\t\tend\n\t\t\tday2 += 1\n\t\tend\n\t\tday1 += 1\n\tend\n\treturn [buyDate, sellDate] \nend",
"def stock_picker(stocks)\n profit = 0\n\n for i in 0...stocks.length\n # ensures when looping through the prices, sell date comes after buy date\n for j in (i + 1)...stocks.length\n if (stocks[j] - stocks[i]) > profit\n profit = stocks[j] - stocks[i]\n buy_date = i\n sell_date = j\n end\n end\n end\n\n days = [buy_date, sell_date]\n p days\n p \"Total profit would be $#{profit}\"\nend",
"def stock_picker(arr)\n best_days = []\n arr.each do |i|\n arr.each do |x|\n if arr.index(x) > arr.index(i)\n if x - i > 0\n best_days.insert(x - i, \"Buying day #{arr.index(i)} and selling day #{arr.index(x)} gives the highest possible profit of #{x - i}\")\n end\n end\n end\n end\n best_days.last\nend",
"def stock_picker(prices)\n\tmax_diffs_for_each_day = []\n\tsecond_days_for_each_max_diff = []\n\t# the - 1 ignores buys on the last day, which can't be sold\n\t# also keeps the remaining_prices range beginning from overshooting its end\n\tfor day in (0...(prices.length - 1)) \n\t\tremaining_prices = prices[(day + 1)...prices.length]\n\t\tmax_remaining_price = remaining_prices.max\n\t\tmax_diffs_for_each_day << (max_remaining_price - prices[day])\n\t\t# for tied maxes, index will return the earliest day, which we want\n\t\t# the + 1 accounts for zero-indexing of remaining_prices\n\t\tsecond_days_for_each_max_diff << (remaining_prices.index(max_remaining_price) + day + 1)\n\tend\n\tmaxest_diff = max_diffs_for_each_day.max\n\t# for tied maxes, index will return the earliest day, which we want\n\tfirst_day = max_diffs_for_each_day.index(maxest_diff)\n\tsecond_day = second_days_for_each_max_diff[first_day]\n\t[first_day, second_day]\nend",
"def stock_picker(arr)\n\thighestGain = 0\n\tbuyDay = 0\n\tsellDay = 0\n\n\tarr.each_index do |i|\n\t\tbiggestGainDayFrom = findDayWithHighestGainFrom(i, arr)\n\t\tif arr[biggestGainDayFrom] - arr[i] > highestGain\n\t\t\thighestGain = arr[biggestGainDayFrom] - arr[i]\n\t\t\tbuyDay = i\n\t\t\tsellDay = biggestGainDayFrom\n\t\tend\n\tend\n\treturn [buyDay,sellDay]\nend",
"def stock_picker(stock_arr)\n highest_profit = 0 \n best_day_to_buy = 0 \n best_day_to_sell = 0 \n\n # Return 0- 9 but due to \"...\" it means it will exclude running the last number \n for i in 0...stock_arr.length \n #I am using a nested array so I can keep track of one number and use the other to iterate \n # Ex. [0, 1-8],[1, 2-8], [2, 3-8], .. [8, 8-8] and so on \n #I am doing this so I can use the i index postion to keep track of each day \n # Then I will use the second for loop to iterate through the stock_arr again and compare and calculate\n # those value to what I have in i(the tracked day) \n # I keep the calculation in profit_calculating until I find the profit_calculating becomes a number with the highest_profit \n for j in i+1...stock_arr.length do \n profit_calculating = stock_arr[j] - stock_arr[i]\n if highest_profit < profit_calculating\n highest_profit = profit_calculating\n best_day_to_buy = i \n best_day_to_sell = j \n end\n end \n end\n return \"[#{best_day_to_buy}, #{best_day_to_sell}] with a profit of #{highest_profit}\"\n\nend",
"def stock_picker(arr)\n buy = \"\"\n sell = \"\"\n biggest_difference = 0\n profit = 0\n arr.each_with_index do |day, index|\n #no days after last day so last day can't be the buy day\n if (day != arr[-1])\n #sell date must be after purchase date, therefore only want indicies after current\n future_date = (index +1)\n while future_date < arr.length\n profit = arr[future_date] - arr[index]\n if profit > biggest_difference\n buy = index\n sell = future_date\n biggest_difference = profit\n end\n future_date += 1\n end\n end\n end\n [buy,sell]\nend",
"def stock_prices(array)\n i = 0\n \n max_profit = -1\n buy_day = nil\n sell_day = nil\n \n length = array.length\n \n while i < length - 1\n j = i + 1\n \n while j < length\n profit = array[j] - array[i]\n \n if profit > max_profit\n max_profit = profit\n buy_day = i\n sell_day = j\n end\n \n j += 1\n end\n \n i += 1\n end\n \n return \"Buy day: #{buy_day}. Sell day: #{sell_day}.\"\nend",
"def stock_picker(stock_prices)\n\n max_profit = 0\n best_days = []\n\n stock_prices.each_with_index do |buying_price, index|\n (index+1).upto(stock_prices.length - 1) do |selling_index|\n selling_price = stock_prices[selling_index]\n profit = selling_price - buying_price\n if profit > max_profit\n max_profit = profit\n best_days = [index, selling_index]\n end\n\n end\n end\n best_days\nend",
"def stock_picker(array)\n sorted_stocks = array.sort.reverse\n profit = 0\n days_buy_sell = []\n sorted_stocks.each do |price_sell|\n array.each do |price_buy|\n if price_buy < price_sell && array.index(price_sell) > array.index(price_buy) && price_sell - price_buy > profit\n days_buy_sell = [array.index(price_buy), array.index(price_sell)]\n profit = price_sell - price_buy\n end\n end\n end\n days_buy_sell\nend",
"def stock_picker(prices)\n\t# Storing variables what I use later\n\t$d = 0\n\t$small = 0\n\t$big = 0\n\tprices.each do |x|\t\t\t# iterating through all prices elements\n\t\ty = prices.index(x)+1 \t# y is the next element in prices array\n\t\twhile y < (prices.length)\t# it runs till we have something in the array\n\t\t\tif (x-prices[y]) < $d \t# only runs when the difference of x element and the next one is lower than the previous pair's (which is stored in $d)\n\t\t\t\t$d = x-prices[y] \t# so we store the lowest difference in $d\n\t\t\t\t$small = prices.index(x) \t# we store in $small the index number of x in the array, that is the day when we need to buy, the lowest price\n\t\t\t\t$big = y \t\t\t\t\t# y is the index number in the array of the number, which is the highest, and have the biggest difference with x\n\t\t\t\ty += 1 \t\t\t\t\t\t# add +1 to y so we can loop through the array\n\t\t\telse\n\t\t\t\ty += 1 \t\t\t\t\t\t# if the difference of the following pair is not smaller than the previous ones then we just move on and don't change $small and $big and $d\n\t\t\tend\n\t\tend\n\tend\n\tresult = []\n\tresult.push($small, $big) \t\t\t# pushing the results into result array\n\tputs result\nend",
"def stock_picker(prices)\n price_diff = 0\n count = 0\n best_days_array = []\n\n prices.each do |price1|\n count += 1\n prices.each do |price2|\n if count > prices.index(price2)\n next\n else\n if (price2 - price1) > price_diff\n price_diff = (price2 - price1)\n best_days_array = [prices.index(price1), prices.index(price2)]\n end\n end\n end\n end\n puts best_days_array\nend",
"def stock_picker(prices)\n\n profit = 0\n\n (prices.length - 1).times do |i|\n\n curr_buy_price = prices[0]\n prices.delete_at(0)\n\n if prices.max - curr_buy_price > profit\n profit = prices.max - curr_buy_price\n buy_index = i\n sell_index = i + prices.index(prices.max) + 1\n @best_days = [buy_index, sell_index]\n end\n\n end\n\n p @best_days\n \nend",
"def pick_stocks(prices)\n profits = []\n pairs = []\n prices.each_with_index do |price_b, buy_date|\n prices.each_with_index do |price_s, sell_date|\n if sell_date > buy_date\n profits << price_s - price_b\n pairs << [buy_date, sell_date]\n end\n end\n end\n pairs[profits.index(profits.max)]\nend",
"def best_profit (stock_prices_yesterday)\n possible_sale_combinations = stock_prices_yesterday.combination(2).to_a\n profits = []\n possible_sale_combinations.each do |pair|\n buy_price = pair[0]\n sell_price = pair[1]\n profit = sell_price - buy_price\n profits << profit\n end\n profits.sort!\n profits.count\n max_profit = profits[-1]\n if max_profit < 0\n return 0\n else\n return max_profit\n end\nend",
"def stock_picker(arr)\n profit = 0\n bestdays = []\n\n arr.each_with_index do |buyp, buyi|\n arr.each_with_index do |sellp, selli|\n next unless buyi < selli && (sellp - buyp) > profit\n\n profit = sellp - buyp\n bestdays[0] = buyi\n bestdays[1] = selli\n end\n end\n puts \"#{bestdays[0]} and #{bestdays[1]}\"\nend",
"def stock_picker prices\n\tbest_buy_date = nil\n\tbest_sell_date = nil\n\tbest_profit = 0\n\tprices.each_index do |buy_date|\n\t\t(buy_date+1...prices.length).each do |sell_date|\n\t\t\tprofit = prices[sell_date] - prices[buy_date]\n\t\t\tif profit > best_profit\n\t\t\t\tbest_profit = profit\n\t\t\t\tbest_buy_date = buy_date\n\t\t\t\tbest_sell_date = sell_date\n\t\t\tend\n\t\tend\n\tend\n\t[best_buy_date,best_sell_date]\nend",
"def stock_picker(number_array)\n #Stores current profit to be gained\n profit = 0\n #Stores the maximum profit from the combination of previous days\n max_profit = 0\n #Stores the days in which max profit can be had. stored_days[0] is buy day. stored_days[1] is sell day\n stored_days = [0, 0]\n\n #Loops through all numbers in array. Compares each iteration against all numbers from the iteration to the end of the array for max profit\n for i in 0..number_array.length-1\n # p \"Day #{i}: \"\n for j in i..number_array.length-1\n if number_array[j] < number_array[i]\n break\n else\n profit = number_array[j] - number_array[i]\n # p \"buy: \" + number_array[i].to_s + \" sell: \" + number_array[j].to_s + \" profit: \" + profit.to_s\n if profit > max_profit\n max_profit = profit\n stored_days[0] = i\n stored_days[1] = j\n end\n end\n end\n end\n return stored_days\nend",
"def stock_picker(prices)\n days = [0,0]\n profit = 0\n i = 0\n\n while i < prices.size\n n = i + 1\n while n < prices.size\n dividend = (prices[n].to_i - prices[i].to_i)\n if dividend > profit\n profit = dividend\n days[0] = prices.index(prices[i])\n days[1] = prices.index(prices[n])\n end\n n += 1\n end\n i += 1\n end\n print \"Buy at $#{prices[days[0]]} and sell at $#{prices[days[1]]}\"\n puts \" on days #{days} for a profit of $#{prices[days[1]] - prices[days[0]]}!\"\nend",
"def stock_picker(prices)\n combinations = prices.combination(2).to_a\n profits = combinations.map { |days| days[1] - days[0] }\n (0...prices.size).to_a.combination(2).to_a[profits.index(profits.max)]\nend",
"def sell(stonks)\n \nreversed = stonks.reverse\nstocks_you_can_sell = stonks.slice(selling_array(stonks),100)\nbiggest = stocks_you_can_sell.max\nsell_day = stocks_you_can_sell.find {|stock| stock <= biggest}\n \nreturn sell_day\n\nend",
"def stock_picker(stock_prices)\n best_pick = 0\n first_index = 0\n second_index = 0\n\n stock_prices.each_with_index do |val, idx|\n current_pick = stock_prices.slice((idx + 1)..(stock_prices.length - 1))\n current_pick.each_with_index do |num, i|\n new_pick = num - val\n if new_pick > best_pick\n best_pick = new_pick\n first_index = idx\n second_index = idx + i + 1\n end\n end\n end\n p \"Best day to buy: #{first_index}. Best day to sell: #{second_index}\"\n p \"Profit: #{best_pick}\"\nend",
"def stock_picker(prices)\n profits_per_day = {}\n prices.each_with_index do |value, index|\n break if index == prices.length - 1\n profit = prices[index + 1] - value\n if (index + 1 == prices.length - 1)\n profits_per_day[profit] = [index, index + 1]\n break\n end\n for i in (index + 2..prices.length - 1)\n profit = prices[i] - value > profit ? prices[i] - value : profit\n end\n profits_per_day[value] = profit\n end\n return profits_per_day.max_by{|k,v| v}\nend",
"def stock_picker(stock_prices)\n buying_price = 0\n buying_index = 0\n selling_price = 0\n max_profit = -1\n max_buy_index = 0\n max_sell_index = 0\n\n change_buy = true\n\n stock_prices.each_with_index do |price, day|\n selling_price = stock_prices[day + 1].to_i\n\n if change_buy\n buying_price = price.to_i\n buying_index = day\n end\n\n if buying_price > selling_price\n change_buy = true;\n else\n profit = selling_price - buying_price\n if profit > max_profit\n max_profit = profit\n max_sell_index = day + 1\n max_buy_index = buying_index\n end\n change_buy = false;\n end\n\n end\n\n [max_buy_index, max_sell_index]\n\nend",
"def stock_picker(prices)\n\t# Empty hash for saving the buy & sell days (key) and the proffit (value)\n\tbuy_sell = Hash.new\n\n\tprices.each do |buy|\n\t\t# loop inside the loop that caluclates proffit ONLY IF the sell date has higher index than the buy date in the array.\n\t\tprices.each do |sell|\n\t\t\tif prices.index(sell) > prices.index(buy)\n\t\t\t\tproffit = sell - buy\n\t\t\t\t# Saves the buy index, sell index and proffit into our hash\n\t\t\t\tbuy_sell[\"#{prices.index(buy)}, #{prices.index(sell)}\"] = proffit\n\t\t\tend\n\t\tend\n\tend\n\t# lists the hash key (buy & sell day) that had the highest proffit value.\n\tputs buy_sell.key(buy_sell.values.max)\nend",
"def stock_picker(arr)\n\n max_profit = 0 \n\n days = []\n\n arr.each.with_index do |num1, idx1|\n arr.each.with_index do |num2, idx2|\n if idx1 < idx2 && (num2 - num1) > max_profit\n max_profit = num2 - num1\n days = [idx1, idx2]\n end\n end\n end\n\n # return most profitable days \n days \n \n end",
"def stock_picker(arr)\n final_profit = 0\n current_profit = 0\n final_dates = []\n\n arr.each do |buy_price|\n buy_date = arr.index(buy_price)\n \n arr.each do |sell_price| \n sell_date = arr.index(sell_price)\n \n if (sell_date > buy_date && sell_price > buy_price) \n current_profit = sell_price - buy_price\n if current_profit > final_profit\n final_profit = current_profit\n final_dates = [buy_date, sell_date]\n end\n end \n end\n end\n puts final_dates\nend",
"def stock_picker(arr)\n\tdifference = 0\n\tstart_index = 0\n\tend_index = 0\n\ti=0\n\twhile i < arr.length #outer loop starts on the 1st day\n\t\tj=i+1 #increment should be 1 greater than the 1st day\n\t\twhile j < arr.length #inner loop goes through all values after i day\n\t\t\tjelly = [arr[j], arr[i]].inject(:-) #calculate largest difference\n\t\t\tif jelly > difference\n\t\t\t\tdifference = jelly #update values if the difference is larger\n\t\t\t\tstart_index = i\n\t\t\t\tend_index = j\n\t\t\tend\n\t\t\tj=j+1\n\t\tend\n\t\ti=i+1\n\tend\n\tanswer=[]\n\tanswer << start_index\n\tanswer << end_index\n\treturn answer #return array of first day followed by second day\nend",
"def stock_picker(arr)\n days = Array.new(2,0)\n profit = 0\n min_index = 0\n cost = arr.first\n\n arr.each_with_index do |price, index|\n if price < cost\n cost = price\n min_index = index\n next\n end\n if (price - cost) > profit\n days = [min_index, index] \n profit = price - cost\n end\n end\n days\nend",
"def stock_picker(stock_prices)\n best_margin = 0\n\n #require \"pry\"; binding.pry\n\n for day in 0..stock_prices.length - 1\n lowest_price = stock_prices[day]\n highest_price = stock_prices[day..-1].max\n margin = highest_price - lowest_price\n\n if best_margin < margin\n best_margin = margin\n best = [lowest_price, highest_price]\n end\n end\n\n lowest_day = stock_prices.index(best[0])\n highest_day = stock_prices.index(best[1])\n [lowest_day, highest_day]\nend",
"def stock_picker stock_prices\n coll = Hash.new \n stock_prices.each_index do |i|\n stock_prices.map.with_index(i) do |e, j|\n if stock_prices[j] && stock_prices[j] > stock_prices[i]\n coll[[i, j]] = stock_prices[j] - stock_prices[i]\n end\n end\n end\n\n coll = coll.key(coll.values.max)\n puts \"Buy on day:\\t#{coll[0]} \\nSell on day:\\t#{coll[1]}\"\n puts \"Profit ($):\\t#{stock_prices[coll[1]] - stock_prices[coll[0]]}\"\nend",
"def stock_picker(stock_prices)\n\n\tstock_prices.map!{|price| price.to_i}\t#Convert array values to integers\n\n#Empty array for buy-low and sell-high differences\n\tdifference = []\n\n#Each day is considered a (low_price) and respective (high_price) is determined\n\tstock_prices.map.with_index do |price, i|\n\t\tlow_price = price\n\t\thigh_price = stock_prices[i+1..-1].max\n#The differnces array collects all high-low differences\t\t\n\t\tdifference.push(high_price.to_i - low_price.to_i)\n\tend\n\n\tday_1 = difference.index(difference.max)\t#Get day of highest difference possible\n\tday_2 = stock_prices.index(stock_prices[day_1+1..-1].max)\t#Calculate correspoinding high value\n\n\ta = [day_1]\n\tb = [day_2]\n\n\tprint a + b\nend",
"def stock(prices)\n\n all_choices = []\n\n prices.each_with_index do |buy, i1|\n prices.each_with_index do |sell, i2|\n next if i1 >= i2 \n all_choices << [buy, sell]\n end\n end\n\n best_choice = 0 # []\n\n all_choices.each do |combination| # [ [] ] \n buy_price, sell_price = combination\n profit = sell_price - buy_price\n if profit > best_choice[1] - best_choice[0]\n best_choice = [buy_price, sell_price]\n end\n end\n best_choice\nend",
"def find_best_day\n day_array = @days.map do |day|\n day.strftime('%A')\n end\n\n day_hash = day_array.each_with_object(Hash.new(0)) { |o, h| h[o] += 1 }\n day_hash.max_by { |_, v| v }\n end",
"def stock_picker(array)\n # loop through array twice. Once to take value, 2nd to compare, store index into result\n result = []\n profit, buy_day, sell_day = 0, 0, 0\n\n array.size.times do |n|\n (n + 1).upto (array.size - 1) do |i|\n if (array[n] - array[i]) > profit\n profit = array[n] - array[i]\n buy_day = n\n sell_day = i\n end\n end\n end\n [buy_day, sell_day]\nend",
"def best_day\n\n end",
"def stock_picker(stock_arr)\n\tdiff=0\n\tbuy_date=0\n\tsell_date=0\n\tcombo=(0...30).to_a.combination(2).to_a\n\tprint combo\n\tputs \"\"\n\tcombo.each do |x,y|\n\t\tif (stock_arr[y] - stock_arr[x]) > diff\n\t\t\tdiff = (stock_arr[y] - stock_arr[x])\n\t\t\tsell_date=y\n\t\t\tbuy_date=x\n\t\tend\n\tend\n\n\tputs \"Buy date: #{buy_date}, Sell date: #{sell_date}, Profit: #{diff}\"\nend",
"def stock_picker(arr)\n profits = []\n arr.each_with_index do |price, day|\n arr[day + 1..-1].each do |price2, day2|\n profit = price - price2\n profits << profit.abs if profit.negative?\n end\n end\n profits.empty? ? -1 : profits.max\nend",
"def best_profit_from_yesterday_greedy(prices_array)\n\n lowest_thus_far = prices_array[0]\n max_profit = 0\n\n prices_array.each do |price|\n if price < lowest_thus_far\n lowest_thus_far = price\n end\n\n potential_profit = price - lowest_thus_far\n if(potential_profit > max_profit)\n max_profit = potential_profit\n end\n end\n max_profit\nend",
"def highest_possible_profit(prices)\n best_profit = 0\n # iterate over the dataset\n prices.each_with_index do |price, index|\n # in each hour compare with the future hours to find difference\n\n # check if difference is positive\n # check if difference is greater than current best\n # keep best difference\n # check next hour\n\n end\n # end return the best difference\n\nend",
"def a_second_failed_stock_picker(array)\n high_stock_price = array.max\n low_stock_price = array.min\n hash = Hash[array.map.with_index.to_a]\n day_to_sell = hash[high_stock_price]\n day_to_buy = hash[low_stock_price]\n if day_to_buy < day_to_sell\n \"on day #{day_to_buy} buy at #{low_stock_price} then on day #{day_to_sell} sell at #{high_stock_price}\"\n else\n p \"you can't buy on day #{day_to_buy} sell on day #{day_to_sell}\"\n p hash\n #so i have a hash, presumably I should be able to pick from it, the next lowest\n end\nend",
"def stock_picker(array)\n\n#store 2 numbered arrays that consist of every combination of numbers in the passed array\n manipulate_array = array.combination(2).to_a\n\n# change each array's 2 index to contain the difference of the two numbers\n manipulate_array.each do |i|\n i.push(i.max - i.min) \n end\n \n# sort the array by thier difference from largest to smalles \n sorted_array = manipulate_array.sort {|a,b| b[2] <=> a[2]}\n \n sorted_array.each do |i|\n# delete the sum from each combonation \n i.delete_at(2)\n# return the position of the smallest price that comes before the postion of the highest price (returning day to buy low then return the day to buy high)\n if array.index(i.min) < array.index(i.max)\n return [array.index(i.min),array.index(i.max)]\n break\n elsif i == sorted_array.last\n return \"There are no buy opportunities in this set of stock prices\"\n end\n end\nend",
"def buy_and_sell_price(prices)\n return if prices.length < 2\n\n buy_price = prices[0]\n current_buy_price = buy_price\n max_profit = (prices[1] - buy_price)\n\n for i in 2..prices.length - 1\n profit = prices[i] - current_buy_price\n\n if profit > max_profit\n buy_price = current_buy_price\n max_profit = profit\n else\n current_buy_price = [current_buy_price, prices[i]].min\n end\n end\n\n [buy_price, max_profit + buy_price]\nend",
"def stock_picker(price_arr)\n profit = 0\n trade_days = [0,0]\n price_arr.each_with_index do |buy_value, buy_day|\n price_arr.each_with_index do |sell_value, sell_day|\n if (sell_value - buy_value) > profit\n profit = (sell_value - buy_value)\n trade_days[0] = buy_day\n trade_days[1] = sell_day\n end\n end\n end\n \"buy on #{trade_days[0]} and sell on #{trade_days[1]} for a profit of #{profit}\"\nend",
"def stock_picker(array)\n result = 0\n largest = 0\n# count is the value of the array to check against the arrays proceeding values, which are represented by step\n count = 0\n step = 1\n while count < array.length - 1\n while step < array.length\n result = array[step] - array[count]\n if result > largest && result > 0\n largest = result\n low = count\n high = step\n end\n step += 1\n end\n count += 1\n step = count + 1\n end\n if low == nil\n puts \"There was never a good day to buy and sell the stock\"\n else\n puts \"The best day to buy the stock was day #{low.to_s} at #{array[low].to_s}, and the best day to sell was day #{high.to_s} at #{array[high].to_s}\"\n end\nend",
"def best_profit (stock_prices_yesterday)\n min_price = stock_prices_yesterday[0]\n max_profit = stock_prices_yesterday[1] - stock_prices_yesterday[0]\n\n stock_prices_yesterday.each do |stock_price|\n if stock_price <= min_price\n min_price = stock_price\n elsif (stock_price - min_price) > max_profit\n max_profit = stock_price - min_price\n end\n end\n max_profit\nend",
"def get_max_profit(stock_prices_yesterday)\n # check for at least 2 prices\n if stock_prices_yesterday.length < 2\n raise IndexError, 'Need at least 2 prices to test.'\n end\n # initialize first price and the first possible profit\n min_price = stock_prices_yesterday[0]\n max_profit = stock_prices_yesterday[1] - stock_prices_yesterday[0]\n\n stock_prices_yesterday.each_with_index do |current_price, index|\n if index == 0 then next end\n # see what our profit would be if we bought at the\n # min price and sold at the current price\n potential_profit = current_price - min_price\n # update max_profit\n max_profit = [max_profit, potential_profit].max\n # update min_price\n min_price = [min_price, current_price].min\n end\n return max_profit\nend",
"def stock_picker(prices)\n\n buy = 0\n sell = 0\n max = 0\n \n prices.each_index do |x|\n prices.each_index do |y|\n if prices[y] - prices[x] > 0 and prices[y] - prices[x] > max and y > x\n buy = x\n sell = y\n max = prices[y] - prices[x]\n end\n end\n end\n \n [buy, sell]\nend",
"def max_profit(prices)\n sell_one, sell_two = 0, 0\n buy_one, buy_two = Float::INFINITY, Float::INFINITY\n \n prices.each do |price|\n buy_one = [buy_one, price].min\n sell_one = [sell_one, price - buy_one].max\n buy_two = [buy_two, price - sell_one].min\n sell_two = [sell_two, price - buy_two].max\n end\n sell_two\nend",
"def bestonetradeprofit(prices)\n # find highest difference between price and subsequent price\n # starting best is second - first\n max = prices[1] - prices[0]\n while prices.length > 1\n e = prices.shift\n prices.each {|v| \n if (v - e) > max \n max=(v-e)\n end\n }\n end\n return max\nend",
"def stock_picker(prices)\r\n\tprice_to_buy = 0\r\n\tprice_to_sell = 0\r\n\tprofit = 0\r\n\r\n\tprices[0..-2].each_with_index do |buy, index_buy|\r\n\t\tprices[(index_buy + 1)..-1].each_with_index do |sell, index_sell|\r\n\t\t\tif profit < sell - buy\r\n\t\t\t\tprofit = sell - buy\r\n\t\t\t\tprice_to_buy = index_buy\r\n\t\t\t\tprice_to_sell = index_sell + (index_buy + 1)\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\t[price_to_buy, price_to_sell]\r\nend",
"def stock_picker(stock_prices)\n lowest, highest = 9999999999, 0\n index_of_highest, index_of_lowest = 0\n\n stock_prices.each_with_index do |price, index|\n \n if price > highest\n highest, index_of_highest = price, index\n end\n\n end\n\n index = 0\n while index < index_of_highest\n\n if stock_prices[index] < lowest\n lowest, index_of_lowest = stock_prices[index], index\n end\n\n index += 1\n end\n \n\n\n\n puts \"You bought stock on Day #{index_of_lowest + 1}, for $#{lowest}, and sold it on Day #{index_of_highest + 1} for $#{highest}. Your profit is $#{highest - lowest}.\"\nend",
"def stock_picker(prices)\n current_max = 0\n buy_index = 0\n sell_index = 1\n (0...prices.length - 1).each do |buy|\n (buy + 1...prices.length).each do |sell|\n if prices[sell] - prices[buy] > current_max\n current_max = prices[sell] - prices[buy]\n buy_index = buy\n sell_index = sell\n end\n end\n end\n [buy_index, sell_index]\nend",
"def calculate_price_per_day(price_per_day, day_count)\n price_per_day * day_count\n end",
"def stock_picker(prices)\n #results array indicates the best time to buy and then sell the stock\n results = [0, 0]\n #this variable keeps tabs of the best positive price difference\n greatest_price_difference = 0\n prices.each_with_index do |price, current_index|\n #index_counter keeps track of the index in the array as it's being\n #looped in the while loop\n \n index_counter = current_index + 1\n #the while loop loops through the array starting with the first \n #potential day to buy and compares the potential difference\n #each day going forward to determine which day would be best to sell on\n #should they buy the stock today\n while index_counter < prices.length\n \n price_difference = prices[index_counter] - prices[current_index]\n if price_difference > greatest_price_difference\n #price difference is updated if a greater difference is found\n greatest_price_difference = price_difference\n results[0] = current_index \n results[1] = index_counter \n end\n index_counter += 1\n end\n end\n\n\n\n puts results\nend",
"def pick_stocks(stocks)\n stocks = stocks[0]\n max_profit = 0\n min_stock = stocks[0]\n index1_temp = 0\n index1_lock = 0\n index2 = 0\n for i in 1...stocks.length()\n if stocks[i] < min_stock\n min_stock = stocks[i]\n index1_temp = i\n else\n if max_profit < (stocks[i]-min_stock)\n max_profit = stocks[i]-min_stock\n index2 = i\n index1_lock = index1_temp\n end\n end\n end\n if index1_lock == index2\n puts \"Not a good time to invest\"\n else\n puts \"I would recommend buying on Day #{index1_lock + 1} and selling on Day #{index2 + 1}.\"\n end\nend",
"def stock_picker(arr)\n answer = []\n highest_value = 0\n buy = 0\n sell = 0\n\n for i in 0..(arr.length-1) do\n for j in (i+1)..(arr.length-1) do\n if arr[j] - arr[i] > highest_value\n highest_value = arr[j] - arr[i]\n buy = i\n sell = j\n end\n end\n end\n\n answer.push(buy)\n answer.push(sell)\n\n puts answer\nend",
"def get_max_profit(stock_prices_yesterday)\n min_price = stock_prices_yesterday.first\n max_profit = stock_prices_yesterday[1] - min_price\n stock_prices_yesterday.each.with_index do |price, idx|\n next if idx == 0\n potential_profit = price - min_price\n max_profit = potential_profit if potential_profit > max_profit\n min_price = price if price < min_price\n end\n max_profit\nend",
"def find_times(hash)\n\n lowest_price = hash.values[0]\n buy_time = hash.keys[0]\n new_buy_time = hash.keys[0]\n sell_time = hash.keys[0]\n max_profit = 0\n\n hash.each do |time, price|\n\n if price < lowest_price\n lowest_price = price\n new_buy_time = time\n end\n\n current_profit = price - lowest_price\n \n if current_profit > max_profit\n max_profit = current_profit\n sell_time = time\n buy_time = new_buy_time\n end\n\n end\n\n return \"Buy at #{buy_time} min, sell at #{sell_time} min\"\n\nend",
"def minCostTravel( days, costs)\n\tn = days.length\n\tmax = days[n - 1]\n\tdp = Array.new(max + 1){0}\n\tj = 0\n\ti = 1\n\twhile (i <= max)\n\t\tif (days[j] == i)\n\t\t\t# That days is definitely travelled.\n\t\t\tj += 1\n\t\t\tdp[i] = dp[i - 1] + costs[0]\n\t\t\tdp[i] = min(dp[i],dp[max(0,i - 7)] + costs[1])\n\t\t\tdp[i] = min(dp[i],dp[max(0,i - 30)] + costs[2])\n\t\telse\n\t\t\tdp[i] = dp[i - 1]\n\t\tend\n\t\ti += 1\n\tend\n\treturn dp[max]\nend",
"def best_day\n date_hash = {}\n date.each do |date|\n if date_hash.has_key? date\n date_hash[date] += 1\n else \n date_hash[date] = 1\n end\n end\n puts date_hash.values.max\n day = date_hash.key(date_hash.values.max)\n return day.strftime(\"%m/%d/%Y\")\n end",
"def stock_picker(prices, best_profit = -(2**(0.size * 8 -2)) )\t\n\tabs_max_sell = prices[1..-1].max\n\n\tmin_buy = prices[0..-2].min\n\tmin_buy_index = prices.index(min_buy)\n\n\tmax_sell = prices[(min_buy_index+1)..-1].max\n\tmax_sell_index = (min_buy_index + 1) + prices[(min_buy_index+1)..-1].index(max_sell)\n\n\tprofit = max_sell - min_buy\n\t\n\tif (profit > best_profit)\n\t\tbest_profit = profit\n\tend\n\tif (max_sell == abs_max_sell || prices[0..(min_buy_index-1)].length == 1)\n\t\tputs \"Best profit is #{best_profit}, buying on day #{min_buy_index} and selling on day #{max_sell_index}\"\n\telse\n\t\tprices = prices[0..(min_buy_index-1)]\n\t\tstock_picker(prices, best_profit)\n\tend\nend",
"def stock_picker(array)\n\n\n\ti = 0 \n\tj = 1\n\n\tprofit_list = Array.new\n\n\twhile i < array.length do\n\t\twhile (j <= array.length && j > i) do\n\t\t\tprofit = array[j].to_i - array[i].to_i\n\t\t\tprofit_list << profit\n\t\t\tif profit_list.max == profit\n\t\t\t\tbuy = i\n\t\t\t\tsell = j\n\t\t\tend\n\t\t\t\n\t\t\tj += 1\n\t\tend\n\t\ti += 1\n\t\tj = i + 1\n\tend\n\tputs [buy,sell]\nend",
"def get_max_profit_v2(yesterday_stock_prices)\n\n max_profit = 0\n\n # go through every price (with its index as the time)\n yesterday_stock_prices.each_with_index do |earlier_price, earlier_time|\n\n # and go through all Later Prices\n (yesterday_stock_prices[+1..-1]).each do |later_price|\n\n # see what our profit will be if we bought at the\n # earlier price and sold at the later price\n potential_profit = later_price - earlier_price\n\n # update max_profit if we can do better\n max_profit = [max_profit, potential_profit].max\n\n end\n\n end\n\n max_profit\n end",
"def stock_profit(stocks)\n minimum = stocks[0]\n profit = stocks[1] - stocks[0]\n\n (1...stocks.size).each do |price|\n current_price = stocks[price]\n current_profit = current_price - minimum\n\n minimum = [minimum, current_price].min\n\n profit = [profit, current_profit].max\n end\n\n profit\nend",
"def get_available_space_sunday(bookings_by_day)\n @bookings = bookings_by_day\n return_hash = Hash.new\n hash_of_times=[[12,00],[12,30],[13,00],[13,30],[14,00],[14,30],[15,00]]\n hash_of_times.each do |time|\n booking = @bookings.first.booking_date_time.change({ hour: time.first, min: time.second })\n \n if get_total_diners_for_current_time(booking) < max_diners_at_current_time(@bookings.first[:restaurant_id])\n return_hash[booking.strftime(\"%H:%M\")]= (max_diners_at_current_time(@bookings.first[:restaurant_id])- (get_total_diners_for_current_time(booking)))\n else\n end \n end\n return return_hash\n end",
"def stock_picker(ray)\n\tdays = []\n\tproft = 0\n\tfor k in 0...ray.length-1\t\n\t\tleft = ray[k]\n\t\tfor i in k+1...ray.length\t\n\t\t\tright = ray[i]\n\t\t\tif right-left > proft\n\t\t\t\tproft = right-left\n\t\t\t\trr = right\n\t\t\t\trri = i\n\t\t\t\tll = left\n\t\t\t\tlli = k\n\t\t\tend\n\t\tend\n\tend\t\n\tdays.append(lli)\n\tdays.append(rri)\n\treturn days\nend",
"def stock_picker(stocks)\n\traise \"You are suck, use array!\" unless stocks.is_a? Array\n\traise \"You are a sock, use numbers!\" unless stocks.all? {|num|num.is_a? Numeric}\n\n buy = 0\n sell = 0\n difference = 0\n\n stocks.each_with_index do |first_number, first_index|\n first_index.upto(stocks.size - 1 ) do |second_index|\n second_number = stocks[second_index]\n\n if second_number - first_number > difference\n difference = second_number - first_number\n buy, sell = first_index, second_index\n end\n\n end\n end\n\n [buy, sell]\n\nend",
"def get_available_space_sunday_adjusted(bookings_by_day)\n @bookings = bookings_by_day\n return_hash = Hash.new\n hash_of_times=[[12,00],[12,30],[13,00],[13,30],[14,00],[14,30],[15,00]]\n hash_of_times.each do |time|\n booking = @bookings.first.booking_date_time.change({ hour: time.first, min: time.second })\n current_big_tables = get_bookings_over_seven_array(@bookings)\n \n if get_total_diners_for_current_time(booking) < max_diners_at_current_time(@bookings.first[:restaurant_id])\n unless ((max_diners_at_current_time(@bookings.first[:restaurant_id])-2)- (get_total_diners_for_current_time(booking)))<= 0\n \n return_hash[booking.strftime(\"%H:%M\")]= (((max_diners_at_current_time(@bookings.first[:restaurant_id]))- (get_total_diners_for_current_time(booking)))-2)\n end\n else\n end \n end\n return return_hash\n end",
"def stock_picker(array)\n greatest = 0\n greatest_pair = []\n\n(0...array.length).each do |i|\n (i+1...array.length).each do |j|\n\n current = array[i] - array[j]\n\n if current < greatest\n greatest = current\n greatest_pair = [i, j]\n end\n end\n end\n\n greatest_pair\nend",
"def stock_picker(array)\n\ndiff = array[0] - array[1]\nlowest, highest = array[0], array[1]\n\n\tarray.each do |first_price|\n\t\tindex_num = array.index(first_price)\n\t\tarray.each_with_index do |next_price, second_index|\n\t\t\tif second_index > index_num\n\t\t\t\tif (first_price - next_price) < diff\n\t\t\t\t\tdiff = first_price - next_price\n\t\t\t\t\tlowest, highest = first_price, next_price\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\t\n\tputs \"Buy on \" + array.index(lowest).to_s + \", sell on \" + array.index(highest).to_s\n\tputs \"You'll buy at the price of #{lowest} and sell at #{highest}.\"\nend",
"def distribute_days_evenly(allocated_days, available_days, num_of_rooms)\n allocation_keys = allocated_days.keys\n\n j = 0\n while j < (allocated_days.size * num_of_rooms)\n i = 0\n until i >= (allocation_keys.size - 1)\n month = allocation_keys[i]\n next_month = allocation_keys[i + 1]\n\n if (get_available_days(available_days, month) * num_of_rooms) > allocated_days[month] &&\n (allocated_days[month] % num_of_rooms != 0) &&\n (allocated_days[next_month] > (allocated_days.values.min * 0.75))\n allocated_days[month] += 1\n allocated_days[next_month] -= 1\n i += 2\n else\n i += 1\n end\n end\n j += 1\n end\n allocated_days\n end",
"def pick_first?(day1, day2)\n if day1[:days] * day2[:fee] < day1[:fee] * day2[:days]\n return 1\n elsif day1[:days] * day2[:fee] == day1[:fee] * day2[:days]\n return 0\n else\n return -1\n end\nend",
"def day_in_week_int \n\t\tdays = []\n\t\ttoday = Time.now\n\t\tdays.push(today.to_i)\n\t\ttoday_week_day = today.wday\n\t\tanothers = (0..6).select {|e| e != today_week_day}\n\t\tanothers.map do |e|\n\t\t\tdays.push(today.to_i - e*day_second)\n\t\tend\n\n\t\tdays.sort\n\tend"
] |
[
"0.77537197",
"0.7420683",
"0.74012536",
"0.7281791",
"0.72262144",
"0.7198446",
"0.71598256",
"0.6956908",
"0.69431067",
"0.6935232",
"0.69343877",
"0.6900047",
"0.68958485",
"0.6879493",
"0.68667895",
"0.68548983",
"0.6835317",
"0.6833143",
"0.68035907",
"0.6799005",
"0.6780741",
"0.67721546",
"0.67537737",
"0.67418957",
"0.67229605",
"0.6711583",
"0.6706332",
"0.6694999",
"0.66705537",
"0.66396654",
"0.6629006",
"0.66251147",
"0.660752",
"0.657619",
"0.6574781",
"0.6550846",
"0.6544801",
"0.65313643",
"0.65229553",
"0.6520539",
"0.6517621",
"0.6483",
"0.64827085",
"0.64728534",
"0.64550173",
"0.64355075",
"0.6409812",
"0.63878167",
"0.638361",
"0.63739264",
"0.6356546",
"0.6339862",
"0.63298374",
"0.6320488",
"0.63174117",
"0.63139606",
"0.6284955",
"0.62806267",
"0.6262601",
"0.6183943",
"0.6180666",
"0.6106002",
"0.61033165",
"0.60887253",
"0.60863936",
"0.60757345",
"0.6061605",
"0.60562646",
"0.6046803",
"0.6028948",
"0.59975874",
"0.59666616",
"0.59580755",
"0.5953639",
"0.5948801",
"0.59344745",
"0.5929985",
"0.59036165",
"0.59028757",
"0.5863758",
"0.58594",
"0.58183086",
"0.5802636",
"0.5742949",
"0.57369804",
"0.5727269",
"0.5715168",
"0.57009125",
"0.5678938",
"0.5656622",
"0.5626285",
"0.5624937",
"0.56200016",
"0.5617754",
"0.55724156",
"0.5570137",
"0.5565114",
"0.5533138",
"0.55211794",
"0.5519812"
] |
0.63693416
|
50
|
GET /candidates GET /candidates.json
|
def index
@candidates = Candidate.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @candidates = Candidate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @candidates }\n end\n end",
"def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end",
"def index\n if Candidate.count == 0\n source = 'https://geekhunter-recruiting.s3.amazonaws.com/code_challenge.json'\n resp = Net::HTTP.get_response(URI.parse(source))\n data = resp.body\n result = JSON.parse(data)\n result[\"candidates\"].each do |c|\n technologies = []\n c[\"technologies\"].each do |tech|\n technologies.push({ name: tech[\"name\"], is_main_tech: tech[\"is_main_tech\"] })\n end\n candidate = Candidate.new({ city: c[\"city\"], experience: c[\"experience\"], technologies: technologies })\n # if Candidate.find_by_cpf(c[\"cpf\"]).nil?\n # candidate.save\n # end\n candidate.save\n end\n end\n @candidates = Candidate.all\n end",
"def index\n @candidates = Candidate.where(user_id: current_user.id)\n end",
"def show\n @candidate = Candidate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @candidate }\n end\n end",
"def index\n @candidates = Candidate.limit(100)\n end",
"def index\n @candidates = Usernew.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usernew }\n end\n end",
"def show\n @candidate_app = CandidateApp.where(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @candidate_app }\n end\n end",
"def new\n @candidate = Candidate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @candidate }\n end\n end",
"def create\n @candidate = current_user.candidates.new(candidate_params)\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @group = @authorized_group\n @candidates = @group.candidates\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @candidates }\n end\n end",
"def index\n @candidate_details = CandidateDetail.all\n end",
"def index\n @candidatedetails = Candidatedetail.all\n end",
"def index\n # @candidates = Candidate.all\n @candidates = Position.find(params[:position_id]).candidates\n end",
"def index\n @candidates=Candidate.all.order(:id)\n end",
"def index\n @candidate_references = @candidate.references\n end",
"def new\n @candidate_app = CandidateApp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @candidate_app }\n end\n end",
"def index\n @votes = @proposal.votes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @votes }\n end\n end",
"def index\n @candidate_course_scores = @candidate.course_scores\n end",
"def index\n candidate = UspsInPersonProofing::Applicant.new(\n address: search_params['street_address'],\n city: search_params['city'], state: search_params['state'],\n zip_code: search_params['zip_code']\n )\n response = proofer.request_facilities(candidate)\n if response.length > 0\n analytics.idv_in_person_locations_searched(\n success: true,\n result_total: response.length,\n )\n else\n analytics.idv_in_person_locations_searched(\n success: false, errors: 'No USPS locations found',\n )\n end\n render json: response.to_json\n end",
"def index\n @election = Election.find(params[:election_id])\n @races = @election.races\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @races }\n end\n end",
"def friend_search()\n users = User.all.map {|u| u.email }.concat( Candidate.all.map {|u| u.email } )\n render :json => users\n end",
"def index\n @vote_candidates = VoteCandidate.all\n authorize VoteCandidate\n end",
"def get_candidate(username)\n candidate = @database.get_item(\n table_name: candidates_table_name,\n key: { \"username\" => username },\n consistent_read: true\n )[:item]\n\n candidate['votes'] = candidate['votes'].to_i if candidate\n candidate\n end",
"def create\n @result = Result.new()\n\n @result.ip_address = request.remote_ip\n\n unless params[:candidates_ids].nil?\n if params[:candidates_ids].count.eql?(NUMBER_OF_CANDIDATES)\n params[:candidates_ids].each do |candidate_id|\n @result.candidates << Candidate.find(candidate_id)\n end\n end\n end\n\n respond_to { |format|\n if params[:candidates_ids].nil? ? false : params[:candidates_ids].count.eql?(NUMBER_OF_CANDIDATES)\n if @result.save\n format.html { redirect_to(results_path, :notice => \"Thanks for your vote\") }\n format.xml { render :xml => @result, :status => :created, :location => @result }\n cookies[:vote] = {:value => 'sent', :expires => 3.days.from_now}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @result.errors, :status => :unprocessable_entity }\n end\n else\n format.html {\n flash[:alert] = \"You should choose \" + NUMBER_OF_CANDIDATES.to_s + \" candidates\"\n redirect_to (new_result_path)\n }\n end }\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n @candidate.vacancies.each { |vacancy| CandidateMailer.thanks(@candidate, vacancy).deliver_now }\n format.json { render :show, status: :created, location: api_candidate_path(@candidate) }\n else\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_candidates\n\t$cand_table.each do |x|\n\t\tputs \"Give me a candidate name:\"\n\t\tx[0] = gets.chomp\n\tend\nend",
"def get_candidates(consistent_read)\n candidates = []\n params = {\n table_name: candidates_table_name,\n consistent_read: consistent_read\n }\n\n loop do\n result = @database.scan(params)\n\n # Convert votes to an integer and add the candidate to the candidates array.\n result.items.each do |candidate|\n candidate['votes'] = candidate['votes'].to_i\n candidate['contributions'] = candidate['contributions'].to_i\n candidates << candidate\n end\n\n break if result.last_evaluated_key.nil?\n\n params[:exclusive_start_key] = result.last_evaluated_key\n end\n\n candidates\n end",
"def set_candidate\n @candidate = Candidate.includes(:user, :resume).find(params[:id])\n end",
"def get_votes\n\t\t@voters.each{ |voter| @votes << voter.vote(@candidates) }\n\tend",
"def index\n @candidate_experiences = @candidate.experiences\n end",
"def create\n @candidate = Candidate.new(params[:candidate])\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render json: @candidate, status: :created, location: @candidate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n case params[:eligible_for]\n when 'collaboration'\n @collaborators = eligible_collaborators.limit(20)\n when 'ownership'\n @collaborators = eligible_owners.limit(20)\n else\n @collaborators = User.none\n end\n\n if params[:q]\n @collaborators = @collaborators.search(params[:q])\n end\n\n respond_to do |format|\n format.json\n end\n end",
"def index\n @choices = Choice.all\n\n render json: @choices\n end",
"def find(id)\nraise \"candidates must be an Array\" if @candidates.nil?\n @candidates.each do |candidate|\n return candidate if candidate[:id] == id\n end\n nil\nend",
"def index\n @challenges = Challenge.user(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def map_current_candidates\n\t\tobj = Candidate.all\n\t\tobj.map { |i| {i.id => i.name} }\n\tend",
"def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners }\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n @candidate.user_id = current_user.id\n\n respond_to do |format|\n if @candidate.save\n flash[:notice] = 'Candidate was successfully created.'\n format.html { redirect_to home_candidate_path(@candidate) }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def candidate\n @candidate\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: \"Candidate was successfully created.\" }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def open_job_candidates\n authorize(JobCandidate.new)\n if active_job_candidate_list.present?\n @open_job_candidates = active_job_candidate_list.includes(:job)\n .where(\"job_candidates.status in (?)\",\n JobCandidate.statuses_opened)\n .page(params[:page])\n end\n end",
"def candidates\n players.map(&:candidate).compact\n end",
"def parse_to_candidate(resume_text)\n path = \"resume/parseToCandidateViaJson?format=text\"\n encodedResume = {\"resume\" => resume_text}.to_json\n res = conn.post path, encodedResume\n Hashie::Mash.new JSON.parse(res.body)\n end",
"def index\n @proposals = current_user.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proposals }\n end\n end",
"def candidate\n self['candidate']\n end",
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def index\n \n @page = params[:page]\n\n @candidates = Candidate.page(@page)\n #@users = User.order(:name).page 3\n # @count = Voter.where(candidate_id => @can)\n\n @voter_all = Voter.all.count\n\n\n end",
"def candidate_details candidate_email, qr: false\n params = init_params\n params[:qr] = qr\n request_url = UrlGenerator.url_for(\"candidates\", candidate_email)\n asgn = SignatureGenerator.signature_for(http_verb: 'GET', url: request_url, params: params)\n\n res = self.get(request_url, query: params.merge!({asgn: asgn}))\n if res[\"status\"] == \"SUCCESS\"\n return res\n else\n return error_response_for(res)\n end\n end",
"def get_candidate_list\n raise NoMethodError, 'get_candidate_list should be defined in subclass of HillClimb'\n end",
"def max_candidates\n return @max_candidates\n end",
"def set_candidate\n @candidate = Role::Candidate.includes(:person).find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def candidate_sheet\n @candidate = Candidate.find(params[:id])\n @resource = @candidate\n end",
"def show\n @grades=@section.grades\n @candidates=Candidate.all\n @user = User.find(current_user.id)\n\n if current_user.admin?\n @candidates = @section.candidates\n else\n @candidates = @section.candidates.where(user_id: current_user.id)\n end\n end",
"def qualified_candidates(candidates)\n begin\n @candidates.select do |candidate|\n experienced?(candidate) &&\n enough_points?(candidate) &&\n proper_languages?(candidate) &&\n applied_recently?(candidate) &&\n old_enough?(candidate)\n end\n rescue CandidateError => ex\n puts \"There was an error in finding qualified candidates. The reason was #{ex.message}\"\n end\nend",
"def index\n @citations = Citation.all\n\n render json: @citations\n end",
"def find(id)\n raise '@candidates must be an array!' if @candidates.nil?\n candidate = @candidates.select { |candidate| candidate[:id] == id }\n\nend",
"def show\n @leader = Leader.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leader }\n end\n end",
"def index\n @elections = Election.all\n end",
"def find(id)\n @candidates.find {|h| h[:id] == id}\nend",
"def create\n @candidate = Candidate.new(permitted_attributes Candidate.new)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: \"Candidate was successfully created.\" }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @proposals = Proposal.all\n\n render json: @proposals\n end",
"def show\n @compromise = Compromise.find(params[:id])\n\n render json: @compromise\n end",
"def show\n @compromise = Compromise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @compromise }\n end\n end",
"def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @challenges }\n end\n end",
"def index\n @proposals = listing.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proposals }\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to user_election_position_candidates_path, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_prefectures\n server_response = handle_timeouts do\n get '/1/neighborhoods.json?locale=en'\n end\n server_response['response']\n end",
"def withdrawn_job_candidates\n authorize(JobCandidate.new)\n if active_job_candidate_list.present?\n @withdrawn_job_candidates = active_job_candidate_list.includes(:job)\n .where(status: JobCandidate.statuses[\"withdrawn\"])\n .page(params[:page])\n end\n end",
"def print_candidates(candidates)\n puts \"----- Starting search -----\"\n if candidates.empty?\n puts \"Couldn't find candidate. Are you sure that's a proper ID integer?\"\n else\n begin\n candidates.each do |candidate|\n candidate.each do |key, value|\n string = @qualified_array.include?(candidate) ? \"#{key} : #{value}\".green : \"#{key} : #{value}\".red\n puts string\n end\n puts \"-----------\"\n end\n rescue\n puts \"There is an error in your database. Certain candidates do not exist.\"\n end\n end\nend",
"def available_collaborators\n input = available_collaborators_input\n return unauthorized unless available_collaborators_auth(input)\n student_id = current_visitor.portal_student.id\n clazz = Portal::Offering.find(input[:offering_id]).clazz\n collaborators = clazz.students.select { |s| s.id != student_id }.map { |s| {:id => s.id, :name => s.name} }\n render json: collaborators\n end",
"def set_candidates(pv)\n @candidates = pv\n @value = @initial_value\n end",
"def find(id)\n @candidates.select{|candidate| candidate[:id] === id }\n #return @candidates\n\nend",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n nil\nend",
"def candidate_matches_list\n Candidate.includes(:candidate_profile).where('candidates.archetype_score >= ?\n and candidates.archetype_score <= ?',\n self.archetype_low,\n self.archetype_high)\n .joins(:candidate_profile)\n .where('candidate_profiles.is_incognito=false')\n .order(id: :asc)\n end",
"def index\n @collaborators = User\n .includes(:chef_account)\n .where.not(id: params[:ineligible_user_ids])\n .limit(20)\n\n if params[:q]\n @collaborators = @collaborators.search(params[:q])\n end\n\n respond_to do |format|\n format.json\n end\n end",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def index\n @challenges = Challenge.order(:id)\n .includes(:user)\n .page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def validate_candidates(candidates)\n uniq_candidates = []\n candidates.each do |candidate|\n if (uid_exists?(\"candidate\", canid = candidate[\"ident\"].to_s))\n if (uniq_candidates.include?(candidate))\n val_warn(\"Duplicate Candidate Declaration\", canid, \"in Election Definition\")\n else\n val_err(\"Non-Unique Candidate UID\", canid, \"in Election Definition\")\n end\n else\n uniq_candidates.push(candidate)\n uid_add(\"candidate\", canid)\n end\n end\n candidates.each do |candidate|\n canid = candidate[\"ident\"].to_s\n conid = candidate[\"contest_ident\"].to_s\n if (uid_exists?(\"contest\", conid))\n self.counts_contests[conid][\"candidate_count_list\"].\n push({\"candidate_ident\"=>canid, \"count\"=>0})\n else \n val_err(\"Non-Existent Contest UID\", conid, \"for Candidate UID\", canid, \"in Election Definition\")\n end\n end\n end",
"def index\n @people = search Person.involved_in(@conference)\n\n respond_to do |format|\n format.html { @people = @people.paginate page: page_param }\n format.json\n end\n end",
"def find(id)\n raise '@candidates must be an array' if @candidates.nil?\n @candidates.detect {|candidate| candidate[:id] == id}\n\nend",
"def candidate\n candidates.first\n end",
"def find(id)\n # binding.pry\n raise '@candidates must be an Array' if @candidates.nil?\n candidate.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end"
] |
[
"0.7828381",
"0.73522097",
"0.72219783",
"0.6928002",
"0.6899774",
"0.6775134",
"0.67688996",
"0.6342606",
"0.6194655",
"0.6079805",
"0.6058217",
"0.60146403",
"0.596775",
"0.5949632",
"0.5942194",
"0.59386665",
"0.5871397",
"0.58210623",
"0.5799082",
"0.57743657",
"0.57622945",
"0.57514733",
"0.56375146",
"0.5632453",
"0.5604177",
"0.55864686",
"0.55673444",
"0.55637956",
"0.5554515",
"0.55472285",
"0.55420184",
"0.5533445",
"0.5525548",
"0.5514009",
"0.55139095",
"0.5506843",
"0.55026436",
"0.55004233",
"0.54912883",
"0.54912883",
"0.54912883",
"0.54912883",
"0.54869276",
"0.5450752",
"0.5450076",
"0.54493606",
"0.5443225",
"0.54279304",
"0.5404538",
"0.54033834",
"0.53980786",
"0.53975403",
"0.53958035",
"0.5391857",
"0.53909457",
"0.53814286",
"0.537766",
"0.537766",
"0.5376075",
"0.5369325",
"0.5365402",
"0.5362923",
"0.53553605",
"0.535234",
"0.53487885",
"0.5346243",
"0.5340467",
"0.53278494",
"0.532728",
"0.53255934",
"0.5322779",
"0.5315783",
"0.5314964",
"0.5310257",
"0.5309812",
"0.5308351",
"0.5303099",
"0.5301258",
"0.52998286",
"0.5294884",
"0.5286069",
"0.5282022",
"0.5263667",
"0.52589417",
"0.5258092",
"0.52521974",
"0.5251969",
"0.5249487",
"0.5247106",
"0.52466",
"0.52466",
"0.52466",
"0.52466",
"0.52466",
"0.52466",
"0.52466"
] |
0.73016286
|
6
|
GET /candidates/1 GET /candidates/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @candidates = Candidate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @candidates }\n end\n end",
"def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end",
"def show\n @candidate = Candidate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @candidate }\n end\n end",
"def index\n if Candidate.count == 0\n source = 'https://geekhunter-recruiting.s3.amazonaws.com/code_challenge.json'\n resp = Net::HTTP.get_response(URI.parse(source))\n data = resp.body\n result = JSON.parse(data)\n result[\"candidates\"].each do |c|\n technologies = []\n c[\"technologies\"].each do |tech|\n technologies.push({ name: tech[\"name\"], is_main_tech: tech[\"is_main_tech\"] })\n end\n candidate = Candidate.new({ city: c[\"city\"], experience: c[\"experience\"], technologies: technologies })\n # if Candidate.find_by_cpf(c[\"cpf\"]).nil?\n # candidate.save\n # end\n candidate.save\n end\n end\n @candidates = Candidate.all\n end",
"def index\n @candidates = Candidate.all\n end",
"def index\n @candidates = Candidate.all\n end",
"def index\n @candidates = Candidate.all\n end",
"def index\n @candidates = Candidate.all\n end",
"def index\n @candidates = Candidate.all\n end",
"def index\n @candidates = Candidate.where(user_id: current_user.id)\n end",
"def index\n @candidates = Usernew.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usernew }\n end\n end",
"def index\n @candidates = Candidate.limit(100)\n end",
"def show\n @candidate_app = CandidateApp.where(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @candidate_app }\n end\n end",
"def new\n @candidate = Candidate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @candidate }\n end\n end",
"def create\n @candidate = current_user.candidates.new(candidate_params)\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def candidate\n candidates.first\n end",
"def index\n @candidate_details = CandidateDetail.all\n end",
"def new\n @candidate_app = CandidateApp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @candidate_app }\n end\n end",
"def index\n @candidates=Candidate.all.order(:id)\n end",
"def get_candidate(username)\n candidate = @database.get_item(\n table_name: candidates_table_name,\n key: { \"username\" => username },\n consistent_read: true\n )[:item]\n\n candidate['votes'] = candidate['votes'].to_i if candidate\n candidate\n end",
"def index\n @candidatedetails = Candidatedetail.all\n end",
"def index\n @group = @authorized_group\n @candidates = @group.candidates\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @candidates }\n end\n end",
"def set_candidate\n @candidate = Candidate.includes(:user, :resume).find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def index\n @votes = @proposal.votes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @votes }\n end\n end",
"def index\n # @candidates = Candidate.all\n @candidates = Position.find(params[:position_id]).candidates\n end",
"def index\n @candidate_references = @candidate.references\n end",
"def find(id)\nraise \"candidates must be an Array\" if @candidates.nil?\n @candidates.each do |candidate|\n return candidate if candidate[:id] == id\n end\n nil\nend",
"def candidate\n @candidate\n end",
"def candidate\n self['candidate']\n end",
"def create\n @result = Result.new()\n\n @result.ip_address = request.remote_ip\n\n unless params[:candidates_ids].nil?\n if params[:candidates_ids].count.eql?(NUMBER_OF_CANDIDATES)\n params[:candidates_ids].each do |candidate_id|\n @result.candidates << Candidate.find(candidate_id)\n end\n end\n end\n\n respond_to { |format|\n if params[:candidates_ids].nil? ? false : params[:candidates_ids].count.eql?(NUMBER_OF_CANDIDATES)\n if @result.save\n format.html { redirect_to(results_path, :notice => \"Thanks for your vote\") }\n format.xml { render :xml => @result, :status => :created, :location => @result }\n cookies[:vote] = {:value => 'sent', :expires => 3.days.from_now}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @result.errors, :status => :unprocessable_entity }\n end\n else\n format.html {\n flash[:alert] = \"You should choose \" + NUMBER_OF_CANDIDATES.to_s + \" candidates\"\n redirect_to (new_result_path)\n }\n end }\n end",
"def create\n @candidate = Candidate.new(params[:candidate])\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render json: @candidate, status: :created, location: @candidate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_candidate\n @candidate = Role::Candidate.includes(:person).find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n nil\nend",
"def find(id)\n @candidates.find {|h| h[:id] == id}\nend",
"def show\n @leader = Leader.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leader }\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n @candidate.user_id = current_user.id\n\n respond_to do |format|\n if @candidate.save\n flash[:notice] = 'Candidate was successfully created.'\n format.html { redirect_to home_candidate_path(@candidate) }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @candidate_course_scores = @candidate.course_scores\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @election = Election.find(params[:election_id])\n @races = @election.races\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @races }\n end\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if id == candidate[:id]\n return candidate\n end\n end\n\n nil\nend",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n \t@election = Candidate.find(params[:id])\n end",
"def find(id)\n # binding.pry\n raise '@candidates must be an Array' if @candidates.nil?\n candidate.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n @candidate.vacancies.each { |vacancy| CandidateMailer.thanks(@candidate, vacancy).deliver_now }\n format.json { render :show, status: :created, location: api_candidate_path(@candidate) }\n else\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: \"Candidate was successfully created.\" }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_candidates\n\t$cand_table.each do |x|\n\t\tputs \"Give me a candidate name:\"\n\t\tx[0] = gets.chomp\n\tend\nend",
"def christian_ministry\n @candidate = Candidate.find(params[:id])\n @resource = @candidate\n end",
"def show\n @compromise = Compromise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @compromise }\n end\n end",
"def show\n @compromise = Compromise.find(params[:id])\n\n render json: @compromise\n end",
"def candidate_sheet\n @candidate = Candidate.find(params[:id])\n @resource = @candidate\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n \tif candidate[:id] == id\n \t return candidate\n \tend\n end\n return nil\nend",
"def find(id)\n raise '@candidates must be an array!' if @candidates.nil?\n candidate = @candidates.select { |candidate| candidate[:id] == id }\n\nend",
"def find(id)\n\traise '@candidates must be an Array' if @candidates.nil?\n\t@candidates.each do |x|\n\t\tif x[:id] == id\n\t\t\treturn x\n\t\tend\n\tend\n\tputs \"Candidate not found\"\n\tnil\nend",
"def find(id)\n @candidates.each do | candidate |\n if candidate[:id] == id\n return candidate \n end\n end\nend",
"def index\n candidate = UspsInPersonProofing::Applicant.new(\n address: search_params['street_address'],\n city: search_params['city'], state: search_params['state'],\n zip_code: search_params['zip_code']\n )\n response = proofer.request_facilities(candidate)\n if response.length > 0\n analytics.idv_in_person_locations_searched(\n success: true,\n result_total: response.length,\n )\n else\n analytics.idv_in_person_locations_searched(\n success: false, errors: 'No USPS locations found',\n )\n end\n render json: response.to_json\n end",
"def find(id)\n # takes single candidate as id :\n @candidates.each do | candidate |\n if candidate[:id] == id \n\n return candidate\n else \n nil\n end\n end\nend",
"def find(id)\n puts id\n @candidates.each do |candidate|\n if candidate[:id] == id \n return candidate\n end\n end\n puts \"No candidate found with that ID\"\n return nil\nend",
"def show\n @collaborator = Collaborator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @collaborator }\n end\n end",
"def find(id)\n @candidates.each do |candidate|\n if id == candidate[:id]\n candidate\n end\n end\n nil\nend",
"def create\n @candidate = Candidate.new(candidate_params)\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to user_election_position_candidates_path, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def find(id)\n raise '@candidates must be an array' if @candidates.nil?\n @candidates.detect {|candidate| candidate[:id] == id}\n\nend",
"def find(id)\n raise '@candidates must be an Array' if @candidates.nil?\n @candidates.detect {|candidate| candidate[:id] == id}\nend",
"def set_candidate_detail\n @candidate_detail = CandidateDetail.find(params[:id])\n end",
"def set_candidatedetail\n @candidatedetail = Candidatedetail.find(params[:id])\n end",
"def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id]==id\n end\n nil\nend",
"def create\n @candidate = Candidate.new(permitted_attributes Candidate.new)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: \"Candidate was successfully created.\" }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @vote_candidates = VoteCandidate.all\n authorize VoteCandidate\n end",
"def show\n @proposal = Proposal.find(params[:id])\n\n @proposal.votes.each do |v|\n if v.user == current_user\n @vote = v\n end\n end\n if can? :vote, @proposal\n if @vote.nil?\n @vote = @proposal.votes.new\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @proposal }\n end\n end",
"def show\n @election_type = ElectionType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @election_type }\n end\n end",
"def find(id)\n @candidates.select{|candidate| candidate[:id] === id }\n #return @candidates\n\nend",
"def show\n @candidate_revision = CandidateRevision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @candidate_revision }\n end\n end",
"def find(id)\n @candidates.each do |candidate|\n if id == candidate[:id] \n return candidate\n end\nend\n\n nil\nend",
"def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to candidates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to candidates_url }\n format.json { head :no_content }\n end\n end",
"def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end",
"def find(id)\n @candidates.each do |candidate|\n return candidate if id == candidate[:id]\n end\n nil\nend",
"def parse_to_candidate(resume_text)\n path = \"resume/parseToCandidateViaJson?format=text\"\n encodedResume = {\"resume\" => resume_text}.to_json\n res = conn.post path, encodedResume\n Hashie::Mash.new JSON.parse(res.body)\n end",
"def index\n @candidate_experiences = @candidate.experiences\n end",
"def find(id)\n # Your code Here\n # puts \"you are looking for id: #{id}\"\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n return nil\nend",
"def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id] == id\n end\n return nil\nend",
"def set_candidate\n @candidate = params[:id] ? Candidate.find(params[:id]) : Candidate.new(candidate_params)\n end",
"def index\n @challenges = Challenge.user(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end"
] |
[
"0.7576062",
"0.719828",
"0.71253955",
"0.71249306",
"0.7115344",
"0.7115344",
"0.7115344",
"0.7115344",
"0.7115344",
"0.674099",
"0.66213965",
"0.6574931",
"0.64875436",
"0.64646935",
"0.61951876",
"0.60203767",
"0.60195625",
"0.601726",
"0.597598",
"0.5966151",
"0.5957981",
"0.59057134",
"0.5888962",
"0.5872949",
"0.5872949",
"0.5871664",
"0.58550066",
"0.58291864",
"0.5802034",
"0.57788444",
"0.57753307",
"0.574274",
"0.5740406",
"0.57202876",
"0.5716884",
"0.5716884",
"0.5716884",
"0.5716884",
"0.5716884",
"0.5716884",
"0.5716884",
"0.5716884",
"0.5716884",
"0.5716884",
"0.5716884",
"0.5716884",
"0.57168067",
"0.5691619",
"0.5691062",
"0.5682975",
"0.5677133",
"0.5674125",
"0.5674125",
"0.5674125",
"0.5674125",
"0.5659494",
"0.5659045",
"0.5654043",
"0.5653378",
"0.56428164",
"0.5640857",
"0.5629934",
"0.5610297",
"0.56023365",
"0.5596037",
"0.5586712",
"0.55819786",
"0.557528",
"0.5563801",
"0.5553614",
"0.5531334",
"0.55279124",
"0.55247176",
"0.5517982",
"0.5509199",
"0.5502619",
"0.55022657",
"0.54815125",
"0.5478599",
"0.54778266",
"0.5470946",
"0.5467161",
"0.54659164",
"0.54591763",
"0.5452584",
"0.54521155",
"0.5447546",
"0.5442897",
"0.54399157",
"0.54374355",
"0.54374355",
"0.54362386",
"0.54362386",
"0.54362386",
"0.5428082",
"0.54231685",
"0.5418373",
"0.5415696",
"0.540279",
"0.5400775",
"0.5400075"
] |
0.0
|
-1
|
POST /candidates POST /candidates.json
|
def create
@candidate = Candidate.new(candidate_params)
if @candidate.resume.resume_data.nil?
@candidate.resume = nil
else
@candidate.resume.file_name, @candidate.resume.content_type, @candidate.resume.resume_data = extract_file(@candidate.resume.resume_data)
end
if current_user.role == 'candidate'
@candidate.user = current_user
else
@candidate.user = User.new do
first_name = @candidate.first_name,
last_name = @candidate.last_name,
email = @candidate.email
end
end
if @candidate.save
redirect_to (current_user.role == 'candidate' ? root_path : @candidate), notice: 'Candidate was successfully created.'
else
render :new
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @candidate = current_user.candidates.new(candidate_params)\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(params[:candidate])\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render json: @candidate, status: :created, location: @candidate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n @candidate.vacancies.each { |vacancy| CandidateMailer.thanks(@candidate, vacancy).deliver_now }\n format.json { render :show, status: :created, location: api_candidate_path(@candidate) }\n else\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: \"Candidate was successfully created.\" }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(permitted_attributes Candidate.new)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: \"Candidate was successfully created.\" }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n if Candidate.count == 0\n source = 'https://geekhunter-recruiting.s3.amazonaws.com/code_challenge.json'\n resp = Net::HTTP.get_response(URI.parse(source))\n data = resp.body\n result = JSON.parse(data)\n result[\"candidates\"].each do |c|\n technologies = []\n c[\"technologies\"].each do |tech|\n technologies.push({ name: tech[\"name\"], is_main_tech: tech[\"is_main_tech\"] })\n end\n candidate = Candidate.new({ city: c[\"city\"], experience: c[\"experience\"], technologies: technologies })\n # if Candidate.find_by_cpf(c[\"cpf\"]).nil?\n # candidate.save\n # end\n candidate.save\n end\n end\n @candidates = Candidate.all\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to user_election_position_candidates_path, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n @candidate.user_id = current_user.id\n\n respond_to do |format|\n if @candidate.save\n flash[:notice] = 'Candidate was successfully created.'\n format.html { redirect_to home_candidate_path(@candidate) }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @result = Result.new()\n\n @result.ip_address = request.remote_ip\n\n unless params[:candidates_ids].nil?\n if params[:candidates_ids].count.eql?(NUMBER_OF_CANDIDATES)\n params[:candidates_ids].each do |candidate_id|\n @result.candidates << Candidate.find(candidate_id)\n end\n end\n end\n\n respond_to { |format|\n if params[:candidates_ids].nil? ? false : params[:candidates_ids].count.eql?(NUMBER_OF_CANDIDATES)\n if @result.save\n format.html { redirect_to(results_path, :notice => \"Thanks for your vote\") }\n format.xml { render :xml => @result, :status => :created, :location => @result }\n cookies[:vote] = {:value => 'sent', :expires => 3.days.from_now}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @result.errors, :status => :unprocessable_entity }\n end\n else\n format.html {\n flash[:alert] = \"You should choose \" + NUMBER_OF_CANDIDATES.to_s + \" candidates\"\n redirect_to (new_result_path)\n }\n end }\n end",
"def index\n @candidates = Candidate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @candidates }\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n unless check_elector\n return\n end\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Your profile was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n #redirect_to new_candidate_path, notice: 'Candidate was successfully created.'\n end",
"def create\n @candidate = Candidate.new(params[:candidate])\n\n if @candidate.save\n redirect_to admin_candidates_path, notice: 'Candidate was successfully created.'\n else\n render action: \"new\"\n end\n end",
"def new\n @candidate = Candidate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @candidate }\n end\n end",
"def index\n @candidates = Usernew.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usernew }\n end\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n set_questionnaire\n format.html { render partial: 'show', status: :created, locals: { candidate: @candidate } }\n else\n format.html { redirect_to candidates_url, alert: @candidate.errors.full_messages.first }\n end\n end\n end",
"def create\n @candidate = Candidate.new(params[:candidate])\n respond_to do |format|\n if @candidate.save\n session[:candidate_id]=@candidate.id\n TestQuestion.generate_candidate_questions(@candidate.id,session[:test_id])\n Result.generate_result(@candidate.id,session[:test_id])\n flash[:notice]='Successfully entered the Test!'\n format.html { redirect_to instructions_path }\n else\n format.html { render action: \"new\" }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @candidates = Candidate.all\n end",
"def index\n @candidates = Candidate.all\n end",
"def index\n @candidates = Candidate.all\n end",
"def index\n @candidates = Candidate.all\n end",
"def index\n @candidates = Candidate.all\n end",
"def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end",
"def create\n @vote_candidate = VoteCandidate.new(vote_candidate_params)\n authorize @vote_candidate\n\n respond_to do |format|\n if @vote_candidate.save\n format.html { redirect_to @vote_candidate, notice: 'Vote candidate was successfully created.' }\n format.json { render :show, status: :created, location: @vote_candidate }\n else\n format.html { render :new }\n format.json { render json: @vote_candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidatedetail = Candidatedetail.new(candidatedetail_params)\n\n respond_to do |format|\n if @candidatedetail.save\n format.html { redirect_to candidateentry_url, notice: 'Candidatedetail was successfully created.' }\n format.json { render :show, status: :created, location: @candidatedetail }\n else\n format.html { render :new }\n format.json { render json: @candidatedetail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def candidate_params\n params.require(:candidate)\n .permit(%i(first_name last_name gender date_of_birth place_of_birth\n date notes education_subject year police_certificate internships cancel_date\n internships_proved education_contract_sent education_contract_received\n internship_contract_sent internship_contract_received cancel_reason status\n debit_mandate contract_notes career_changer rank) +\n [\n address: %i(street zip city),\n contact: %i(email phone mobile),\n school_graduate: %i(graduate proved),\n profession_graduate: %i(graduate proved comments),\n interview: %i(date time place comments invited answer result reason),\n ])\n end",
"def candidate_params\n params.fetch(:candidate, {}).permit(:name, :biography, :position_id, :id)\n\n end",
"def candidate_params\n params.require(:candidate).permit(:name, :email)\n end",
"def create\n @group = Group.find(params[:group_id])\n @candidate = @group.candidates.build(params[:candidate])\n if @candidate.save\n redirect_to group_candidates_url(@group)\n else\n render :action => \"new\"\n end\n end",
"def create\n @candidate_reference = @candidate.references.build(candidate_reference_params)\n\n respond_to do |format|\n if @candidate_reference.save\n flash[:success] = 'Reference was successfully created.' \n format.html { redirect_to edit_candidate_references_path(params[:candidate_id])}\n format.json { render :show, status: :created, location: @candidate_reference }\n else\n flash[:failure] = 'Reference creation unsuccessful.' \n format.html { redirect_to edit_candidate_references_path(params[:candidate_id]) }\n format.json { render json: @candidate_reference.errors, status: :unprocessable_entity }\n end\n end\n end",
"def candidate_params\n params.require(:candidate).permit(:name, :avatar)\n end",
"def create\n @candidate_detail = @candidate.candidate_details.new(candidate_detail_params)\n\n respond_to do |format|\n if @candidate_detail.save\n format.html { redirect_to candidate_candidate_detail_path(@candidate,@candidate_detail), notice: 'Candidate detail was successfully created.' }\n format.json { render :show, status: :created, location: @candidate_detail }\n else\n format.html { render :new }\n format.json { render json: @candidate_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n $SEARCHES.push({\n \"query\" => params[:query],\n \"candidate_ids\" => nil,\n \"search_status\" => \"In progress\",\n \"get_candidate_status\" => \"Not Started\",\n \"candidate_details\" => nil\n })\n\n # We build our query using the Connect find_candidates schema.\n # We can stack as many filters as we like here, but for this example we\n # only show filtering by email address.\n query = JSON.generate(\n {'filters': [{'field': 'email', 'operator': '==', 'value': params[:query]}]}\n )\n \n # We can choose to either include a callback header with our\n # request, or to poll until the search is complete. Here\n # we use the callback functionality.\n uri = URI.parse(\"%s/v1/%s/find_candidates\" % [\n Rails.application.config.connect_url,\n Rails.application.config.connector['connector_id']\n ])\n\n search_id = $SEARCHES.length - 1\n callback_url = Rails.application.routes.url_for(\n controller: 'search_complete_callback', action: 'create', id: search_id)\n\n resp = ConnectHelper.request_to_connect(\n uri, Net::HTTP::Post, callback_url: callback_url, request_body: query)\n\n redirect_to '/'\n end",
"def candidate_params\n params.require(:candidate).permit(:name, :date_submitted)\n end",
"def validate_candidates(candidates)\n uniq_candidates = []\n candidates.each do |candidate|\n if (uid_exists?(\"candidate\", canid = candidate[\"ident\"].to_s))\n if (uniq_candidates.include?(candidate))\n val_warn(\"Duplicate Candidate Declaration\", canid, \"in Election Definition\")\n else\n val_err(\"Non-Unique Candidate UID\", canid, \"in Election Definition\")\n end\n else\n uniq_candidates.push(candidate)\n uid_add(\"candidate\", canid)\n end\n end\n candidates.each do |candidate|\n canid = candidate[\"ident\"].to_s\n conid = candidate[\"contest_ident\"].to_s\n if (uid_exists?(\"contest\", conid))\n self.counts_contests[conid][\"candidate_count_list\"].\n push({\"candidate_ident\"=>canid, \"count\"=>0})\n else \n val_err(\"Non-Existent Contest UID\", conid, \"for Candidate UID\", canid, \"in Election Definition\")\n end\n end\n end",
"def create\n @election = Election.new(election_params)\n\n respond_to do |format|\n if @election.save\n format.html { redirect_to @election, notice: \"Election was successfully created.\" }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def candidate_params\n params.require(:candidate).permit( :name , :bios , :url_image , :category_id , :selection_process_id , :avatar_file )\n end",
"def vote_candidate_params\n params.require(:vote_candidate).permit(:candidate_id, :vote_id)\n end",
"def candidate_params\n params.require(:candidate).permit(:city, :experience)\n end",
"def create\n @candidate = Candidate.new(candidate_params)\n user_session[:category_id] = @candidate.category_id\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate , notice: 'Candidato creado correctamente.' }\n format.json { render 'show', status: :created , location: @candidate }\n else\n format.html { render 'new' }\n format.json { render json: @candidate.errors , status: :unprocessable_entity }\n end\n end\n end",
"def new\n @candidate_app = CandidateApp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @candidate_app }\n end\n end",
"def candidate_params\n params.require(:candidate).permit(:first_name, :last_name, :preferred_name, :email_address, :phone_number)\n end",
"def create\n @election = Election.new(election_params)\n\n respond_to do |format|\n if @election.save\n format.html { redirect_to @election, notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @election = Election.new(election_params)\n\n respond_to do |format|\n if @election.save\n format.html { redirect_to @election, notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_candidate_set(name,candidates)\n result = @candidate_set_factory.new\n result.add(name,candidates) unless candidates.empty?\n result\n end",
"def candidate_params\n params.require(:candidate).permit(:name, :plan, :loaction, :image)\n end",
"def create_candidate_set(name,candidates)\n result = @candidate_set_factory.new\n result.add(name,candidates) unless candidates.empty?\n result\n end",
"def candidate_params\n params.require(:candidate).permit(:name, :published, :description, :constituency, \n :avatar, :avatar_cache, :remove_avatar,\n :image, :image_cache, :remove_image, \n :help_image, :help_image_cache, :remove_help_image,\n :donate_image, :donate_image_cache, :remove_donate_image,\n :fb_link, :help_link, :donate_form, :job, :education, :experience,\n :year, :kind, :in_campaign)\n end",
"def candidate_params\n params.require(:candidate).permit(:area_id, :party_list_id, :name, :image, :district_list_id, :desc, :avatar, :x1, :x2, :x3, :x4, :x5, :x6, :x7, :x8, :x9, :x10, :x11, :x12, :x13, :x14, :x15,:cm_candidate)\n end",
"def candidate_params\n params.require(:candidate).permit(:genre, :legal_name, :avatar, :mailing_address, :country, :avatar_id, :postal_code, :cell_phone, :email, :date_of_grade, :university, :programs, :certifications, :degree, :languages, :salary_expectation, :area_of_interest, :job_type, :additional_information, :professional_presentation, :work_experience, :professional_reference, :personal_reference, :skills, :hobbies, :extracurricular_activities, :linkedin, :internships, :behavioral_assessment_id, :arrow_id)\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find_by id: params[:id]\n authorize @candidate\n end",
"def parse_to_candidate(resume_text)\n path = \"resume/parseToCandidateViaJson?format=text\"\n encodedResume = {\"resume\" => resume_text}.to_json\n res = conn.post path, encodedResume\n Hashie::Mash.new JSON.parse(res.body)\n end",
"def candidate_params\n \tparams.require(:candidate).permit(:first_name, :last_name, :party_id, :profile, parties_attributes: [:name])\n end",
"def candidate_params\n params.require(:candidate).permit(:user_id, :first_name, :last_name, :email, :phone, :desired_position, :current_company, :linked_in_url, :twitter_url, :git_hub_url, :portfolio_url, :website_url,\n resume_attributes:[:resume_data])\n end",
"def new\n @election = Election.find(params[:election_id])\n @race = @election.races.build\n @race.race_candidates.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @race }\n end\n end",
"def create_from_candidates\n authorize @competition.competitors.new\n\n heat = params[:heat].to_i\n competitors = params[:competitors]\n begin\n LaneAssignment.transaction do\n competitors.each do |_, competitor|\n reg = Registrant.find_by!(bib_number: competitor[:bib_number])\n lane_assignment = LaneAssignment.new(registrant_id: reg.id, lane: competitor[:lane].to_i, heat: heat, competition: @competition)\n lane_assignment.allow_competitor_auto_creation = true\n lane_assignment.save!\n end\n end\n flash[:notice] = \"Created Lane Assignments & Competitors\"\n rescue StandardError => e\n flash[:alert] = \"Error creating lane assignments/competitors #{e}\"\n end\n redirect_to competition_competitors_path(@competition)\n end",
"def candidate_params\n params.require(:candidate).permit(:name, :email, knowledges_attributes: [:item, :level])\n end",
"def index\n @candidates = Candidate.where(user_id: current_user.id)\n end",
"def candidate_params\n params.require(:candidate).permit(:name, :cellphone, :birth_date, :genre, :status, :regional_candidate, :country_code,\n :civil_status, :recruitment_source, :relocate, :actual_salary, :email,\n :variable_salary, :wage_aspiration, :position, :comparative_chart, :specific_benefit,\n :general_benefits, :general_comments, :address, :conditions_to_move, :telephone,\n :interview_date, :nationality, :actual_company, skills_attributes: [:id, :name, :_destroy],\n education_levels_attributes: [:id, :name, :_destroy], \n careers_attributes: [:id, :name, :_destroy], languages_attributes: [:id, :name, :_destroy],\n performance_areas_attributes: [:id, :name, :_destroy], industries_attributes: [:id, :name, :_destroy])\n end",
"def candidate_params\n params.require(:candidate).permit( :first_name,:last_name,:dob,:gender, :marital_status, :status,:languages,:summary)\n end",
"def create\n votes = params[:vote]\n voter = params[:voter_id]\n\n if votes\n votes.each do |k,v|\n @vote = Vote.new({:voter_id => voter,\n :position_id => v,\n :candidate_id => k })\n @vote.save\n end\n end\n\n\n redirect_to '/vote'\n\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",
"def vote_params\n params.permit(\n :election_id,\n :candidate_id \n )\n end",
"def create\n @candidate_course_score = @candidate.course_scores.build(candidate_course_score_params)\n\n respond_to do |format|\n if @candidate_course_score.save\n flash[:notice] = 'Course score was successfully created.'\n format.html { redirect_to candidate_course_score_path(course_score_path_params(@candidate_course_score)) }\n format.json { render :show, status: :created, location: @candidate_course_score }\n else\n format.html { render :new }\n format.json { render json: @candidate_course_score.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def index\n @candidates = Candidate.limit(100)\n end",
"def set_candidate\n \t@election = Candidate.find(params[:id])\n end",
"def show\n @candidate = Candidate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @candidate }\n end\n end",
"def set_candidate\n @candidate = params[:id] ? Candidate.find(params[:id]) : Candidate.new(candidate_params)\n end",
"def save_candidate_data\n raise('Captcha found.') if captcha?\n puts \"Saving candidate's information.\"\n candidates ||= []\n candidate_results = select_elements(:result_tiles)\n candidate_results.each do |candidate_elem|\n candidates.push(candidate_info(candidate_elem)) \\\n unless company?(candidate_elem)\n end\n fail('No data found.') if candidates.empty?\n end_section\n candidates\n end",
"def create\n # Create election from parameters\n @election = Election.new(params[:election])\n user_id = params[:election][:user_id]\n if user_id == \"\"\n flash[:error] = \"You may choose owner for election\"\n redirect_back_or_default(:action => 'new')\n return\n end\n @election.owner = ::User.find(user_id)#current_user\n\n faculty_id = params[:election][:faculty_id]\n # validate\n if faculty_id == \"\"\n flash[:error] = \"You may choose faculty for election\"\n redirect_back_or_default(:action => 'new')\n return\n end\n\n faculty_num = Faculty.find(@election.faculty_id).num\n\n # Get votes by faculty\n voters = Array.new\n voters = ::User.find_users_by_faculty(faculty_num)\n\n # Validates existence of voters\n if voters.empty?\n flash[:error] = \"The are no registered students on a faculty\"\n redirect_back_or_default(:action => 'new')\n return\n end\n\n # Create voting ballots\n ballots = Array.new\n voters.each do |voter|\n ballot = Ballot.new_from_params(voter, @election)\n ballots << ballot\n end\n\n # Save the records to the database\n begin\n Election.transaction do\n @election.save!\n ballots.each {|b| b.save!}\n end\n rescue Exception\n render :action => :new and return\n end\n\n flash[:notice] = \"Election created successfully\"\n redirect_to(object_url(@election))\n end",
"def set_candidates(pv)\n @candidates = pv\n @value = @initial_value\n end",
"def update\n respond_to do |format|\n if @candidate.update(permitted_attributes @candidate)\n format.html { redirect_to @candidate, notice: \"Candidate was successfully updated.\" }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @final_decision = FinalDecision.new(:user_id => session[:candidate], :interview_id => session[:interview_id], :decision => params[:decision])\n\n\n if @final_decision.save\n redirect_to organization_show_candidates_path\n else\n format.html { render action: 'new' }\n format.json { render json: @final_decision.errors, status: :unprocessable_entity }\n end\n\n end",
"def create\n\n reviews = []\n params[:scores].keys.each{ |name|\n score = params[:scores][name]\n peer_review = PeerReview.new(name:name, score:score, miniproject_id:params[:project][:id])\n peer_review.save\n reviews << peer_review\n }\n\n render json: reviews\n\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def create\n params[:interview][:scheduler_id] = current_user.id\n @interview = @candidate.interviews.new(params[:interview])\n params[:other_interviewers].split(\",\").each do |interviewer|\n @interview.interviewers.new({:user_id => interviewer})\n end\n respond_to do |format|\n if @interview.save\n format.html { redirect_to candidate_path(@candidate), notice: 'Interview was successfully created.' }\n format.js { render :index }\n format.json { render json: @interview, status: :created, location: @interview }\n else\n format.html { render action: \"new\" }\n format.js { render :index }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @alliance = find_alliance\n @candidate = Candidate.new(candidate_params).tap do |t|\n t.student_number = current_haka_user.student_number # sensitive\n t.electoral_alliance = @alliance # sensitive\n end\n\n if @candidate.save\n flash.notice = \"Ehdokasilmoittautuminen vastaanotettu!\"\n redirect_to registrations_candidate_path(@candidate.student_number)\n else\n flash.alert = \"Ehdokasilmoittautuminen ei onnistunut, koska lomakkeen tiedoissa oli virheitä.\"\n render :new\n end\n end",
"def candidate_params\n params.require(:user).permit(:first_name, :middle_name, :last_name, :email)\n end",
"def set_candidate\n @candidate = Candidate.includes(:user, :resume).find(params[:id])\n end",
"def create\n @election = Election.new(election_params)\n respond_to do |format|\n if @election.save\n @election.users << current_user #add the current user to the users for this election\n format.html { redirect_to user_elections_path, notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @election = Election.new(election_params)\n respond_to do |format|\n if @election.save\n format.html { redirect_to [:admin, @election], notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @election = Election.new\n @election.choices.build\n @election.choices.each do |choice|\n choice.election_id = @election.id\n end\n respond_with @election\n\tend",
"def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end"
] |
[
"0.73996586",
"0.69050306",
"0.6875307",
"0.6840989",
"0.6840989",
"0.6840989",
"0.6840989",
"0.68375486",
"0.68206316",
"0.6752525",
"0.67350394",
"0.6661347",
"0.6624552",
"0.65386087",
"0.64996314",
"0.64925003",
"0.6466578",
"0.6317362",
"0.63112783",
"0.6292041",
"0.62748843",
"0.6263035",
"0.6263035",
"0.6263035",
"0.6263035",
"0.6263035",
"0.6223629",
"0.6214525",
"0.60610753",
"0.6047276",
"0.59914696",
"0.59822476",
"0.5924303",
"0.59171975",
"0.59110427",
"0.5861408",
"0.58151865",
"0.58061594",
"0.58049303",
"0.5804285",
"0.57975453",
"0.5797129",
"0.5789055",
"0.57703304",
"0.5769978",
"0.5768044",
"0.57677454",
"0.57677454",
"0.5765535",
"0.5761502",
"0.57588595",
"0.5748943",
"0.5721717",
"0.5708067",
"0.56982106",
"0.56982106",
"0.5693914",
"0.56920874",
"0.56822395",
"0.5682166",
"0.56784517",
"0.56667966",
"0.56647867",
"0.5618734",
"0.5608235",
"0.5577225",
"0.55649483",
"0.5562542",
"0.5559256",
"0.5543848",
"0.5543848",
"0.5543848",
"0.5543848",
"0.5543848",
"0.5543848",
"0.5543848",
"0.5543848",
"0.5543848",
"0.5543848",
"0.5543848",
"0.5543848",
"0.55380285",
"0.5531896",
"0.55250925",
"0.5519289",
"0.5514087",
"0.5508311",
"0.548425",
"0.54822093",
"0.5469462",
"0.54672885",
"0.5451965",
"0.54447144",
"0.5433583",
"0.5429187",
"0.5423632",
"0.5421003",
"0.5418291",
"0.5403239",
"0.5398617",
"0.5398617"
] |
0.0
|
-1
|
PATCH/PUT /candidates/1 PATCH/PUT /candidates/1.json
|
def update
if @candidate.update(candidate_params)
redirect_to (current_user.role == 'candidate' ? root_path : @candidate), notice: 'Candidate was successfully updated.'
else
render :edit
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @candidate = Candidate.find(params[:id])\n\n respond_to do |format|\n if @candidate.update_attributes(params[:candidate])\n format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate.update(permitted_attributes @candidate)\n format.html { redirect_to @candidate, notice: \"Candidate was successfully updated.\" }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to @candidate, notice: \"Candidate was successfully updated.\" }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n flash[:success] = 'Candidate was successfully updated'\n format.html { redirect_to edit_candidate_path(@candidate), notice: 'Candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate }\n else\n flash[:failure] = 'Candidate updation unsuccessful'\n format.html { render :edit }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @candidate = Candidate.find(params[:id])\n\n respond_to do |format|\n if @candidate.update_attributes(params[:candidate])\n flash[:notice]='Successfully updated Details!'\n format.html { redirect_to :controller=>\"test_center\",:action=>\"instructions\" }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to user_election_position_candidates_path, notice: 'Candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @candidate = Candidate.find(params[:id])\n\n if @candidate.update_attributes(params[:candidate])\n redirect_to admin_candidates_path, notice: 'Candidate was successfully updated.'\n else\n render action: \"edit\"\n end\n end",
"def update\n authorize @vote_candidate\n respond_to do |format|\n if @vote_candidate.update(vote_candidate_params)\n format.html { redirect_to @vote_candidate, notice: 'Vote candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @vote_candidate }\n else\n format.html { render :edit }\n format.json { render json: @vote_candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n set_questionnaire\n format.html { redirect_to candidates_url, notice: \"Candidate was successfully updated.\" }\n else\n format.html { redirect_to edit_candidate_url(@candidate), alert: @candidate.errors.full_messages.first }\n end\n end\n end",
"def update\n @candidate_app = CandidateApp.find(params[:id])\n\n respond_to do |format|\n if @candidate_app.update_attributes(params[:candidate_app])\n format.html { redirect_to @candidate_app, notice: 'Candidate app was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @candidate_app.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to @candidate , notice: 'Información actualizada correctamente.' }\n format.json { head :no_content }\n else\n format.html { render 'edit' }\n format.json { render json: @candidate.errors , status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @candidate_detail.update(candidate_detail_params)\n format.html { redirect_to candidate_candidate_detail_path(@candidate,@candidate_detail), notice: 'Candidate detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate_detail }\n else\n format.html { render :edit }\n format.json { render json: @candidate_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @candidate_info = args[:candidate_info] if args.key?(:candidate_info)\n @contain_user_quotes = args[:contain_user_quotes] if args.key?(:contain_user_quotes)\n @contain_vulgar_candidates = args[:contain_vulgar_candidates] if args.key?(:contain_vulgar_candidates)\n @disable_ng3_scoring = args[:disable_ng3_scoring] if args.key?(:disable_ng3_scoring)\n @disable_query_features = args[:disable_query_features] if args.key?(:disable_query_features)\n @snippet_brain_selected_candidate_index = args[:snippet_brain_selected_candidate_index] if args.key?(:snippet_brain_selected_candidate_index)\n @snippetsbrain_model_info = args[:snippetsbrain_model_info] if args.key?(:snippetsbrain_model_info)\n end",
"def update\n respond_to do |format|\n if @candidatedetail.update(candidatedetail_params)\n format.html { redirect_to @candidatedetail, notice: 'Candidatedetail was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidatedetail }\n else\n format.html { render :edit }\n format.json { render json: @candidatedetail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @candidate = @alliance.candidates.find(params[:id])\n\n authorize! :update, @candidate\n\n if @candidate.log_and_update_attributes(candidate_params)\n flash[:notice] = \"Muutokset tallennettu.\"\n else\n flash[:alert] = \"Muutosten tallentaminen epäonnistui!\"\n render :action => :edit and return\n end\n\n respond_with(@alliance) do |format|\n format.html { redirect_to advocates_alliance_path(@alliance) }\n end\n end",
"def update\n\n # Note: use form validation to ensure that\n # params[:uploaded_file] is not null\n\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @candidate = args[:candidate] if args.key?(:candidate)\n @reference = args[:reference] if args.key?(:reference)\n end",
"def update\n @election = Election.find(election_params[:id])\n respond_to do |format|\n if @election.update(election_params)\n format.html { redirect_to user_elections_path, notice: 'Election was successfully updated.' }\n format.json { render :show, status: :ok, location: @election }\n else\n format.html { render :edit }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @compromise = Compromise.find(params[:id])\n\n respond_to do |format|\n if @compromise.update_attributes(params[:compromise])\n format.html { redirect_to @compromise, notice: 'Compromise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @compromise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n# if @proposal.update(proposal_params)\n if @proposal.update_with_conflict_validation(proposal_params)\n format.html { redirect_to @proposal, notice: '提案を1件更新しました。' }\n format.json { render :show, status: :ok, location: @proposal }\n else\n format.html { render :edit }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @candidates = args[:candidates] if args.key?(:candidates)\n @query = args[:query] if args.key?(:query)\n @weight = args[:weight] if args.key?(:weight)\n end",
"def update\n @choice = Choice.find(params[:id])\n\n if @choice.update(choice_params)\n head :no_content\n else\n render json: @choice.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @candidate_reference.update(candidate_reference_params)\n flash[:success] = 'Reference was successfully updated.' \n format.html { redirect_to edit_candidate_references_path(params[:candidate_id])}\n format.json { render :show, status: :ok, location: @candidate_reference }\n else\n flash[:failure] = 'Reference updation unsuccessful.' \n @candidate_references = [@candidate_reference]\n @new_candidate_reference = Candidate::Reference.new\n format.html { redirect_to edit_candidate_references_path(params[:candidate_id]) }\n format.json { render json: @candidate_reference.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!(**args)\n @candidate_index = args[:candidate_index] if args.key?(:candidate_index)\n end",
"def patch!\n request! :patch\n end",
"def update\n @proposal = Proposal.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @proposal = listing.proposals.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n @proposal = Proposal.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(update_params)\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @concept_id = args[:concept_id] if args.key?(:concept_id)\n @contact_source = args[:contact_source] if args.key?(:contact_source)\n @is_relationship_from_annotation = args[:is_relationship_from_annotation] if args.key?(:is_relationship_from_annotation)\n @is_relationship_from_source = args[:is_relationship_from_source] if args.key?(:is_relationship_from_source)\n @is_single_candidate = args[:is_single_candidate] if args.key?(:is_single_candidate)\n @is_starred = args[:is_starred] if args.key?(:is_starred)\n @matched_name_type = args[:matched_name_type] if args.key?(:matched_name_type)\n @num_alternate_name_from_fuzzy_contact_match = args[:num_alternate_name_from_fuzzy_contact_match] if args.key?(:num_alternate_name_from_fuzzy_contact_match)\n @num_alternate_names_from_s3 = args[:num_alternate_names_from_s3] if args.key?(:num_alternate_names_from_s3)\n @num_alternative_names_from_interpretation = args[:num_alternative_names_from_interpretation] if args.key?(:num_alternative_names_from_interpretation)\n @num_candidates = args[:num_candidates] if args.key?(:num_candidates)\n @recognition_alternate_source = args[:recognition_alternate_source] if args.key?(:recognition_alternate_source)\n end",
"def update\n @candidate_revision = CandidateRevision.find(params[:id])\n\n respond_to do |format|\n if @candidate_revision.update_attributes(params[:candidate_revision])\n flash[:notice] = 'CandidateRevision was successfully updated.'\n format.html { redirect_to(@candidate_revision) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @candidate_revision.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @candidate = Usernew.find(params[:id])\n\n respond_to do |format|\n if @candidate.update_attributes(params[:usernew])\n format.html { redirect_to @usernew, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @usernew.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 respond_to do |format|\n if @election.update(election_params)\n format.html { redirect_to @election, notice: \"Election was successfully updated.\" }\n format.json { render :show, status: :ok, location: @election }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\n end",
"def update\n @person = Person.find(params[:id]) \n respond_to do |format|\n if @person.update(person_params)\n format.json { render json: @person, status: :ok }\n else\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @coffer.update(coffer_params)\n format.html { redirect_to @coffer, notice: 'Coffer was successfully updated.' }\n format.json { render :show, status: :ok, location: @coffer }\n else\n format.html { render :edit }\n format.json { render json: @coffer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @proposal.accepted == true\n format.html { redirect_to @proposal, notice: 'The Proposal Can Not Be Changed After It Has Been Assigned' }\n end\n unless params[:proposal][:bts].nil? || params[:proposal][:bts].count == 0\n @proposal.bts.clear\n params[:proposal][:bts].each do |bt|\n @proposal.bts << bt\n end\n end\n unless params[:proposal][:focus_points].nil? || params[:proposal][:focus_points].count == 0\n @proposal.focus_points.clear\n params[:proposal][:focus_points].each do |fp|\n @proposal.focus_points << fp\n end\n end\n if @proposal.update(proposal_params)\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { render :show, status: :ok, location: @proposal }\n else\n format.html { render :edit }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @leader = Leader.find(params[:id])\n\n respond_to do |format|\n if @leader.update_attributes(params[:leader])\n format.html { redirect_to @leader, notice: 'Leader was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @leader.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_candidate\n @candidate = Candidate.includes(:user, :resume).find(params[:id])\n end",
"def update\n respond_to do |format|\n if @election.update(election_params)\n format.html { redirect_to @election, notice: 'Election was successfully updated.' }\n format.json { render :show, status: :ok, location: @election }\n else\n format.html { render :edit }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @election.update(election_params)\n format.html { redirect_to @election, notice: 'Election was successfully updated.' }\n format.json { render :show, status: :ok, location: @election }\n else\n format.html { render :edit }\n format.json { render json: @election.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 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 # PATCH\n raise NotImplementedError\n end",
"def update\n respond_to do |format|\n if election.update_attributes(params[:election] ? election_attributes : {})\n format.html { redirect_to(election, flash: { success: 'Election updated.' }) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => election.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @requester.update(requester_params)\n format.html { redirect_to @requester, notice: 'Requester was successfully updated.' }\n format.json { render :show, status: :ok, location: @requester }\n else\n format.html { render :edit }\n format.json { render json: @requester.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @collaborator = Collaborator.find(params[:id])\n\n respond_to do |format|\n if @collaborator.update_attributes(params[:collaborator])\n format.html { redirect_to @collaborator, notice: 'Collaborator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_candidate\n \t@election = Candidate.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @proposal.update(proposal_params)\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { render :show, status: :ok, location: @proposal }\n else\n format.html { render :edit }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end",
"def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_request\n end\n end",
"def set_candidate\n @candidate = params[:id] ? Candidate.find(params[:id]) : Candidate.new(candidate_params)\n end",
"def set_candidate\n @candidate = Candidate.find(params[:id])\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 @proposal.update(proposal_params)\n format.html { redirect_to :back, notice: 'La proposition a été modifiée.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize [:api, :v1, @requesting_object]\n ticket = ServiceTicket.where(\n client_key: params['avatar_key'],\n id: params['id']\n ).first\n if params['comment_text']\n ticket.comments << Comment.new(author: params['avatar_name'],\n text: params['comment_text'])\n end\n ticket.update(status: params['status']) if params['status']\n render json: { message: 'OK' }, status: :ok\n end",
"def update\n respond_to do |format|\n if @exam_candidate.update_attributes(params[:exam_candidate])\n format.html { redirect_to(@exam_candidate, :notice => 'Candidate was successfully updated.') }\n format.xml { head :ok }\n else\n @exam_candidate.attachments.build\n @exam_candidate.internships.build\n # @exam_candidate.build_address\n\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @exam_candidate.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chore.where(id: params[:id]).first\n #Here we're checking if we have user_id in our body, and if we do, we'll change the selected chore's properties\n #with the parameters of the body, we go through the specific group to our specific chore with the path\n if v1_chore_params[:user_id]\n @v1_chore.user_id = params[:user_id]\n @v1_chore.assigned = true\n if @v1_chore.save\n render :show, status: :ok\n end\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n end\n end",
"def update\n course = Course.includes(:professors).find(params[:id])\n course.update!(course_params)\n \n course.professor_ids=(params[:professors])\n\n render json: course.to_json(include: :professors)\n end",
"def update\n @solution = @idea.solutions.find(params[:id])\n\n if @solution.update_attributes(params[:solution])\n render json: { text: \"success\" }\n else\n render json: { text: \"fail\"}\n end\n end",
"def update\n respond_to do |format|\n if @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 @election.update(election_params)\n format.html { redirect_to [:admin, @election], notice: 'Election was successfully updated.' }\n format.json { render :show, status: :ok, location: @election }\n else\n format.html { render :edit }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @request.assign_json_attributes(params) if @request.resume?\n respond_to do |format|\n if @request.update(request_params)\n format.html { redirect_to @request, notice: 'Request was successfully updated.' }\n format.json { render :show, status: :ok, location: @request }\n else\n format.html { render :edit }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_concern.update(api_v1_concern_params)\n format.html { redirect_to @api_v1_concern, notice: 'Concern was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_concern }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_concern.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by(id: params[:id])\n suggested_pathway.name = params[:name]\n suggested_pathway.year = params[:year]\n suggested_pathway.course_id = params[:course_id]\n suggested_pathway.data = params[:data]\n suggested_pathway.save\n render json: suggested_pathway\n end",
"def update\n recipe.update(recipe_params)\n render json: recipe\n end",
"def update\n # @person = Person.find(params[:id])\n # @person.pct_complete = @person.requirement_progress\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, :notice => 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @person.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @completion.update(completion_params)\n format.html { redirect_to @completion, notice: 'Completion was successfully updated.' }\n format.json { render :show, status: :ok, location: @completion }\n else\n format.html { render :edit }\n format.json { render json: @completion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end",
"def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end",
"def set_candidate\n @candidate = Candidate.find_by id: params[:id]\n authorize @candidate\n end",
"def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end",
"def update\n respond_to do |format|\n if @potential_client.update(potential_client_params)\n format.html { redirect_to @potential_client, notice: 'Potential client was successfully updated.' }\n format.json { render :show, status: :ok, location: @potential_client }\n else\n format.html { render :edit }\n format.json { render json: @potential_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @election = Election.find(params[:id])\n\n respond_to do |format|\n if @election.update_attributes(params[:election])\n flash[:notice] = 'Election was successfully updated.'\n format.html { redirect_to(@election) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @election.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @contests = args[:contests] if args.key?(:contests)\n @drop_off_locations = args[:drop_off_locations] if args.key?(:drop_off_locations)\n @early_vote_sites = args[:early_vote_sites] if args.key?(:early_vote_sites)\n @election = args[:election] if args.key?(:election)\n @kind = args[:kind] if args.key?(:kind)\n @mail_only = args[:mail_only] if args.key?(:mail_only)\n @normalized_input = args[:normalized_input] if args.key?(:normalized_input)\n @other_elections = args[:other_elections] if args.key?(:other_elections)\n @polling_locations = args[:polling_locations] if args.key?(:polling_locations)\n @precinct_id = args[:precinct_id] if args.key?(:precinct_id)\n @state = args[:state] if args.key?(:state)\n end",
"def update\n respond_to do |format|\n if @leadership.update(leadership_params)\n format.html { redirect_to @leadership, notice: 'Leadership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @leadership.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6997068",
"0.6843286",
"0.6768482",
"0.6768482",
"0.6768482",
"0.6768482",
"0.6768482",
"0.6768482",
"0.6768482",
"0.67535204",
"0.6686334",
"0.65477365",
"0.6542974",
"0.6518262",
"0.6458349",
"0.64341927",
"0.6364452",
"0.63492894",
"0.624964",
"0.61845785",
"0.6174728",
"0.61387515",
"0.61366266",
"0.60592806",
"0.5986286",
"0.5959036",
"0.59154475",
"0.58870035",
"0.5873875",
"0.58720976",
"0.5858716",
"0.5844691",
"0.5828282",
"0.58240527",
"0.58112353",
"0.58010906",
"0.5795901",
"0.5795901",
"0.57757664",
"0.5769659",
"0.575372",
"0.5735932",
"0.5734777",
"0.57078874",
"0.5703897",
"0.56987894",
"0.56987894",
"0.56987894",
"0.56987894",
"0.56987894",
"0.56987894",
"0.56987894",
"0.56987894",
"0.56987894",
"0.56987894",
"0.56987894",
"0.56987894",
"0.56845856",
"0.56807595",
"0.5678208",
"0.56728816",
"0.56700325",
"0.56653214",
"0.56653214",
"0.56632763",
"0.56608087",
"0.5653734",
"0.5646902",
"0.5640472",
"0.56397325",
"0.5631545",
"0.5623582",
"0.56233525",
"0.56231695",
"0.56139874",
"0.5607637",
"0.55942726",
"0.558184",
"0.5581213",
"0.55786675",
"0.5575969",
"0.55748516",
"0.55638546",
"0.5561009",
"0.55540925",
"0.55514455",
"0.55433476",
"0.5535228",
"0.5535117",
"0.5533403",
"0.55330044",
"0.5531925",
"0.5531925",
"0.5531925",
"0.55258906",
"0.5525867",
"0.5511647",
"0.55110914",
"0.5509521",
"0.5508668"
] |
0.5920511
|
26
|
DELETE /candidates/1 DELETE /candidates/1.json
|
def destroy
@candidate.destroy
redirect_to candidates_url, notice: 'Candidate was successfully destroyed.'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to candidates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to candidates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: 'Candidate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: 'Candidate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: 'Candidate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: 'Candidate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: 'Candidate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: 'Candidate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: 'Candidate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: 'Candidate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: \"Candidate was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: \"Candidate was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: \"Candidate was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n flash[:notice] = 'Candidate was successfully destroyed.'\n format.html { redirect_to candidates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: 'Your profile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @vote_candidate\n @vote_candidate.destroy\n respond_to do |format|\n format.html { redirect_to vote_candidates_url, notice: 'Vote candidate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exam_candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to(candidates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @candidate_detail.destroy\n respond_to do |format|\n format.html { redirect_to candidate_candidate_details_path(@candidate), notice: 'Candidate detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate_reference.destroy\n respond_to do |format|\n flash[:success] = 'Reference was successfully deleted' \n format.html { redirect_to edit_candidate_references_path(params[:candidate_id])}\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate_app = CandidateApp.find(params[:id])\n @candidate_app.destroy\n\n respond_to do |format|\n format.html { redirect_to candidate_apps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidatedetail.destroy\n respond_to do |format|\n format.html { redirect_to candidatedetails_url, notice: 'Candidatedetail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @election = Election.find(params[:id])\n @election.destroy\n respond_to do |format|\n format.html { redirect_to user_elections_path, notice: 'Election was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n redirect_to admin_jobs_url\n end",
"def destroy_candidates\n candidates.each do |candidate|\n candidate.destroy\n end\n end",
"def destroy\n @candidate_revision = CandidateRevision.find(params[:id])\n @candidate_revision.destroy\n\n respond_to do |format|\n format.html { redirect_to(candidate_revisions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @election.destroy\n respond_to do |format|\n format.html { redirect_to elections_url, notice: \"Election was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @election.destroy\n respond_to do |format|\n format.html { redirect_to elections_url, notice: 'Election was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @election.destroy\n respond_to do |format|\n format.html { redirect_to elections_url, notice: 'Election was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nudge.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to :back , status: 303 , notice: 'Candidato borrado correctamente.' }\n # if !params[:category_id].nil?\n #format.html { redirect_to(category_candidates_path(@category), notice: 'Categoría borrada correctamente.')\n # else\n #format.html { redirect_to candidates_url, notice: 'Candidato borrado correctamente.' }\n # end\n format.json { head :no_content }\n\n end\n end",
"def destroy\n @optin_contestant = OptinContestant.find(params[:id])\n @optin_contestant.destroy\n\n respond_to do |format|\n format.html { redirect_to optin_contestants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @election.destroy\n respond_to do |format|\n format.html { redirect_to admin_elections_url, notice: 'Election was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collaborator = Collaborator.find(params[:id])\n @collaborator.destroy\n\n respond_to do |format|\n format.html { redirect_to canvases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @election = Election.find(params[:id])\n @election.destroy\n\n respond_to do |format|\n format.html { redirect_to(elections_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @leader.destroy\n respond_to do |format|\n format.html { redirect_to leaders_url, notice: 'leader was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ai_contest = AiContest.find(params[:id])\n @ai_contest.destroy\n\n respond_to do |format|\n format.html { redirect_to ai_contests_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @challenge.destroy\n respond_to do |format|\n format.html { redirect_to challenges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @challenge ||= Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to challenges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vote = Vote.find(params[:id])\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to proposal_url(@proposal) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reply_vote = ReplyVote.find(params[:id])\n @reply_vote.destroy\n\n respond_to do |format|\n format.html { redirect_to reply_votes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @election_type = ElectionType.find(params[:id])\n @election_type.destroy\n\n respond_to do |format|\n format.html { redirect_to election_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @contestant = Contestant.find(params[:id])\n @contestant.destroy\n\n respond_to do |format|\n format.html { redirect_to contestants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to challenges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to challenges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @leader = Leader.find(params[:id])\n @leader.destroy\n\n respond_to do |format|\n format.html { redirect_to leaders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vote = @votable.votes.find(params[:id])\n @vote.destroy\n respond_to do |format|\n format.html { redirect_to build_path_votes }\n format.json { head :no_content }\n end\n end",
"def destroy\n @compromise = Compromise.find(params[:id])\n @compromise.destroy\n\n head :no_content\n end",
"def destroy\n @coffee_attempt.destroy\n respond_to do |format|\n format.html { redirect_to coffee_attempts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @decision.destroy\n respond_to do |format|\n format.html { redirect_to decisions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_answer = ClientAnswer.find(params[:id])\n @client_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to client_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @compromise = Compromise.find(params[:id])\n @compromise.destroy\n\n respond_to do |format|\n format.html { redirect_to compromises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @election = Election.find(params[:election_id])\n @race = @election.races.find(params[:id])\n @race.destroy\n\n respond_to do |format|\n format.html { redirect_to election_races_url(@election) }\n format.json { head :no_content }\n end\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def destroy\n @residence = Residence.find(params[:id])\n @residence.destroy\n\n respond_to do |format|\n format.html { redirect_to residences_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @counselledperson.destroy\n respond_to do |format|\n format.html { redirect_to counselledpersons_index_url, notice: 'Counselledpersons was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candy.destroy\n respond_to do |format|\n format.html { redirect_to candies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n\n\n @vote = Vote.find(params[:id])\n\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to votes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @proxy_votes_collected.destroy\n respond_to do |format|\n format.html { redirect_to proxy_votes_collected_index_url, notice: 'Proxy votes collected was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comm_vote = CommVote.find(params[:id])\n @comm_vote.destroy\n\n respond_to do |format|\n format.html { redirect_to comm_votes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate_course_score.destroy\n flash[:notice] = 'Course score was successfully destroyed.'\n respond_to do |format|\n format.html { redirect_to candidate_course_scores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @leadership.destroy\n respond_to do |format|\n format.html { redirect_to leaderships_url }\n format.json { head :no_content }\n end\n end",
"def delete_candidate(accountID)\n\t\tputs \"DB::delete #{accountID}\"\n\tend",
"def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end",
"def destroy\n @client = Client.find(params[:client_id])\n @casenote = Casenote.find(params[:id])\n @casenote.destroy\n\n respond_to do |format|\n format.html { redirect_to client_casenotes_path(@client) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @clientcase = Clientcase.find(params[:id])\n @clientcase.destroy\n\n respond_to do |format|\n format.html { redirect_to clientcases_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @reqdifficulty.destroy\n respond_to do |format|\n format.html { redirect_to reqdifficulties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vote.destroy\n respond_to do |format|\n format.html { redirect_to votes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vote.destroy\n respond_to do |format|\n format.html { redirect_to votes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fundamental_alliance_leader_vote = Fundamental::AllianceLeaderVote.find(params[:id])\n @fundamental_alliance_leader_vote.destroy\n\n respond_to do |format|\n format.html { redirect_to fundamental_alliance_leader_votes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to(challenges_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to(challenges_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @election_user.destroy\n respond_to do |format|\n format.html { redirect_to election_users_url, notice: 'Election user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @completion.destroy\n respond_to do |format|\n format.html { redirect_to completions_url, notice: 'Completion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidat.destroy\n respond_to do |format|\n format.html { redirect_to candidats_url, notice: 'Candidat was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by_id(params[:pathway_id])\n suggested_pathway.destroy\n render json: suggested_pathway\n end",
"def destroy\n @clonet = Clonet.find(params[:id])\n @clonet.destroy\n\n respond_to do |format|\n format.html { redirect_to clonets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_need = ClientNeed.find(params[:id])\n @client_need.destroy\n\n respond_to do |format|\n format.html { redirect_to client_needs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n election.destroy\n\n respond_to do |format|\n format.html { redirect_to(elections_url, flash: { success: 'Election destroyed.' }) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cb_person.destroy\n respond_to do |format|\n format.html { redirect_to cb_people_url, notice: 'Cb person was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solution = Solution.find(params[:id])\n @solution.destroy\n\n render json: { text: \"success\" }\n end",
"def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_challenges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @borrow_request = BorrowRequest.find(params[:id])\n @borrow_request.destroy\n\n respond_to do |format|\n format.html { redirect_to borrow_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crowd = Crowd.find(params[:id])\n @crowd.destroy\n\n respond_to do |format|\n format.html { redirect_to crowds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group = Group.find(params[:group_id])\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to group_candidates_path(@group) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\t\trequire_admin!\n\t\t@election.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to elections_url, notice: 'Election was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def remove_candidate\n job_candidate = JobCandidate.where(:job_id => params[:job_id],\n :candidate_id => params[:candidate_id]).first\n authorize(job_candidate)\n job_candidate.status = JobCandidate.statuses[:deleted]\n job_candidate.save\n\n tracker = Mixpanel::Tracker.new(ENV[\"NT_MIXPANEL_TOKEN\"])\n tracker.track('employer-'+current_employer.email, 'removed candidate from job')\n\n redirect_to employer_show_path(params[:job_id]), notice: 'Candidate removed'\n end",
"def destroy\n @judge.destroy\n respond_to do |format|\n format.html { redirect_to judges_url, notice: 'Judge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @response_challenge = ResponseChallenge.find(params[:id])\n @response_challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to response_challenges_url }\n format.json { head :ok }\n end\n end",
"def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end",
"def destroy\n @proposal = Proposal.find(params[:id])\n @proposal.destroy\n\n respond_to do |format|\n format.html { redirect_to proposals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @proposal = Proposal.find(params[:id])\n @proposal.destroy\n\n respond_to do |format|\n format.html { redirect_to proposals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collaborator = Collaborator.find(params[:id])\n @collaborator.destroy\n\n respond_to do |format|\n format.html { redirect_to collaborators_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidato = Candidato.find(params[:id])\n @candidato.destroy\n\n respond_to do |format|\n format.html { redirect_to candidatos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidato = Candidato.find(params[:id])\n @candidato.destroy\n\n respond_to do |format|\n format.html { redirect_to candidatos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @leaderboard = Leaderboard.find(params[:id])\n @leaderboard.destroy\n\n respond_to do |format|\n format.html { redirect_to leaderboards_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vote = Vote.find(params[:id])\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to votes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @vote = Vote.find(params[:id])\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to votes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @vote = Vote.find(params[:id])\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to votes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n block_non_user\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7436304",
"0.7436304",
"0.7173674",
"0.717342",
"0.717342",
"0.717342",
"0.717342",
"0.717342",
"0.717342",
"0.717342",
"0.71688795",
"0.71688795",
"0.71688795",
"0.7097595",
"0.7083692",
"0.68879616",
"0.67611915",
"0.67196244",
"0.6716783",
"0.6674849",
"0.6648467",
"0.6633264",
"0.663056",
"0.66255254",
"0.6576449",
"0.6526477",
"0.65194345",
"0.65194345",
"0.64890724",
"0.642545",
"0.6422706",
"0.64081264",
"0.6396868",
"0.63886106",
"0.6381237",
"0.63802",
"0.636675",
"0.6365772",
"0.6364582",
"0.6348014",
"0.63422453",
"0.6327351",
"0.6324292",
"0.63236165",
"0.6322857",
"0.63193166",
"0.6297445",
"0.6291996",
"0.628649",
"0.62850165",
"0.62737197",
"0.62736523",
"0.6264915",
"0.6256736",
"0.6230692",
"0.6227171",
"0.6225559",
"0.6223271",
"0.6216569",
"0.6215832",
"0.6215332",
"0.62119544",
"0.62115073",
"0.62103444",
"0.6207261",
"0.6204181",
"0.62036335",
"0.6199471",
"0.6199471",
"0.61977476",
"0.61927426",
"0.61927426",
"0.6192732",
"0.61917764",
"0.61895466",
"0.61887217",
"0.6180557",
"0.6177055",
"0.6174683",
"0.61686796",
"0.61645234",
"0.616419",
"0.6163393",
"0.6159672",
"0.6159524",
"0.61511433",
"0.6149595",
"0.6149081",
"0.6148826",
"0.61476666",
"0.6146734",
"0.6146734",
"0.61462843",
"0.61453307",
"0.61453307",
"0.6143446",
"0.61318916",
"0.61318916",
"0.61318916",
"0.6129284"
] |
0.6708224
|
19
|
Use callbacks to share common setup or constraints between actions.
|
def set_candidate
@candidate = Candidate.includes(:user, :resume).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 candidate_params
params.require(:candidate).permit(:user_id, :first_name, :last_name, :email, :phone, :desired_position, :current_company, :linked_in_url, :twitter_url, :git_hub_url, :portfolio_url, :website_url,
resume_attributes:[:resume_data])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def valid_params_request?; end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\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 ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def url_whitelist; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def backend_user_params\n params.permit!\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586",
"0.629103",
"0.6282451",
"0.6243152",
"0.62413",
"0.6219024",
"0.6213724",
"0.62103724",
"0.61945",
"0.61786324",
"0.61755824",
"0.6173267",
"0.6163613",
"0.6153058",
"0.61521065",
"0.6147508",
"0.61234015",
"0.61168665",
"0.6107466",
"0.6106177",
"0.6091159",
"0.60817343",
"0.6071238",
"0.6062299",
"0.6021663",
"0.60182893",
"0.6014239",
"0.6011563",
"0.60080767",
"0.60080767",
"0.60028875",
"0.60005623",
"0.59964156",
"0.5993086",
"0.5992319",
"0.5992299",
"0.59801805",
"0.59676576",
"0.59606016",
"0.595966",
"0.59591126",
"0.59589803",
"0.5954058",
"0.5953234",
"0.5944434",
"0.5940526",
"0.59376484",
"0.59376484",
"0.5935253",
"0.5930846",
"0.5926387",
"0.59256274",
"0.5917907",
"0.5910841",
"0.590886",
"0.59086543",
"0.59060425",
"0.58981544",
"0.5898102",
"0.5896809",
"0.5895416",
"0.58947027",
"0.58923644",
"0.5887903",
"0.58830196",
"0.5880581",
"0.5873854",
"0.58697754",
"0.5869004",
"0.58669055",
"0.5866886",
"0.58664906",
"0.5864619",
"0.58630043",
"0.5862495",
"0.5861368",
"0.5859712",
"0.5855544",
"0.58551925",
"0.5851284",
"0.5850602"
] |
0.0
|
-1
|
before_action :authenticate_applicant!, only: [:index, :show]
|
def index
@application = Application.new
@vacancies = Vacancy.all.order("deadline ASC")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n # authorize Admin\n end",
"def show\n authorize @career\n end",
"def show\n authorize @activist_front\n end",
"def show\n authorize @staff_request\n end",
"def show\n authorize!\n end",
"def show\n authorize!\n end",
"def show\n authorize!\n end",
"def show\n authorize User\n end",
"def show\n authorize User\n end",
"def show \n if user_signed_in?\n unless current_user.email == @app.user.email || @app.is_public\n authorize! :show, @app\n end\n else\n unless @app.is_public\n authorize! :show, @app\n end\n end\n end",
"def show\n\t\tauthorize! :show, AsignacionFuncion\n end",
"def index\n #@applicants = ApplicantUser.all.page(page: params[:page] || 1, per_page: 20)\n @applicants = ApplicantUser.all\n end",
"def show\n authorize! :show, @user\n end",
"def show\n authorize Section\n end",
"def index\n @applicants = Applicant.all\n end",
"def index\n @applicants = Applicant.all\n end",
"def index\n @activist_fronts = ActivistFront.all\n authorize ActivistFront\n end",
"def authorize\n redirect_to :root, alert: 'You must be logged in to view this page' if current_user.nil?\n end",
"def show\n skip_authorization\n end",
"def authorize\n redirect_to '/' unless current_user || current_dealer\n end",
"def show\n authorize Session\n end",
"def show\n if not ( paziente_signed_in? or administrator_signed_in?)\n redirect_to root_path and return\n end\n end",
"def show\n authorize! :create, Administrator\n end",
"def show\n enforce_view_permission(@user)\n \n end",
"def authorized!\n redirect_to root_url, alert: \"You need to be set up for receiving whispers first\" and return unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorized\n redirect_to :controller => 'home', :action => 'index' unless logged_in?\n end",
"def index\n redirect_to current_user\n end",
"def show\n authorize @info_practice\n end",
"def show\n @user = current_user\n authorize @user\n end",
"def show\n authorize EmployeeType\n end",
"def set_applicant\n @applicant = ApplicantUser.find(params[:id])\n end",
"def authorize\n redirect_to root_path unless current_recruiter\n end",
"def show\n current_client == current_user\n unless current_user.admin?\n unless @client == current_user\n redirect_to :back, :alert => \"Access denied.\"\n end\n end\n\n end",
"def show\n authorize @user\n end",
"def show\n authorize @user\n end",
"def show\n authorize @admin\n end",
"def show\n @applicants = get_applicants if params[:applicants]\n end",
"def show\n \n # security check\n @job = Job.find(params[:id], :conditions => [\"employer_id = ?\", current_user.employer.id])\n (@job.employer_id == current_user.employer.id).to_console\n if @job.employer_id == current_user.employer.id\n @applicants = Applicant.paginate(:conditions => [\"job_id = ?\", @job.id], :per_page => 10, :page => params[:page])\n \n else\n render :text => \"You do not own that listing\"\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @applicant }\n end\n end",
"def show\n @applicant = Applicant.where('applicant_id = ?', @application.applicant_id)\n end",
"def show\n authorize! :show, @dj_application\n end",
"def show\n authorize! :update, Hospital\n end",
"def authorize_admin\n redirect_to root_path unless current.user.immortal?\n end",
"def authorized_user!\n unless user_logged_in?\n redirect_to root_path\n end\n end",
"def show \n #if current_user.company_id == @user.company_id \n authorize @user \n end",
"def index\n if user_signed_in?\n redirect_to :controller=>'reviews', :action => 'index'\n end\nend",
"def index\n @event_applicants = EventApplicant.all\n end",
"def index\n @applicants = current_user.applicants rescue nil\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def show\n\t\tauthorize! :show, DetalleRestriccion\n end",
"def show\n redirect_user\n end",
"def index\n if current_user.roles == 'admin' or current_user.roles == 'editor' #checks if user is admin, if so displays all of the students in database.\n @emergency_contacts = EmergencyContact.all\n elsif user_signed_in?\n @emergency_contacts = EmergencyContact.all.where(:user_id => current_user.id) #Only displays the the users student. \n else\n @emergency_contacts = EmergencyContact.all\n end\n authorize @emergency_contacts\n end",
"def show\n require_user()\n end",
"def index\n redirect_to @current_user if current_user\n end",
"def show\n authorize @booking\n end",
"def index\n @admins = Admin.order(:email)\n authorize @admins\n end",
"def show\n redirect_to root_path, alert: \"You are not authorised to view that page.\"\n end",
"def authorize\n redirect_to('/login') unless @current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def show\n authorize @other\n end",
"def show\n current_email = current_user.email\n if !current_user.admin? && current_email.gsub(\".\",\"-dot-\") != params[:id]\n flash.keep[:notice] = 'You must be an administrator to access that feature.'\n redirect_to '/'\n end\n super\n end",
"def show\n check_user\n end",
"def authorized\n\t unless admin?\n\t redirect_to root_path\n\t end\n end",
"def show\n authorize @s_other\n end",
"def show\n \tauthorize! :read, @user\n end",
"def show\n render layout: false\n @activite = Activite.find(params[:id])\n authorize @activite\n end",
"def landing\n redirect_to dashboard_path if current_user\n end",
"def authorize\n redirect_to :login unless user_signed_in?\n end",
"def confirm_logged_in\n unless session[:user_id]\n flash[:notice] = \"Please log in.\"\n render('show')\n #redirect_to(:action => 'login')\n \n #redirect_to(:action => 'login')\n #redirect_to(:controller => 'contacts', :action => 'list')\n \n \n return false # halts the before_filter\n else\n redirect_to(:controller => 'admin_users')\n return true\n end\n end",
"def show\n authorize @customer, :show?\n end",
"def show\n authorize @accountant_profile\n end",
"def show\n authorize RoleCutoff\n end",
"def index\n if(Admin.new.type== current_user.type)\n @instructors = Instructor.all\n else\n flash[:danger] = \"You are not authorized to view this page!\"\n redirect_to user_path(current_user.id)\n end\n end",
"def show\n redirect_to root_path unless ViewMerchant.new(current_company_user, current_admin, current_merchant_user).check\n determine_user_role()\n load_permission_names()\n end",
"def authorize_user\n unless current_user.id == @profile.user_id\n flash[:unauthorized] = \"Not authorized\"\n redirect_to listings_path\n end \n end",
"def index\n # set_user, is the only action taken here\n end",
"def index\n # set_user, is the only action taken here\n end",
"def show\n if current_user.application == @application or current_user.is_admin?\n redirect_to user_path(@application.user)\n else\n redirect_to root_path\n end\n end",
"def set_applicant\n @applicant = Applicant.find(params[:id]) unless params[:username]\n end",
"def show\n authorize @expense_report\n end",
"def officer\n redirect_to root_path, notice: \"You are not authorized to do that\" if !current_member.officer?\n end",
"def show\n authorize @primer\n end",
"def authorize\n redirect_to new_session_path unless current_user #call method curent_user in sessions_helper\n end",
"def show\n admin_only\n end",
"def show\n admin_only\n end",
"def show\n admin_only\n end",
"def show\n authorize @development\n end",
"def show\n authorize HigherEducationInstitution\n end",
"def show\n authorize_action_for @department, at: current_store\n end",
"def set_applicant\n @applicant = Applicant.find(params[:id])\n end",
"def set_applicant\n @applicant = Applicant.find(params[:id])\n end",
"def index\n authorize! :creat, Administrator\n hospital = Hospital.findn(params[:hospital_id])\n @administrators = hospital.administrators\n end",
"def index\n if instructor_signed_in? and current_instructor.is_admin\n # Only an admin has access to this information. Ohter instructors will not get the link\n @instructor = Instructor.all\n else \n redirect_to root_path\n return\n end\n end",
"def show\n authorize_action_for(@revise)\n end"
] |
[
"0.7231183",
"0.70272654",
"0.70261455",
"0.6985931",
"0.6967366",
"0.6967366",
"0.6967366",
"0.69617504",
"0.69617504",
"0.6900996",
"0.6887286",
"0.6850788",
"0.6836222",
"0.6830097",
"0.6805661",
"0.6805661",
"0.679926",
"0.67859143",
"0.67700255",
"0.6749594",
"0.6744",
"0.67305917",
"0.66846555",
"0.667092",
"0.66607255",
"0.66561973",
"0.6652144",
"0.66490054",
"0.6648433",
"0.66367084",
"0.6632552",
"0.663086",
"0.6628407",
"0.6624384",
"0.6619823",
"0.6619823",
"0.6618763",
"0.66173655",
"0.66123366",
"0.66117495",
"0.66104317",
"0.6600511",
"0.6595994",
"0.65938866",
"0.6578279",
"0.6577095",
"0.6576327",
"0.65757734",
"0.6571503",
"0.6571503",
"0.6571503",
"0.6571503",
"0.6571503",
"0.6571503",
"0.6571503",
"0.6571503",
"0.65704256",
"0.65675026",
"0.6563973",
"0.65595186",
"0.6553037",
"0.6546384",
"0.65441173",
"0.65437263",
"0.6540291",
"0.6536437",
"0.65316135",
"0.6526155",
"0.6522109",
"0.6517966",
"0.6515342",
"0.65151596",
"0.6511653",
"0.65106875",
"0.6506893",
"0.6506821",
"0.65030366",
"0.64957315",
"0.64850605",
"0.6482527",
"0.64811224",
"0.6471556",
"0.6469192",
"0.6469192",
"0.6467197",
"0.64651865",
"0.6464671",
"0.6462788",
"0.6450166",
"0.6449978",
"0.6446333",
"0.6446333",
"0.6446333",
"0.6445607",
"0.6443783",
"0.64430183",
"0.64386255",
"0.64386255",
"0.6433887",
"0.6429892",
"0.6426194"
] |
0.0
|
-1
|
Default behavior for calculating the next_run date, which will be generally overriden by the subclass (except for the case of a run once job). When a job completes, the task scheduler will invoke this method to persist a new instance of the job to run based on the value returned by this method. A return value of nil indicates that the job should not run again, in which case a new job instance will not be created.
|
def calc_next_run
nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def calc_next_run\n RunAtPeriodicJob.new(:name => self.name, :job => self.job, :run_at_minutes => self.run_at_minutes)\n end",
"def set_next_run\n self.next_run_at = calc_next_run_at_date\n end",
"def calc_next_run\n self.next_run_at = nil\n end",
"def last_run_at\n super || self.schedule.try(:previous_occurrence)\n end",
"def set_next_run\n self.next_run_at = Time.zone.now unless self.next_run_at\n end",
"def run!\n TaskServerLogger.instance.error \"Executing job id #{self.id}, #{self.to_s}...\"\n begin\n self.last_run_at = Time.zone.now\n self.next_run_at = nil\n self.save\n eval(self.job.gsub(/#JOBID#/, self.id.to_s).gsub(/#RAILS_ROOT#/, RAILS_ROOT))\n self.last_run_result = \"OK\"\n TaskServerLogger.instance.info \"Job completed successfully\"\n rescue Exception\n err_string = \"'#{self.job}' could not run: #{$!.message}\\n#{$!.backtrace}\"\n TaskServerLogger.instance.error err_string\n puts err_string unless ENV['RAILS_ENV'] == \"test\"\n self.last_run_result = err_string.slice(1..500)\n begin\n Notifier.deliver_job_failure(self)\n rescue\n end\n end\n self.save\n\n # ...and persist the next run of this job if one exists\n set_next_job\n end",
"def calculate_next_run_at(start_time = Time.zone.now)\n ideal_next_run = ideal_next_run_from(start_time)\n\n if ideal_next_run == cron_worker_next_run_from(start_time)\n ideal_next_run\n else\n cron_worker_next_run_from(ideal_next_run)\n end\n end",
"def set_initial_next_run\n self.next_run_at = Time.zone.now if self.next_run_at.nil?\n end",
"def set_initial_next_run\n self.next_run_at = Time.zone.now if self.next_run_at.nil?\n end",
"def run!\n PeriodicJob.log_error \"Executing job id #{self.id}, #{self.to_s}...\"\n begin\n self.last_run_at = Time.now\n self.next_run_at = nil\n self.save\n command = self.job.gsub(/#JOBID#/, self.id.to_s).gsub(/#RAILS_ROOT#/, Rails.root.to_s)\n puts command\n eval(command)\n self.last_run_result = \"OK\"\n PeriodicJob.log_info \"Job completed successfully\"\n rescue Exception\n err_string = \"'#{self.job}' could not run: #{$!.message}\\n#{$!.backtrace}\"\n PeriodicJob.log_error err_string\n self.last_run_result = err_string.slice(1..500)\n begin\n GeneralMailer.failed_periodic_job(self).deliver\n rescue\n end\n end\n self.save\n\n # ...and persist the next run of this job if one exists\n set_next_job\n end",
"def fail_job\n self.last_run_at = Time.zone.now\n self.next_run_at = nil\n self.last_run_result = \"Timeout\"\n self.save\n\n # ...and persist the next run of this job if one exists\n set_next_job\n end",
"def next_execute_time\n if (@count > 0 && @count <= @job.run_time) || @interval <= 0\n return nil\n end\n @next_time += @interval\n end",
"def fail_job\n self.last_run_at = Time.now\n self.next_run_at = nil\n self.last_run_result = \"Timeout\"\n self.save\n\n # ...and persist the next run of this job if one exists\n set_next_job\n end",
"def get_next_to_last_run\n now = Time.now.utc\n run = Time.utc(now.year, now.month, now.day,\n (now.hour / run_interval) * run_interval)\n\n run - run_interval * 3600\n end",
"def next_refresh_date\n if next_job = temporize_client.next_job\n DateTime.parse(next_job['next']).strftime('%b %-d %Y, %-l:%M%P %Z')\n else\n nil\n end\n end",
"def datetime_for_job_start\n if self.job_start_datetime.present?\n self.job_start_datetime.strftime(\"%B %d, %Y\")\n else\n \"Not Scheduled\"\n end\n end",
"def next_job_id\n new_id = rand(10*5)\n get_job_status(new_id).nil? ? new_id : next_job_id\n end",
"def rocket_job_restart_new_instance\n return if expired?\n attrs = attributes.dup\n rocket_job_restart_excludes.each { |attr| attrs.delete(attr) }\n\n # Copy across run_at for future dated jobs\n attrs['run_at'] = run_at if run_at && (run_at > Time.now)\n\n rocket_job_restart_create(attrs)\n end",
"def next_run_time(from, to)\n next_time = cron.next_time(from)\n next_run = next_time.to_local_time.in_time_zone(next_time.zone)\n next_run <= to ? next_run : nil\n end",
"def next_run_time(from, to)\n next_time = cron.next_time(from)\n next_run = next_time.to_local_time.in_time_zone(next_time.zone)\n next_run <= to ? next_run : nil\n end",
"def next_run_time(from, to)\n next_time = cron.next_time(from)\n next_run = next_time.to_local_time.in_time_zone(next_time.zone)\n next_run <= to ? next_run : nil\n end",
"def update!\n scheduling.total_runs = scheduling.total_runs.to_i + qjob.stats['releases']\n scheduling.last_run = Time.now\n end",
"def run\n case self[:job]\n when Proc\n self[:job].call\n else\n self[:job]\n end\n end",
"def run!\n logger.info(\"Running task #{self.class.to_s}\")\n @block.call\n @next_run = cron_parser && cron_parser.next(Time.now)\n end",
"def next_run\n return nil unless active\n\n # - - -\n if !active_since && !active_till && !interval\n return @executed ? nil : @last_run_at\n \n # - - +\n elsif !active_since && !active_till && interval\n return @last_run_at + interval\n \n # - + -\n elsif !active_since && active_till && !interval\n return nil if @last_run_at >= active_till\n \n return @executed ? nil : @last_run_at\n \n # - + +\n elsif !active_since && active_till && interval\n return nil if @last_run_at >= active_till\n\n return @last_run_at + interval\n\n # + - -\n elsif active_since && !active_till && !interval\n return @executed ? nil : active_since\n \n # + - +\n elsif active_since && !active_till && interval \n return @last_run_at < active_since ? active_since : @last_run_at + interval\n\n # + + -\n elsif active_since && active_till && !interval\n return (@last_run_at >= active_till || @executed) ? nil : active_since\n\n # + + +\n elsif active_since && active_till && interval\n return nil if @last_run_at >= active_till\n \n return @last_run_at < active_since ? active_since : @last_run_at + interval\n end\n end",
"def create_or_update_previous_runs!; end",
"def create_or_update_previous_runs!; end",
"def run_now!\n update_attributes(run_at: nil) if cron_schedule\n end",
"def job \n @job\n end",
"def next_time(*args)\n cron_schedule.next_time(*args)\n end",
"def run_date_time\n return @run_date_time\n end",
"def get_run_time\n return next_to_last_run if @time >= next_to_last_run\n\n Time.utc(@time.year, @time.month, @time.day,\n (@time.hour / run_interval) * run_interval)\n end",
"def job\n @job\n end",
"def job\n @job\n end",
"def find_next_day\n day = @date.to_date + ((@schedule.start_date - @date.to_date) % @schedule.period_num)\n return day\n end",
"def rocket_job_restart_new_instance\n return unless cron_schedule\n super\n end",
"def rocket_job_restart_new_instance\n return unless cron_schedule\n super\n end",
"def rocket_job_restart_new_instance\n return unless cron_schedule\n\n super\n end",
"def attempt_to_run\n if recipe.schedule.runnable?\n\n if rhizomes_in_use?\n [\n :danger,\n \"Could not start <strong>#{name.html_safe}</strong> It appears the requested Rhizomes are currently in use!\"\n ]\n else\n rhizomes.each do |r|\n r.batch = self\n r.save!\n Rails.logger.info \"Assigned Rhizome #{r.name} to Batch #{r.batch.name}\"\n end\n end\n\n self.start_time = Time.now.to_datetime\n result = ScheduleJob.set(queue: queue_name).perform_later(recipe.schedule)\n\n if result\n start!\n reload\n [:success, \"Starting <strong>#{name.html_safe}</strong>\"]\n else\n [:danger, \"Could not start <strong>#{name.html_safe}</strong>!\"]\n end\n\n else\n [\n :danger,\n \"Could not start <strong>#{name.html_safe}</strong>! \" <<\n 'There is something wrong with the Batch\\'s schedule that needs to be fixed first. ' <<\n 'Make sure you have set a root task and that it saves with no errors, then try again.'\n ]\n end\n end",
"def next\n # try to set next job to running (already running is ok)\n until ready_jobs.empty? || ready_jobs.first.running?\n unless set_to_running(ready_jobs.first)\n locked_jobs << ready_jobs.shift # some other executor running this\n end\n end\n if ready_jobs.empty?\n return nil\n else\n return ready_jobs.first.next_cucumber_test_case\n end\n end",
"def next_date\n @schedule=schedules.where(\"schedules.end >= ?\", DateTime.now).sort_by(&:start).first\n if @schedule.nil?\n return schedules.sort_by(&:start).first\n else\n return @schedule\n end\n end",
"def scheduled_date\n return Date.today if @header == 'Today' # Change tomorrow to Today if you're generating it in the morning.\n return Date.today + 1 if @header == 'Tomorrow'\n parse_date_in_the_future(@header)\n end",
"def getNextJob()\n\t\t\t\tjob = nil\n\t\t\t\t\n\t\t\t\tThread.exclusive {\n\t\t\t\t\ti = @jobs.index { |j| j.canStart() }\n\t\t\t\t\tjob = @jobs.delete_at( i ) if ( i != nil )\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn job\n\t\t\tend",
"def remember_to_review\n if self.id and self.redeemed_at \n RunOncePeriodicJob.create!(:name => 'RememberToReview',\n :job => \"Credit.review_reminder(#{self.id})\",\n :next_run_at => (7.days.from_now)) unless self.redeemed_at.nil?\n end\n end",
"def task_schedule\n RecurringBatchTask.task_schedule(self).first\n end",
"def job\n @job\n end",
"def perform_now\n raise(::Mongoid::Errors::Validations, self) unless valid?\n\n worker = RocketJob::Worker.new(inline: true)\n start if may_start?\n # Re-Raise exceptions\n rocket_job_work(worker, true) if running?\n result\n end",
"def get_job (job_id)\n\n @cron_jobs[job_id] || @non_cron_jobs[job_id]\n end",
"def launched\n @launched ||= date_from_components(@launched_year, @launched_month, @launched_day)\n end",
"def base_date\n self.job.close_on || self.job.created_at.to_date\n end",
"def schedule_evaluation\n ActiveRecord::Base.transaction do\n job = EvaluateRecommendationJob.perform_later(self)\n self.ingredient.add_job(job.job_id)\n job\n end\n end",
"def save\n # if job is invalid return false\n return false unless valid?\n\n # update next_enqueue_timestamp\n @next_enqueue_timestamp = calculate_next_enqueue_time(Time.now.utc).to_i\n\n Sidekiq.redis do |conn|\n # add to set of all jobs\n conn.sadd(self.class.jobs_key, redis_key)\n\n # add informations for this job!\n conn.hmset(redis_key, *hash_to_redis(to_hash))\n end\n\n logger.info { \"CRON JOB: add job with name: #{@name}\" }\n end",
"def reserve_and_run_one_job; end",
"def execute_time\n @next_time\n end",
"def run_job\n end",
"def new\n @run = Run.new(:run_date => Date.today)\n end",
"def next_runnable_job(queue)\n tracking_key = get_next_runnable(queue)\n return nil unless tracking_key\n\n job = nil\n lock_key = lock_key(tracking_key)\n\n run_atomically(lock_key) do\n \n # since we don't have a lock when we get the runnable,\n # we need to check it again\n still_runnable = runnable?(tracking_key, queue)\n if still_runnable\n klazz = tracking_class(tracking_key)\n job = klazz.pop_from_restriction_queue(tracking_key, queue)\n end\n\n end\n\n return job\n \n end",
"def next_time\n\n schedule_info\n end",
"def next_scheduled_use_date\n next_date = nil\n\n open_orders.each do |o|\n if o.access_date_start\n next_date ||= o.access_date_start\n if o.access_date_start < next_date\n next_date = o.access_date_start\n end\n end\n end\n next_date\n end",
"def rocket_job_cron_next_time(time = Time.now)\n RocketJob::Plugins::Rufus::CronLine.new(cron_schedule).next_time(time)\n end",
"def rocket_job_cron_next_time(time = Time.now)\n RocketJob::Plugins::Rufus::CronLine.new(cron_schedule).next_time(time)\n end",
"def perform tenant_id\n accepting_new_jobs = $redis.setnx \"generating_docset\", Time.now.to_i\n\n if !accepting_new_jobs \n $redis.setnx \"new_docset_request\", Time.now.to_i\n\n if stale?\n Rails.logger.debug \"assume prev job died, doing heavy lifting anyway\"\n run_job tenant_id\n else\n Rails.logger.debug \"already in progress, skipping\"\n end\n\n else\n Rails.logger.debug \"starting new job\"\n run_job tenant_id\n end\n\n end",
"def last_run\n DateTime.parse(\"1 Jan 2007\")\n end",
"def job # this is a getter\n @job\n end",
"def try_again(job)\n if job['period'] && job['period'] > 0\n job['make_after'] = job['period']\n else\n job['make_after'] = job['attempt'] * JobReactor.config[:retry_multiplier]\n end\n job['args'].delete(:job_itself)\n self.storage.save(job) do |job|\n self.schedule(job)\n end\n end",
"def calculate_past\n site_id = params[:id]\n year = DateTime.now.year\n month = DateTime.now.month\n x = 0\n while x < 2 do\n month -= 1\n if month == 0 then \n year -= 1\n month = 12\n end\n x = x+1\n puts \"Calculating\"\n puts site_id\n date_start = Date.new(year, month, 1)\n d = date_start\n d += 42\n date_end = Date.new(d.year, d.month) - 1\n puts date_end.to_s\n puts date_start.to_s\n \n Delayed::Job.enqueue CalculateSite.new(site_id,date_start,date_end)\n end\n render :nothing => true\n end",
"def run_date_time=(value)\n @run_date_time = value\n end",
"def set_running_job\n @running_job = RunningJob.find(params[:id])\n end",
"def [](key)\n @timestamps[key][:accessed] = Time.now if @jobs[key]\n @jobs[key]\n end",
"def get_this_one(number)\n case @conditions[:breakdown_type]\n when \"Weekly\"\n @start_date + (7*number)\n when \"Quarterly\"\n d = @start_date.to_s.split(\"-\").map{|x| x.to_i}\n number.times{|x|\n d = increase_arr(d)\n }\n Date.parse(d.map{|x| x.to_s}.join(\"-\"))\n when \"Daily w/weekends\" # NOT ACTUALLY used.\n @start_date + number\n when \"Daily\"\n date = @start_date + number\n if [0,1].include?(date.wday) # MEEP. the hard coded sunday and monday are *HORRIBLE*\n return nil\n else\n return date\n end\n when \"Yearly\"\n Date.parse((@start_date.year + number).to_s + \"-01-01\")\n when \"Monthly\"\n month = @start_date.month\n year = @start_date.year\n month += number\n while month > 12\n year += 1\n month -= 12\n end\n Date.parse(\"#{year}-#{month}-01\")\n else\n raise NoMethodError\n end\n end",
"def start_recurring_payment\n return unless recurring_period.present?\n run_at = nil\n if recurring_period.to_s.is_i? # each custom days\n run_at = recurring_period.to_i.days.from_now\n # run_at = recurring_period.to_i.minutes.from_now\n else\n case recurring_period\n when 'daily'\n run_at = 1.day.from_now\n when 'weekly'\n run_at = 7.days.from_now\n when 'monthly'\n run_at = 1.month.from_now\n when 'quarterly'\n run_at = 3.months.from_now\n when 'biannually'\n run_at = 6.months.from_now\n when 'yearly'\n run_at = 1.year.from_now\n end\n end\n Delayed::Job.enqueue(LongTasks::RecurringPaymentNotification.new(id), run_at: run_at - 1.day) if run_at && ['tithe', 'partnership'].include?(goal)\n Delayed::Job.enqueue(LongTasks::RecurringPayment.new(id), run_at: run_at) if run_at\n end",
"def scheduled_at\n run_at || created_at\n end",
"def next_scheduled_at\n reviewed_at + (24.hours * next_interval)\n end",
"def get_running_time(job)\n case job.status \n when 'running' then ChronicDuration.output((Time.now - job.started_at+1).to_i, :format => :short) \n when 'done' then ChronicDuration.output((job.completed_at - job.started_at+1).to_i, :format => :short)\n else ''\n end\n end",
"def calculate_next_delivery\n interval = @schedulable.repeat_every\n next_delivery_date =\n case\n when @schedulable.company_survey.counter == 0 || @schedulable.time.present?\n set_next_delivery\n when @schedulable.repeat_mode == 'd'\n @schedulable.next_delivery_at + interval.days\n when @schedulable.repeat_mode == 'w'\n @schedulable.next_delivery_at + interval.weeks\n end\n\n @schedulable.update_column(:next_delivery_at, next_delivery_date)\n next_delivery_date\n end",
"def execute\n\n\n raise \"this job is not in the planned phase yet\" unless planned?\n\n if schedule_form == 'at'\n Gremlin.scheduler.at schedule_time do Gremlin.world.execute(plan_id) end\n else\n Gremlin.scheduler.in schedule_time do Gremlin.world.execute(plan_id) end\n end\n\n self.save\n end",
"def save!\n start_scheduler\n end",
"def inspection_shedule#(last_inspect_date)\n \t#self.inspection_at = Date.today\n if self.inspection_at.nil?\n else\n if self.rebuke == true\n next_inspect_at = self.inspection_at.next_day()\n else\n next_inspect_at = self.inspection_at.next_year()\n end\n if next_inspect_at.cwday == 6\n \tself.next_inspection_at = next_inspect_at.next_day(2)\n elsif next_inspect_at.cwday == 7\n \tself.next_inspection_at = next_inspect_at.next_day()\n else\n self.next_inspection_at = next_inspect_at\n end\n end\n end",
"def update\n\t\t\t@last_run = Time.new\n\t\tend",
"def finish_date\n if self.program_budge.nil?\n return nil\n elsif self.start_date.nil?\n return nil\n end\n duration=self.program_budge.duration_in_days\n default=self.start_date+duration.day\n \n if self.completed?\n #if already finished with level - return date they finished\n return self.last_completed_date.nil? ? default : self.last_completed_date\n else\n return default\n end\n end",
"def launch_date\n @delegated_to_object.date_launch\n end",
"def next!\n self.start = self.send(:\"next_#{frequency}_in_recurrence\") \n self\n end",
"def reschedule\n\n h.schedule_id = @context.storage.put_schedule(\n 'cron',\n h.fei,\n h.schedule,\n 'action' => 'reply',\n 'fei' => h.fei,\n 'workitem' => h.applied_workitem)\n\n @context.storage.delete_schedule(h.schedule_id) if try_persist\n #\n # if the persist failed, immediately unschedule\n # the just scheduled job\n #\n # this is meant to cope with cases where one worker reschedules\n # while another just cancelled\n end",
"def reschedule(job, time = T.unsafe(nil)); end",
"def reschedule_on_with_earlier_date!(date)\n return if date.nil?\n\n if start_date.blank? || start_date != date\n if due_date.present?\n self.due_date = RedmineBetterGanttChart::Calendar.workdays_from_date(date, duration - 1)\n end\n self.start_date = date\n save\n end\n end",
"def next_day\r\n if @next_day.nil?\r\n @next_day = convert_day_to_date(current_day).tomorrow.strftime('%Y%m%d')\r\n end\r\n @next_day\r\n end",
"def next_date\n next_observance.try(:start_on) || 100.years.from_now.to_date\n end",
"def make_scheduler_last_run(time)\n Que::Scheduler::VersionSupport.execute(<<~SQL)\n UPDATE que_jobs SET run_at = '#{time}'\n WHERE job_class = 'Que::Scheduler::SchedulerJob'\n SQL\n args = Que::Scheduler::VersionSupport.execute(<<~SQL).first[:args]\n SELECT * FROM que_jobs WHERE job_class = 'Que::Scheduler::SchedulerJob'\n SQL\n args.first[\"last_run_time\"] = time\n Que::Scheduler::VersionSupport.execute(<<~SQL)\n UPDATE que_jobs\n SET args = '#{args.to_json}'\n WHERE job_class = 'Que::Scheduler::SchedulerJob'\n SQL\n end",
"def process_recurrence(recurrence)\n return true unless recurrence.today?\n recurrence.update_job\n end",
"def running()\n self.status = :running\n self.run_start_time = DateTime.now\n save()\n end",
"def schedule_next_review\n self.next.save! if just_reviewed?\n end",
"def job\n return nil if self.job_id.nil?\n Delayed::Job.find(self.job_id)\n end",
"def run_next_job(proc_node)\n job = nil\n get_next_job = true\n self.transaction do\n while get_next_job\n begin\n job = jobs.first\n job.run(proc_node) if job\n get_next_job = false\n rescue => ex\n # Just name sure we go on\n logger.info \"Exception getting next job from queue: #{ex}\"\n get_next_job = false\n reload\n end\n end\n end\n job\n end",
"def set_scheduled_job\n @scheduled_job = ScheduledJob.find(params[:id])\n end",
"def next!\n if @date.month + 1 > 12\n @date = Date.new(@date.year+1,@date.month,1)\n else\n @date = Date.new(@date.year,@date.month+1,1)\n end\n end",
"def schedule_repetition\n self.due = Date.today + interval\n self.studied_at = Date.today\n end",
"def create_default_estimated_date\n Date.today + 7\n end",
"def current_job\n return @job_current\n end",
"def update_job job\n job.check_number = '0' if job.check_number.blank?\n job.pages_from = 1\n job.payer = Payer.find_by_payer(\"No Payer\")\n return job\n end"
] |
[
"0.72519344",
"0.7017858",
"0.6573886",
"0.64207494",
"0.64111346",
"0.63758737",
"0.6369535",
"0.6367696",
"0.6367696",
"0.60448647",
"0.60129595",
"0.59517425",
"0.59456",
"0.59294236",
"0.5834945",
"0.57872",
"0.56720597",
"0.56209594",
"0.55748844",
"0.55748844",
"0.55748844",
"0.5558549",
"0.55557626",
"0.55284387",
"0.55082554",
"0.5492673",
"0.5492673",
"0.5478067",
"0.5474798",
"0.54709756",
"0.5469986",
"0.5467461",
"0.5448835",
"0.5448835",
"0.5433919",
"0.54121554",
"0.54121554",
"0.54085934",
"0.537317",
"0.53709173",
"0.53616416",
"0.5358547",
"0.53516704",
"0.5346427",
"0.53423756",
"0.5316638",
"0.5289014",
"0.5280932",
"0.5272663",
"0.5267209",
"0.5263904",
"0.52634513",
"0.5251513",
"0.52514076",
"0.5239382",
"0.52324414",
"0.5231157",
"0.5229986",
"0.5222012",
"0.52214515",
"0.52214515",
"0.5220932",
"0.5205132",
"0.5192616",
"0.5186617",
"0.5179968",
"0.51776224",
"0.51623535",
"0.51568145",
"0.5146562",
"0.5131572",
"0.5124797",
"0.5123575",
"0.51226884",
"0.5114678",
"0.51128095",
"0.5110586",
"0.50906336",
"0.50854355",
"0.50839823",
"0.5028934",
"0.50236374",
"0.50233585",
"0.50160533",
"0.5013039",
"0.5009452",
"0.50087994",
"0.50036716",
"0.49984017",
"0.4997803",
"0.49906525",
"0.49882862",
"0.4979394",
"0.4973529",
"0.497239",
"0.4969905",
"0.49690914",
"0.49618098",
"0.49578756"
] |
0.6091187
|
10
|
When a new record is created, calculate the time when it should first run
|
def set_initial_next_run
self.next_run_at = Time.zone.now if self.next_run_at.nil?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_time(); @create_time; end",
"def instance_create_time\n data[:instance_create_time]\n end",
"def enter_created; end",
"def create\n self[:created] = Time.now.to_s\n save\n end",
"def time_since_creation\n ((Time.now - created_at) / 3600).round\n end",
"def before_create\n \tself.day_made ||= Date.current if new_record?\n \tself.got_bonus = false\n \tend",
"def time_since_creation\n ((Time.now - created_at) / 3600).round\n end",
"def create_timestamp\n self.created_at = Time.now\n end",
"def create_timestamp\n self.created_at = Time.now\n end",
"def created_time\n ctime\n end",
"def touch!\n @created = Time.now.to_i\n end",
"def created; BoxesConsoleHelpers.simple_time(created_at) rescue \"nil\"; end",
"def create_time=(time)\n @create_time = time\n update_times\n end",
"def before_create\n temp_time = Time.sl_local\n self.created_at = temp_time\n self.modified_at = temp_time\n end",
"def created_at\n ensure_full_data!\n Time.at(@gapi[\"creationTime\"] / 1000.0)\n end",
"def start_time; end",
"def timestamps!\n before(:create) do\n self['updated_at'] = self['created_at'] = Time.now\n end \n before(:update) do \n self['updated_at'] = Time.now\n end\n end",
"def creation_time\n data[:creation_time]\n end",
"def record_update_time(record)\n # HACK: Models like PersonAddress are missing the preferred\n # `date_changed` field thus we are falling back to date_created\n if immutable_model?(record, true)\n return record_date_voided(record) || record.date_created\n end\n\n if record.class == DrugOrder\n order = Order.unscoped.find(record.order_id)\n return order.date_voided || order.date_created\n end\n\n if record.class == ProgramWorkflowState || record.class == ProgramWorkflow\n return record.date_changed || record.date_created\n end\n\n record_date_voided(record) || record.date_changed || record.date_created\n end",
"def execute_time\n @next_time\n end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def getCreatedTime\r\n\t\t\t\t\treturn @createdTime\r\n\t\t\t\tend",
"def getCreatedTime\r\n\t\t\t\t\treturn @createdTime\r\n\t\t\t\tend",
"def before_create; self.created_on = Time.now.utc; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def create_time\n Convert.timestamp_to_time @grpc.create_time\n end",
"def create_time\n Convert.timestamp_to_time @grpc.create_time\n end",
"def seconds_since_last_moment_created\n Time.now - self.moments.last.created_at \n end",
"def total_time; end",
"def creation_time # :nodoc:\n @creation_time.dup\n end",
"def update\n\t\t\t@last_run = Time.new\n\t\tend",
"def log_create\n if self.class.name == 'ParticipantsSportEntry'\n model = self.sport_entry\n action = 'UPDATE'\n else\n model = self\n action = 'CREATE'\n end\n\n ModelAuditJob.perform_now(model, action, audit_user_id)\n end",
"def process_creation_date_time\n return @process_creation_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_date_time\n return @created_date_time\n end",
"def created_at\n if able_to_store_created_at?\n time = instance_read(:created_at)\n time && time.to_f.to_i\n end\n end",
"def date() updated; end",
"def before_create\n self.created_at ||= Time.now\n super # ($)\n end",
"def time_elapsed_secs\n ((winned_at || updated_at || Time.zone.now) - created_at).to_i.seconds\n end",
"def autolog_created\n autolog_event(:created)\n end",
"def lead_time\n 1\n end",
"def creationtime\r\n\t\t\t`#{BITS::BITSADMIN} /getcreationtime {#{@id}}`\r\n\t\tend",
"def start_time\n start\n end",
"def lead_time\n 0\n end",
"def launched_time\n\n @root_expression && @root_expression.created_time\n end",
"def create\n @time_record = TimeRecord.new(params[:time_record])\n @time_record.value = (@time_record.ended_at - @time_record.started_at) / 1.hour\n @time_record.recorded_on = @time_record.started_at.to_date\n\n respond_to do |format|\n if @time_record.save\n format.html { redirect_to time_records_path, notice: 'Time record was successfully created.' }\n format.json { render json: @time_record.to_json, status: :created, location: @time_record }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_record.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end",
"def set_time_before_save\n \n if self.quiz.quiz_type_id == QuizType.find_by_name(\"FullQuiz\").id\n if self.section_type_id == SectionType.find_by_name(\"Quant\").id\n self.time = 35\n elsif self.section_type_id == SectionType.find_by_name(\"Verbal\").id\n self.time = 30\n end\n elsif self.quiz.quiz_type_id == QuizType.find_by_name(\"SectionQuiz\").id\n if self.section_type_id == SectionType.find_by_name(\"Quant\").id\n self.time = 35\n elsif self.section_type_id == SectionType.find_by_name(\"Verbal\").id\n self.time = 30\n end\n else\n self.time = 0 \n end\n \n # This is required as the call_back will fail if false is returned.\n nil\n \n end",
"def start_trial\n self.trial_started_at = Time.now if self.new_record?\n end",
"def created_date_time\n return @created_date_time\n end",
"def initialize\n @created_at = Time.now\n end",
"def addtime\n \n end",
"def create(record)\n now = Time.now\n record['created_at'] ||= now\n record['updated_at'] ||= now\n collection.insert(record)\n end",
"def record_creation_timestamp(path, timestamp)\n # Hook method: Linux filesystems doesn't store creation datetime\n end",
"def creation_date\n# stat.ctime\n @bson['uploadDate'] || Date.new\n end",
"def creation_date\n stat.ctime\n end",
"def time\n super\n end",
"def before_create\n self.created_at = Time.now\n self.updated_at = Time.now\n end",
"def lead_time\n if completed_at\n completed_at - created_at\n else\n 0.0\n end\n end",
"def creation_epoch\n saved_at.try(:to_i)\n end",
"def current_time\r\n return @owner.timestamp.to_i - @start.to_i\r\n end",
"def getCreatedTimeLong\r\n\t\t\t\t\treturn @createdTimeLong\r\n\t\t\t\tend",
"def getCreatedTimeLong\r\n\t\t\t\t\treturn @createdTimeLong\r\n\t\t\t\tend",
"def now; end"
] |
[
"0.7812308",
"0.7321703",
"0.6958651",
"0.6904216",
"0.67879105",
"0.6738086",
"0.6736327",
"0.6733391",
"0.6731828",
"0.67078125",
"0.66799533",
"0.66673815",
"0.65622777",
"0.65558004",
"0.6481178",
"0.6462483",
"0.6459509",
"0.64408976",
"0.64320576",
"0.64148587",
"0.63966423",
"0.63966423",
"0.63966423",
"0.63966423",
"0.63966423",
"0.63966423",
"0.63642144",
"0.63642144",
"0.63638103",
"0.63307405",
"0.63307405",
"0.63307405",
"0.63307405",
"0.63307405",
"0.63307405",
"0.63307405",
"0.63307405",
"0.63307405",
"0.6316203",
"0.6316203",
"0.6296584",
"0.6284812",
"0.6278913",
"0.6267308",
"0.62579024",
"0.62350553",
"0.6234623",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.623418",
"0.62155396",
"0.621292",
"0.62082404",
"0.6206084",
"0.619292",
"0.61925995",
"0.6183505",
"0.6181563",
"0.6177399",
"0.6174998",
"0.61678237",
"0.6165018",
"0.6161032",
"0.6153767",
"0.61481774",
"0.61296755",
"0.6117418",
"0.61074257",
"0.61060464",
"0.60971946",
"0.6081969",
"0.6077279",
"0.60762304",
"0.60645545",
"0.6061592",
"0.6052929",
"0.6052929",
"0.6051552"
] |
0.0
|
-1
|
Runs a job and updates the +last_run_at+ field.
|
def run!
PeriodicJob.log_error "Executing job id #{self.id}, #{self.to_s}..."
begin
self.last_run_at = Time.now
self.next_run_at = nil
self.save
command = self.job.gsub(/#JOBID#/, self.id.to_s).gsub(/#RAILS_ROOT#/, Rails.root.to_s)
puts command
eval(command)
self.last_run_result = "OK"
PeriodicJob.log_info "Job completed successfully"
rescue Exception
err_string = "'#{self.job}' could not run: #{$!.message}\n#{$!.backtrace}"
PeriodicJob.log_error err_string
self.last_run_result = err_string.slice(1..500)
begin
GeneralMailer.failed_periodic_job(self).deliver
rescue
end
end
self.save
# ...and persist the next run of this job if one exists
set_next_job
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def run!\n TaskServerLogger.instance.error \"Executing job id #{self.id}, #{self.to_s}...\"\n begin\n self.last_run_at = Time.zone.now\n self.next_run_at = nil\n self.save\n eval(self.job.gsub(/#JOBID#/, self.id.to_s).gsub(/#RAILS_ROOT#/, RAILS_ROOT))\n self.last_run_result = \"OK\"\n TaskServerLogger.instance.info \"Job completed successfully\"\n rescue Exception\n err_string = \"'#{self.job}' could not run: #{$!.message}\\n#{$!.backtrace}\"\n TaskServerLogger.instance.error err_string\n puts err_string unless ENV['RAILS_ENV'] == \"test\"\n self.last_run_result = err_string.slice(1..500)\n begin\n Notifier.deliver_job_failure(self)\n rescue\n end\n end\n self.save\n\n # ...and persist the next run of this job if one exists\n set_next_job\n end",
"def update\n\t\t\t@last_run = Time.new\n\t\tend",
"def last_ended(job, batch)\n sql = \"Select * from #{schema_name}.job_runs where job_id = '#{job.id}' and batch = '#{batch.to_json}' and (status = 'success' or status = 'error') ORDER BY ended_at DESC;\"\n runs = job_run_query(sql)\n runs.first\n end",
"def make_scheduler_last_run(time)\n Que::Scheduler::VersionSupport.execute(<<~SQL)\n UPDATE que_jobs SET run_at = '#{time}'\n WHERE job_class = 'Que::Scheduler::SchedulerJob'\n SQL\n args = Que::Scheduler::VersionSupport.execute(<<~SQL).first[:args]\n SELECT * FROM que_jobs WHERE job_class = 'Que::Scheduler::SchedulerJob'\n SQL\n args.first[\"last_run_time\"] = time\n Que::Scheduler::VersionSupport.execute(<<~SQL)\n UPDATE que_jobs\n SET args = '#{args.to_json}'\n WHERE job_class = 'Que::Scheduler::SchedulerJob'\n SQL\n end",
"def fail_job\n self.last_run_at = Time.zone.now\n self.next_run_at = nil\n self.last_run_result = \"Timeout\"\n self.save\n\n # ...and persist the next run of this job if one exists\n set_next_job\n end",
"def fail_job\n self.last_run_at = Time.now\n self.next_run_at = nil\n self.last_run_result = \"Timeout\"\n self.save\n\n # ...and persist the next run of this job if one exists\n set_next_job\n end",
"def run_now!\n update_attributes(run_at: nil) if cron_schedule\n end",
"def update!\n scheduling.total_runs = scheduling.total_runs.to_i + qjob.stats['releases']\n scheduling.last_run = Time.now\n end",
"def do_job(job)\n job['run_at'] = Time.now\n job['status'] = 'in progress'\n job['attempt'] += 1\n storage.save(job) do |job|\n begin\n args = job['args'].merge(JR.config[:merge_job_itself_to_args] ? {:job_itself => job.dup} : {})\n job.succeed(args)\n job['args'] = args\n job_completed(job)\n rescue CancelJob\n cancel_job(job)\n rescue Exception => e\n rescue_job(e, job)\n end\n end\n end",
"def run\n case self[:job]\n when Proc\n self[:job].call\n else\n self[:job]\n end\n end",
"def perform\n self.status = STATUS_DONE\n self.save\n job.update_status\n end",
"def rerun!\n ensure_service!\n gapi = service.insert_job @gapi.configuration, location: location\n Job.from_gapi gapi, service\n end",
"def perform_job(entry)\n job_item = entry.item\n return unless job_item\n\n if job_item.rdf_repository_configured?\n job_item.update_repository_rdf\n else\n job_item.delete_rdf_file\n job_item.save_rdf_file\n end\n\n if entry.refresh_dependents?\n job_item.queue_dependents_rdf_generation\n end\n end",
"def get_running_time(job)\n case job.status \n when 'running' then ChronicDuration.output((Time.now - job.started_at+1).to_i, :format => :short) \n when 'done' then ChronicDuration.output((job.completed_at - job.started_at+1).to_i, :format => :short)\n else ''\n end\n end",
"def set_latest(rule_key, timestamp)\n @timestamps[rule_key]['latest_run'] = timestamp\n end",
"def last_run_at\n super || self.schedule.try(:previous_occurrence)\n end",
"def execute_cron_job\n lambda do\n |request, jle|\n $db_lock.synchronize {\n jle.run_status = 'Running'\n jle.start_time = Time.now\n jle.save(:validate => false)\n }\n jlh = Hash.new\n jlh[:run_status] = \"Failure\"\n @@thread_count = @@thread_count + 1;\n Thread.current[:name] = \"JOB_THREAD \" + request.to_s + ' ' + @@thread_count.to_s;\n Thread.current[:watchdogged] = false\n begin\n jmd = JobMetadata.job_code(request)[0]\n @job_map[Thread.current] = jmd.max_execution_minutes.to_i.minutes.from_now\n\n jlh[:jmd] = jmd\n jlh[:jle] = jle\n commands = gather_commands(true,request)\n commands = commands[request]\n if (commands.nil? || commands.empty?)\n $logger.error(\"There are no commands for request #{request}. Exiting...\")\n return\n end\n $logger.debug(\"The size of commands is \" << commands.length.to_s)\n #total_result = nil\n commands.each do |command|\n command.chomp!\n $logger.debug(\"command = #{command}\")\n #$stderr.puts(\"executing #{command}\")\n #result = `#{command}` There seems to be a bug in ruby where backticks hang in multi threaded situations\n result = JobEngine.execute_command_to_temp(command)\n #$stderr.puts(\"executed #{command}\")\n result.chomp!\n\n if (jlh[:job_result].nil?)\n jlh[:job_result] = result\n else\n jlh[:job_result] << \"\\n\" << result\n end\n $logger.debug(\"the result is #{result}...\")\n #check to see if the command is in\n end\n # $stderr.puts(\"About to finish the jle\")\n # finish_job_log_entry(Time.now,total_result, jle, nil)\n jlh[:run_status] = \"Completed\"\n # $stderr.puts(\"finished the jle\")\n # email_job_result(total_result,jle,jmd) if jmd.email_result\n # $stderr.puts(\"emailed\") if jmd.email_result\n # $stderr.puts(\"not emailed\") unless jmd.email_result\n\n rescue =>ex\n error = \"An execution thread terminated while executing \" << request\n $logger.error(error)\n $logger.error(ex.to_s)\n jlh[:job_result] = '' if jlh[:job_result].nil?\n jlh[:job_result] << ex.to_s\n ensure\n unless jlh[:run_status].eql?(\"Completed\")\n jlh[:job_result] = '' if jlh[:job_result].nil?\n if (Thread.current[:watchdogged])\n jlh[:job_result] << \"\\nKilled by the job watch dog at \" + Thread.current[:watchdogged_time].to_s + \"!\"\n else\n jlh[:job_result] << \"\\nAn exceptional event occurred!\"\n end\n end\n finish_job_log_entry(jlh)\n end\n end\n end",
"def run_job\n end",
"def perform(build, launcher, listener)\n context = BuildContext.new(build, launcher, listener)\n notes = BuildNotes.new(context).notes\n update_git_notes(notes, context)\n notify_sqs(notes, context)\n end",
"def perform(build, launcher, listener)\n BuildContext.instance.set(build, launcher, listener) do\n git_updater = GitUpdater.new\n retries = Constants::CONCURRENT_UPDATE_RETRIES\n notes = BuildNotes.new.notes\n begin\n info \"updating git notes\"\n git_updater.update!(notes)\n rescue GitUpdater::ConcurrentUpdateError => e\n if retries > 0\n warn \"caught ConcurrentUpdateError while updating git notes, retrying (#{retries}x left)\"\n retries -= 1\n retry\n else\n raise e\n end\n end\n info \"updated git notes: #{notes}\"\n end\n end",
"def calc_next_run\n RunAtPeriodicJob.new(:name => self.name, :job => self.job, :run_at_minutes => self.run_at_minutes)\n end",
"def run_date_time=(value)\n @run_date_time = value\n end",
"def update!(**args)\n @latest_job_end_time = args[:latest_job_end_time] if args.key?(:latest_job_end_time)\n @latest_job_start_time = args[:latest_job_start_time] if args.key?(:latest_job_start_time)\n end",
"def process_job job\n begin\n log.info \"Performing job #{job.id}\"\n jo = job.job_object\n jo.log = log\n jo.perform\n log.info \"Job #{job.id} completed\"\n job.complete\n Model::Worker.increment(id, {:'stats.done' => 1})\n rescue Exception => e\n log.error \"Job #{job.id} failed\"\n log.error e\n job.fail e\n Model::Worker.increment(id, {:'stats.failed' => 1})\n p e\n end\n end",
"def call(job)\n @last_job_id = job.job_id\n block.call(job)\n end",
"def update_last_run(gauges_config)\n gauges_config[:last_run] = Date.today\n File.open(\"#{CACHE_DIR_PATH}/config\", 'w') do |file|\n file.puts YAML.dump(gauges_config)\n end\n end",
"def perform(*args)\n if Service.get_service.jobs_enabled?\n # Job processing is enabled.\n Delayed::Worker.logger.info \"---> running #{self.class}(#{args.join(',')}) on #{self.queue_name} at priority #{Process::getpriority(Process::PRIO_PROCESS, 0)}\"\n start_time = Time.current\n perform_if_enabled(*args)\n Delayed::Worker.logger.info \"<--- finished #{self.class} after #{time_ago_in_words(start_time)}\"\n else\n # Resubmit the job with the required parameters after the specified delay. If the inline adapter is being used, we just ignore this.\n Delayed::Worker.logger.warn \"**** job processing disabled for #{self.class}\"\n begin\n self.class.set(wait: DISABLED_RETRY_INTERVAL).perform_later(*args)\n rescue NotImplementedError => _e\n Delayed::Worker.logger.error \"**** no job queue available for future job #{self.class}\"\n end\n end\n end",
"def update!(**args)\n @job_results = args[:job_results] if args.key?(:job_results)\n end",
"def update!(**args)\n @job_results = args[:job_results] if args.key?(:job_results)\n end",
"def last_run\n DateTime.parse(\"1 Jan 2007\")\n end",
"def update!(**args)\n @job_results = args[:job_results] if args.key?(:job_results)\n end",
"def find_latest_job_run(job_id, opts = {})\n status = opts[:status]\n group_by = 'group by id, created_at, updated_at, job_id, batch, status, queued_at, started_at, ended_at, rows_processed, message'\n sql = \"select Max(ended_at) as ended_at, id, created_at, updated_at, job_id, batch, status, queued_at, started_at, rows_processed, message from #{@schema_name}.job_runs where job_id = '#{job_id}'\"\n unless status.nil?\n sql = sql + \" and status = '#{status}'\"\n end\n sql = sql + \" #{group_by}\"\n job_run_query(sql)\n end",
"def update_timestamp(work)\n # these timestamps are the Hyrax managed fields, not rails timestamps\n if work.date_uploaded\n work.date_modified = Time.current\n else\n work.date_uploaded = Time.current\n end\n end",
"def job_completed(operation)\n jobs = operation.jobs.sort_by(&:updated_at)\n jobs.last.updated_at\n end",
"def run\n while (get_job() ) do\n checkout_job()\n do_job()\n complete_job()\n end\n end",
"def update_job! changed_job\n jobs.where(id: changed_job[:id]).update(changed_job)\n rescue ::Sequel::DatabaseError => e\n retry if on_error e\n end",
"def do_trigger\n\n hit_exception = false\n\n begin\n\n @block.call @job_id, @at, @params\n\n rescue Exception => e\n\n @scheduler.send(:log_exception, e)\n\n hit_exception = true\n end\n\n if \\\n @scheduler.instance_variable_get(:@exit_when_no_more_jobs) or\n (@params[:dont_reschedule] == true) or\n (hit_exception and @params[:try_again] == false)\n\n @scheduler.instance_variable_get(:@non_cron_jobs).delete(job_id)\n # maybe it'd be better to wipe that reference from here anyway...\n\n return\n end\n\n #\n # ok, reschedule ...\n\n\n params[:job] = self\n\n @at = @at + Rufus.duration_to_f(params[:every])\n\n @scheduler.send(:do_schedule_at, @at, params)\n end",
"def attempt_to_run\n if recipe.schedule.runnable?\n\n if rhizomes_in_use?\n [\n :danger,\n \"Could not start <strong>#{name.html_safe}</strong> It appears the requested Rhizomes are currently in use!\"\n ]\n else\n rhizomes.each do |r|\n r.batch = self\n r.save!\n Rails.logger.info \"Assigned Rhizome #{r.name} to Batch #{r.batch.name}\"\n end\n end\n\n self.start_time = Time.now.to_datetime\n result = ScheduleJob.set(queue: queue_name).perform_later(recipe.schedule)\n\n if result\n start!\n reload\n [:success, \"Starting <strong>#{name.html_safe}</strong>\"]\n else\n [:danger, \"Could not start <strong>#{name.html_safe}</strong>!\"]\n end\n\n else\n [\n :danger,\n \"Could not start <strong>#{name.html_safe}</strong>! \" <<\n 'There is something wrong with the Batch\\'s schedule that needs to be fixed first. ' <<\n 'Make sure you have set a root task and that it saves with no errors, then try again.'\n ]\n end\n end",
"def run!\n logger.info(\"Running task #{self.class.to_s}\")\n @block.call\n @next_run = cron_parser && cron_parser.next(Time.now)\n end",
"def run(job, queue=:default)\n Metriks.timer(\"handler.job.run\").time do\n job.run(queue, payload, params)\n end\n end",
"def perform!\n Quebert.config.before_job(self)\n Quebert.config.around_job(self)\n\n # Honor the timeout and kill the job in ruby-space. Beanstalk\n # should be cleaning up this job and returning it to the queue\n # as well.\n val = ::Timeout.timeout(ttr, Job::Timeout){ perform(*args) }\n\n Quebert.config.around_job(self)\n Quebert.config.after_job(self)\n\n val\n end",
"def set_run_at\n self.run_at = Time.now + check_seconds\n end",
"def perform_work\n logger.debug \"update_marc handing off to dor-services-app job for update to #{druid}\"\n object_client.update_marc_record\n\n # Since the actual update work is completed by dor-services-app in a job,\n # workflow logging (marking step completed or failed) is done there.\n LyberCore::ReturnState.new(status: :noop, note: 'Initiated update_marc_record API call.')\n end",
"def update\n # FIXME: this should use retry_it\n xml = render_template\n begin\n print \"Updating #{job_name}\\n\"\n xml_debug(xml) if @debug\n Jenkins.job.create_or_update(job_name, xml)\n rescue => e\n # FIXME: use retry_it to fail after a number of tries\n puts e\n retry\n end\n job_name\n end",
"def update!(**args)\n @latest_job = args[:latest_job] if args.key?(:latest_job)\n @update_time = args[:update_time] if args.key?(:update_time)\n end",
"def step_trigger\n\n now = Time.now\n\n if @exit_when_no_more_jobs && @pending_jobs.size < 1\n\n @stopped = true\n return\n end\n\n # TODO : eventually consider running cron / pending\n # job triggering in two different threads\n #\n # but well... there's the synchronization issue...\n\n #\n # cron jobs\n\n if now.sec != @last_cron_second\n\n @last_cron_second = now.sec\n\n @cron_jobs.each do |cron_id, cron_job|\n #trigger(cron_job) if cron_job.matches?(now, @precision)\n cron_job.trigger if cron_job.matches?(now)\n end\n end\n\n #\n # pending jobs\n\n now = now.to_f\n #\n # that's what at jobs do understand\n\n loop do\n\n break if @pending_jobs.length < 1\n\n job = @pending_jobs[0]\n\n break if job.at > now\n\n #if job.at <= now\n #\n # obviously\n\n job.trigger\n\n @pending_jobs.delete_at 0\n end\n end",
"def run_job\n begin\n set_initial_status\n initialize_job\n run_job_template\n rescue => err\n job_error_handler(err)\n ensure\n close_job\n end\n end",
"def job_completed(job)\n report_success(job) if job['on_success']\n if job['period'] && job['period'].to_i > 0\n job['status'] = 'queued'\n job['make_after'] = job['period']\n job['args'].delete(:job_itself)\n storage.save(job) { |job| schedule(job) }\n else\n if JR.config[:remove_done_jobs]\n storage.destroy(job)\n else\n job['status'] = 'complete'\n storage.save(job)\n end\n end\n end",
"def perform(time)\n puts \"This job was published at #{}\"\n end",
"def run_task\n\t\tif params[:job] == 'xapian'\n\t\t\tsystem(\"rake xapian:update_index RAILS_ENV=#{RAILS_ENV}\")\n\t\tend\n\t\tif params[:job] == 'feeds'\n\t\t\tsystem(\"ruby script/runner -e #{RAILS_ENV} 'FeedSource.update_feed_source'\")\n\t\tend\n\t\tif params[:job] == 'newsletter'\n\t\t\tDelayed::Job.enqueue(NewsletterJob.new)\n\t\tend\n\t\tif params[:job] == 'translations'\n\t\t\tLANGUAGES.each do |l|\n\t\t\t\tcommand_backup = \"mv config/locales/\" + l + \".yml tmp/backup/\" + Time.now.strftime(\"%Y%m%d\") + \"_\" + l + \".yml\"\n\t\t\t\tcommand_get = \"wget \" + TRANSLATION_SITE + \"/translations/\" + PROJECT_NAME + \"/\" + l + \".yaml -O config/locales/\" + l + \".yml\"\n\t\t\t\tsystem(command_backup)\n\t\t\t\tsystem(command_get)\n\t\t\tend\n\t\t\tmessage = \"Translation files Retrieved\"\n\t\tend\n\t\tif params[:job] == 'restart_server'\n\t\t\tsystem \"touch #{RAILS_ROOT}/tmp/restart.txt\" # tells passenger to restart the server\n\t\t\tmessage = \"Server restarted successfully\"\n\t\tend\n\t\t\n\t\tmessage.nil? ? @message = \"#{params[:job].capitalize} Updated Sucessfully \" : @message = message\n\t\t\n\t\trespond_to do |format|\n \t format.js {render :layout => false}\n \tend\n \t\n\t\t# render :update do |page|\n\t\t# page.show 'notice'\n\t\t# page.replace_html 'notice', \n\t\t# end\n end",
"def failed_at\n Time.at(self[Job::WORKFLOW_FINISHED_AT_FIELD].to_f) if failed?\n end",
"def reschedule\n\n h.schedule_id = @context.storage.put_schedule(\n 'cron',\n h.fei,\n h.schedule,\n 'action' => 'reply',\n 'fei' => h.fei,\n 'workitem' => h.applied_workitem)\n\n @context.storage.delete_schedule(h.schedule_id) if try_persist\n #\n # if the persist failed, immediately unschedule\n # the just scheduled job\n #\n # this is meant to cope with cases where one worker reschedules\n # while another just cancelled\n end",
"def perform(*args)\n # start a \"timer\" and run it until whenever\n start_time = Time.now.to_i\n\n expiration_time = Config.find_by(description: 'Timer expiration').value.to_f\n \n # just run forever (i.e. until expired or cancelled)\n while !cancelled? && (Time.now.to_f - start_time) < expiration_time\n end\n\n # remove own JID from Timer table\n timer = Timer.find_by(jid: jid)\n # Don't try this update if a Timer with this JID does not exist\n if timer\n timer.update(jid: nil)\n end\n\n end_time = Time.now.to_f\n\n puts \"Timer JID:#{jid} ran for: #{end_time - start_time} seconds\"\n end",
"def run\n process_queue\n RailsPipeline.logger.info \"Queue: '#{@queue}'. Processed: #{@processed}\"\n if Time.now - @failure_last_checked > @failure_check_interval\n @failure_last_checked = Time.now\n check_for_failures\n end\n end",
"def save\n # if job is invalid return false\n return false unless valid?\n\n # update next_enqueue_timestamp\n @next_enqueue_timestamp = calculate_next_enqueue_time(Time.now.utc).to_i\n\n Sidekiq.redis do |conn|\n # add to set of all jobs\n conn.sadd(self.class.jobs_key, redis_key)\n\n # add informations for this job!\n conn.hmset(redis_key, *hash_to_redis(to_hash))\n end\n\n logger.info { \"CRON JOB: add job with name: #{@name}\" }\n end",
"def do_trigger\n\n @block.call @job_id, @cron_line, @params\n end",
"def update_last_comment\n if self.call\n self.call.update_attribute(:last_comment, self.body)\n end\n end",
"def save\n self.class.store(job_id, data, expire_at)\n self\n end",
"def create_run(batch)\n jr = JobRun.create_for_job(self, batch)\n jr.save\n jr\n end",
"def update!(**args)\n @job = args[:job] if args.key?(:job)\n end",
"def update!(**args)\n @job = args[:job] if args.key?(:job)\n end",
"def update!(**args)\n @failed_jobs = args[:failed_jobs] if args.key?(:failed_jobs)\n @job = args[:job] if args.key?(:job)\n end",
"def reschedule(job, time = T.unsafe(nil)); end",
"def run_template\n launched_job.update(status_message: \"Running TplDevTest job\")\n launched_job.job_log.info \"Logging within TplDevTest job\"\n\n sleep self.sleep_seconds\n\n launched_job.status\n end",
"def after_perform_job_stats_performed(*args)\n Resque.redis.incr(jobs_performed_key)\n end",
"def submit_job\n unless inputfile_identifier.nil?\n set_version if version.nil?\n submit_script = generate_submit_script(input_deck: inputfile_identifier)\n\n if !submit_script.nil?\n Dir.chdir(jobdir) {\n cmd = \"qsub #{prefix}.sh\"\n self.pid = `#{cmd}`\n }\n end\n end\n\n # If successful, set the status to \"Submitted\" and save to database.\n unless pid.nil? || pid.empty?\n self.pid = pid.strip\n self.submitted_at = Time.new.ctime\n set_status! :b\n else\n self.pid = nil\n self.submitted_at = '---'\n set_status! :f\n end\n end",
"def submit_job\n unless inputfile_identifier.nil?\n set_version if version.nil?\n submit_script = generate_submit_script(input_deck: inputfile_identifier)\n\n if !submit_script.nil?\n Dir.chdir(jobdir) {\n cmd = \"qsub #{prefix}.sh\"\n self.pid = `#{cmd}`\n }\n end\n end\n\n # If successful, set the status to \"Submitted\" and save to database.\n unless pid.nil? || pid.empty?\n self.pid = pid.strip\n self.submitted_at = Time.new.ctime\n set_status! :b\n else\n self.pid = nil\n self.submitted_at = '---'\n set_status! :f\n end\n end",
"def do_trigger\n\n @block.call @job_id, @at\n\n @scheduler.instance_variable_get(:@non_cron_jobs).delete @job_id\n end",
"def reschedule(job, time = nil)\n if (job.attempts += 1) < max_attempts(job)\n time ||= job.reschedule_at\n job.run_at = time\n job.unlock\n job.save!\n else\n job_say job, \"REMOVED permanently because of #{job.attempts} consecutive failures\", 'error'\n failed(job)\n end\n end",
"def runPostRunCmd(previousJobName)\n postRunCmd = \"ruby \" + File.dirname(__FILE__) + \"/bwa_postrun.rb\"\n objPostRun = Scheduler.new(@fcAndLane + \"_post_run\", postRunCmd)\n objPostRun.setMemory(2000)\n objPostRun.setNodeCores(1)\n objPostRun.setPriority(@priority)\n if previousJobName != nil && !previousJobName.empty?() \n objPostRun.setDependency(previousJobName)\n end\n objPostRun.runCommand()\n end",
"def submit_job\n input_deck = generate_input_deck\n # results_script = generate_results_script\n\n if !input_deck.nil? #&& !results_script.nil?\n submit_script = generate_submit_script(input_deck: input_deck)\n # submit_script = generate_submit_script(input_deck: input_deck,\n # results_script: results_script)\n\n if !submit_script.nil?\n Dir.chdir(jobdir) {\n cmd = \"qsub #{prefix}.sh\"\n self.pid = `#{cmd}`\n }\n end\n end\n\n # If successful, set the status to \"Submitted\" and save to database.\n unless pid.nil? || pid.empty?\n self.pid = pid.strip\n # self.submitted_at = Time.new.ctime\n set_status! :b\n else\n self.pid = nil\n # self.submitted_at = '---'\n set_status! :f\n end\n end",
"def execute\n\n\n raise \"this job is not in the planned phase yet\" unless planned?\n\n if schedule_form == 'at'\n Gremlin.scheduler.at schedule_time do Gremlin.world.execute(plan_id) end\n else\n Gremlin.scheduler.in schedule_time do Gremlin.world.execute(plan_id) end\n end\n\n self.save\n end",
"def finish(output, time_taken)\n update_attributes({\n :status => SUCCEEDED,\n :worker_record => nil,\n :attempts => self.attempts + 1,\n :output => output,\n :time => time_taken\n })\n end",
"def run_with_logs(job)\n capture_logs do\n job.perform\n end.map{ |log| log[:msg] }.join(\"\\n\")\n end",
"def try_again(job)\n if job['period'] && job['period'] > 0\n job['make_after'] = job['period']\n else\n job['make_after'] = job['attempt'] * JobReactor.config[:retry_multiplier]\n end\n job['args'].delete(:job_itself)\n self.storage.save(job) do |job|\n self.schedule(job)\n end\n end",
"def [](key)\n @timestamps[key][:accessed] = Time.now if @jobs[key]\n @jobs[key]\n end",
"def perform\n gid = recurring_job_data[:dynamic_def]\n dynamic_def = GlobalID::Locator.locate gid\n dynamic_def.reload\n dynamic_def.option_configs force: true\n bt = dynamic_def.configurations&.dig(:batch_trigger)\n unless bt\n msg = \"Attempted to perform recurring batch job for #{gid} - but _configurations:\" \\\n \"has no batch_trigger: defined\\n\" \\\n \"#{dynamic_def.configurations || '(nil _configurations)'}\"\n Rails.logger.warn msg\n raise FphsException, msg\n end\n limit = bt[:limit]\n\n user = dynamic_def.class.user_for_conf_snippet(bt)\n\n dynamic_def_imp_class = dynamic_def.implementation_class\n dynamic_def_imp_class.trigger_batch_now(limit: limit, alt_user: user)\n rescue StandardError => e\n Rails.logger.warn \"Recurring job failed: #{self} - #{gid} - #{e}\"\n Rails.logger.warn e.backtrace.join(\"\\n\")\n ApplicationJob.notify_failure self\n raise\n end",
"def complete_at\n Time.at(self[Job::WORKFLOW_FINISHED_AT_FIELD].to_f) if complete?\n end",
"def call(rjob, time)\n # Since Rufus scheduler starts a new thread for each job, we must manage the connection\n # pool ourselves.\n # http://stackoverflow.com/questions/11248808/connection-pool-issue-with-activerecord-objects-in-rufus-scheduler\n ActiveRecord::Base.connection_pool.with_connection do\n new_launched_job.run_job\n end\n end",
"def job \n @job\n end",
"def log_job_end(name, message = nil)\n ellapsed = Time.now - job_started_at\n ms = (ellapsed.to_f * 1000).to_i\n action_word = message ? 'Finished' : 'Completed'\n log_info(\"#{action_word} #{name} in #{ms}ms #{message}\")\n end",
"def job= (work)\n @job = work\n end",
"def finished!\n t = Time.now.utc\n update_attribute(:finished_at, t)\n # Save errors counts\n if errs = error_messages\n BackupJobError.increment_errors_count(*errs)\n end\n backup_source.backup_complete!\n on_finish :errors => errs, :messages => messages\n end",
"def perform_now\n raise(::Mongoid::Errors::Validations, self) unless valid?\n\n worker = RocketJob::Worker.new(inline: true)\n start if may_start?\n # Re-Raise exceptions\n rocket_job_work(worker, true) if running?\n result\n end",
"def run(job)\n resp = command %{run job=\"#{job}\" yes}\n expr = /^Job queued. JobId=(\\d+)$/\n if resp =~ expr\n $1.to_i\n else\n raise \"Command error:\" + \\\n \" expected #{expr.inspect},\" + \\\n \" got #{resp.inspect}\"\n end\n end",
"def run_batch\n make_run_batch_call\n end",
"def run_date_time\n return @run_date_time\n end",
"def update\n\t\tproject = Project.editable(current_user).find_by_name(params[:project_id])\n\t\traise \"There is no such project.\" unless project.present?\n\n\t\tjob = Job.find(params[:id])\n\t\traise \"The project does not have the job.\" unless job.project == project\n\n\t\tjob.stop_if_running\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to :back }\n\t\tend\n\tend",
"def set_running_job\n @running_job = RunningJob.find(params[:id])\n end",
"def running()\n self.status = :running\n self.run_start_time = DateTime.now\n save()\n end",
"def run\r\n return unless if?\r\n job_name.constantize.send method_name, formatted_arguments\r\n end",
"def create_or_update_previous_runs!; end",
"def create_or_update_previous_runs!; end",
"def work( payload, metadata )\n\t\tself.job_counter.mark\n\t\tself.job_timer.time do\n\t\t\tsuper\n\t\tend\n\tend",
"def get_run_time\n return next_to_last_run if @time >= next_to_last_run\n\n Time.utc(@time.year, @time.month, @time.day,\n (@time.hour / run_interval) * run_interval)\n end",
"def perform()\n query = Query.find(BSON::ObjectId.from_string(query_id))\n result = query.executions.find(execution_id).results.find(result_id);\n\n url = URI.parse result.result_url\n request = Net::HTTP::Get.new(url.path)\n PollJob.submit(request, url, query, result)\n end",
"def invoke_job\n self.attempts += 1\n payload_object.perform\n end",
"def was_successful?\n self.class.job_run_class.was_successful?(@job, @batch)\n end",
"def job\n @job\n end",
"def job\n @job\n end"
] |
[
"0.7211853",
"0.63806945",
"0.62906766",
"0.60734063",
"0.6009462",
"0.59831697",
"0.5980262",
"0.59266365",
"0.58394057",
"0.5718038",
"0.55837923",
"0.55430067",
"0.5506809",
"0.54610294",
"0.5419358",
"0.5409527",
"0.5385332",
"0.5309621",
"0.5297598",
"0.5290517",
"0.52904063",
"0.5264686",
"0.5259248",
"0.5243999",
"0.52183765",
"0.5181243",
"0.51804155",
"0.5172503",
"0.5172503",
"0.5169716",
"0.5169669",
"0.5168925",
"0.5159669",
"0.515872",
"0.51447743",
"0.5114655",
"0.51122993",
"0.5101157",
"0.50943184",
"0.50883514",
"0.5087173",
"0.5086838",
"0.5085877",
"0.5085621",
"0.5083513",
"0.5076857",
"0.50758517",
"0.507376",
"0.5069759",
"0.50650764",
"0.5064287",
"0.5040107",
"0.5031847",
"0.502693",
"0.5026673",
"0.50208527",
"0.50172806",
"0.5016634",
"0.5016502",
"0.50138515",
"0.50138515",
"0.500906",
"0.5000893",
"0.49952447",
"0.49951932",
"0.49849918",
"0.49849918",
"0.49829638",
"0.49714324",
"0.49670926",
"0.4965332",
"0.496376",
"0.4963036",
"0.4956367",
"0.49512517",
"0.494449",
"0.4939829",
"0.49361885",
"0.49277088",
"0.49227154",
"0.49201673",
"0.4917505",
"0.49025634",
"0.49002743",
"0.48877022",
"0.48859665",
"0.48751688",
"0.48736772",
"0.4870475",
"0.48652256",
"0.48617813",
"0.4860938",
"0.4860938",
"0.48586366",
"0.4857661",
"0.48401186",
"0.48392397",
"0.48333326",
"0.4832376",
"0.4832376"
] |
0.68404543
|
1
|
Mark the current job as Timed out, and rerun it...used to process zombie jobs
|
def fail_job
self.last_run_at = Time.now
self.next_run_at = nil
self.last_run_result = "Timeout"
self.save
# ...and persist the next run of this job if one exists
set_next_job
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def requeue_timed_out_jobs\n # older than x\n jobs.where{started_working_at <= (Time.now - EQ.config.job_timeout)}\\\n .update(started_working_at: nil)\n end",
"def fail_job\n self.last_run_at = Time.zone.now\n self.next_run_at = nil\n self.last_run_result = \"Timeout\"\n self.save\n\n # ...and persist the next run of this job if one exists\n set_next_job\n end",
"def perform!\n # Honor the timeout and kill the job in ruby-space. Beanstalk\n # should be cleaning up this job and returning it to the queue\n # as well.\n begin\n Quebert::Timeout.timeout(@ttr){ perform(*args) }\n rescue ::Timeout::Error\n raise Job::Timeout\n end\n end",
"def try_again(job)\n if job['period'] && job['period'] > 0\n job['make_after'] = job['period']\n else\n job['make_after'] = job['attempt'] * JobReactor.config[:retry_multiplier]\n end\n job['args'].delete(:job_itself)\n self.storage.save(job) do |job|\n self.schedule(job)\n end\n end",
"def attempt_to_stop\n recipe.schedule.clean_up_task_jobs\n self.stop_time = Time.now.to_datetime\n rhizomes.each do |r|\n r.batch = nil\n r.save!\n end\n stop!\n [:success, \"Stopped <strong>#{name.html_safe}</strong>!\"]\n end",
"def perform!\n Quebert.config.before_job(self)\n Quebert.config.around_job(self)\n\n # Honor the timeout and kill the job in ruby-space. Beanstalk\n # should be cleaning up this job and returning it to the queue\n # as well.\n val = ::Timeout.timeout(ttr, Job::Timeout){ perform(*args) }\n\n Quebert.config.around_job(self)\n Quebert.config.after_job(self)\n\n val\n end",
"def unschedule\r\n if (self.time != :forever)\r\n @job.unschedule\r\n @time = :forever\r\n @timed_out = false\r\n end\r\n end",
"def reschedule(job, time = nil)\n if (job.attempts += 1) < max_attempts(job)\n time ||= job.reschedule_at\n job.run_at = time\n job.unlock\n job.save!\n else\n job_say job, \"REMOVED permanently because of #{job.attempts} consecutive failures\", 'error'\n failed(job)\n end\n end",
"def reply (workitem)\n\n unschedule_timeout(workitem)\n\n super\n end",
"def on_timeout\n trigger\n reset\n end",
"def stub_idv_job_to_timeout_in_background(idv_job_class)\n allow(idv_job_class).to receive(:perform_now)\n end",
"def on_timeout\n trigger\n reset\n end",
"def rocket_job_restart_abort\n return unless cron_schedule\n\n rocket_job_restart_new_instance\n update_attribute(:cron_schedule, nil)\n end",
"def stop_timeout\n @expire_time = nil\n end",
"def rocket_job_restart_abort\n return unless cron_schedule\n rocket_job_restart_new_instance\n update_attribute(:cron_schedule, nil)\n end",
"def rocket_job_restart_abort\n return unless cron_schedule\n rocket_job_restart_new_instance\n update_attribute(:cron_schedule, nil)\n end",
"def worker_shutdown_timeout(timeout); end",
"def kill_job(job_id)\n __push([], :kill_job, job_id)\n end",
"def reject\n log_debug { \"Rejecting job with jid: #{item[JID_KEY]} already running\" }\n send_to_deadset\n end",
"def kill() end",
"def do_job\r\n# disable recycle invites\r\n# min = Time.now.min\r\n# #recycle invites 1 min per hour\r\n# if min == 0\r\n# ret = ActiveRecord::Base.connection.execute(\"delete from invites where invitee_id is null and created_at < subdate(now(), interval 3 day)\")\r\n# puts \"recycle invites: #{ret}\"\r\n# end\r\n end",
"def reset_on_timeout_state\n super\n end",
"def start_timed_out\n end",
"def worker_timeout(timeout); end",
"def quitWorkingJob\n\t\t@db.hdel('sgt-unit:'+@id, 'job')\n\tend",
"def set_timedout_flag (workitem)\n\n workitem.attributes['__timed_out__'] = 'true'\n end",
"def reschedule(job, time = T.unsafe(nil)); end",
"def done_working\n super\n self.job = nil\n end",
"def complete_rescue(job)\n if job['attempt'].to_i < JobReactor.config[:max_attempt]\n try_again(job)\n else\n job['status'] = 'failed'\n report_error(job) if job['on_error']\n if JR.config[:remove_failed_jobs]\n storage.destroy(job)\n else\n storage.save(job)\n end\n end\n end",
"def timeout!; end",
"def destroy_job\n with_advisory_lock do\n execution = head_execution(reload: true)\n\n raise ActionForStateMismatchError if execution.finished_at.blank?\n\n destroy\n end\n end",
"def handle_timeout!(timeout)\n # Synchronized so that check and kill operation occur as an\n # atomic operation, see exec above\n @pool_lock.synchronize { \n if @being_executed && (Time.now - @timestamp) > timeout\n RJR::Logger.debug \"timeout detected on thread #{@thread} started at #{@timestamp}\"\n @thread.kill\n return true\n end\n return false\n }\n end",
"def stopKill\n self.stop_d\n return\n end",
"def endJob\n\t\tunits.each do |unit|\n\t\t\tunemployUnit unit\n\t\tend\n\t\t\n\t\t# TODO: Remove job from it's queue\n\t\t\n\t\t@db.del('sgt-job:' + @id + ':units')\n\t\t@db.del('sgt-job:'+@id)\n\tend",
"def check_zombie_jobs # rubocop:disable MethodLength, Metrics/AbcSize\n return unless @submission.attempting?\n\n submitted_answers = @submission.latest_answers.select(&:submitted?)\n return if submitted_answers.empty?\n\n dead_answers = submitted_answers.select do |a|\n job = a.auto_grading&.job\n job && job.submitted? &&\n job.created_at < Time.zone.now - Course::Assessment::ProgrammingEvaluation::TIMEOUT\n end\n\n dead_answers.each do |a|\n old_job = a.auto_grading.job\n job = a.auto_grade!(redirect_to_path: old_job.redirect_to,\n reattempt: true, reduce_priority: true)\n\n logger.debug(message: 'Restart Answer Grading', answer_id: a.id, job_id: job.job.id,\n old_job_id: old_job.id)\n end\n end",
"def disable_until_finished_or_interrupted; end",
"def retry\n job = Job.find(params[:id])\n job.enter(Job::Scheduled)\n respond_with job do |format|\n format.html { redirect_to jobs_path }\n end\n end",
"def kill!() end",
"def run_interrupted; end",
"def cancel\n @timers.cancel self\n end",
"def kill_job\n raise UnableToKillJobNotRunningError unless self.status == RUNNING\n begin\n JobScheduler.find.try(:kill_job, self)\n raise KilledJobError.new 'Job Killed'\n rescue => err\n job_error_handler(err)\n ensure\n close_job \n end\n end",
"def lock_timeout_retries; end",
"def lay_to_rest(pid, timeout=10)\n #refuse to kill ourselves, or to pass a bad arg to Process.kill\n return 0 unless pid.is_a?(Integer) && pid > 0\n\n Process.kill('TERM', pid)\n time_waited = 0\n loop do\n if time_waited >= timeout\n Process.kill('KILL', pid)\n # can't waitpid here, because the ssh-agent isn't our\n # child. Still, after SIGKILL it will die and init will\n # reap it, so continue\n return\n end\n # still can't waitpid here, so we see if it's still alive\n return unless still_alive?(pid)\n sleep 1\n time_waited += 1\n end\n end",
"def kill\n @queue << \"kill\"\n end",
"def reaper\n pstate = wait(0.5)\n do_kill(\"KILL\") unless pstate\n end",
"def stop\n # TODO: can this be elsewhere?\n puts \"Stopping job #{@sandbox.job.id}\"\n\n @thread.kill\n ActiveRecord::Base.clear_active_connections!\n @mutex.synchronize { @thread_status.running = false }\n end",
"def reschedule(time)\n assert_kind_of(Time, time)\n fail \"Time should not be in past\" if time < Time.now\n\n time = Rufus.to_datetime time\n\n self.job.unschedule\n\n self.job = self.scheduler.at time.to_s do\n self.timed_out = true\n self.subscribers.each { |object| object.timed_out }\n end\n end",
"def kill\n @alive = false\n end",
"def lock_timeout; end",
"def work\n if @busy && @remaining_job_time > 0\n @remaining_job_time -= 1\n end\n end",
"def execute\n @job = nil\n @job = @beanstalk.reserve(120) rescue nil\n if @job\n $stdout.puts \"[C] #{Process.pid} processing job #{@job.inspect}\"\n # ... do more processing here\n end\n rescue Beanstalk::TimedOut\n ensure\n @job.delete rescue nil if @job\n end",
"def cancel\n @timers.cancel self\n end",
"def kill\n @executor.shutdownNow\n nil\n end",
"def handle_timeout\n pop_outstanding_request\n nil\n end",
"def daemonization_timed_out\n end",
"def handle_child_workflow_execution_timed_out(event)\n handle_event(event,\n {:id_methods => [:workflow_execution, :workflow_id],\n :consume_symbol => :handle_completion_event,\n :decision_helper_scheduled => :scheduled_external_workflows,\n :handle_open_request => lambda do |event, open_request|\n exception = ChildWorkflowTimedOutException.new(event.id, open_request.description, nil)\n open_request.completion_handle.fail(exception)\n end\n })\n end",
"def unlock\n if job\n job.report_running if report_job_status\n job.set_status(\"Unlocking #{to_s}\")\n end\n\n attempt_unlock\n\n report(true)\n end",
"def _rtimeout(wi)\n Ruote.participant_send(self, :rtimeout, 'workitem' => wi)\n end",
"def timeout\n super\n end",
"def timeout\n super\n end",
"def lock_timeout_retries=(_arg0); end",
"def evict_timeout(timeout)\n @evict_timeout = timeout.to_i\n self\n end",
"def abort\n @thread.kill\n unset_thread_task\n end",
"def do_schedule_timeout (timeout)\n\n return unless timeout\n return if timeout.strip == ''\n\n h.timeout_schedule_id = @context.storage.put_schedule(\n 'at',\n h.fei,\n timeout,\n 'action' => 'cancel',\n 'fei' => h.fei,\n 'flavour' => 'timeout')\n end",
"def retry\n reque_single_job(params[:id])\n redirect_to failures_path(redirect_params)\n end",
"def timer_timed_out\n self.log(\"Globaler Timer ist abgelaufen\")\n JavaScript::Runtime.call_slot(Global.timer_path, Global.timer_slot)\n end",
"def reap_dead_workers(reason='unknown')\n if workers.list.length > 0\n DTR.info \"Reaping #{workers.list.length} threads because of '#{reason}'\"\n error_msg = \"#{Time.now}: WorkerClub timed out this thread: #{reason}\"\n mark = Time.now\n workers.list.each do |worker|\n worker[:started_on] = Time.now if not worker[:started_on]\n\n if mark - worker[:started_on] > timeout\n DTR.info \"Thread #{worker.inspect} is too old, killing.\"\n worker.raise(TimeoutError.new(error_msg))\n end\n end\n end\n\n return workers.list.length\n end",
"def terminate\n @state = :terminating\n cancel_timer\n true\n end",
"def finish_job job\n job_id = job.respond_to?(:id) ? job.id : job\n @current_jobs.delete job_id\n @job_pids.delete(job_id)\n end",
"def fail!\n return if state == 'FAILED'\n JobTracker.transaction do\n update_attribute(:state, 'FAILED')\n Delayed::Job.destroy_failed_jobs ? delayed_jobs.each(&:destroy) : delayed_jobs.each do |dj|\n dj.update_attribute(:failed_at, Time.now)\n end\n end\n end",
"def dequeue\n self.job.destroy if self.job.present?\n self.job_id = nil\n end",
"def vanquish_undead(bjobs,jobid)\n return unless @should_vanquish_undead\n job=bjobs[jobid]\n return nil if job.nil?\n\n\n\n if not job[:reservation_time].nil? and not job[:lsf_runlimit].nil?\n now=Time.now\n reservation_age=now-job[:reservation_time]\n runlimit=job[:lsf_runlimit]\n past=reservation_age/60.0-runlimit\n if past > 10\n WorkflowMgr.stderr(\"#{job[:jobid]}: Is a zombie, falsely reported as running. Will bkill job and list as failed with exit status 1000. Info: now=#{now} res age=#{reservation_age} runlimit=#{runlimit} past=#{past}.\",1)\n job[:state]='FAILED'\n job[:native_state]='ZOMBIE_RUNNING'\n job[:exit_status]=100\n job[:end_time]=now\n else\n WorkflowMgr.stderr(\"#{job[:jobid]}: Running for #{(reservation_age/60).floor} of #{runlimit} reservation (past=#{past}).\",1)\n end\n end\n return nil\n end",
"def timeout_stop(timeout)\n model.timeout_stop(timeout)\n end",
"def extend_lock!\n Resque.redis.expire(key, timeout)\n end",
"def quiet\n cron_poller.terminate\n super\n end",
"def stop_watching\n @thread.kill\n end",
"def failsafe_timeout\n super\n end",
"def perform(*args)\n # start a \"timer\" and run it until whenever\n start_time = Time.now.to_i\n\n expiration_time = Config.find_by(description: 'Timer expiration').value.to_f\n \n # just run forever (i.e. until expired or cancelled)\n while !cancelled? && (Time.now.to_f - start_time) < expiration_time\n end\n\n # remove own JID from Timer table\n timer = Timer.find_by(jid: jid)\n # Don't try this update if a Timer with this JID does not exist\n if timer\n timer.update(jid: nil)\n end\n\n end_time = Time.now.to_f\n\n puts \"Timer JID:#{jid} ran for: #{end_time - start_time} seconds\"\n end",
"def queue_lock_timeout\n 3600\n end",
"def kill instance, why\n\t\t\tbegin\n\t\t\t\tProcess.kill 15, instance.pid\n\t\t\t\tsleep 0.2\n\t\t\t\tProcess.kill 9, instance.pid\n\t\t\trescue Errno::ESRCH\n\t\t\t\t# We can safely ignore it if the thing has already died.\n\t\t\tend\n\t\t\tinstance.killed! why\n\t\t\treconfigure_rproxies\n\t\tend",
"def requeue_dead_server(server_name)\n # Need to requeue paused, failed since user may have transitioned job before it finished\n where(:state.in => %i[running paused failed]).each do |job|\n job.requeue!(server_name) if job.may_requeue?(server_name)\n end\n end",
"def on_timeout\n trigger\n @active = false\n end",
"def restart!\n if failed? \n update_attributes!(\n :result => nil, \n :progress => nil, \n :started_at => nil, \n :state => \"pending\"\n )\n logger.info(\"MerbBackground: Job restarted. Job(id: #{id}).\")\n end\n end",
"def timeout_after(time); end",
"def refresh_jid_expiration\n return unless jid\n\n Gitlab::SidekiqStatus.set(jid, StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION)\n end",
"def kill\n if TerminateJobObject(@job_handle, Process.pid) == 0\n raise Error, get_last_error\n end\n end",
"def cancel\n @client.call('unrecur', @jid)\n end",
"def terminate_timeout\n workers.map(&:stop_timeout).compact.max.to_i + 10\n end",
"def terminate\n find_job\n if @job.nil?\n type = :error\n text = \"Sorry, this job does not exist or is not accessible by you\"\n path = api_jobs_path\n\n render json: { path: path, message: { type: type, text: text } }, adapter: :json\n return\n end\n if !@job.terminal?\n DNAnexusAPI.new(@context.token).call(@job.dxid, \"terminate\")\n type = :success\n text = \"Job was successfully terminated\"\n else\n type = :warning\n text = \"Job is in terminal state and can not be terminated\"\n end\n path = api_job_path(@job)\n\n render json: { path: path, message: { type: type, text: text } }, adapter: :json\n end",
"def reschedule(time)\r\n \"missing time\" if time.nil?\r\n\r\n time_rufus = Rufus.to_datetime time\r\n\r\n @job.unschedule unless (self.time == :forever)\r\n\r\n @job = @scheduler.at time_rufus.to_s do\r\n @timed_out = true\r\n @subscribers.each { |object| object.timed_out }\r\n end\r\n\r\n @time = time\r\n end",
"def lock_timeout_limit=(_arg0); end",
"def timeout(spec_timeout)\n EM.cancel_timer(@spec_timer) if @spec_timer\n @spec_timer = EM.add_timer(spec_timeout) do\n @spec_exception = SpecTimeoutExceededError.new \"Example timed out\"\n done\n end\n end",
"def lock_timeout_retry_delay; end",
"def cancel\n to_run.clear\n reset\n current_self\n end",
"def cancel\n return unless @running\n @running = false\n end",
"def shutdown_after(timeout); end",
"def restart( timeout = 5 )\n stop( timeout )\n start\n end",
"def timeout; end",
"def timeout; end",
"def timeout; end"
] |
[
"0.73669684",
"0.66212237",
"0.6544433",
"0.6540633",
"0.6449734",
"0.63333625",
"0.6280775",
"0.6166026",
"0.60948735",
"0.607705",
"0.60596967",
"0.6026616",
"0.5998994",
"0.5998957",
"0.59879327",
"0.59879327",
"0.59696597",
"0.5961413",
"0.59424746",
"0.5910612",
"0.58976305",
"0.5890649",
"0.58707875",
"0.586872",
"0.5850501",
"0.58190364",
"0.58158296",
"0.5805031",
"0.57943124",
"0.5770625",
"0.5749564",
"0.5743874",
"0.57408774",
"0.5739499",
"0.57333875",
"0.57276654",
"0.57259226",
"0.57138646",
"0.5708619",
"0.5697737",
"0.5693925",
"0.56895125",
"0.56764287",
"0.56740904",
"0.56688803",
"0.56641877",
"0.5661679",
"0.5658781",
"0.56472254",
"0.5642621",
"0.56351393",
"0.56316537",
"0.562775",
"0.5618237",
"0.5611292",
"0.56048816",
"0.56005085",
"0.5584497",
"0.5572041",
"0.5572041",
"0.55658317",
"0.5563442",
"0.5562476",
"0.55602247",
"0.55589336",
"0.5551953",
"0.55491465",
"0.55485785",
"0.5547718",
"0.5546115",
"0.5545853",
"0.55270773",
"0.55223125",
"0.5517547",
"0.5517367",
"0.5490875",
"0.5489631",
"0.54694736",
"0.5465515",
"0.5464259",
"0.5461874",
"0.5460048",
"0.54562634",
"0.54395825",
"0.5436635",
"0.5433828",
"0.54318005",
"0.5430485",
"0.54300356",
"0.5406505",
"0.54062235",
"0.53991103",
"0.53972703",
"0.53964406",
"0.53947955",
"0.53947204",
"0.5393461",
"0.5381694",
"0.5381694",
"0.5381694"
] |
0.6585353
|
2
|
GET /world_instances/1 GET /world_instances/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @instances = Instance.all\n render json: @instances\n end",
"def index\n @instances = Instance.all\n render :json => @instances\n end",
"def destroy\n @world_instance.destroy\n respond_to do |format|\n format.html { redirect_to world_instances_url, notice: 'World instance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n world_name = params[\"name\"]\n superclass_uri = params[\"type-parent\"]\n container_uri = params[\"location-parent\"]\n description = params[\"description\"]\n if params.has_key?(:options)\n options = {protected: false, locked: false}\n options[:protected] = true if (params[\"options\"].include?(\"protected\"))\n options[:locked] = true if (params[\"options\"].include?(\"locked\"))\n end\n host_port = request.host_with_port\n hostname = host_port.split(\":\").first\n port = host_port.split(\":\").last\n\n if (WorldAdmin.has_visibility_privilege?(superclass_uri, session[:user_uri]) && WorldAdmin.has_frame_level_privilege?(container_uri, session[:user_uri]))\n w = WorldInstance.create_world_instance_with_uri(world_name, superclass_uri, container_uri, description, nil, options, nil, nil, nil, hostname, port)\n\n puts w.world_instance_uri\n redirect_to w.world_instance_uri\n else\n head(status=401)\n end\n\n # @world_instance = WorldInstance.new(world_instance_params)\n #\n # respond_to do |format|\n # if @world_instance.save\n # format.html { redirect_to @world_instance, notice: 'World instance was successfully created.' }\n # format.json { render :show, status: :created, location: @world_instance }\n # else\n # format.html { render :new }\n # format.json { render json: @world_instance.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def load_world_info \n # First, let's check if info is saved in Redis\n worlds = @redis.get(\"worlds\")\n if worlds.nil?\n # Grab information from API\n response = Faraday.get \"#{API_ENDPOINT}/v2/worlds?ids=all\"\n raise \"Couldn't retrieve world info from API, status: #{response.status}\" if response.status != 200\n \n @worlds = {}\n api_response = JSON.parse(response.body)\n api_response.each do |world|\n @worlds[world[\"id\"]] = world[\"name\"].gsub(/ \\[.*$/, \"\")\n end\n \n @redis.set(\"worlds\", @worlds.to_json)\n else\n @worlds = JSON.parse(worlds)\n end\nend",
"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 instance\n perform_request_with_object(:get, '/api/v1/instance', {}, Mastodon::Instance)\n end",
"def instance\n perform_request_with_object(:get, '/api/v1/instance', {},\n Mastodon::Instance)\n end",
"def instances\n instances = []\n JSON.parse(resource['/instances'].get)[\"instances\"].each do |i|\n instances << Instance.new(i)\n end\n return instances\n end",
"def show\n @instance = Instance.find(params[:id])\n render :json =>@instance\n end",
"def get_instance_data\n JSON.parse(Net::HTTP.get(URI.parse('http://169.254.169.254/latest/dynamic/instance-identity/document')))\n end",
"def show\n @neighborhood = Neighborhood.find(params[:id])\n\n render json: @neighborhood\n end",
"def update\n respond_to do |format|\n if @world_instance.update(world_instance_params)\n format.html { redirect_to @world_instance, notice: 'World instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @world_instance }\n else\n format.html { render :edit }\n format.json { render json: @world_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_by_id(id)\n self.class.get(\"/aldebaran-instances/instances/#{id}\", :basic_auth => @auth)\n end",
"def show\n @server_instance = ServerInstance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @server_instance }\n end\n end",
"def index\n @world_regions = WorldRegion.all\n end",
"def instances\n IbmCloudRest.get \"#{@uri}/instances\"\n end",
"def index\n @instances = Instance.all\n end",
"def index\n @instances = Instance.all\n end",
"def new\n @flavours = @provider.get_flavors\n puts \"getting the flavors #{@flavours.inspect}\"\n @images = @provider.get_images\n puts \"getting the flavors #{@images.inspect}\"\n @instance = @provider.instances.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instance }\n end\n end",
"def my_instance_id\n Net::HTTP.get(URI('http://169.254.169.254/1.0/meta-data/instance-id'))\n end",
"def show\n @instance = Instance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance }\n end\n end",
"def show\n @neighborhood = Neighborhood.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def index\n page = params[:page]\n per_page = (params[:per_page] || 10).to_i\n if page\n entities = _all_instances_query.page(page).per(per_page)\n render json: entities, entity: _get_class,\n meta: { total_pages: entities.total_pages, total_count: entities.total_count }\n else\n entities = _all_instances_query\n respond_with entities, entity: '_get_class'\n end\n end",
"def get_instance instance_id\n instances.get_instance name: instance_path(instance_id)\n end",
"def get_instances\n instances = [ ]\n get_clouds.each do |cloud|\n instances += cloud.instances.index(:filter => [], :view => 'tiny')\n end\n instances\n end",
"def show\n @simulation = Simulation.find(params[:id])\n\n #this is super crap, just for debugging ATM, moving out soon\n @world = World.new\n @roombot = RoombaSimulation.new\n @world.spawn(@roombot)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @simulation }\n end\n end",
"def show\n @cluster = Cluster.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cluster }\n end\n end",
"def show\n @instance_type = InstanceType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance_type }\n end\n end",
"def show\n #@instance = Instance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance }\n end\n end",
"def index\n account = Account.find(params[:account_id])\n @instances = obtain_instances(account.id, account.account_regions.first.region)\n\n @servers = {}\n @instances.each do |instance|\n @servers[instance.instance_id] = Server.find_by(instance_id: instance.instance_id) || @account.servers.create(instance_id: instance.instance_id)\n end\n rescue => e\n render text: e.message\n end",
"def show\n @slab = Slab.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @slab }\n end\n end",
"def find_by_id(client, id, options: {})\n\n self.new(parse(client.get(\"/worlds/#{id}\", options: options)).first, client: client)\n end",
"def list_instances\n puts \"OK, Listing instances..\"\n\n response = RestClient.post( \n $uri,\n 'Version' => '2010-12-30',\n 'ACSAccessKeyId' => $ACSAccessKeyId,\n 'Format' => 'json',\n 'Timestamp' => $current_time,\n 'Rndguid' => $rndguid,\n 'Signature' => calculate_signature($api_private_key, $rndguid, $current_time),\n 'Action' => \"list-instances\")\n\n puts response\n puts response.code\nend",
"def get_world;\t@world \t\tend",
"def show\n tile = Tile.find(params[:id]) \n render json: tile\n end",
"def instance_data\n @instance_data ||= JSON.parse(Net::HTTP.get(URI.parse('http://169.254.169.254/latest/dynamic/instance-identity/document')))\n end",
"def show\n simulation = Simulation.retrieve_by_id(params[:id])\n\n render json: simulation\n end",
"def new\n @server_instance = ServerInstance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server_instance }\n end\n end",
"def show\n # proxy to GET /roi/id\n @result = ImageServer.get('/roi/'+params[:id]);\n render :json => @result\n end",
"def show\n render json: @instance\n end",
"def lookup_instance_id\n metadata_endpoint = 'http://169.254.169.254/latest/meta-data/'\n instance_id = Net::HTTP.get( URI.parse( metadata_endpoint + 'instance-id' ) )\n end",
"def show\n render json: Server.where(name: params[:name]).first\n end",
"def get_pcloud_instance\n get(\"cloud-instances/#{guid}\")\n end",
"def show\n @console_pool = ConsolePool.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @console_pool }\n end\n end",
"def show\n @core_machine = Core::Machine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @core_machine }\n end\n end",
"def list_instances_detail()\n response = dbreq(\"GET\", dbmgmthost, \"#{dbmgmtpath}/instances/detail\", dbmgmtport, dbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n instances = CloudDB.symbolize_keys(JSON.parse(response.body)[\"instances\"])\n return instances\n end",
"def show\n @neighborhood = Neighborhood.find(params[:id])\n @units = @neighborhood.units\n @jobs = @neighborhood.jobs\n @operations_centers = @neighborhood.operations_centers\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def show\n @cloud = Cloud.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cloud }\n end\n end",
"def show\n @game_game_instance = Game::GameInstance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_game_instance }\n end\n end",
"def index\n @neighborhoods = Neighborhood.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @neighborhoods }\n end\n end",
"def show\n @tile = Tile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tile }\n end\n end",
"def show\n @tile = Tile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tile }\n end\n end",
"def show\n @game_server = Game::Server.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_server }\n end\n end",
"def show\n @voxel = Voxel.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @voxel }\n end\n end",
"def fetch_instance(shortname = :all, options = {})\n return instances if instances && !options[:force]\n\n fetch_stack\n unless instance_list\n self.instance_list = self.instances =\n aws_client.describe_instances(stack_id: stack[:stack_id])[:instances]\n end\n\n if shortname != :all\n fetch_layer(shortname, force: true)\n self.instances = []\n\n layers.each do |layer|\n instance = aws_client.describe_instances(\n layer_id: layer[:layer_id])\n self.instances << instance[:instances]\n end\n\n self.instances.flatten!\n end\n end",
"def index\n @mirrors = Mirror.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mirrors }\n end\n end",
"def index\n @machines = @location.machines\n @machine = Machine.new\n @titles = Title.all\n\n respond_to do |format|\n format.html {require_user}\n format.json { render json: @machines }\n end\n end",
"def show\n @system_site_map = SystemSiteMap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @system_site_map }\n end\n end",
"def aws_instance_get(opts)\n AWS::EC2.new.instances[opts[:instance_id]]\n end",
"def index\n @dungeon_instances = current_user.dungeon_instances.all\n end",
"def get_instance instance_id\n execute do\n instances.get_instance(\n instance_path(instance_id)\n )\n end\n end",
"def get_cloud_instances(cloud_id)\n http_get_request(Scalarium.clouds_url+\"/#{cloud_id}/instances\") \n end",
"def show\n\th = Hostmap.new()\n\t@map = h.map_single(params[:id])\n end",
"def show\n @gethotelstaticdatagd = Gethotelstaticdatagd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gethotelstaticdatagd }\n end\n end",
"def show\n render json: @region\n end",
"def describe_instances( options = {} )\n options = { :instance_id => [] }.merge(options)\n params = pathlist(\"InstanceId\", options[:instance_id])\n return response_generator(:action => \"DescribeInstances\", :params => params)\n end",
"def show\n @asset_host = DayzGps::Application.config.action_controller.asset_host ||\n \"http://localhost:#{request.port.inspect}\"\n respond_to do |format|\n format.html\n format.json { render json: @group_map.map_markers }\n end\n end",
"def show\n @machine = Machine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @machine }\n end\n end",
"def show\n @machine = Machine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @machine }\n end\n end",
"def show\n @machine = Machine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @machine }\n end\n end",
"def show\n @machine = Machine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @machine }\n end\n end",
"def index\n info = Aws.get_recipes_from_db\n render :json => info\n end",
"def populate\n response = @connection.dbreq(\"GET\",@lbmgmthost,\"#{@lbmgmtpath}/instances/#{CloudDB.escape(@id.to_s)}\",@lbmgmtport,@lbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n data = JSON.parse(response.body)['instance']\n @id = data[\"id\"]\n @name = data[\"name\"]\n @hostname = data[\"hostname\"]\n @created = data[\"created\"]\n @updated = data[\"updated\"]\n @flavor_id = data[\"flavor\"][\"id\"]\n @volume_size = data[\"volume\"][\"size\"]\n @status = data[\"status\"]\n true\n end",
"def show\n @host = Host.find_by(hostname: params[:id])\n\n render json: @host\n end",
"def show\n @instance = Instance.find(params[:id])\n @flavor = Flavor.find_by_flavor_id(@instance.flavor_id)\n @image = Image.find_by_image_id(@instance.image_id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance }\n end\n end",
"def show\n @game = Game.find(params[:id])\n render json: @game, status: 200\n end",
"def show\n @registry = Registry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @registry }\n end\n end",
"def index\n @instances = Instance.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @instances }\n end\n end",
"def show\n @island = Island.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @island }\n end\n end",
"def show\n @domain_map = DomainMap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @domain_map }\n end\n end",
"def show\n @host = Host.find(params[:id])\n\n render json: @host\n end",
"def show\n @admin_hotspot = Admin::Hotspot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_hotspot }\n end\n end",
"def index\n weathers = Weather.all\n render json: weathers, status: 200\n end",
"def show\n render json: Game.find(params[:id])\n end",
"def show\n @shard = Shard.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shard }\n end\n end",
"def index\n @instances = Instance.page params[:page]\n authorize! :read, @instances\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @instances }\n end\n end",
"def get_instance_of_cloud(cloud_id, instance_of_cloud_id)\n http_get_request(Scalarium.clouds_url+\"/#{cloud_id}/instances/#{instance_of_cloud_id}\") \n end",
"def me\n require 'open-uri'\n begin\n instance_id = open('http://169.254.169.254/latest/meta-data/instance-id').read\n instance instance_id\n rescue OpenURI::HTTPError => e\n nil\n end\n end",
"def collection_stream\n world ? \"/world/#{world.id}/players.json\" : super\n end",
"def new\n @cluster = Cluster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cluster }\n end\n end",
"def index\r\n @locations = Location.all\r\n @mv = MapsVersion.first\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @locations }\r\n end\r\n end",
"def new\n #@instance = Instance.new\n @instance.url = \"http://#{request.host}\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instance }\n end\n end",
"def new\n @slab = Slab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @slab }\n end\n end",
"def show\n @map = Map.find(params[:id], :include => \"tiles\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @map }\n end\n end",
"def new\n @lab = Lab.find(params[:lab_id])\n @machine = Machine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @machine }\n end\n end",
"def show\n @platform = Platform.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @platform }\n end\n end",
"def show\n @game = Game.instance\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @game }\n end\n end",
"def show\n @map = Map.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @map }\n end\n end",
"def show\n @map = Map.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @map }\n end\n end",
"def show\n @theoretical_background = TheoreticalBackground.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @theoretical_background }\n end\n end"
] |
[
"0.6351823",
"0.63199824",
"0.62205565",
"0.62056786",
"0.6202137",
"0.6101092",
"0.60921156",
"0.6024565",
"0.5999781",
"0.5966",
"0.59372294",
"0.5923806",
"0.5918633",
"0.5906558",
"0.58607775",
"0.5837128",
"0.57803255",
"0.57553566",
"0.57553566",
"0.57405645",
"0.56961906",
"0.5689505",
"0.5655479",
"0.56532097",
"0.5646377",
"0.5642077",
"0.56379527",
"0.55799353",
"0.55743885",
"0.5529305",
"0.54980326",
"0.5496142",
"0.54929125",
"0.5487344",
"0.54739124",
"0.54712087",
"0.5469481",
"0.54503554",
"0.5425581",
"0.5417462",
"0.5408691",
"0.53957283",
"0.53898144",
"0.53822523",
"0.53754234",
"0.53743535",
"0.5372885",
"0.5369967",
"0.5369287",
"0.5363676",
"0.5361141",
"0.5356191",
"0.5356191",
"0.5354593",
"0.5347196",
"0.53399926",
"0.53332645",
"0.532465",
"0.5324567",
"0.5320684",
"0.5317519",
"0.5311204",
"0.53090733",
"0.53071135",
"0.52976847",
"0.5297663",
"0.5291794",
"0.52915263",
"0.5272335",
"0.5272335",
"0.5272335",
"0.5272335",
"0.52644813",
"0.5259026",
"0.5250676",
"0.52488333",
"0.524485",
"0.5242802",
"0.5242667",
"0.5242182",
"0.52410007",
"0.52382714",
"0.52356684",
"0.52302176",
"0.5227983",
"0.52271444",
"0.5227041",
"0.5226535",
"0.5225219",
"0.5223685",
"0.5222373",
"0.52159506",
"0.5209391",
"0.5209225",
"0.52075654",
"0.5205363",
"0.5197127",
"0.51965266",
"0.51882315",
"0.51882315",
"0.51867765"
] |
0.0
|
-1
|
POST /world_instances POST /world_instances.json
|
def create
world_name = params["name"]
superclass_uri = params["type-parent"]
container_uri = params["location-parent"]
description = params["description"]
if params.has_key?(:options)
options = {protected: false, locked: false}
options[:protected] = true if (params["options"].include?("protected"))
options[:locked] = true if (params["options"].include?("locked"))
end
host_port = request.host_with_port
hostname = host_port.split(":").first
port = host_port.split(":").last
if (WorldAdmin.has_visibility_privilege?(superclass_uri, session[:user_uri]) && WorldAdmin.has_frame_level_privilege?(container_uri, session[:user_uri]))
w = WorldInstance.create_world_instance_with_uri(world_name, superclass_uri, container_uri, description, nil, options, nil, nil, nil, hostname, port)
puts w.world_instance_uri
redirect_to w.world_instance_uri
else
head(status=401)
end
# @world_instance = WorldInstance.new(world_instance_params)
#
# respond_to do |format|
# if @world_instance.save
# format.html { redirect_to @world_instance, notice: 'World instance was successfully created.' }
# format.json { render :show, status: :created, location: @world_instance }
# else
# format.html { render :new }
# format.json { render json: @world_instance.errors, status: :unprocessable_entity }
# end
# end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @world_region = WorldRegion.new(world_region_params)\n\n respond_to do |format|\n if @world_region.save\n format.html { redirect_to @world_region, notice: 'World region was successfully created.' }\n format.json { render :show, status: :created, location: @world_region }\n else\n format.html { render :new }\n format.json { render json: @world_region.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @world_instance.destroy\n respond_to do |format|\n format.html { redirect_to world_instances_url, notice: 'World instance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @world_map = WorldMap.new(params[:world_map])\n\n respond_to do |format|\n if @world_map.save\n\n format.html { redirect_to @world_map, notice: 'World map was successfully created.' }\n format.json { render json: @world_map, status: :created, location: @world_map }\n else\n format.html { render action: \"new\" }\n format.json { render json: @world_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_world\n my_world = World.create!(:world_template => WorldTemplate.first, :user => self)\n end",
"def create\n @instance = @provider.instances.new(params[:instance])\n @instance.state = \"Building\"\n respond_to do |format|\n if @instance.save\n @instance.create_instance(@provider.connect!)\n format.html { redirect_to cloud_provider_instance_path(@provider,@instance), notice: 'Instance was successfully created.' }\n format.json { render json: @instance, status: :created, location: @instance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def aws_write_instances\n File.open( aws_instances_json, 'w' ) do |fout|\n aws_dump_instances( fout )\n end\n end",
"def create\n party = []\n (1..6).each do |p_number|\n level = params[:dungeon_instance][\"hero#{p_number}_level\"].to_i\n party << level if level > 0\n end\n\n dungeon = Dungeon.new\n dungeon.generate( params[:dungeon_instance][:size].to_i, party,\n encounters_difficulty: params[:dungeon_instance][:difficulty].to_sym )\n # p dungeon.to_json\n\n @dungeon_instance = DungeonInstance.new( dungeon_instance_params.merge( dungeon_data: dungeon.to_json ) )\n\n respond_to do |format|\n if current_user.dungeon_instances << @dungeon_instance\n format.html { redirect_to dungeon_instance_play_path( @dungeon_instance ), notice: 'Dungeon instance was successfully created.' }\n else\n format.html { redirect_to dungeon_instances_path, error: 'Dungeon instance was successfully created.' }\n end\n end\n end",
"def create\n @world_city = WorldCity.new(world_city_params)\n\n respond_to do |format|\n if @world_city.save\n format.html { redirect_to @world_city, notice: 'World city was successfully created.' }\n format.json { render :show, status: :created, location: @world_city }\n else\n format.html { render :new }\n format.json { render json: @world_city.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_worldmap\n @pokemon_worldmap = GamePlay::WorldMap.new(:pokedex, $env.get_worldmap)\n @pokemon_worldmap.create_graphics\n end",
"def create\n @world_admin = WorldAdmin.new(world_admin_params)\n\n respond_to do |format|\n if @world_admin.save\n format.html { redirect_to @world_admin, notice: 'World admin was successfully created.' }\n format.json { render :show, status: :created, location: @world_admin }\n else\n format.html { render :new }\n format.json { render json: @world_admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_instances request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, body, query_string_params = transcode_create_instances_request request_pb\n response = @client_stub.make_post_request(\n uri: uri,\n body: body,\n params: query_string_params,\n options: options\n )\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n result\n end",
"def update\n respond_to do |format|\n if @world_instance.update(world_instance_params)\n format.html { redirect_to @world_instance, notice: 'World instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @world_instance }\n else\n format.html { render :edit }\n format.json { render json: @world_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @server_instance = ServerInstance.new(params[:server_instance])\n\n respond_to do |format|\n if @server_instance.save\n format.html { redirect_to @server_instance, notice: 'Server instance was successfully created.' }\n format.json { render json: @server_instance, status: :created, location: @server_instance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @server_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @instance = Instance.new(params[:instance])\n\n respond_to do |format|\n if @instance.save\n\n system(\"ssh root@#{CloudGui::Application.config.hypervisor_ip} \\\"exec /data/cloud/scripts/provision.sh #{params[:instance][:cpus]} #{params[:instance][:memory]} #{params[:instance][:baseimage]} 2>&1 | tee /data/cloud/logs/cloud_gui.log\\\"\")\n\n format.html { redirect_to @instance, notice: 'Instance was successfully created.' }\n format.json { render json: @instance, status: :created, location: @instance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @world = current_user.worlds.build(world_params)\n\n if @world.save\n redirect_to world_path(@world)\n else\n render 'new'\n end \nend",
"def create\n @instance = Instance.new(instance_params)\n\n respond_to do |format|\n if @instance.save\n format.html { redirect_to @instance, notice: 'Instance was successfully created.' }\n format.json { render :show, status: :created, location: @instance }\n else\n format.html { render :new }\n format.json { render json: @instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @instance_type = InstanceType.new(params[:instance_type])\n\n respond_to do |format|\n if @instance_type.save\n format.html { redirect_to @instance_type, notice: 'Instance type was successfully created.' }\n format.json { render json: @instance_type, status: :created, location: @instance_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @instance_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lab = Lab.find(params[:lab_id])\n @machine = @lab.machines.create(machine_params)\n\n respond_to do |format|\n if @machine.save\n format.html { redirect_to lab_path(@lab), notice: 'Machine was successfully created.' }\n format.json { render json: @machine, status: :created, location: @machine }\n else\n format.html { render action: \"new\" }\n format.json { render json: @machine.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @instances = Instance.all\n render json: @instances\n end",
"def create\n @instance_eni = InstanceEni.new(instance_eni_params)\n\n respond_to do |format|\n if @instance_eni.save\n format.html { redirect_to @instance_eni, notice: 'Instance eni was successfully created.' }\n format.json { render :show, status: :created, location: @instance_eni }\n else\n format.html { render :new }\n format.json { render json: @instance_eni.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @homeworld = Homeworld.new(homeworld_params)\n\n respond_to do |format|\n if @homeworld.save\n format.html { redirect_to @homeworld, notice: 'Homeworld was successfully created.' }\n format.json { render action: 'show', status: :created, location: @homeworld }\n else\n format.html { render action: 'new' }\n format.json { render json: @homeworld.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @flavours = @provider.get_flavors\n puts \"getting the flavors #{@flavours.inspect}\"\n @images = @provider.get_images\n puts \"getting the flavors #{@images.inspect}\"\n @instance = @provider.instances.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instance }\n end\n end",
"def create_pvm_instance(instance_hash)\n post(\"cloud-instances/#{guid}/pvm-instances\", instance_hash.to_json)\n end",
"def index\n @instances = Instance.all\n render :json => @instances\n end",
"def create\n @instance_type = InstanceType.new(instance_type_params)\n\n respond_to do |format|\n if @instance_type.save\n format.html { redirect_to @instance_type, notice: 'Instance type was successfully created.' }\n format.json { render action: 'show', status: :created, location: @instance_type }\n else\n format.html { render action: 'new' }\n format.json { render json: @instance_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n account = Account.find(params[:account_id])\n @instances = obtain_instances(account.id, account.account_regions.first.region)\n\n @servers = {}\n @instances.each do |instance|\n @servers[instance.instance_id] = Server.find_by(instance_id: instance.instance_id) || @account.servers.create(instance_id: instance.instance_id)\n end\n rescue => e\n render text: e.message\n end",
"def create\n @neighborhood = Neighborhood.new(params[:neighborhood])\n\n respond_to do |format|\n if @neighborhood.save\n format.html { redirect_to @neighborhood, notice: 'Neighborhood was successfully created.' }\n format.json { render json: @neighborhood, status: :created, location: @neighborhood }\n else\n format.html { render action: \"new\" }\n format.json { render json: @neighborhood.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @neighborhood = Neighborhood.new(params[:neighborhood])\n\n respond_to do |format|\n if @neighborhood.save\n format.html { redirect_to @neighborhood, notice: 'Neighborhood was successfully created.' }\n format.json { render json: @neighborhood, status: :created, location: @neighborhood }\n else\n format.html { render action: \"new\" }\n format.json { render json: @neighborhood.errors, status: :unprocessable_entity }\n end\n end\n end",
"def recreate_instances request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, body, query_string_params = transcode_recreate_instances_request request_pb\n response = @client_stub.make_post_request(\n uri: uri,\n body: body,\n params: query_string_params,\n options: options\n )\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n result\n end",
"def instances\n instances = []\n JSON.parse(resource['/instances'].get)[\"instances\"].each do |i|\n instances << Instance.new(i)\n end\n return instances\n end",
"def create_instance_for_env(instance)\n whitelist = [:instance_id, :instance_index, :name, :uris, :users, :version, :start, :runtime, :state_timestamp, :port]\n env_hash = {}\n whitelist.each {|k| env_hash[k] = instance[k] if instance[k]}\n env_hash[:limits] = {\n :fds => instance[:fds_quota],\n :mem => instance[:mem_quota],\n :disk => instance[:disk_quota],\n }\n env_hash[:host] = @local_ip\n env_hash.to_json\n end",
"def newWorld(db, name)\n\tif db.hexists('sgt-worlds', name)\n\t\treturn World.new(db, db.hget('sgt-worlds', name))\n\tend\n\tnewId = newUUID(db)\n\t\n\t# Associate this name to the world id\n\tdb.hset('sgt-worlds', name, newId)\n\t\t\n\t# The 'name' property of the object\n\tdb.hset('sgt-world:'+newId, 'name', name)\n\t\n\tworld = World.new(db, newId)\n\tworld\nend",
"def create_world_map\n @world_map = World_Minimap.new(@viewport2)\n open_world_map\n end",
"def run_instances(num_vms, opts, roles, disks)\n # Make a copy (the options are a simple hash so shallow copy does the\n # trick) to not modify the original.\n options = opts.clone\n options['num_vms'] = num_vms.to_s\n\n uri = URI(\"http://#{@ip}:#{SERVER_PORT}/instances\")\n headers = {'Content-Type' => 'application/json',\n 'AppScale-Secret' => @secret}\n request = Net::HTTP::Post.new(uri.path, headers)\n\n request.body = JSON.dump(options)\n\n run_result = JSON.parse(make_call(request, uri))\n Djinn.log_debug(\"[IM] Run instances info says [#{run_result}]\")\n operation_id = run_result['operation_id']\n\n vm_info = {}\n loop {\n begin\n describe_result = describe_operation(operation_id)\n rescue Djinn::FailedNodeException => error\n Djinn.log_warn(\n \"[IM] Error describing run instances operation #{operation_id}. \" \\\n \"Error: #{error.message}\")\n next\n end\n Djinn.log_debug(\"[IM] Describe run operation has vm_info \" \\\n \"#{describe_result['vm_info'].inspect}.\")\n\n if describe_result['state'] == 'success'\n vm_info = describe_result['vm_info']\n break\n elsif describe_result['state'] == 'failed'\n raise AppScaleException.new(describe_result['reason'])\n end\n Kernel.sleep(SMALL_WAIT)\n }\n\n # ip:role:instance-id\n instances_created = []\n vm_info['public_ips'].each_index { |index|\n tmp_roles = roles[index]\n tmp_roles = 'open' if roles[index].nil?\n instances_created << {\n 'public_ip' => vm_info['public_ips'][index],\n 'private_ip' => vm_info['private_ips'][index],\n 'roles' => tmp_roles,\n 'instance_id' => vm_info['instance_ids'][index],\n 'disk' => disks[index],\n 'instance_type' => options['instance_type']\n }\n }\n\n instances_created\n end",
"def create\n @user = current_user\n @resource = Resource.new(resource_params)\n @myWorld = World.where(:title => @user[:email])\n worldID = @myWorld[0].id\n @resource.user_id = @user.id\n @resource.date_published = Date.today\n respond_to do |format|\n if @resource.save\n invoke(\"Resource created: \" + @resource.title, @user[:email], \"admin\", worldID.to_s)\n # puts(\"Resource created: \" + @resource.title, @user[:email], \"admin\", worldID)\n format.html { redirect_to :root, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list_instances\n puts \"OK, Listing instances..\"\n\n response = RestClient.post( \n $uri,\n 'Version' => '2010-12-30',\n 'ACSAccessKeyId' => $ACSAccessKeyId,\n 'Format' => 'json',\n 'Timestamp' => $current_time,\n 'Rndguid' => $rndguid,\n 'Signature' => calculate_signature($api_private_key, $rndguid, $current_time),\n 'Action' => \"list-instances\")\n\n puts response\n puts response.code\nend",
"def save(*args, &block)\n super\n # begin\n # require 'restclient'\n # server[\"/instances/#{instance_id}\"].put(to_json)\n # rescue Exception => e\n # Metavirt::Log.error \"cloudkit fail:\\n\\t#{e.inspect}\"\n # end\n self\n end",
"def create\n @universe = Universe.new(universe_params)\n\n respond_to do |format|\n if @universe.save\n format.html { redirect_to @universe, notice: 'Universe was successfully created.' }\n format.json { render action: 'show', status: :created, location: @universe }\n else\n format.html { render action: 'new' }\n format.json { render json: @universe.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def get_instance_data\n JSON.parse(Net::HTTP.get(URI.parse('http://169.254.169.254/latest/dynamic/instance-identity/document')))\n end",
"def create\n @game_instance = GameInstance.new(params[:game_instance])\n\n respond_to do |format|\n if @game_instance.save\n format.html { redirect_to @game_instance, notice: 'Game instance was successfully created.' }\n format.json { render json: @game_instance, status: :created, location: @game_instance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @location = Location.new\n @location.build_series\n @city = @location.build_city\n \n set_site_entities @location\n \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 @server_instance = ServerInstance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server_instance }\n end\n end",
"def create\n positions = JSON.parse(params['positions'])\n\n # Fill in body to initialize the game and return a 200 response\n\n render plain: \"OK\"\n end",
"def create_region\n Region.create!(params[:record])\n render :json => {}\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 index\n @world_regions = WorldRegion.all\n end",
"def create\n neo = Neography::Rest.new\n city = neo.create_node(params[:city])\n redirect_to cities_path\n end",
"def create_instances(count)\n result = client.run_instances(AwsForm.map(params.merge(count: count)))\n instance_ids = result.instances.map(&:instance_id)\n ret = wait_for_create(instance_ids)\n # need to make sure add_tags is done after after wait_until or can have error that instance ids dont exist\n add_tags?(instance_ids, with_dtk_tag: true)\n IamInstanceProfile.set_iam_instance_profiles(self, instance_ids, params.iam_instance_profile) unless params.iam_instance_profile.nil?\n ret\n end",
"def create_servers\n # use \"rsc\" tool to get detailed deployment + server view from api 1.6, not supported by right_api_client\n old_deployment = JSON.parse(`rsc -a #{@options[:src]} cm16 show /api/deployments/#{@options[:deployment]} view=full`)\n\n old_deployment['servers'].each do |server|\n @api.account_id = @options[:src]\n name = server['next_instance']['name']\n\n puts \"Creating server: #{name} ...\\n\"\n\n cloud = find_cloud(server['next_instance']['links']['cloud']['href'], name)\n @api.account_id = @options[:src]\n\n ssh_key = choose_ssh_key(cloud)\n @api.account_id = @options[:src]\n\n instance_type = choose_instance_type(cloud)\n old_st_url = server['next_instance']['server_template']['href']\n new_st_url = @server_templates[old_st_url]['new_st_url']\n \n mci = choose_mci(new_st_url)\n @api.account_id = @options[:src]\n\n subnets = choose_subnets(cloud)\n @api.account_id = @options[:src]\n\n security_groups = choose_security_groups(cloud)\n @api.account_id = @options[:src]\n\n inputs_hash = format_inputs(@api.resource(server['next_instance']['href']).show.inputs)\n\n # Create server\n params = {}\n params[:server] = {}\n params[:server][:name] = name\n params[:server][:deployment_href] = @new_deployment\n params[:server][:instance] = {}\n params[:server][:instance][:cloud_href] = cloud\n params[:server][:instance][:server_template_href] = new_st_url\n params[:server][:instance][:ssh_key_href] = ssh_key if ssh_key\n params[:server][:instance][:instance_type_href] = instance_type\n params[:server][:instance][:multi_cloud_image_href] = mci\n params[:server][:instance][:subnet_hrefs] = subnets if subnets\n params[:server][:instance][:security_group_hrefs] = security_groups\n params[:server][:instance][:inputs] = inputs_hash\n @api.account_id = @options[:dst]\n @api.servers.create(params)\n end\nend",
"def create_instances(count)\n fail DTK::Error::Usage, \"Attribute 'admin_state' cannot be set to powered_off if node not created\" if admin_state_powered_off?\n aws_api_operation(:create).create_instances(count)\n end",
"def post_compute(request)\n # --- Create the new Instance ---\n vm = VirtualMachineOCCI.new(\n VirtualMachine.build_xml,\n @client,\n request.body.read,\n @config[:instance_types],\n @config[:template_location])\n\n # --- Generate the template and Allocate the new Instance ---\n template = vm.to_one_template\n return template, 500 if OpenNebula.is_error?(template)\n\n rc = vm.allocate(template)\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n # --- Prepare XML Response ---\n vm.info\n return to_occi_xml(vm, :code=>201)\n end",
"def create\n @title = Title.find_by_id(params[:title_id])\n logger.debug \"Creating a new machine. current user is #{current_user}\"\n @machine = Machine.new({\n location: @location,\n title: @title,\n created_by: current_user\n })\n\n respond_to do |format|\n if @machine.save\n format.html { redirect_to location_machines_path(@location), notice: 'Machine was successfully created.' }\n format.json { render json: @machine, status: :created, location: @machine }\n else\n format.html { redirect_to location_machines_path(@location), notice: @machine.errors.full_messages.join('. ') }\n format.json { render json: @machine.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @instance_type = InstanceType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instance_type }\n end\n end",
"def create\n @region = Region.new(region_params)\n\n if @region.save\n render json: @region, status: :created, location: @region\n else\n render json: @region.errors, status: :unprocessable_entity\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 create\n @hotspot_registration = HotspotRegistration.new(guest_params)\n\n respond_to do |format|\n if @hotspot_registration.save\n format.html { redirect_to @hotspot_registration, notice: 'Guest was successfully created.' }\n format.json { render :show, status: :created, location: @hotspot_registration }\n else\n format.html { render :new }\n format.json { render json: @hotspot_registration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @science_instance = ScienceInstance.new(science_instance_params)\n\n respond_to do |format|\n if @science_instance.save\n format.html { redirect_to @science_instance, notice: 'Science instance was successfully created.' }\n format.json { render :show, status: :created, location: @science_instance }\n else\n format.html { render :new }\n format.json { render json: @science_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @robot_instance = RobotInstance.new(robot_instance_params)\n\n respond_to do |format|\n if @robot_instance.save\n format.html { redirect_to @robot_instance, notice: 'Robot instance was successfully created.' }\n format.json { render :show, status: :created, location: @robot_instance }\n else\n format.html { render :new }\n format.json { render json: @robot_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @docker_instance = DockerInstance.new(docker_instance_params)\n @docker_instance.creating!\n respond_to do |format|\n if @docker_instance.save\n format.js\n else\n format.html { render :new }\n format.json { render json: @docker_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put_instance(opts)\n opts = check_params(opts,[:instances])\n super(opts)\n end",
"def create_server(zone: \"fi-hel1\", title:, hostname:, core_number: 1,\n memory_amount: 1024, storage_devices:, ip_addresses: :all)\n data = {\n \"server\" => {\n \"zone\" => zone,\n \"title\" => title,\n \"hostname\" => hostname,\n \"core_number\" => core_number,\n \"memory_amount\" => memory_amount,\n \"storage_devices\" => { \"storage_device\" => storage_devices }\n }\n }\n\n if ip_addresses != :all\n ips = []\n ips << { \"access\" => \"public\", \"family\" => \"IPv4\" } if ip_addresses.include? :public\n ips << { \"access\" => \"private\", \"family\" => \"IPv4\" } if ip_addresses.include? :private\n ips << { \"access\" => \"public\", \"family\" => \"IPv6\" } if ip_addresses.include? :ipv6\n\n data[\"server\"][\"ip_addresses\"] = {}\n data[\"server\"][\"ip_addresses\"][\"ip_address\"] = ips\n end\n\n json = JSON.generate data\n response = post \"server\", json\n response\n end",
"def create\n @method = 'create'\n @voxel = Voxel.new(voxel_params)\n\n respond_to do |format|\n if @voxel.save\n flash[:notice] = '作成されました!'\n format.html { redirect_to action: 'index' }\n format.json { render action: 'show', status: :created, location: @voxel }\n else\n format.html { render action: 'new' }\n format.json { render json: @voxel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def instance_data\n @instance_data ||= JSON.parse(Net::HTTP.get(URI.parse('http://169.254.169.254/latest/dynamic/instance-identity/document')))\n end",
"def create\n @instance_eni_tag = InstanceEniTag.new(instance_eni_tag_params)\n\n respond_to do |format|\n if @instance_eni_tag.save\n format.html { redirect_to @instance_eni_tag, notice: 'Instance eni tag was successfully created.' }\n format.json { render :show, status: :created, location: @instance_eni_tag }\n else\n format.html { render :new }\n format.json { render json: @instance_eni_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #@instance = Instance.new(params[:instance])\n\n respond_to do |format|\n if @instance.save\n format.html { redirect_to @instance, notice: '创建成功' }\n format.json { render json: @instance, status: :created, location: @instance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game_game_instance = Game::GameInstance.new(params[:game_game_instance])\n\n respond_to do |format|\n if @game_game_instance.save\n format.html { redirect_to @game_game_instance, notice: 'Game instance was successfully created.' }\n format.json { render json: @game_game_instance, status: :created, location: @game_game_instance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game_game_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def create\n megam_rest.post_node(to_hash)\n end",
"def create\n @admin_hotspot = Admin::Hotspot.new(params[:admin_hotspot])\n\n respond_to do |format|\n if @admin_hotspot.save\n format.html { redirect_to admin_hotspots_path, notice: 'Hotspot was successfully created.' }\n format.json { render json: @admin_hotspot, status: :created, location: @admin_hotspot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_hotspot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_random_world\n randomize_terrain\n randomize_entities\n end",
"def new\n @lab = Lab.find(params[:lab_id])\n @machine = Machine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @machine }\n end\n end",
"def index\n\n credentials = Aws::Credentials.new('AKIAJ2JD2EKKFVDSR37A', 'cnZUnzuyYPqUevEPb045VJUnW55VR+rUCQrplzd/')\n ec2 = Aws::EC2::Client.new(\n region: \"us-east-1\",\n credentials: credentials\n )\n #i = ec2.instances.create(:image_id => \"ami-e3106686\")\n resp = ec2.run_instances({\n dry_run: true,\n image_id: \"ami-e3106686\", # required\n min_count: 1, # required\n max_count: 1, # required\n instance_type: \"t1.micro\", # accepts t1.micro, m1.small, m1.medium, m1.large, m1.xlarge, m3.medium, m3.large, m3.xlarge, m3.2xlarge, m4.large, m4.xlarge, m4.2xlarge, m4.4xlarge, m4.10xlarge, t2.micro, t2.small, t2.medium, t2.large, m2.xlarge, m2.2xlarge, m2.4xlarge, cr1.8xlarge, i2.xlarge, i2.2xlarge, i2.4xlarge, i2.8xlarge, hi1.4xlarge, hs1.8xlarge, c1.medium, c1.xlarge, c3.large, c3.xlarge, c3.2xlarge, c3.4xlarge, c3.8xlarge, c4.large, c4.xlarge, c4.2xlarge, c4.4xlarge, c4.8xlarge, cc1.4xlarge, cc2.8xlarge, g2.2xlarge, cg1.4xlarge, r3.large, r3.xlarge, r3.2xlarge, r3.4xlarge, r3.8xlarge, d2.xlarge, d2.2xlarge, d2.4xlarge, d2.8xlarge\n placement: {\n tenancy: \"default\", # accepts default, dedicated\n },\n\n block_device_mappings: [\n {\n virtual_name: \"String\",\n device_name: \"String\",\n ebs: {\n snapshot_id: \"String\",\n volume_size: 1,\n delete_on_termination: true,\n volume_type: \"standard\", # accepts standard, io1, gp2\n iops: 1,\n encrypted: true,\n },\n\n },\n ],\n monitoring: {\n enabled: true, # required\n },\n disable_api_termination: true,\n instance_initiated_shutdown_behavior: \"stop\", # accepts stop, terminate\n network_interfaces: [\n {\n delete_on_termination: true,\n private_ip_addresses: [\n {\n private_ip_address: \"172.31.2.177\", # required\n primary: true,\n },\n ],\n secondary_private_ip_address_count: 1,\n associate_public_ip_address: true,\n },\n ],\n ebs_optimized: true,\n })\n @ec2_instances = Ec2Instance.all\n end",
"def create\n @ocean = Ocean.new(ocean_params)\n\n respond_to do |format|\n if @ocean.save\n format.html { redirect_to @ocean, notice: 'Ocean was successfully created.' }\n format.json { render :show, status: :created, location: @ocean }\n else\n format.html { render :new }\n format.json { render json: @ocean.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\trespond_with Species.create(species_params)\n\tend",
"def instances_params\n params.require(:instances) #.permit(:test_case, :module, :omp_num_threads,\n # :inlists, :mem_rn, :success_type,\n # :mem_re, :success_type, :checksum,\n # :outcome)\n end",
"def create\n @instance = Instance.new(instance_params)\n\n #respond_to do |format|\n if @instance.save\n #format.html { redirect_to @instance, notice: 'Instance was successfully created.' }\n #format.json { render :show, status: :created, location: @instance }\n\t@response = { :message => \"Instance successfully created.\"}\n\trender :json => @response \n else\n #format.html { render :new }\n render :json => @instance.errors\n end\n #end\n end",
"def create\n @regions = Region.all\n @location = Location.new(location_params)\n\n if params[:regions]\n @location_regions = Region.find(params[:regions])\n else\n @location_regions = []\n end\n\n @location.regions = @location_regions\n\n respond_to do |format|\n if @location.save\n @location.create_stat\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ec2_instance = Ec2Instance.new(ec2_instance_params)\n\n respond_to do |format|\n if @ec2_instance.save\n format.html { redirect_to @ec2_instance, notice: 'Ec2 instance was successfully created.' }\n format.json { render :show, status: :created, location: @ec2_instance }\n else\n format.html { render :new }\n format.json { render json: @ec2_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @voxel = Voxel.new(params[:voxel])\n \n respond_to do |format|\n if @voxel.save\n format.html { redirect_to @voxel, notice: 'Voxel was successfully created.' }\n format.json { render json: @voxel, status: :created, location: @voxel }\n else\n format.html { render action: \"new\" }\n format.json { render json: @voxel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stage_population = StagePopulation.new(params[:stage_population])\n\n respond_to do |format|\n if @stage_population.save\n format.html { redirect_to @stage_population, notice: 'Stage population was successfully created.' }\n format.json { render json: @stage_population, status: :created, location: @stage_population }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stage_population.errors, status: :unprocessable_entity }\n end\n end\n end",
"def spawn\n connection.puts \"\\nSpawning in the world!\\n\"\n\n @world.render\n\n process_input\n end",
"def new\n @instance = Instance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instance }\n end\n end",
"def create_instance(credentials, image_id, opts)\n racks = new_client( credentials )\n hwp_id = opts[:hwp_id] || 1\n name = Time.now.to_s\n if (opts[:name]) then name = opts[:name] end\n safely do\n return convert_srv_to_instance(racks.start_server(image_id, hwp_id, name))\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 build\n if @scenarioYAML[\"STUDENT_COUNT\"]\n build_world_from_students\n #elsif !@scenarioYAML[\"SCHOOL_COUNT\"].nil?\n # build_world_from_edOrgs()\n # --> not supported yet\n else\n @log.error \"STUDENT_COUNT or SCHOOL_COUNT must be set for a world to be created --> Exiting...\"\n end\n @world\n end",
"def create\n #@server_node = ServerNode.new(params[:server_node])\n #@server_node = ServerNode.create() do |n|\n # n.name = params[:node][:name]\n\t# n.region = params[:node][:region]\n\t# n.status = params[:node][:status]\n\n #end\n\n respond_to do |format|\n if @server_node.save\n format.html { redirect_to @server_node, notice: 'Server node was successfully created.' }\n format.json { render json: @server_node, status: :created, location: @server_node }\n else\n format.html { render action: \"new\" }\n format.json { render json: @server_node.errors, status: :unprocessable_entity }\n end\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 create\n @new_game = Game.create(game_params)\n render json: @new_game\n\n end",
"def create\n @cloud = Cloud.new(params[:cloud])\n\n respond_to do |format|\n if @cloud.save\n format.html { redirect_to @cloud, :notice => 'Cloud was successfully created.' }\n format.json { render :json => @cloud, :status => :created, :location => @cloud }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @cloud.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n authenticate_user!\n @server = Server.new\n @rackspace_servers = Server.rackspace_servers\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server }\n end\n end",
"def create_objects\n cloud Mash.new\n cloud[:public_ips] = Array.new\n cloud[:private_ips] = Array.new\n end",
"def create\n @species = Species.new(species_params)\n\n respond_to do |format|\n if @species.save\n format.html { redirect_to @species, notice: 'Species was successfully created.' }\n format.json { render :show, status: :created, location: @species }\n else\n format.html { render :new }\n format.json { render json: @species.errors, status: :unprocessable_entity }\n end\n end\n end",
"def aws_instance_create(opts)\n AWS::EC2::InstanceCollection.new.create(\n image_id: Rails.configuration.x.aws[Rails.configuration.x.aws['region']][\"ami_#{self.os}\"], \n private_ip_address: self.ip_address,\n key_name: Rails.configuration.x.aws['ec2_key_pair_name'],\n user_data: self.generate_init,\n instance_type: \"t2.small\",\n subnet: self.subnet.driver_id\n )\n end",
"def create\n plant = Plant.create(plant_params)\n render json: plant, status: :created\n end",
"def create\n @machine = Machine.new(params[:machine])\n\n respond_to do |format|\n if @machine.save\n format.html { redirect_to @machine, notice: t('controller.successfully_created', :model => t('activerecord.models.machine')) }\n format.json { render json: @machine, status: :created, location: @machine }\n else\n format.html { render action: \"new\" }\n format.json { render json: @machine.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @instance_action = InstanceAction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instance_action }\n end\n end",
"def add_instance(opts)\n unless %w[app util].include?(opts[:role].to_s)\n # Fail immediately because we don't have valid arguments.\n raise InvalidInstanceRole, \"Instance role must be one of: app, util\"\n end\n\n # Sanitize the name to remove whitespace if there is any\n if opts[:name]\n name = opts[:name].gsub(/\\s+/, '')\n end\n\n if opts[:role] == 'util'\n unless name && name.length > 0\n raise InvalidInstanceName, \"When specifying a util instance you must also specify a name.\"\n end\n end\n \n request = { \"role\" => opts[:role], \"name\" => opts[:name] }\n request['snapshot_id'] = opts[:snapshot_id] if opts.key?(:snapshot_id)\n request['instance_size'] = opts[:instance_size] if opts.key?(:instance_size)\n\n # We know opts[:role] is right, name can be passed straight to the API.\n # Return the response body for error output, logging, etc.\n return api.post(\"/environments/#{id}/add_instances\", :request => request)\n end",
"def create\n @instance_action = InstanceAction.new(params[:instance_action])\n\n respond_to do |format|\n if @instance_action.save\n format.html { redirect_to @instance_action, notice: 'Instance action was successfully created.' }\n format.json { render json: @instance_action, status: :created, location: @instance_action }\n else\n format.html { render action: \"new\" }\n format.json { render json: @instance_action.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @instance = Instance.new(params[:instance])\n\n respond_to do |format|\n if @instance.save\n format.html { redirect_to(@instance, :notice => 'Instance was successfully created.') }\n format.xml { render :xml => @instance, :status => :created, :location => @instance }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @instance.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.62200654",
"0.606405",
"0.5965815",
"0.58907104",
"0.58460814",
"0.5845035",
"0.5787671",
"0.57634324",
"0.57342815",
"0.57021827",
"0.56860375",
"0.566433",
"0.56354827",
"0.5526175",
"0.5477664",
"0.5467237",
"0.5433888",
"0.5413798",
"0.5384082",
"0.53668237",
"0.53328073",
"0.5318276",
"0.53052694",
"0.5293846",
"0.52819455",
"0.52560127",
"0.5254323",
"0.5254323",
"0.52432424",
"0.52361727",
"0.522615",
"0.52182966",
"0.5214787",
"0.52021354",
"0.5190933",
"0.5187171",
"0.5185992",
"0.51654196",
"0.5162316",
"0.51599354",
"0.5137159",
"0.5130031",
"0.5129318",
"0.51230973",
"0.5119002",
"0.5116902",
"0.5113204",
"0.5113168",
"0.5105277",
"0.51047605",
"0.5101416",
"0.5099871",
"0.50900495",
"0.5075924",
"0.50599205",
"0.5055431",
"0.50497216",
"0.5030806",
"0.5026425",
"0.5025871",
"0.5025707",
"0.5022476",
"0.5022015",
"0.50212914",
"0.50172925",
"0.50118035",
"0.49845564",
"0.4980209",
"0.49697077",
"0.49682975",
"0.49680918",
"0.49658588",
"0.49562466",
"0.49541515",
"0.4946738",
"0.49445078",
"0.49366707",
"0.49343503",
"0.49234158",
"0.492139",
"0.49151018",
"0.49107176",
"0.49018916",
"0.4898155",
"0.4898155",
"0.4895615",
"0.48868832",
"0.48806566",
"0.4867011",
"0.4864654",
"0.48579842",
"0.48567164",
"0.48559603",
"0.4853125",
"0.4847987",
"0.484524",
"0.48445687",
"0.48434576",
"0.48408917",
"0.4836677"
] |
0.6729135
|
0
|
PATCH/PUT /world_instances/1 PATCH/PUT /world_instances/1.json
|
def update
respond_to do |format|
if @world_instance.update(world_instance_params)
format.html { redirect_to @world_instance, notice: 'World instance was successfully updated.' }
format.json { render :show, status: :ok, location: @world_instance }
else
format.html { render :edit }
format.json { render json: @world_instance.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update!(**args)\n @instances = args[:instances] if args.key?(:instances)\n @parameters = args[:parameters] if args.key?(:parameters)\n end",
"def update\n respond_to do |format|\n if @world_region.update(world_region_params)\n format.html { redirect_to @world_region, notice: 'World region was successfully updated.' }\n format.json { render :show, status: :ok, location: @world_region }\n else\n format.html { render :edit }\n format.json { render json: @world_region.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @instances = args[:instances] if args.key?(:instances)\n end",
"def update\n respond_to do |format|\n if @resource.update(resource_params)\n @myWorld = World.where(:title => @user[:email])\n worldID = @myWorld[0].id\n invoke(\"Resource destroyed: \" + @resource.title, @user[:email], \"admin\", worldID)\n format.html { redirect_to :root, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @server_instance = ServerInstance.find(params[:id])\n\n respond_to do |format|\n if @server_instance.update_attributes(params[:server_instance])\n format.html { redirect_to @server_instance, notice: 'Server instance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @server_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @instances = args[:instances] if args.key?(:instances)\n @labels = args[:labels] if args.key?(:labels)\n @location = args[:location] if args.key?(:location)\n @network = args[:network] if args.key?(:network)\n @placement = args[:placement] if args.key?(:placement)\n @service_account = args[:service_account] if args.key?(:service_account)\n end",
"def update\n respond_to do |format|\n if @world_admin.update(world_admin_params)\n format.html { redirect_to @world_admin, notice: 'World admin was successfully updated.' }\n format.json { render :show, status: :ok, location: @world_admin }\n else\n format.html { render :edit }\n format.json { render json: @world_admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_worldmap\n if data = (@environment[\"gps\"] || @environment[\"network\"])\n worldmap_request \"PUT\", \"/hoc\", data.to_json\n end\n end",
"def update\n @species = Species.find(params[:id])\n @species.update_attributes(params[:species])\n \n respond_with(@species, :location => admin_species_path(@species))\n end",
"def update\n @cluster = Cluster.find(params[:id])\n\n respond_to do |format|\n if @cluster.update_attributes(params[:cluster])\n format.html { redirect_to @cluster, notice: 'Cluster was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if request.xhr?\n @instance = Instance.find(params[:id])\n else\n @instance = @provider.instances.find(params[:id])\n end\n respond_to do |format|\n if @instance.update_attributes(params[:instance])\n @instance.resize_instance(@provider.connect!)\n format.html { redirect_to @instance, notice: 'Instance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @all = args[:all] if args.key?(:all)\n @group_labels = args[:group_labels] if args.key?(:group_labels)\n @instance_name_prefixes = args[:instance_name_prefixes] if args.key?(:instance_name_prefixes)\n @instances = args[:instances] if args.key?(:instances)\n @zones = args[:zones] if args.key?(:zones)\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 options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n respond_to do |format|\n if @world_city.update(world_city_params)\n format.html { redirect_to @world_city, notice: 'World city was successfully updated.' }\n format.json { render :show, status: :ok, location: @world_city }\n else\n format.html { render :edit }\n format.json { render json: @world_city.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @instance_id = args[:instance_id] if args.key?(:instance_id)\n @type = args[:type] if args.key?(:type)\n end",
"def update\n @instance = Instance.find(params[:id])\n\n respond_to do |format|\n if @instance.update_attributes(params[:instance])\n format.html { redirect_to @instance, notice: 'Instance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @deployed_model_id = args[:deployed_model_id] if args.key?(:deployed_model_id)\n @explanation_spec_override = args[:explanation_spec_override] if args.key?(:explanation_spec_override)\n @instances = args[:instances] if args.key?(:instances)\n @parameters = args[:parameters] if args.key?(:parameters)\n end",
"def destroy\n @world_instance.destroy\n respond_to do |format|\n format.html { redirect_to world_instances_url, notice: 'World instance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def update!(**args)\n @clusters = args[:clusters] if args.key?(:clusters)\n @instance = args[:instance] if args.key?(:instance)\n @instance_id = args[:instance_id] if args.key?(:instance_id)\n @parent = args[:parent] if args.key?(:parent)\n end",
"def update!(**args)\n @clusters = args[:clusters] if args.key?(:clusters)\n @instance = args[:instance] if args.key?(:instance)\n @instance_id = args[:instance_id] if args.key?(:instance_id)\n @parent = args[:parent] if args.key?(:parent)\n end",
"def update\n @lab = Lab.find(params[:lab_id])\n @machine = @lab.machines.find(params[:id])\n\n respond_to do |format|\n if @machine.update_attributes(machine_params)\n format.html { redirect_to lab_path(@lab), notice: 'Machine was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @machine.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n name = Server.find(params[:id]).name\n n = Neography::Node.find('servers', 'name', name)\n n.name = server_params[:name]\n n.add_to_index('servers', 'name', server_params[:name]) #TODO: is this necessary?\n if @server.update(server_params)\n format.html { redirect_to @server, notice: 'Server was successfully updated.' }\n format.json { render :show, status: :ok, location: @server }\n else\n format.html { render :edit }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def update\n @voxel = Voxel.find(params[:id])\n \n respond_to do |format|\n if @voxel.update_attributes(params[:voxel])\n format.html { redirect_to @voxel, notice: 'Voxel was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @voxel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @voxel.update(voxel_params)\n format.html { redirect_to @voxel, notice: '更新されました!' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @voxel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Location.update(params[\"id\"], params[\"location\"])\n end",
"def update\n @instance_type = InstanceType.find(params[:id])\n\n respond_to do |format|\n if @instance_type.update_attributes(params[:instance_type])\n format.html { redirect_to @instance_type, notice: 'Instance type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @instance_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put_instance(opts)\n opts = check_params(opts,[:instances])\n super(opts)\n end",
"def update(*args)\n put(*args)\n end",
"def update(*args)\n put(*args)\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update!(**args)\n @instance = args[:instance] if args.key?(:instance)\n @update_mask = args[:update_mask] if args.key?(:update_mask)\n end",
"def update!(**args)\n @instance = args[:instance] if args.key?(:instance)\n @update_mask = args[:update_mask] if args.key?(:update_mask)\n end",
"def update_cluster instance_id, cluster_id, location, serve_nodes\n instances.update_cluster name: cluster_path(instance_id, cluster_id),\n location: location,\n serve_nodes: serve_nodes\n end",
"def put(*args)\n request :put, *args\n end",
"def update\n respond_to do |format|\n if @cluster.update(cluster_params)\n format.html { redirect_to @cluster, notice: 'Cluster was successfully updated.' }\n format.json { render :show, status: :ok, location: @cluster }\n else\n format.html { render :edit }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cluster.update(cluster_params)\n format.html { redirect_to @cluster, notice: 'Cluster was successfully updated.' }\n format.json { render :show, status: :ok, location: @cluster }\n else\n format.html { render :edit }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @docker_instance.update(docker_instance_params)\n format.html { redirect_to @docker_instance, notice: 'Docker instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @docker_instance }\n else\n format.html { render :edit }\n format.json { render json: @docker_instance.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 update\n @slab = Slab.find(params[:id])\n\n respond_to do |format|\n if @slab.update_attributes(params[:slab])\n format.html { redirect_to @slab, :notice => 'Slab was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @slab.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @autoscaling_spec = args[:autoscaling_spec] if args.key?(:autoscaling_spec)\n @disk_spec = args[:disk_spec] if args.key?(:disk_spec)\n @id = args[:id] if args.key?(:id)\n @machine_spec = args[:machine_spec] if args.key?(:machine_spec)\n @replica_count = args[:replica_count] if args.key?(:replica_count)\n @used_replica_count = args[:used_replica_count] if args.key?(:used_replica_count)\n end",
"def update\n @sphere = Sphere.find(params[:id])\n\n respond_to do |format|\n if @sphere.update_attributes(params[:sphere])\n format.html { redirect_to @sphere, notice: 'Sphere a été édité avec succès.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sphere.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ec2_instance.update(ec2_instance_params)\n format.html { redirect_to @ec2_instance, notice: 'Ec2 instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @ec2_instance }\n else\n format.html { render :edit }\n format.json { render json: @ec2_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def modify_server(server_uuid, params)\n data = { \"server\" => params }\n json = JSON.generate data\n response = put \"server/#{server_uuid}\", json\n\n response\n end",
"def update\n respond_to do |format|\n if @instance_type.update(instance_type_params)\n format.html { redirect_to @instance_type, notice: 'Instance type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @instance_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @app_instance.update(app_instance_params)\n format.html { redirect_to @app_instance, notice: 'App instance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @app_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update\n respond_to do |format|\n if @homeworld.update(homeworld_params)\n format.html { redirect_to @homeworld, notice: 'Homeworld was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @homeworld.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @instance_eni.update(instance_eni_params)\n format.html { redirect_to @instance_eni, notice: 'Instance eni was successfully updated.' }\n format.json { render :show, status: :ok, location: @instance_eni }\n else\n format.html { render :edit }\n format.json { render json: @instance_eni.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @science_instance.update(science_instance_params)\n format.html { redirect_to @science_instance, notice: 'Science instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @science_instance }\n else\n format.html { render :edit }\n format.json { render json: @science_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @instance.update(instance_params)\n format.html { redirect_to @instance, notice: 'Instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @instance }\n else\n format.html { render :edit }\n format.json { render json: @instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @instance.update(instance_params)\n format.html { redirect_to @instance, notice: 'Instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @instance }\n else\n format.html { render :edit }\n format.json { render json: @instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @allowed_projects = args[:allowed_projects] if args.key?(:allowed_projects)\n @cluster_hostname = args[:cluster_hostname] if args.key?(:cluster_hostname)\n @enable_private_endpoint = args[:enable_private_endpoint] if args.key?(:enable_private_endpoint)\n @service_attachment_uri = args[:service_attachment_uri] if args.key?(:service_attachment_uri)\n end",
"def update!(**args)\n @info = args[:info] if args.key?(:info)\n @instance = args[:instance] if args.key?(:instance)\n end",
"def save(*args, &block)\n super\n # begin\n # require 'restclient'\n # server[\"/instances/#{instance_id}\"].put(to_json)\n # rescue Exception => e\n # Metavirt::Log.error \"cloudkit fail:\\n\\t#{e.inspect}\"\n # end\n self\n end",
"def update!(**args)\n @instance_config = args[:instance_config] if args.key?(:instance_config)\n end",
"def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end",
"def put(obj, which=:groups)\n path = \"/#{which}\"\n path += \"/#{obj['ID']}\" unless obj['ID'].nil? \n resp = self.class.post(path, { :body => obj })\n check_errors resp\n res = resp.parsed_response['Response']['Entry']\n rebuild_groups! res\n res\n end",
"def update!(**args)\n @deployed_model_id = args[:deployed_model_id] if args.key?(:deployed_model_id)\n @endpoint = args[:endpoint] if args.key?(:endpoint)\n end",
"def update\n @game_instance = GameInstance.find(params[:id])\n\n respond_to do |format|\n if @game_instance.update_attributes(params[:game_instance])\n format.html { redirect_to @game_instance, notice: 'Game instance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @game_instance.errors, status: :unprocessable_entity }\n end\n end\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 update\n\t@instance = Instance.find(params[:id])\n #respond_to do |format|\n if @instance.update_attributes(instance_params)\n #format.html { redirect_to @instance, notice: 'Instance was successfully updated.' }\n #format.json { render :show, status: :ok, location: @instance }\n\t@response = { :message => \"Instance successfully updated.\"}\n\trender :json => @response\n else\n #format.html { render :edit }\n render :json => @instance.errors\n end\n #end\n end",
"def update!(**args)\n @description = args[:description] if args.key?(:description)\n @etag = args[:etag] if args.key?(:etag)\n @multi_cluster_routing_use_any = args[:multi_cluster_routing_use_any] if args.key?(:multi_cluster_routing_use_any)\n @name = args[:name] if args.key?(:name)\n @single_cluster_routing = args[:single_cluster_routing] if args.key?(:single_cluster_routing)\n end",
"def update!(**args)\n @api_server_args = args[:api_server_args] if args.key?(:api_server_args)\n @control_plane_node_pool_config = args[:control_plane_node_pool_config] if args.key?(:control_plane_node_pool_config)\n end",
"def update!(**args)\n @api_server_args = args[:api_server_args] if args.key?(:api_server_args)\n @control_plane_node_pool_config = args[:control_plane_node_pool_config] if args.key?(:control_plane_node_pool_config)\n end",
"def update!(**args)\n @annotations = args[:annotations] if args.key?(:annotations)\n @bare_metal_version = args[:bare_metal_version] if args.key?(:bare_metal_version)\n @binary_authorization = args[:binary_authorization] if args.key?(:binary_authorization)\n @cluster_operations = args[:cluster_operations] if args.key?(:cluster_operations)\n @control_plane = args[:control_plane] if args.key?(:control_plane)\n @create_time = args[:create_time] if args.key?(:create_time)\n @delete_time = args[:delete_time] if args.key?(:delete_time)\n @description = args[:description] if args.key?(:description)\n @endpoint = args[:endpoint] if args.key?(:endpoint)\n @etag = args[:etag] if args.key?(:etag)\n @fleet = args[:fleet] if args.key?(:fleet)\n @load_balancer = args[:load_balancer] if args.key?(:load_balancer)\n @local_name = args[:local_name] if args.key?(:local_name)\n @maintenance_config = args[:maintenance_config] if args.key?(:maintenance_config)\n @maintenance_status = args[:maintenance_status] if args.key?(:maintenance_status)\n @name = args[:name] if args.key?(:name)\n @network_config = args[:network_config] if args.key?(:network_config)\n @node_access_config = args[:node_access_config] if args.key?(:node_access_config)\n @node_config = args[:node_config] if args.key?(:node_config)\n @os_environment_config = args[:os_environment_config] if args.key?(:os_environment_config)\n @proxy = args[:proxy] if args.key?(:proxy)\n @reconciling = args[:reconciling] if args.key?(:reconciling)\n @security_config = args[:security_config] if args.key?(:security_config)\n @state = args[:state] if args.key?(:state)\n @status = args[:status] if args.key?(:status)\n @storage = args[:storage] if args.key?(:storage)\n @uid = args[:uid] if args.key?(:uid)\n @update_time = args[:update_time] if args.key?(:update_time)\n @validation_check = args[:validation_check] if args.key?(:validation_check)\n end",
"def update\n @chef_mapping = ChefMapping.find(params[:id])\n\n respond_to do |format|\n if @chef_mapping.update_attributes(params[:chef_mapping])\n format.html { redirect_to @chef_mapping, notice: 'Chef mapping was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @chef_mapping.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @automatic_resources = args[:automatic_resources] if args.key?(:automatic_resources)\n @create_time = args[:create_time] if args.key?(:create_time)\n @dedicated_resources = args[:dedicated_resources] if args.key?(:dedicated_resources)\n @deployed_index_auth_config = args[:deployed_index_auth_config] if args.key?(:deployed_index_auth_config)\n @deployment_group = args[:deployment_group] if args.key?(:deployment_group)\n @display_name = args[:display_name] if args.key?(:display_name)\n @enable_access_logging = args[:enable_access_logging] if args.key?(:enable_access_logging)\n @id = args[:id] if args.key?(:id)\n @index = args[:index] if args.key?(:index)\n @index_sync_time = args[:index_sync_time] if args.key?(:index_sync_time)\n @private_endpoints = args[:private_endpoints] if args.key?(:private_endpoints)\n @reserved_ip_ranges = args[:reserved_ip_ranges] if args.key?(:reserved_ip_ranges)\n end",
"def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @description = args[:description] if args.key?(:description)\n @display_name = args[:display_name] if args.key?(:display_name)\n @dry_run = args[:dry_run] if args.key?(:dry_run)\n @duration = args[:duration] if args.key?(:duration)\n @error_message = args[:error_message] if args.key?(:error_message)\n @instance_details_summary = args[:instance_details_summary] if args.key?(:instance_details_summary)\n @instance_filter = args[:instance_filter] if args.key?(:instance_filter)\n @name = args[:name] if args.key?(:name)\n @patch_config = args[:patch_config] if args.key?(:patch_config)\n @patch_deployment = args[:patch_deployment] if args.key?(:patch_deployment)\n @percent_complete = args[:percent_complete] if args.key?(:percent_complete)\n @rollout = args[:rollout] if args.key?(:rollout)\n @state = args[:state] if args.key?(:state)\n @update_time = args[:update_time] if args.key?(:update_time)\n end",
"def put(*args)\n request(:put, *args)\n end",
"def create\n world_name = params[\"name\"]\n superclass_uri = params[\"type-parent\"]\n container_uri = params[\"location-parent\"]\n description = params[\"description\"]\n if params.has_key?(:options)\n options = {protected: false, locked: false}\n options[:protected] = true if (params[\"options\"].include?(\"protected\"))\n options[:locked] = true if (params[\"options\"].include?(\"locked\"))\n end\n host_port = request.host_with_port\n hostname = host_port.split(\":\").first\n port = host_port.split(\":\").last\n\n if (WorldAdmin.has_visibility_privilege?(superclass_uri, session[:user_uri]) && WorldAdmin.has_frame_level_privilege?(container_uri, session[:user_uri]))\n w = WorldInstance.create_world_instance_with_uri(world_name, superclass_uri, container_uri, description, nil, options, nil, nil, nil, hostname, port)\n\n puts w.world_instance_uri\n redirect_to w.world_instance_uri\n else\n head(status=401)\n end\n\n # @world_instance = WorldInstance.new(world_instance_params)\n #\n # respond_to do |format|\n # if @world_instance.save\n # format.html { redirect_to @world_instance, notice: 'World instance was successfully created.' }\n # format.json { render :show, status: :created, location: @world_instance }\n # else\n # format.html { render :new }\n # format.json { render json: @world_instance.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def update!(**args)\n @accelerators = args[:accelerators] if args.key?(:accelerators)\n @boot_disk_size_gb = args[:boot_disk_size_gb] if args.key?(:boot_disk_size_gb)\n @confidential_instance_config = args[:confidential_instance_config] if args.key?(:confidential_instance_config)\n @disable_public_ip_addresses = args[:disable_public_ip_addresses] if args.key?(:disable_public_ip_addresses)\n @enable_nested_virtualization = args[:enable_nested_virtualization] if args.key?(:enable_nested_virtualization)\n @machine_type = args[:machine_type] if args.key?(:machine_type)\n @pool_size = args[:pool_size] if args.key?(:pool_size)\n @pooled_instances = args[:pooled_instances] if args.key?(:pooled_instances)\n @service_account = args[:service_account] if args.key?(:service_account)\n @shielded_instance_config = args[:shielded_instance_config] if args.key?(:shielded_instance_config)\n @tags = args[:tags] if args.key?(:tags)\n end",
"def update\n @cluster = Cluster.find(params[:id])\n\n respond_to do |format|\n if @cluster.update_attributes(params[:cluster])\n flash[:notice] = 'Cluster was successfully updated.'\n format.html { redirect_to(@cluster) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cluster.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @instance = args[:instance] if args.key?(:instance)\n end",
"def update_remote!(attributes_hash)\n path = \"/#{resource_name}/#{id}/\"\n UserEngage.client.put(path, attributes_hash)\n end",
"def update_current_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n respond_to do |format|\n if @species.update(species_params)\n format.html { redirect_to @species, notice: 'Species was successfully updated.' }\n format.json { render :show, status: :ok, location: @species }\n else\n format.html { render :edit }\n format.json { render json: @species.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n @laboratory = Laboratory.find(params[:id])\n\n if @laboratory.update!(laboratory_params)\n render json: @laboratory\n else \n render json: @laboratory.errors, status: :unprocessable_entity\n end\n end",
"def update\n @environment = current_user.organization.environments.find(params[:id])\n\n respond_to do |format|\n if @environment.update_attributes(params[:environment])\n format.html { redirect_to @environment, notice: 'Instance record was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @environment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @ip = args[:ip] if args.key?(:ip)\n @labels = args[:labels] if args.key?(:labels)\n @port = args[:port] if args.key?(:port)\n @principal = args[:principal] if args.key?(:principal)\n @region_code = args[:region_code] if args.key?(:region_code)\n end",
"def update\n @neighborhood = Neighborhood.find(params[:id])\n\n respond_to do |format|\n if @neighborhood.update_attributes(params[:neighborhood])\n format.html { redirect_to @neighborhood, notice: 'Neighborhood was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @neighborhood.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @neighborhood = Neighborhood.find(params[:id])\n\n respond_to do |format|\n if @neighborhood.update_attributes(params[:neighborhood])\n format.html { redirect_to @neighborhood, notice: 'Neighborhood was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @neighborhood.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(options)\n data = JSON.generate(:server => options)\n response = @compute.connection.csreq(\"PUT\",@svrmgmthost,\"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}\",@svrmgmtport,@svrmgmtscheme,{'content-type' => 'application/json'},data)\n OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)\n # If we rename the instance, repopulate the object\n self.populate if options[:name]\n true\n end",
"def update!(**args)\n @attributes = args[:attributes] if args.key?(:attributes)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update\n #@instance = Instance.find(params[:id])\n\n respond_to do |format|\n if @instance.update_attributes(params[:instance])\n format.html { redirect_to @instance, notice: '更新成功。' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n if is_dungeon_master?\n if @map.update(map_params)\n head :no_content\n else\n render json: @map.errors, status: :unprocessable_entity\n end\n else\n render json: @map.errors, status: :forbidden\n end\n end",
"def update\n do_patch { return } # check if patch and do submission and return early if it is a patch (submission)\n # otherwise this is a PUT of the dataset metadata\n check_status { return } # check it's in progress, clone a submitted or raise an error\n respond_to do |format|\n format.json do\n dp = if @resource\n DatasetParser.new(hash: params['dataset'], id: @resource.identifier, user: @user) # update dataset\n else\n DatasetParser.new(hash: params['dataset'], user: @user, id_string: params[:id]) # upsert dataset with identifier\n end\n @stash_identifier = dp.parse\n ds = Dataset.new(identifier: @stash_identifier.to_s) # sets up display objects\n render json: ds.metadata, status: 200\n end\n end\n end",
"def update\n animal = Animal.find(params[:id])\n\n if validate_params(animal_params)\n animal.update(animal_params)\n render json: animal, status: 200, location: [:api, animal]\n else\n render json: { errors: animal.errors }, status: 422\n end\n end",
"def update\n respond_to do |format|\n if @robot_instance.update(robot_instance_params)\n format.html { redirect_to @robot_instance, notice: 'Robot instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @robot_instance }\n else\n format.html { render :edit }\n format.json { render json: @robot_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @admin_cluster_membership = args[:admin_cluster_membership] if args.key?(:admin_cluster_membership)\n @admin_cluster_name = args[:admin_cluster_name] if args.key?(:admin_cluster_name)\n @annotations = args[:annotations] if args.key?(:annotations)\n @bare_metal_version = args[:bare_metal_version] if args.key?(:bare_metal_version)\n @binary_authorization = args[:binary_authorization] if args.key?(:binary_authorization)\n @cluster_operations = args[:cluster_operations] if args.key?(:cluster_operations)\n @control_plane = args[:control_plane] if args.key?(:control_plane)\n @create_time = args[:create_time] if args.key?(:create_time)\n @delete_time = args[:delete_time] if args.key?(:delete_time)\n @description = args[:description] if args.key?(:description)\n @endpoint = args[:endpoint] if args.key?(:endpoint)\n @etag = args[:etag] if args.key?(:etag)\n @fleet = args[:fleet] if args.key?(:fleet)\n @load_balancer = args[:load_balancer] if args.key?(:load_balancer)\n @local_name = args[:local_name] if args.key?(:local_name)\n @maintenance_config = args[:maintenance_config] if args.key?(:maintenance_config)\n @maintenance_status = args[:maintenance_status] if args.key?(:maintenance_status)\n @name = args[:name] if args.key?(:name)\n @network_config = args[:network_config] if args.key?(:network_config)\n @node_access_config = args[:node_access_config] if args.key?(:node_access_config)\n @node_config = args[:node_config] if args.key?(:node_config)\n @os_environment_config = args[:os_environment_config] if args.key?(:os_environment_config)\n @proxy = args[:proxy] if args.key?(:proxy)\n @reconciling = args[:reconciling] if args.key?(:reconciling)\n @security_config = args[:security_config] if args.key?(:security_config)\n @state = args[:state] if args.key?(:state)\n @status = args[:status] if args.key?(:status)\n @storage = args[:storage] if args.key?(:storage)\n @uid = args[:uid] if args.key?(:uid)\n @update_time = args[:update_time] if args.key?(:update_time)\n @upgrade_policy = args[:upgrade_policy] if args.key?(:upgrade_policy)\n @validation_check = args[:validation_check] if args.key?(:validation_check)\n end",
"def update\n @region = Region.find(params[:id])\n\n if @region.update(region_params)\n head :no_content\n else\n render json: @region.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @group_map.update_attributes(params[:group_map])\n format.html { redirect_to @group_map, notice: 'Group map was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stage = Stage.find(params[:id])\n\n if @stage.update_attributes(params[:stage])\n head :no_content\n else\n format.json { render json: @stage.errors, status: :unprocessable_entity }\n end\n end",
"def update\n respond_to do |format|\n if @galactic_cluster.update(galactic_cluster_params)\n format.html { redirect_to @galactic_cluster, notice: 'Galactic cluster was successfully updated.' }\n format.json { render :show, status: :ok, location: @galactic_cluster }\n else\n format.html { render :edit }\n format.json { render json: @galactic_cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_region\n Region.find(params[:record][:id]).update_attributes(params[:record])\n render :json => {}\n end",
"def update\n @plate = Plate.find(params[:id])\n\n if @plate.update(params[:plate])\n head :no_content\n else\n render json: @plate.errors, status: :unprocessable_entity\n end\n end"
] |
[
"0.61995953",
"0.6135081",
"0.6067482",
"0.60623163",
"0.60295266",
"0.6027825",
"0.5984719",
"0.5972078",
"0.5853953",
"0.579697",
"0.5763218",
"0.5728873",
"0.5702792",
"0.56962323",
"0.568443",
"0.5683357",
"0.5679044",
"0.56556773",
"0.5655598",
"0.56532097",
"0.56518537",
"0.56518537",
"0.5633417",
"0.56333244",
"0.5625247",
"0.5615559",
"0.5614815",
"0.5600247",
"0.5588753",
"0.55722916",
"0.55689436",
"0.55689436",
"0.5546174",
"0.5543948",
"0.5543948",
"0.55425733",
"0.5508236",
"0.549305",
"0.549305",
"0.5490827",
"0.5483072",
"0.5482767",
"0.5475289",
"0.5466206",
"0.5466061",
"0.5461384",
"0.5460322",
"0.54576504",
"0.5455541",
"0.5450527",
"0.5448008",
"0.5444876",
"0.54388165",
"0.54388165",
"0.54375005",
"0.5437228",
"0.5429087",
"0.5419601",
"0.54157907",
"0.5399144",
"0.5391882",
"0.5391486",
"0.5390893",
"0.53891885",
"0.53840655",
"0.5381313",
"0.53791606",
"0.53791606",
"0.5378825",
"0.53612566",
"0.53591913",
"0.5357324",
"0.53510606",
"0.53495693",
"0.53469974",
"0.5346903",
"0.53419614",
"0.5341009",
"0.5340619",
"0.5337357",
"0.53356147",
"0.5334454",
"0.5333283",
"0.5329792",
"0.5329792",
"0.53290653",
"0.53213805",
"0.53202194",
"0.5319448",
"0.53177893",
"0.5313492",
"0.5312066",
"0.53119737",
"0.5305491",
"0.5297201",
"0.5294356",
"0.52931654",
"0.5287293",
"0.5284406",
"0.52842605"
] |
0.72476095
|
0
|
DELETE /world_instances/1 DELETE /world_instances/1.json
|
def destroy
@world_instance.destroy
respond_to do |format|
format.html { redirect_to world_instances_url, notice: 'World instance was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @resource.destroy\n @myWorld = World.where(:title => @user[:email])\n worldID = @myWorld[0].id\n invoke(\"Resource destroyed: \" + @resource.title, @user[:email], \"admin\", worldID)\n respond_to do |format|\n format.html { redirect_to resources_url, notice: 'Resource was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server_instance = ServerInstance.find(params[:id])\n @server_instance.destroy\n\n respond_to do |format|\n format.html { redirect_to server_instances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @world_region.destroy\n respond_to do |format|\n format.html { redirect_to world_regions_path, notice: 'World region 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 @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 @world_admin.destroy\n respond_to do |format|\n format.html { redirect_to world_admins_url, notice: 'World admin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dungeon_instance = @current_user.dungeon_instances.find(params[:id])\n @dungeon_instance.destroy\n respond_to do |format|\n format.html { redirect_to dungeon_instances_url, notice: 'Dungeon instance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @world_city.destroy\n respond_to do |format|\n format.html { redirect_to world_cities_url, notice: 'World city was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@instance = Instance.find(params[:id])\n @instance.destroy\n\n respond_to do |format|\n format.html { redirect_to instances_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @slab = Slab.find(params[:id])\n @slab.destroy\n\n respond_to do |format|\n format.html { redirect_to slabs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instance = Instance.find(params[:id])\n @instance.destroy\n\n respond_to do |format|\n format.html { redirect_to instances_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 @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 @lifespan = Lifespan.find(params[:id])\n @lifespan.destroy\n\n respond_to do |format|\n format.html { redirect_to lifespans_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game_instance = GameInstance.find(params[:id])\n @game_instance.destroy\n\n respond_to do |format|\n format.html { redirect_to game_instances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @docker_instance.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @homeworld.destroy\n respond_to do |format|\n format.html { redirect_to homeworlds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cluster = Cluster.find(params[:id])\n @cluster.destroy\n\n respond_to do |format|\n format.html { redirect_to clusters_url }\n format.json { head :ok }\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 @orbituarysite = Orbituarysite.find(params[:id])\n @orbituarysite.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.delete( name )\n end",
"def destroy\n @robot_instance.destroy\n respond_to do |format|\n format.html { redirect_to robot_instances_url, notice: 'Robot instance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instance.destroy\n respond_to do |format|\n format.html { redirect_to instances_url, notice: 'Instance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instance.destroy\n respond_to do |format|\n format.html { redirect_to instances_url, notice: 'Instance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cocoon_example.destroy\n respond_to do |format|\n format.html { redirect_to cocoon_examples_url, notice: 'Cocoon example was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_region\n Region.find(params[:id]).destroy\n render :json => {}\n end",
"def destroy\n @neighborhood = Neighborhood.find(params[:id])\n @neighborhood.destroy\n\n respond_to do |format|\n format.html { redirect_to neighborhoods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @neighborhood = Neighborhood.find(params[:id])\n @neighborhood.destroy\n\n respond_to do |format|\n format.html { redirect_to neighborhoods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @app_instance.destroy\n respond_to do |format|\n format.html { redirect_to app_instances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lab = Lab.find(params[:lab_id])\n @machine = @lab.machines.find(params[:id])\n @machine.destroy\n\n respond_to do |format|\n format.html { redirect_to lab_path(@lab) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server1 = Server1.find(params[:id])\n @server1.destroy\n\n respond_to do |format|\n format.html { redirect_to server1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @voxel.destroy\n respond_to do |format|\n format.html { redirect_to voxels_url }\n format.json { head :no_content }\n end\n end",
"def orchio_delete\n response = client.send_request :delete, inst_args\n orchio_status response, 204\n end",
"def destroy\n @roadmap_step.destroy\n respond_to do |format|\n format.html { redirect_to roadmap_steps_url, notice: 'Roadmap step was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instance_type.destroy\n respond_to do |format|\n format.html { redirect_to instance_types_url }\n format.json { head :no_content }\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 @admin_neighbourhood.destroy\n respond_to do |format|\n format.html { redirect_to admin_neighbourhoods_url, notice: 'Neighbourhood 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 @client.delete(@name)\n end",
"def destroy\n @inst.destroy\n respond_to do |format|\n format.html { redirect_to insts_url, notice: 'Inst was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instance = @provider.instances.find(params[:id])\n InstanceOperations.terminate_instances(@provider.connect!, @instance)\n @instance.destroy\n redirect_to cloud_provider_path(@provider) \n end",
"def delete!\n server.delete(name)\n end",
"def destroy\n @instance_type = InstanceType.find(params[:id])\n @instance_type.destroy\n\n respond_to do |format|\n format.html { redirect_to instance_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ge_city_api.destroy\n respond_to do |format|\n format.html { redirect_to ge_city_apis_url, notice: 'Ge city api was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @galactic_cluster.destroy\n respond_to do |format|\n format.html { redirect_to galactic_clusters_url, notice: 'Galactic cluster was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game_server = Game::Server.find(params[:id])\n @game_server.destroy\n\n respond_to do |format|\n format.html { redirect_to game_servers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @map_version.destroy\n respond_to do |format|\n format.html { redirect_to admin_map_versions_url, notice: 'Map version was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @level_container = LevelContainer.find(params[:id])\n @level_container.destroy\n\n respond_to do |format|\n format.html { redirect_to level_containers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game_game_instance = Game::GameInstance.find(params[:id])\n @game_game_instance.destroy\n\n respond_to do |format|\n format.html { redirect_to game_game_instances_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @shard = Shard.find(params[:id])\n @shard.destroy\n\n respond_to do |format|\n format.html { redirect_to shards_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @measure_instance.destroy\n respond_to do |format|\n format.html { redirect_to measure_instances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unity3d.destroy\n respond_to do |format|\n format.html { redirect_to unity3ds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n @server.send_delete\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @cloud.delete\n respond_to do |format|\n format.html { redirect_to clouds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n vehicle = Vehicle.where(uid: params[:id]).first\n # vehicle.locations.destroy_all\n vehicle.destroy\n render nothing: true, :status =>204\n end",
"def destroy\n @instance_name = InstanceName.find(params[:id])\n @instance_name.destroy\n\n respond_to do |format|\n format.html { redirect_to(instance_names_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @instance = Instance.find(params[:id])\n @instance.destroy\n\n respond_to do |format|\n format.html { redirect_to(instances_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_index_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @health.destroy\n respond_to do |format|\n format.html { redirect_to \"/dashboard\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @neighbourhood.destroy\n respond_to do |format|\n format.html { redirect_to neighbourhoods_url, notice: 'Neighbourhood was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hotspot_registration.destroy\n respond_to do |format|\n format.html { redirect_to admin_guests_url, notice: 'Guest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_location.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_locations_url, notice: 'Location was successfully destroyed.' }\n format.json { render json: { results: @api_v1_location, message: 'Location was successfully destroyed.' } }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @tile.destroy\n respond_to do |format|\n format.html { redirect_to tiles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tile.destroy\n respond_to do |format|\n format.html { redirect_to tiles_url }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n @node = Node.find_key(params[:id] || params[:name])\n @node.destroy\n respond_to do |format|\n format.html { redirect_to deployment_path(@node.deployment_id) }\n format.json { render api_delete @node }\n end\n end",
"def destroy\n @gce_region.destroy\n respond_to do |format|\n format.html { redirect_to gce_regions_url, notice: 'Gce region 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 @server_node = ServerNode.find(params[:id])\n @server_node.destroy\n\n respond_to do |format|\n format.html { redirect_to server_nodes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sphere = Sphere.find(params[:id])\n @sphere.destroy\n\n respond_to do |format|\n format.html { redirect_to spheres_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_instance.destroy\n respond_to do |format|\n format.html { redirect_to test_instances_url, notice: 'Test instance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collab = Collab.find(params[:id])\n @collab.destroy\n\n respond_to do |format|\n format.html { redirect_to collabs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @graphium_city.destroy\n respond_to do |format|\n format.html { redirect_to graphium_cities_url, notice: 'City was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @science_instance.destroy\n respond_to do |format|\n format.html { redirect_to science_instances_url, notice: 'Science instance was successfully destroyed.' }\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\n @gameserver.destroy\n respond_to do |format|\n format.html { redirect_to gameservers_path, notice: 'Server was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cloud = Cloud.find(params[:id])\n @cloud.destroy\n\n respond_to do |format|\n format.html { redirect_to clouds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instance_eni.destroy\n respond_to do |format|\n format.html { redirect_to instance_enis_url, notice: 'Instance eni was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @scene.destroy\n\n respond_to do |format|\n format.html { redirect_to action: \"index\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n return if @name.nil?\n delete_rest \"vservers/#{@name}\"\n end",
"def destroy\n debug(\"#{self.class}::destroy\")\n\n #Retrieval of key\n if ((defined? $key) && !(($key.nil?) || ($key.empty?)))\n Puppet.debug('INFO: key already provided as a command parameter ' + $key)\n\n elsif (!($name.to_s.empty?) )\n\n #Retrieve key\n uriAttributeMap1 = {}\n uriAttributeMap1[:name] = $name\n resourceType = \"storage-service-levels\"\n $key = self.retrieveKeyOfObjectType('/api/1.0/slo/storage-service-levels', resourceType, uriAttributeMap1)\n\n end\n\n\n apiUri = '/api/1.0/slo/storage-service-levels/'+$key\n resourceType = \"storageservicelevel\"\n\n if(transport.http_delete_request(apiUri ,resourceType))\n if(resource[:name] != null)\n puts \"#{resourceType} : #{resource[:name]} successfully deleted\"\n\t\t\telse\n\t\t\t puts \" #{resourceType} successfully deleted\"\n\t\t\tend\n else\n if(resource[:name] != null)\n puts \" #{resourceType} : #{resource[:name]} deletion failed\"\n\t\t else\n\t\t\t puts \" #{resourceType} deletion failed\"\n\t\t end\n end\n\nend",
"def destroy\n @gameserver.destroy\n respond_to do |format|\n format.html { redirect_to servers_url, notice: 'Server was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clapme_stage.destroy\n respond_to do |format|\n format.html { redirect_to website_stages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chef_mapping = ChefMapping.find(params[:id])\n @chef_mapping.destroy\n\n respond_to do |format|\n format.html { redirect_to chef_mappings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @startup.destroy\n respond_to do |format|\n format.html { redirect_to startups_url, notice: 'startup was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @serverhascontainer.destroy\n respond_to do |format|\n format.html { redirect_to serverhascontainers_url, notice: 'Serverhascontainer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @startup = Startup.find(params[:id])\n @startup.destroy\n\n respond_to do |format|\n format.html { redirect_to startups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n chef_server_rest.delete(\"nodes/#{name}\")\n end",
"def delete\n stop\n [ @resource['instances_dir'] + \"/\" + @resource[:name],\n @resource['instances_dir'] + \"/\" + \"_\" + @resource[:name]\n ].each do |dir|\n FileUtils.rm_rf(dir) if File.directory?(dir)\n end\n end",
"def destroy\n @earth.destroy\n respond_to do |format|\n format.html { redirect_to earths_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def destroy\n @erogenous_zone = ErogenousZone.find(params[:id])\n @erogenous_zone.destroy\n\n respond_to do |format|\n format.html { redirect_to erogenous_zones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @island = Island.find(params[:id])\n @island.destroy\n\n respond_to do |format|\n format.html { redirect_to islands_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cluster = Cluster.find(params[:id])\n @cluster.destroy\n\n respond_to do |format|\n format.html { redirect_to(clusters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @api_state.destroy\n\n head :no_content\n end"
] |
[
"0.6947151",
"0.68925005",
"0.6871639",
"0.68688583",
"0.68147826",
"0.6753604",
"0.66819865",
"0.66485727",
"0.66289926",
"0.66065156",
"0.6598677",
"0.6580668",
"0.65695715",
"0.65672123",
"0.65670717",
"0.65354246",
"0.65161675",
"0.64934194",
"0.6490549",
"0.648567",
"0.64844584",
"0.6477114",
"0.647704",
"0.64751464",
"0.64746624",
"0.6471196",
"0.6464418",
"0.6450363",
"0.6450363",
"0.6449687",
"0.64407593",
"0.64308214",
"0.6429725",
"0.64296097",
"0.6427782",
"0.6402439",
"0.63984865",
"0.6389632",
"0.6385432",
"0.6382516",
"0.6380264",
"0.6379829",
"0.6370329",
"0.6362041",
"0.63587195",
"0.6354578",
"0.63545",
"0.63526124",
"0.63387454",
"0.6334235",
"0.63322604",
"0.6324171",
"0.6318641",
"0.63159585",
"0.63128316",
"0.63121164",
"0.6306869",
"0.6306702",
"0.63048893",
"0.63041943",
"0.6300669",
"0.6298047",
"0.62966245",
"0.6294923",
"0.6294681",
"0.6294681",
"0.62902313",
"0.62888765",
"0.6287136",
"0.62861687",
"0.6284587",
"0.62840676",
"0.6281728",
"0.62817085",
"0.62789434",
"0.62789065",
"0.6275897",
"0.6273894",
"0.62723535",
"0.62720907",
"0.6269577",
"0.62663454",
"0.6264482",
"0.6264262",
"0.62635654",
"0.6259534",
"0.6258185",
"0.6256734",
"0.6248536",
"0.62463826",
"0.62418157",
"0.62402487",
"0.6239854",
"0.6239854",
"0.6239854",
"0.6239854",
"0.6239265",
"0.6235279",
"0.62349373",
"0.62348837"
] |
0.77915865
|
0
|
This is the only way I found to prevent deleting materials from a set via 'patch'
|
def check_lock
if Aker::Set.find(resource_id).locked?
return render json: { errors: [{ status: '422', title: 'Unprocessable entity', detail: 'Set is locked' }]}, status: :unprocessable_entity
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @material.destroy\n end",
"def material_use\n materials = []\n materials\n end",
"def unpatch!(patchset)\n Diff::LCS.unpatch!(self, patchset)\n end",
"def clear_materials\n\t\t@materials_charged_hash = Hash.new\n\tend",
"def clear_patches\n @patches.clear\n end",
"def destroy\n self.class.where(:id => self.id).update_all(:is_mirrored => false) if self.is_mirrored?\n super\n end",
"def update!(**args)\n @material = args[:material] if args.key?(:material)\n end",
"def material=(material)\n end",
"def changes_on_stack_delete(template, _changeset_set)\n mock_delete_changeset(template)\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to materials_url }\n format.json { head :no_content }\n end\n end",
"def before_destroy; raise ActiveRecord::ReadOnlyRecord; end",
"def unpatch_me(patchset)\n if respond_to? :replace\n replace(unpatch!(patchset))\n else\n unpatch!(patchset)\n end\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to materials_url }\n format.json { head :ok }\n end\n end",
"def destroy\n self.littles.each do | little|\n little.big_id = nil;\n end\n self.positions.each do | pos |\n pos.dke_info_id = nil;\n end\n return super\n end",
"def destroy\n\t\tif @material.destroy\n\t\t\tflash[:notice] = \"Successfully deleted material!\"\n\t\t\tredirect_to materials_path\n\t\telse\n\t\t\tflash[:alert] = \"Error updating material!\"\n\t\tend\n\tend",
"def destroy\n @admin_block_material.destroy\n respond_to do |format|\n format.html { redirect_to admin_block_materials_path, notice: I18n.t('deleted') }\n format.json { head :no_content }\n end\n end",
"def onMaterialUndoRedo(materials, material)\n end",
"def test_should_require_one_asset_if_has_been_deleted_with_attributes\n AssetRelation.destroy_all\n item = AssetType.new\n item.multiple.options[:required] = true\n\n begin\n item.update_attributes :multiple_attributes => two_asset_relation_attributes\n assert_equal 2, item.multiple.size\n assert item.valid?\n assert !item.update_attributes(:multiple_attributes => {})\n ensure\n # cleanup\n item.multiple.options[:required] = false\n end\n end",
"def destroy\n @material_type.destroy\n\n head :no_content\n end",
"def destroy\n @patch.destroy\n respond_to do |format|\n format.html { redirect_to patches_url }\n format.json { head :no_content }\n end\n end",
"def ensure_deletion_fixes \n # TO DO\n end",
"def delete(name)\n @parent.gemset_delete(name)\n end",
"def other_patches\n patch_set.patches.all(:order => [ :id.asc ]).reject { |p| p == self }\n end",
"def remove_marked\n @objects.remove_marked\n end",
"def material; end",
"def material; end",
"def unpatch!(src, patchset)\n patch(src, patchset, :unpatch)\n end",
"def destroy\n @raw_material.destroy\n respond_to do |format|\n format.html { redirect_to raw_materials_url, notice: 'Raw material was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @raw_material.destroy\n respond_to do |format|\n format.html { redirect_to raw_materials_url, notice: 'Raw material was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def add_material(material_name)\n # First check model and return material if it already exists\n self.getMaterials.each do |material|\n if material.name.get.to_s == material_name\n OpenStudio::logFree(OpenStudio::Debug, 'openstudio.standards.Model', \"Already added material: #{material_name}\")\n return material\n end\n end\n \n #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"Adding material: #{material_name}\")\n\n # Get the object data\n data = self.find_object(self.standards['materials'], {'name'=>material_name})\n if !data\n OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Model', \"Cannot find data for material: #{material_name}, will not be created.\")\n return false #TODO change to return empty optional material\n end\n \n material = nil\n material_type = data['material_type']\n\n if material_type == 'StandardOpaqueMaterial'\n material = OpenStudio::Model::StandardOpaqueMaterial.new(self)\n material.setName(material_name)\n\n material.setRoughness(data['roughness'].to_s)\n material.setThickness(OpenStudio.convert(data['thickness'].to_f, 'in', 'm').get)\n material.setConductivity(OpenStudio.convert(data['conductivity'].to_f, 'Btu*in/hr*ft^2*R', 'W/m*K').get)\n material.setDensity(OpenStudio.convert(data['density'].to_f, 'lb/ft^3', 'kg/m^3').get)\n material.setSpecificHeat(OpenStudio.convert(data['specific_heat'].to_f, 'Btu/lb*R', 'J/kg*K').get)\n material.setThermalAbsorptance(data['thermal_absorptance'].to_f)\n material.setSolarAbsorptance(data['solar_absorptance'].to_f)\n material.setVisibleAbsorptance(data['visible_absorptance'].to_f)\n\n elsif material_type == 'MasslessOpaqueMaterial'\n material = OpenStudio::Model::MasslessOpaqueMaterial.new(self)\n material.setName(material_name)\n material.setThermalResistance(OpenStudio.convert(data['resistance'].to_f, 'hr*ft^2*R/Btu', 'm^2*K/W').get)\n\n material.setConductivity(OpenStudio.convert(data['conductivity'].to_f, 'Btu*in/hr*ft^2*R', 'W/m*K').get)\n material.setDensity(OpenStudio.convert(data['density'].to_f, 'lb/ft^3', 'kg/m^3').get)\n material.setSpecificHeat(OpenStudio.convert(data['specific_heat'].to_f, 'Btu/lb*R', 'J/kg*K').get)\n material.setThermalAbsorptance(data['thermal_absorptance'].to_f)\n material.setSolarAbsorptance(data['solar_absorptance'].to_f)\n material.setVisibleAbsorptance(data['visible_absorptance'].to_f)\n\n elsif material_type == 'AirGap'\n material = OpenStudio::Model::AirGap.new(self)\n material.setName(material_name)\n\n material.setThermalResistance(OpenStudio.convert(data['resistance'].to_f, 'hr*ft^2*R/Btu*in', 'm*K/W').get)\n\n elsif material_type == 'Gas'\n material = OpenStudio::Model::Gas.new(self)\n material.setName(material_name)\n\n material.setThickness(OpenStudio.convert(data['thickness'].to_f, 'in', 'm').get)\n material.setGasType(data['gas_type'].to_s)\n\n elsif material_type == 'SimpleGlazing'\n material = OpenStudio::Model::SimpleGlazing.new(self)\n material.setName(material_name)\n\n material.setUFactor(OpenStudio.convert(data['u_factor'].to_f, 'Btu/hr*ft^2*R', 'W/m^2*K').get)\n material.setSolarHeatGainCoefficient(data['solar_heat_gain_coefficient'].to_f)\n material.setVisibleTransmittance(data['visible_transmittance'].to_f)\n\n elsif material_type == 'StandardGlazing'\n material = OpenStudio::Model::StandardGlazing.new(self)\n material.setName(material_name)\n\n material.setOpticalDataType(data['optical_data_type'].to_s)\n material.setThickness(OpenStudio.convert(data['thickness'].to_f, 'in', 'm').get)\n material.setSolarTransmittanceatNormalIncidence(data['solar_transmittance_at_normal_incidence'].to_f)\n material.setFrontSideSolarReflectanceatNormalIncidence(data['front_side_solar_reflectance_at_normal_incidence'].to_f)\n material.setBackSideSolarReflectanceatNormalIncidence(data['back_side_solar_reflectance_at_normal_incidence'].to_f)\n material.setVisibleTransmittanceatNormalIncidence(data['visible_transmittance_at_normal_incidence'].to_f)\n material.setFrontSideVisibleReflectanceatNormalIncidence(data['front_side_visible_reflectance_at_normal_incidence'].to_f)\n material.setBackSideVisibleReflectanceatNormalIncidence(data['back_side_visible_reflectance_at_normal_incidence'].to_f)\n material.setInfraredTransmittanceatNormalIncidence(data['infrared_transmittance_at_normal_incidence'].to_f)\n material.setFrontSideInfraredHemisphericalEmissivity(data['front_side_infrared_hemispherical_emissivity'].to_f)\n material.setBackSideInfraredHemisphericalEmissivity(data['back_side_infrared_hemispherical_emissivity'].to_f)\n material.setConductivity(OpenStudio.convert(data['conductivity'].to_f, 'Btu*in/hr*ft^2*R', 'W/m*K').get)\n material.setDirtCorrectionFactorforSolarandVisibleTransmittance(data['dirt_correction_factor_for_solar_and_visible_transmittance'].to_f)\n if /true/i.match(data['solar_diffusing'].to_s)\n material.setSolarDiffusing(true)\n else\n material.setSolarDiffusing(false)\n end\n\n else\n puts \"Unknown material type #{material_type}\"\n exit\n end\n\n return material\n \n end",
"def before_destroy\n raise ActiveRecord::ReadOnlyRecord\n end",
"def before_destroy\n raise ActiveRecord::ReadOnlyRecord\n end",
"def update\n authorize @s_material\n files = @s_material.s_material_files\n files += s_material_params[:s_material_files] if s_material_params[:s_material_files]\n @s_material.assign_attributes(s_material_params)\n @s_material.s_material_files = files\n\n if params[:s_material_files_remove]\n\n remain_files = @s_material.s_material_files\n\n params[:s_material_files_remove].reverse_each do |file, state|\n if state.to_i == 1\n deleted_files = remain_files.delete_at(file.to_i)\n deleted_files.try(:remove!)\n end\n end\n\n @s_material.remove_s_material_files! if remain_files.empty?\n end\n respond_to do |format|\n if @s_material.save\n format.html { redirect_to s_materials_url, notice: t('Record has been saved') }\n format.json { render :show, status: :ok, location: @s_material }\n else\n format.html { render :edit }\n format.json { render json: @s_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to materials_url, :notice => \"Material was successfully delete.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to(materials_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to(materials_url) }\n format.xml { head :ok }\n end\n end",
"def onMaterialRefChange(materials, material)\n end",
"def destroy\n authorize @s_material\n @s_material.destroy\n respond_to do |format|\n format.html { redirect_to s_materials_url, notice: t('Record has been deleted') }\n format.json { head :no_content }\n end\n end",
"def can_destroy?\n line_items.blank?\n end",
"def material\n end",
"def no_admin_set_abilities\n cannot [:edit, :create, :delete], Hydra::Admin::Collection\n end",
"def delete( *gems_or_gemsets )\n \n return @gemset.delete( *gems_or_gemsets )\n \n end",
"def is_material(options={})\n\n Kobble.object_model(self)\n\n possible_definitions = [:collection, :owners, :illustration, :file, :organisation, :bookmarking, :description, :annotation, :discussion, :index, :log, :undelete, :selection]\n cattr_accessor possible_definitions.map{|d| \"_has_#{d.to_s}\".intern }\n \n if options[:except]\n definitions = possible_definitions - Array(options[:except]) \n elsif options[:only]\n definitions = possible_definitions & Array(options[:only])\n else\n definitions = possible_definitions\n end\n \n self.material = true\n self.material_definitions = definitions\n \n possible_definitions.each do |d|\n send( \"_has_#{d.to_s}=\".intern, definitions.include?(d)) # note that _has_x doesn't mean that the necesary columns are there, just that they ought to be\n end\n\n # collection -> attachment to (and usually confinement within) a collection\n \n if definitions.include?(:collection)\n if table_exists? && self.column_names.include?('collection_id')\n belongs_to :collection\n named_scope :in_collection, lambda { |collection| {:conditions => { :collection_id => collection.id }} }\n named_scope :in_collections, lambda { |collections| {:conditions => [\"#{table_name}.collection_id in (\" + collections.map{'?'}.join(',') + \")\"] + collections.map { |c| c.id }} }\n else\n logger.warn(\"!! #{self.to_s} should belong_to collection but has no collection_id column\")\n end\n end\n \n # owners -> standard creator and updater relationships\n \n if definitions.include?(:owners)\n belongs_to :created_by, :class_name => 'User'\n belongs_to :updated_by, :class_name => 'User'\n named_scope :created_by_user, lambda { |user| {:conditions => { :created_by_id => user.id }} }\n if table_exists? && self.column_names.include?('speaker_id')\n belongs_to :speaker, :class_name => 'Person'\n named_scope :spoken_by_person, lambda { |person| {:conditions => { :speaker_id => person.id }} }\n end\n end\n \n # illustration -> attached image file\n \n if definitions.include?(:illustration)\n if table_exists? && self.column_names.include?('image_file_name')\n has_attached_file :image, \n :path => \":rails_root/public/:class/:attachment/:id/:style/:basename.:extension\", \n :url => \"/:class/:attachment/:id/:style/:basename.:extension\",\n :styles => { \n \"thumb\" => \"56x56#\",\n \"slide\" => \"135x135#\",\n \"illustration\" => \"240x240>\",\n \"preview\" => \"750x540>\"\n }\n else\n logger.warn(\"!! #{self.to_s} should be illustrated but lacks necessary image columns\")\n end\n end\n\n # file -> attached document or media file\n\n if definitions.include?(:file)\n \n # during transition:\n if table_exists? && self.column_names.include?('clip_file_name')\n has_attached_file :clip, \n :path => \":rails_root/public/:class/:attachment/:id/:basename.:extension\",\n :url => \"/:class/:attachment/:id/:basename.:extension\"\n end\n \n # but this is the real one.\n if table_exists? && self.column_names.include?('file_file_name')\n has_attached_file :file, \n :path => \":rails_root/public/:class/:attachment/:id/:basename.:extension\",\n :url => \"/:class/:attachment/:id/:basename.:extension\"\n #! here we add the :processors for audio, video and documents\n \n end\n end\n\n # description -> tagging\n\n if definitions.include?(:description)\n has_many :taggings, :as => :taggable, :dependent => :destroy\n has_many :tags, :through => :taggings\n self.can_catch( :tag )\n Kobble.described_model(self)\n end\n \n # manipulation -> workbench drag and droppability\n \n if definitions.include?(:bookmarking)\n has_many :bookmarkings, :as => :bookmark, :dependent => :destroy\n has_many :bookmarkers, :through => :bookmarkings, :source => :created_by\n User.can_catch( self.to_s.downcase.intern )\n Kobble.bookmarked_model(self)\n end\n \n # organisation -> bundling\n \n if definitions.include?(:organisation)\n has_many :bundlings, :as => :member, :dependent => :destroy\n has_many :bundles, :through => :bundlings, :source => :superbundle \n Bundle.can_catch( self.to_s.downcase.intern )\n Bundle.create_accessors_for(self)\n Kobble.organised_model(self)\n end\n\n # annotation -> attached field notes\n\n if definitions.include?(:annotation)\n has_many :annotations, :as => :annotated, :dependent => :destroy\n Kobble.annotated_model(self)\n end\n\n # discussion -> attached topics\n\n if definitions.include?(:discussion)\n has_many :topics, :as => :referent, :dependent => :destroy, :order => 'topics.created_at DESC'\n Kobble.discussed_model(self)\n end\n\n # log -> attached events\n\n if definitions.include?(:log)\n attr_accessor :just_changed\n has_many :logged_events, :class_name => 'Event', :as => :affected, :dependent => :destroy, :order => 'at DESC'\n Kobble.logged_model(self)\n end\n \n # undelete -> acts_as_paranoid\n \n if definitions.include?(:undelete)\n if table_exists? && self.column_names.include?('deleted_at')\n acts_as_paranoid\n attr_accessor :newly_undeleted\n attr_accessor :reassign_to\n else\n logger.warn(\"!! #{self.to_s} should be paranoid but has no deleted_at column\")\n end\n end\n\n # selection -> some named scopes useful for limiting lists in the interface\n\n if definitions.include?(:selection)\n named_scope :other_than, lambda {|thing| {:conditions => ['id != ?', thing.id]}}\n named_scope :latest, { :limit => 20, :order => 'created_at DESC' }\n named_scope :latest_few, { :limit => 5, :order => 'created_at DESC' }\n named_scope :latest_many, { :limit => 100, :order => 'created_at DESC' }\n named_scope :changed_since, lambda {|start| { :conditions => ['created_at > ? or updated_at > ?', start, start] } }\n named_scope :created_by, lambda {|user| { :conditions => ['created_by = ?', user.id] } }\n end\n \n # index -> searchability (and also find-like-thisability)\n \n if definitions.include?(:index)\n acts_as_xapian :texts => [:name, :description, :body].select{ |m| column_names.include?(m.to_s) }\n Kobble.indexed_model(self)\n end\n\n class_eval {\n extend Kobble::Kore::KobbleClassMethods\n include Kobble::Kore::KobbleInstanceMethods\n }\n end",
"def del_craft_material\n @craftmaterial = CraftMaterial.find(params[:id])\n @craftmaterial.destroy\n redirect_to :back,:notice => \"Your post has been deleted successfully.\"\n end",
"def destroy\n @raw_material = RawMaterial.find(params[:id])\n @raw_material.destroy\n\n respond_to do |format|\n format.html { redirect_to(raw_materials_url) }\n format.xml { head :ok }\n end\n end",
"def remove_dismantle_mask(key, id)\n case key\n when :item\n $data_items[id].set_dismantle_mask_flags(true)\n when :armor\n $data_armors[id].set_dismantle_mask_flags(true)\n when :weapon\n $data_weapons[id].set_dismantle_mask_flags(true)\n end\n end",
"def test_putrelation_delete_inuse\n relation = create(:relation)\n super_relation = create(:relation)\n create(:relation_member, :relation => super_relation, :member => relation)\n cs_id = relation.changeset.id\n user = relation.changeset.user\n\n amf_content \"putrelation\", \"/1\", [\"#{user.email}:test\", cs_id, relation.version, relation.id, relation.tags, relation.members, false]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 2, result.size\n assert_equal -1, result[0]\n assert_match /relation #{relation.id} is used in/, result[1]\n\n new_relation = Relation.find(relation.id)\n assert_equal relation.version, new_relation.version\n assert_equal relation.members, new_relation.members\n assert_equal relation.tags, new_relation.tags\n assert_equal true, new_relation.visible\n end",
"def delete_matched\n raise NotImplementedError, \"#{self.class} does not support delete_matched\"\n end",
"def reinitialize_spec_set!\n Bundler.remove_instance_variable(:@locked_gems)\n Bundler.remove_instance_variable(:@definition)\n end",
"def destroy\n @patch = Patch.find(params[:id])\n @patch.destroy\n\n respond_to do |format|\n format.html { redirect_to patches_url }\n format.json { head :no_content }\n end\n end",
"def recipe_materials_attributes=(attributes)\n @recipe_materials ||= []\n attributes.each do |i, material_params|\n if material_params[\"_destroy\"] == '1' && !material_params[\"id\"].nil?\n # Delete relation\n RecipeMaterial.find(material_params[\"id\"]).destroy\n elsif material_params[\"_destroy\"] == '0'\n material_params.delete \"_destroy\" \n # puts material_params\n if material_params[\"id\"].nil?\n # New relation\n material_params.delete \"id\" \n material = RecipeMaterial.create(quantity: material_params[\"quantity\"])\n\n raw = Raw.find(material_params[\"raw_id\"])\n material.raw = raw\n\n if !self.cost.nil?\n value = self.cost\n value += (material.quantity * material.raw.cost)\n self.update cost: value\n end\n\n self.recipe_materials << material\n else\n # Update relation\n RecipeMaterial.find(material_params[\"id\"]).update(quantity: material_params[\"quantity\"])\n end\n end\n end\n end",
"def destroy\n @rehearsal_material.destroy\n respond_to do |format|\n format.html { redirect_to rehearsal_materials_url, notice: 'Rehearsal material was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove plataform\n end",
"def destroy\n @rawmaterial = Rawmaterial.find(params[:id])\n @rawmaterial.destroy\n\n respond_to do |format|\n format.html { redirect_to(rawmaterials_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @material = @current_shop.materials.find(params[:material_id]) rescue nil\n @article.destroy\n respond_to do |format|\n format.js {}\n end\n end",
"def remove!; end",
"def destroy\n @material.destroy\n respond_to do |format|\n format.html { redirect_to materials_url, notice: 'Material was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_plates\n show do \n title \"Discard Plates\"\n \n discard_plate_ids = operations.select { |op| op.temporary[:delete] }.map { |op| op.input(\"Plate\").item.id }\n note \"Discard the following plates with 0 colonies: #{discard_plate_ids}\"\n end if operations.any? { |op| op.temporary[:delete] }\n end",
"def destroy(also_opinions=false)\n opinions.each(&:destroy) if also_opinions\n super() \n end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def maesb_generate_equip_set\n @maesb_belongs_to_sets = []\n end",
"def collins_set_can_be_altered!\n self.collins_osc_state = nil\n end",
"def should_skip_copy(key)\n key == \"valid_setters\"\n end",
"def read_me_delete( file_set: )\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"id=#{id}\",\n \"read_me_file_set_id=#{read_me_file_set_id}\",\n \"file_set.id=#{file_set.id}\",\n \"\" ] if umrdr_work_behavior_debug_verbose\n return unless Array( read_me_file_set_id ).first == file_set.id\n self[:read_me_file_set_id] = nil\n save!( validate: false )\n end",
"def unlink_from_work\n work = parent_for(file_set: file_set)\n return unless work && (work.thumbnail_id == file_set.id || work.representative_id == file_set.id || work.rendering_ids.include?(file_set.id))\n work.thumbnail = nil if work.thumbnail_id == file_set.id\n work.representative = nil if work.representative_id == file_set.id\n work.rendering_ids -= [file_set.id]\n work.save!\n end",
"def delete_dirty?\n false\n end",
"def without_set_blocks(options)\n piece = options[:piece]\n game = options[:game]\n\n collection = clone\n collection.sets.map! { |set| set.without_blocks(piece: piece, game: game) }\n collection\n end",
"def destroy\n @component_material.destroy\n respond_to do |format|\n format.html { redirect_to component_materials_url, notice: 'Component material was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def atomic_delete_modifier\n atomic_paths.delete_modifier\n end",
"def update_packages\n # Go through each selected package\n # and update its resources to include this material.\n # Go through each other package that is not selected and remove this material from it.\n packages = params[:material][:package_ids].select{|p| !p.blank?}\n packages = packages.collect{|package| Package.find_by_id(package)}\n packages_to_remove = @material.packages - packages\n packages.each do |package|\n package.update_resources_by_id((package.materials + [@material.id]).uniq, nil, nil)\n end\n packages_to_remove.each do |package|\n package.update_resources_by_id((package.materials.collect{|x| x.id} - [@material.id]).uniq, nil, nil)\n end\n flash[:notice] = \"Material has been included in #{pluralize(packages.count, 'package')}\"\n redirect_to @material\n end",
"def destroy_and_child\n materials.each do |material|\n material.destroy\n end\n measures.each do |measure|\n measure.destroy\n end\n destroy\n end",
"def patch!(patchset)\n Diff::LCS.patch!(self, patchset)\n end",
"def edit_pack_materials\n return if authorise_for_web(program_name?, 'production_run_setup')==false\n begin\n id = params[:id]\n if id && @production_run = ProductionRun.find(id)\n @production_run_pack_material = ProductionRunPackMaterial.new\n @production_run_pack_material.production_run = @production_run\n render_edit_pack_materials\n end\n rescue\n handle_error(\"pack material edit form could not be rendered\")\n end\n end",
"def destroy\n regions = Region.all\n regions.each do |region|\n region.recipe.ingredients.each do |ingredient|\n if ingredient.model.to_s == LandmarkSet.name && self.name == ingredient.attributes[:name]\n return false\n end\n end\n end\n\n super\n end",
"def destroy\n @specification = Specification.find(params[:id])\n category = @specification.category\n \n #set requirements that point this to point to nil\n @specification.requirements.each do |requirement|\n requirement.specification_id = nil\n requirement.save\n end\n \n @specification.destroy\n\n respond_to do |format|\n format.html { redirect_to :controller => \"categories\", \n :action => \"show\", :id => category.id }\n format.json { head :no_content }\n end\n end",
"def destroy\n @metal_color.products.each do |product|\n product.metal_color = nil\n product.save\n end\n @metal_color_tmp = @metal_color.dup\n @metal_color.destroy\n record_activity(@metal_color_tmp)\n respond_to do |format|\n format.html { redirect_to admin_metal_colors_url, notice: 'Цвет металла был успешно удален.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @material\n @material.create_activity :destroy, owner: current_user\n @material.destroy\n respond_to do |format|\n format.html { redirect_to materials_url, notice: 'Material was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @material.destroy\n respond_to do |format|\n format.html { redirect_to workshop_materials_url(@workshop), notice: 'Material fue borrado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n Material.destroy_all(:id => @dashboard_material.id)\r\n @dashboard_material.destroy\r\n respond_to do |format|\r\n flash[:success] = \"Material removido com sucesso.\"\r\n format.html { redirect_to dashboard_materials_path }\r\n format.json { head :no_content }\r\n end\r\n end",
"def set_pack_material_product\n\n\tpack_material_product = PackMaterialProduct.find_by_pack_material_product_code_and_id(self.pack_material_product_code,self.id)\n\t if pack_material_product != nil \n\t\t self.pack_material_product = pack_material_product\n\t\t return true\n\t else\n\t\terrors.add_to_base(\"combination of: 'pack_material_product_code' and 'id' is invalid- it must be unique\")\n\t\t return false\n\tend\nend",
"def remove_set_from_hand(card)\n\t\t@cards.delete(card)\n\tend",
"def mark_for_destruction(attributes)\n self.class.embeddings.each do |embed|\n if attributes[embed]\n updates = attributes[embed].map { |model| model[:id] }.compact\n destroy = updates.empty? ? send(\"_super_#{embed}\".to_sym).select(:id) : send(\"_super_#{embed}\".to_sym).select(:id).where('id NOT IN (?)', updates)\n destroy.each { |model| attributes[embed] << { :id => model.id, :_destroy => '1' } }\n end\n end\n\n attributes\n end",
"def unlink_from_work\n work = parent_for(file_set: file_set)\n return unless work && (work.thumbnail_id == file_set.id || work.representative_id == file_set.id || work.rendering_ids.include?(file_set.id))\n work.thumbnail = nil if work.thumbnail_id == file_set.id\n work.representative = nil if work.representative_id == file_set.id\n work.rendering_ids -= [file_set.id]\n work.save!\n end",
"def patch(patch_property_set)\r\n number_patches_applied = 0\r\n properties = get_properties\r\n patch_property_set.properties.each do |patch_properties_key, patch_properties_value|\r\n if patch_properties_value != properties[patch_properties_key] \r\n properties[patch_properties_key] = patch_properties_value\r\n number_patches_applied += 1\r\n end\r\n end\r\n save(properties)\r\n number_patches_applied\r\n end",
"def item_effect_setup\r\n self.critical = false\r\n end",
"def delete; raise ActiveRecord::ReadOnlyRecord; end",
"def destroy_specification\n return false if !self.specification\n self.specification.destroy\n self.reload\n return true\n end",
"def destroy\n super(:multiple_delete)\n end",
"def produce(game, unit_or_structure)\n # producing a Zerg unit consumes the larva\n game.army.delete(self)\n super\n end",
"def destroy\n authorize @almoxarifado_material\n respond_to do |format|\n if @almoxarifado_material.destroy\n format.html { redirect_to almoxarifado_materiais_url, notice: 'Material excluído com sucesso.' }\n else\n format.html { redirect_to almoxarifado_materiais_url, alert: 'Não foi possível apagar material, material possui entradas/retiradas' }\n end\n end\n end",
"def destroy\n @instrument_patch.destroy\n respond_to do |format|\n format.html { redirect_to instrument_patches_url }\n format.json { head :no_content }\n end\n end",
"def enforce_delete_permissions\n enforce_edit_permissions\n end",
"def destroy\n @merchandise_option_set = MerchandiseOptionSet.find(params[:id])\n\t\tif @merchandise_option_set.deletable?\n \t@merchandise_option_set.destroy\n\t\telse\n\t\t\tflash[:error] = \"Cannot delete a set that has members!\"\n\t\tend\n\n respond_to do |format|\n format.html { redirect_to(merchandise_option_sets_url) }\n format.xml { head :ok }\n end\n end",
"def allowed_to_destroy \n allowed_to_save\n end",
"def prune\n @parent.gemset_prune\n end",
"def suitable_for_none\n \tself.disciplines.delete_all\n end",
"def remove_vertex(id)\n # YOUR WORK HERE\n end",
"def destroy\n if _immutable?\n raise ActiveRecord::ReadOnlyRecord \n else\n super\n end\n end"
] |
[
"0.5997042",
"0.5908725",
"0.58023065",
"0.5708017",
"0.5529989",
"0.55141705",
"0.54935527",
"0.54932624",
"0.54703134",
"0.5464181",
"0.5439459",
"0.543778",
"0.542281",
"0.5418227",
"0.54018164",
"0.5374226",
"0.5368965",
"0.53652287",
"0.5359539",
"0.534018",
"0.53384286",
"0.5327228",
"0.53226906",
"0.5311638",
"0.5298762",
"0.5298762",
"0.5298761",
"0.52883476",
"0.52883476",
"0.5276155",
"0.52750576",
"0.52750576",
"0.52741134",
"0.5270712",
"0.526885",
"0.526885",
"0.5267577",
"0.52639836",
"0.52617484",
"0.5257442",
"0.5249487",
"0.5234791",
"0.5230971",
"0.52197915",
"0.5217053",
"0.521488",
"0.52122366",
"0.5204692",
"0.5189761",
"0.5179043",
"0.5178716",
"0.5162169",
"0.5157725",
"0.5154734",
"0.51532",
"0.51462966",
"0.5142029",
"0.512865",
"0.5117114",
"0.51157147",
"0.51157147",
"0.51157147",
"0.51157147",
"0.5111251",
"0.51079196",
"0.5106771",
"0.5104906",
"0.5101443",
"0.50986767",
"0.50978523",
"0.5086065",
"0.5080743",
"0.50767815",
"0.5072735",
"0.5066347",
"0.50649315",
"0.50501585",
"0.50443596",
"0.50355834",
"0.5026747",
"0.5026054",
"0.50201327",
"0.5015462",
"0.5013306",
"0.50118124",
"0.50106657",
"0.50088865",
"0.500546",
"0.50031686",
"0.49980405",
"0.49967787",
"0.4994927",
"0.49932772",
"0.497233",
"0.49685022",
"0.49643415",
"0.4961615",
"0.4960606",
"0.49559855",
"0.49537614",
"0.49445534"
] |
0.0
|
-1
|
Fail request if the materials do not exist in materials service
|
def validate_uuids
unless Material.valid?(param_uuids)
return render json: { errors: [{ status: '422', title: 'Unprocessable entity', detail: 'Invalid Material UUIDs' }]}, status: :unprocessable_entity
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def check_exists\n @material = Material.check_exists(material_params)\n\n if @material\n respond_to do |format|\n format.html { redirect_to @material }\n #format.json { render json: @material }\n format.json { render :show, location: @material }\n end\n else\n respond_to do |format|\n format.html { render :nothing => true, :status => 200, :content_type => 'text/html' }\n format.json { render json: {}, :status => 200, :content_type => 'application/json' }\n end\n end\n end",
"def retrieve_materials(materials)\n return unless materials.present?\n\n show do\n title 'Retrieve Materials'\n note 'Please get the following items'\n table create_location_table(materials)\n end\n end",
"def set_material\n begin\n @material = type.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n redirect_to materials_path, alert: \"Could not find #{type.name.split(':').last} with ID #{params[:id]}!\"\n end\n end",
"def gathered_materials?(materials, number = 1)\n materials.each{|material|\n return false if item_number(material.item) < material.quantity * number\n }\n true\n end",
"def material_use\n materials = []\n materials\n end",
"def add_material(material_name)\n # First check model and return material if it already exists\n self.getMaterials.each do |material|\n if material.name.get.to_s == material_name\n OpenStudio::logFree(OpenStudio::Debug, 'openstudio.standards.Model', \"Already added material: #{material_name}\")\n return material\n end\n end\n \n #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"Adding material: #{material_name}\")\n\n # Get the object data\n data = self.find_object(self.standards['materials'], {'name'=>material_name})\n if !data\n OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Model', \"Cannot find data for material: #{material_name}, will not be created.\")\n return false #TODO change to return empty optional material\n end\n \n material = nil\n material_type = data['material_type']\n\n if material_type == 'StandardOpaqueMaterial'\n material = OpenStudio::Model::StandardOpaqueMaterial.new(self)\n material.setName(material_name)\n\n material.setRoughness(data['roughness'].to_s)\n material.setThickness(OpenStudio.convert(data['thickness'].to_f, 'in', 'm').get)\n material.setConductivity(OpenStudio.convert(data['conductivity'].to_f, 'Btu*in/hr*ft^2*R', 'W/m*K').get)\n material.setDensity(OpenStudio.convert(data['density'].to_f, 'lb/ft^3', 'kg/m^3').get)\n material.setSpecificHeat(OpenStudio.convert(data['specific_heat'].to_f, 'Btu/lb*R', 'J/kg*K').get)\n material.setThermalAbsorptance(data['thermal_absorptance'].to_f)\n material.setSolarAbsorptance(data['solar_absorptance'].to_f)\n material.setVisibleAbsorptance(data['visible_absorptance'].to_f)\n\n elsif material_type == 'MasslessOpaqueMaterial'\n material = OpenStudio::Model::MasslessOpaqueMaterial.new(self)\n material.setName(material_name)\n material.setThermalResistance(OpenStudio.convert(data['resistance'].to_f, 'hr*ft^2*R/Btu', 'm^2*K/W').get)\n\n material.setConductivity(OpenStudio.convert(data['conductivity'].to_f, 'Btu*in/hr*ft^2*R', 'W/m*K').get)\n material.setDensity(OpenStudio.convert(data['density'].to_f, 'lb/ft^3', 'kg/m^3').get)\n material.setSpecificHeat(OpenStudio.convert(data['specific_heat'].to_f, 'Btu/lb*R', 'J/kg*K').get)\n material.setThermalAbsorptance(data['thermal_absorptance'].to_f)\n material.setSolarAbsorptance(data['solar_absorptance'].to_f)\n material.setVisibleAbsorptance(data['visible_absorptance'].to_f)\n\n elsif material_type == 'AirGap'\n material = OpenStudio::Model::AirGap.new(self)\n material.setName(material_name)\n\n material.setThermalResistance(OpenStudio.convert(data['resistance'].to_f, 'hr*ft^2*R/Btu*in', 'm*K/W').get)\n\n elsif material_type == 'Gas'\n material = OpenStudio::Model::Gas.new(self)\n material.setName(material_name)\n\n material.setThickness(OpenStudio.convert(data['thickness'].to_f, 'in', 'm').get)\n material.setGasType(data['gas_type'].to_s)\n\n elsif material_type == 'SimpleGlazing'\n material = OpenStudio::Model::SimpleGlazing.new(self)\n material.setName(material_name)\n\n material.setUFactor(OpenStudio.convert(data['u_factor'].to_f, 'Btu/hr*ft^2*R', 'W/m^2*K').get)\n material.setSolarHeatGainCoefficient(data['solar_heat_gain_coefficient'].to_f)\n material.setVisibleTransmittance(data['visible_transmittance'].to_f)\n\n elsif material_type == 'StandardGlazing'\n material = OpenStudio::Model::StandardGlazing.new(self)\n material.setName(material_name)\n\n material.setOpticalDataType(data['optical_data_type'].to_s)\n material.setThickness(OpenStudio.convert(data['thickness'].to_f, 'in', 'm').get)\n material.setSolarTransmittanceatNormalIncidence(data['solar_transmittance_at_normal_incidence'].to_f)\n material.setFrontSideSolarReflectanceatNormalIncidence(data['front_side_solar_reflectance_at_normal_incidence'].to_f)\n material.setBackSideSolarReflectanceatNormalIncidence(data['back_side_solar_reflectance_at_normal_incidence'].to_f)\n material.setVisibleTransmittanceatNormalIncidence(data['visible_transmittance_at_normal_incidence'].to_f)\n material.setFrontSideVisibleReflectanceatNormalIncidence(data['front_side_visible_reflectance_at_normal_incidence'].to_f)\n material.setBackSideVisibleReflectanceatNormalIncidence(data['back_side_visible_reflectance_at_normal_incidence'].to_f)\n material.setInfraredTransmittanceatNormalIncidence(data['infrared_transmittance_at_normal_incidence'].to_f)\n material.setFrontSideInfraredHemisphericalEmissivity(data['front_side_infrared_hemispherical_emissivity'].to_f)\n material.setBackSideInfraredHemisphericalEmissivity(data['back_side_infrared_hemispherical_emissivity'].to_f)\n material.setConductivity(OpenStudio.convert(data['conductivity'].to_f, 'Btu*in/hr*ft^2*R', 'W/m*K').get)\n material.setDirtCorrectionFactorforSolarandVisibleTransmittance(data['dirt_correction_factor_for_solar_and_visible_transmittance'].to_f)\n if /true/i.match(data['solar_diffusing'].to_s)\n material.setSolarDiffusing(true)\n else\n material.setSolarDiffusing(false)\n end\n\n else\n puts \"Unknown material type #{material_type}\"\n exit\n end\n\n return material\n \n end",
"def index\n @items_materials = ItemMaterial.all\n end",
"def set_material_item\n @material_item = MaterialItem.find_by_slug(params[:id])\n raise if params[:material_id] != @material_item.material.slug\n end",
"def materials\n @materials ||= materials_data[]\n .map { |material|\n { title: material[\"bib_data\"][\"title\"],\n barcode: barcode(material),\n call_number: material[\"holding_data\"][\"call_number\"],\n library: library_name_from_short_code(material.library),\n location: materials_location(material),\n raw_library: material[\"item_data\"][\"library\"][\"value\"],\n raw_location: material[\"item_data\"][\"location\"][\"value\"],\n availability: availability_status(material) }\n .with_indifferent_access }\n .uniq { |material| material.except(:barcode) }\n end",
"def create\n @material = Material.new(params[:material])\n\n if !@material.valid?\n flash[:error_created] = @material.errors.full_messages.join(\"<br>\").html_safe\n redirect_to new_material_path\n else\n respond_to do |format|\n if @material.save\n format.html { redirect_to @material, notice: 'Material was successfully created.' }\n format.json { render json: @material, status: :created, location: @material }\n else\n format.html { render action: \"new\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n \n end\n end",
"def index\n if params[:part_id]\n @materials = Material.find(:all, :conditions => [\"part_id = ?\", params[:part_id]])\n else\n @materials = Material.all\n end\n respond_to do |format|\n format.html\n format.json { render :json => @materials }\n end\n end",
"def create\n @material = Material.new(params[:material])\n\n respond_to do |format|\n if @material.save\n @topic.materials << @material\n @topic.save\n format.html { redirect_to(course_topic_material_url(@course, @topic, @material), :notice => 'Material was successfully created.') }\n format.xml { render :xml => @material, :status => :created, :location => @material }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @material.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_material\n @material = Material.find(params[:id])\n end",
"def create\n\n @material = Material.new(material_params)\n\n if @material.save\n render :show, status: :created, location: @material\n else\n render json: @material.errors, status: :unprocessable_entity\n end\n end",
"def material_filter(attributes)\n material_id = attributes[\"material_id\"]\n ass_id = attributes[\"id\"]\n\n retv = material_id.blank? || \n !Material.exists?(material_id) || \n # don't add duplicate assignments\n (foo = ass_id && MaterialAssignment.where(material_id: material_id, fabric_id: id).where.not(id: ass_id).exists?)\n\n retv\n end",
"def index\n if false\n @material_properties = MaterialProperty.all\n else\n render :file => \"/public/404.html\",:status => \"404\" \n end \n end",
"def create\n @material = Material.new(params[:material])\n\n respond_to do |format|\n if @material.save\n format.html { redirect_to @material, notice: 'Material was successfully created.' }\n format.json { render json: @material, status: :created, location: @material }\n else\n format.html { render action: \"new\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @material.update(material_params)\n render :show, status: :ok, location: @material\n else\n render json: @material.errors, status: :unprocessable_entity\n end\n end",
"def set_material\n @material = Material.find(params[:id])\n end",
"def set_material\n @material = Material.find(params[:id])\n end",
"def set_material\n @material = Material.find(params[:id])\n end",
"def set_material\n @material = Material.find(params[:id])\n end",
"def set_material\n @material = Material.find(params[:id])\n end",
"def set_material\n @material = Material.find(params[:id])\n end",
"def findMaterialModellingError(entity)\n if(entity == nil)\n return\n end\n if(entity.material != nil)\n if(entity.class == Sketchup::Group)\n dicts = entity.attribute_dictionaries()\n\n if(dicts != nil)\n dicts.each do |dict|\n dict.each_pair { | key, value |\n if(key == \"id\" || key == \"ID\")\n buildingid = FHGelsenkirchen::stringDecode(value.to_s())\n puts \"Group material ignored in the following building with id: \" + buildingid.to_s\n return\n end\n }\n end\n end\n # Wenn keine id Flächen zahl ausgeben\n surfaceCount = 0\n entity.entities.each do |ent|\n if(ent.class == Sketchup::Face)\n surfaceCount += 1\n end\n end\n puts \"Group material ignored in the following building with \" + surfaceCount.to_s + \" surfaces\"\n end\n end\n end",
"def index\n @materials = Material.all\n end",
"def load_materials(materials)\n mt = 1\n materials.each do |material|\n case mt\n when 1\n self.mat_item1 = material.item_key.to_s + \" - \" + material.item\n self.mat_qty_1 = material.quantity\n when 2\n self.mat_item2 = material.item_key.to_s + \" - \" + material.item\n self.mat_qty_2 = material.quantity\n when 3\n self.mat_item3 = material.item_key.to_s + \" - \" + material.item\n self.mat_qty_3 = material.quantity\n when 4\n self.mat_item4 = material.item_key.to_s + \" - \" + material.item\n self.mat_qty_4 = material.quantity\n when 5\n self.mat_item5 = material.item_key.to_s + \" - \" + material.item\n self.mat_qty_5 = material.quantity\n when 6\n self.mat_item6 = material.item_key.to_s + \" - \" + material.item\n self.mat_qty_6 = material.quantity\n else\n #nothing\n end\n mt += 1\n end\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to materials_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to materials_url }\n format.json { head :no_content }\n end\n end",
"def index\n if params[:name].nil?\n @materials = Material.search(current_user.organization.id, params[:term])\n else\n @materials = Material.search(current_user.organization.id, params[:name])\n end\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {\n if params[:name].nil?\n render json: @materials.map(&:name)\n else\n render json: @materials\n end\n\n }\n end\n end",
"def set_material\n @material = Material.friendly.find(params[:id])\n end",
"def update\n @material_type = MaterialType.find(params[:id])\n\n if @material_type.update(material_type_params)\n head :no_content\n else\n render json: @material_type.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @material.update(material_params)\n format.html { redirect_to workshop_materials_url(@workshop), notice: 'Material fue editado exitosamente.' }\n format.json { render :show, status: :ok, location: @material }\n else\n format.html { render :edit }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @materials = Material.includes(:user_materials, :subject, :level).where(:user_materials => {role: \"owner\", user_id: current_user.id})\n @collaborations = Material.includes(:user_materials, :subject, :level).where(:user_materials => {role: \"collaborator\", user_id: current_user.id})\n @material= Material.new\n end",
"def update\n respond_to do |format|\n if @material.update(material_params)\n format.html { redirect_to @material, notice: 'Material was successfully updated.' }\n format.json { render :show, status: :ok, location: @material }\n else\n format.html { render :edit }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @material = Material.new(material_params)\n @material.workshop = @workshop\n\n respond_to do |format|\n if @material.save\n format.html { redirect_to workshop_materials_url(@workshop), notice: 'Material fue subido exitosamente.' }\n format.json { render :show, status: :created, location: @material }\n else\n format.html { render :new }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @component_materials = ComponentMaterial.all\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to materials_url, :notice => \"Material was successfully delete.\" }\n format.json { head :no_content }\n end\n end",
"def create\n \t@material = @requerimiento.materiales.create(params[:material])\n\n logger.debug(\"Material a crear: #{@material}\")\n\n respond_to do |format|\n if @material.save\n format.html { redirect_to(@requerimiento, :notice => \"Se asigno el material al requerimiento nro: #{@requerimiento.id}\") }\n format.xml { render :xml => @material, :status => :created, :location => @requerimiento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @material.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n\t\tif @material.destroy\n\t\t\tflash[:notice] = \"Successfully deleted material!\"\n\t\t\tredirect_to materials_path\n\t\telse\n\t\t\tflash[:alert] = \"Error updating material!\"\n\t\tend\n\tend",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to(materials_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @material = Material.find(params[:id])\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to(materials_url) }\n format.xml { head :ok }\n end\n end",
"def update\n @material = Material.find(params[:id])\n\n respond_to do |format|\n if @material.update_attributes(params[:material])\n format.html { redirect_to @material, notice: 'Material was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @s_material = SMaterial.new(s_material_params)\n authorize @s_material\n\n respond_to do |format|\n if @s_material.save\n format.html { redirect_to s_materials_url, notice: t('Record has been saved') }\n format.json { render :show, status: :created, location: @s_material }\n else\n format.html { render :new }\n format.json { render json: @s_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @material_items = MaterialItem.all\n end",
"def show\n @material = Material.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material }\n end\n end",
"def show\n @material = Material.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material }\n end\n end",
"def index\n @user_materials = UserMaterial.all\n end",
"def update\n @project = Project.find(params[:project_id])\n @material_usage = @project.material_usages.find(params[:id])\n @material_usage.material = @project.materials.find_by_id(params[:material_usage][:material_id])\n @material_usage.phase = @project.phases.find_by_id(params[:material_usage][:phase_id])\n\n respond_to do |format|\n if @material_usage.update_attributes(params[:material_usage].except(:material_id, :phase_id))\n format.html { redirect_to [@project, @material_usage], notice: 'Material usage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @material_usage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_material_management\n @material_management = MaterialManagement.find(params[:id])\n end",
"def set_material_list\n @material_list = MaterialList.find(params[:id])\n end",
"def create\n @material_item = MaterialItem.new(material_item_params)\n\n respond_to do |format|\n if @material_item.save\n format.html { redirect_to @material_item, notice: 'Material item was successfully created.' }\n format.json { render :show, status: :created, location: @material_item }\n else\n format.html { render :new }\n format.json { render json: @material_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if !validate_params(material_params) then\n redirect_to !material_params['currency'] ? \"/materials/new_internal\" : \"/materials/new\", notice: 'تعذر تسجيل عملية الشراء. برجاء مراجعة المدخلات'\n else\n @material = Material.new(material_params)\n @material.user_name = current_user.name\n\n raw_materials = RawMaterial.find(params['raw_material_ids'])\n @material.price = 0\n @material.prices.each_with_index do |price, i|\n @material.price = @material.price + price.to_f * @material.quantities[i].to_f\n end\n if params['paid_amount'].present? && @material.price_with_taxes < params['paid_amount'].to_f\n redirect_to '/materials/new', notice: 'لا يمكن أن يكون المبلغ المدفوع أكبر من السعر الكلي'\n return\n end\n if (@material.payment_state == \"آجل\")\n @material.debt = @material.price_with_taxes - params[\"paid_amount\"].to_f\n else\n @material.debt = 0\n end\n\n if !check_treasury(material_params[:payment_method], (params['price'].to_f - params['debt'].to_f))\n redirect_to !material_params['currency'] ? \"/materials/new_internal\" : \"/materials/new\", notice: 'المبلغ الموجود بالخزنة أقل من المبلغ المطلوب'\n return\n end\n respond_to do |format|\n if @material.save\n if (@material.debt != @material.price_with_taxes)\n update_treasury(@material.payment_method, @material.debt - @material.price_with_taxes, MATERIAL, @material.id, \"عملية شراء\", 0, @material.date_added)\n end\n\n @material.raw_material_ids.each_with_index do |r, i|\n raw_material = RawMaterial.find(r)\n raw_material.in_stock = raw_material.in_stock + @material.quantities[i].to_f\n raw_material.save\n end\n supplier = Supplier.find(@material.supplier_id)\n supplier.credit = supplier.credit + @material.debt\n permission1 = AddMaterialPermission.create!({transaction_id: @material.id})\n permission2 = ReleaseMoneyPermission.create!({transaction_for: MATERIAL, transaction_id: @material.id, quantity: @material.price - @material.debt})\n supplier.save\n MaterialPaymentDetail.create()\n format.html { redirect_to \"/permission/material/#{permission1.id}/#{permission2.id}\" }\n format.json { render :show, status: :created, location: @material }\n else\n format.html { redirect_to \"/materials/new\", notice: 'تعذر تسجيل عملية الشراء. برجاء مراجعة المدخلات' }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @user_material = UserMaterial.new(user_material_params)\n\n respond_to do |format|\n if @user_material.save\n format.html { redirect_to @user_material, notice: 'User material was successfully created.' }\n format.json { render :show, status: :created, location: @user_material }\n else\n format.html { render :new }\n format.json { render json: @user_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @material_item = MaterialItem.find(params[:id])\n\n unless @material_item.destroy\n flash[:notice] = @material_item.errors.full_messages\n end\n\n respond_to do |format|\n format.html { redirect_to(material_items_url) }\n format.xml { head :ok }\n end\n end",
"def create_material\n # upload a files\n materials = Material\n .upload(params[:meeting][:materials_attributes], @meeting.id)\n\n materials.each do |material|\n @meeting.materials.new(material)\n end\n end",
"def create\n\t\t@material = Material.new(material_params)\n\t\tif @material.save\n\t\t\tflash[:notice] = \"Successfully created material!\"\n\t\t\tredirect_to material_path(@material)\n\t\telse\n\t\t\tflash[:alert] = \"Error creating new material!\"\n\t\t\trender :new\n\t\tend\n\tend",
"def create\n @almoxarifado_material = Almoxarifado::Material.new(almoxarifado_material_params)\n authorize @almoxarifado_material\n respond_to do |format|\n if @almoxarifado_material.save\n format.html { redirect_to almoxarifado_materiais_path, notice: 'Material criado com sucesso.' }\n format.json { render :show, status: :created, location: @almoxarifado_material }\n else\n format.html { render :new }\n format.json { render json: @almoxarifado_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.find(params[:project_id])\n @material_usage = @project.material_usages.build(params[:material_usage].except(:material_id, :phase_id))\n @material_usage.material = @project.materials.find_by_id(params[:material_usage][:material_id])\n @material_usage.phase = @project.phases.find_by_id(params[:material_usage][:phase_id])\n\n respond_to do |format|\n if @material_usage.save\n format.html { redirect_to [@project, @material_usage], notice: 'Material usage was successfully created.' }\n format.json { render json: @material_usage, status: :created, location: @material_usage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @material_usage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @material = Material.find(params[:id])\n\n respond_to do |format|\n if @material.update_attributes(params[:material])\n format.html { redirect_to @material, notice: 'Material was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def checkMandatories(items)\n # exception handeling if user not gave any id\n if items.key?(\"id\") == false || items[\"id\"].match(IdPattern) == false\n raise \"id is required and can only contain Numbers,- and Alphabet.\"\n end\n end",
"def update\n @material = @current_shop.materials.find(event_params[:material_id]) rescue nil\n if @material\n @event.material = @material\n @event.is_system_keyword = false\n @event.system_keyword = nil\n elsif Event::SYSTEM_KEY.map{|key| key[1]}.include? event_params[:material_id]\n @event.material = nil\n @event.is_system_keyword = true\n @event.system_keyword = event_params[:material_id].gsub(Event::KEY_PREFIX, \"\")\n end\n respond_to do |format|\n if @event.update(event_params.except(:material_id))\n format.html { redirect_to backend_shop_events_path(@current_shop.slug), notice: t('Event was successfully updated.') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @material_list = MaterialList.find(params[:id])\n end",
"def destroy\n @material.destroy\n respond_to do |format|\n format.html { redirect_to materials_url, notice: 'Material was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @base_materials = BaseMaterial.all\n end",
"def create\n @component_material = ComponentMaterial.new(component_material_params)\n\n respond_to do |format|\n if @component_material.save\n format.html { redirect_to @component_material, notice: 'Component material was successfully created.' }\n format.json { render :show, status: :created, location: @component_material }\n else\n format.html { render :new }\n format.json { render json: @component_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def material_params\n pms = params.require(:material).permit!\n pms['raw_material_ids'] = params['raw_material_ids']\n pms[:internal] = params[:internal]\n return pms\n end",
"def show\n @material = Material.find(params[:id])\n #TODO: improve visual style of material.show page\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @material }\n end\n end",
"def index\n @raw_materials = RawMaterial.all\n end",
"def index\n @raw_materials = RawMaterial.all\n end",
"def set_component_material\n @component_material = ComponentMaterial.find params[:id]\n end",
"def user_material_params\n params.require(:user_material).permit(:user_id, :material_id)\n end",
"def set_s_material\n @s_material = SMaterial.find(params[:id])\n end",
"def material_params\n params.require(:material).permit(:name, :description, :url, :archived)\n end",
"def update\n @material = Material.find(params[:id])\n\n respond_to do |format|\n if @material.update_attributes(permitted_params(nil).material)\n format.html { redirect_to @material, notice: 'Material was successfully updated.' }\n format.json { head :no_content }\n format.mobile { redirect_to @material, notice: t('activerecord.messages.material.updated_successfully', material: @material.name) }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n format.mobile { redirect_to :back }\n end\n end\n end",
"def resource_exists\n unless MANAGEABLE_RESOURCES.include?(resource)\n errors.add(:resource, \"invalid. You must select a resource that rails can identify.\")\n end\n end",
"def index\r\n @tipo_materials = TipoMaterial.all\r\n end",
"def index\n @materials = Material.joins(:images).group(\"#{Material.table_name}.id\").having(\"COUNT(#{Image.table_name}.id) > 0\").order(\"`materials`.`blend_updated_at` DESC\").paginate(:page => params[:page])\n\n #TODO: sort materials by number of downloads, rating, etc.\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @materials }\n end\n end",
"def create\r\n @dashboard_material = Material.new(dashboard_material_params)\r\n respond_to do |format|\r\n if @dashboard_material.save\r\n flash[:success] = \"Material para \" + @dashboard_material.discipline.name + \" cadastrado com sucesso.\"\r\n format.html { redirect_to dashboard_materials_path }\r\n format.json { render :show, status: :created, location: @dashboard_material }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @dashboard_material.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @material = Material.new(params[:material]) \n @materials = Material.page(params[:page]).per(10)\n\n respond_to do |format|\n if @material.save\n format.html { redirect_to @material, notice: 'Employee was successfully created.' }\n format.json { render json: @material, status: :created, location: @material }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @material.errors, status: :unprocessable_entity }\n format.js \n end\n end\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @material }\n end\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @material }\n end\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @material }\n end\n end",
"def destroy\n authorize @s_material\n @s_material.destroy\n respond_to do |format|\n format.html { redirect_to s_materials_url, notice: t('Record has been deleted') }\n format.json { head :no_content }\n end\n end",
"def create\n #logger.info params.to_json\n @material = @current_shop.materials.find(params[:material_id])\n @articles = @material.articles\n @article = @material.articles.build(article_params)\n respond_to do |format|\n if @article.save\n @article.set_position(params[:article][:position])\n format.html {redirect_to backend_shop_materials_path(@current_shop)}\n else\n logger.error \"errors are #{@article.errors.to_json}\"\n @errors = @article.errors\n format.html {redirect_to [backend_shop_materials_path(@current_shop), \"error=#{@article.errors.full_messages.join \",\"}\"].join(\"?\")}\n end\n end\n end",
"def create\n @raw_material = RawMaterial.new(raw_material_params)\n\n respond_to do |format|\n if @raw_material.save\n format.html { redirect_to @raw_material, notice: 'Raw material was successfully created.' }\n format.json { render :show, status: :created, location: @raw_material }\n else\n format.html { render :new }\n format.json { render json: @raw_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @raw_material = RawMaterial.new(raw_material_params)\n\n respond_to do |format|\n if @raw_material.save\n format.html { redirect_to @raw_material, notice: 'Raw material was successfully created.' }\n format.json { render :show, status: :created, location: @raw_material }\n else\n format.html { render :new }\n format.json { render json: @raw_material.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_component_material\n @component_material = ComponentMaterial.find(params[:id])\n end",
"def update\n @material = Material.find(params[:id])\n\n respond_to do |format|\n if @material.update_attributes(params[:material])\n format.html { redirect_to(@material, :notice => 'Material was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @material.errors, :status => :unprocessable_entity }\n end\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 show\n\t\tmaterial = nil\n\t\tmaterial = params[:material] if params[:material] != nil\n if material == nil then\n @questions = @exam.questions.where(\"material = 'md' or material = 'html'\")\n else\n @questions = @exam.questions.where(\"material = ?\", material)\n end\n\n end",
"def edit_pack_materials\n return if authorise_for_web(program_name?, 'production_run_setup')==false\n begin\n id = params[:id]\n if id && @production_run = ProductionRun.find(id)\n @production_run_pack_material = ProductionRunPackMaterial.new\n @production_run_pack_material.production_run = @production_run\n render_edit_pack_materials\n end\n rescue\n handle_error(\"pack material edit form could not be rendered\")\n end\n end",
"def district_supplemental_materials\n @body_class = 'supplemental-materials'\n @admin = current_admin_user\n district = @admin.district\n\n # Get materials based on required or not\n district_supplemental_materials = SupplementalMaterial.where(authority_level: SupplementalMaterial.authority_levels[:district], district: district)\n district_supplemental_materials_required = district_supplemental_materials.where(is_required: true)\n district_supplemental_materials_optional = district_supplemental_materials.where(is_required: false)\n\n # Central supplemental materials\n central_supplemental_materials = SupplementalMaterial.where(authority_level: SupplementalMaterial.authority_levels[:central])\n central_supplemental_materials_required = central_supplemental_materials.where(is_required: true)\n central_supplemental_materials_optional = central_supplemental_materials.where(is_required: false)\n\n # Sort by required or not\n @supplemental_materials = district_supplemental_materials + central_supplemental_materials\n @supplemental_materials_required = district_supplemental_materials_required + central_supplemental_materials_required\n @supplemental_materials_optional = district_supplemental_materials_optional + central_supplemental_materials_optional\n return render 'district_supplemental_materials'\n end",
"def destroy\n authorize @almoxarifado_material\n respond_to do |format|\n if @almoxarifado_material.destroy\n format.html { redirect_to almoxarifado_materiais_url, notice: 'Material excluído com sucesso.' }\n else\n format.html { redirect_to almoxarifado_materiais_url, alert: 'Não foi possível apagar material, material possui entradas/retiradas' }\n end\n end\n end",
"def central_supplemental_materials\n @admin = current_admin_user\n\n @supplemental_materials = SupplementalMaterial.where(authority_level: SupplementalMaterial.authority_levels[:central])\n @supplemental_materials_required = @supplemental_materials.where(is_required: true)\n @supplemental_materials_optional = @supplemental_materials.where(is_required: false)\n\n return render 'central_supplemental_materials'\n end",
"def destroy\r\n Material.destroy_all(:id => @dashboard_material.id)\r\n @dashboard_material.destroy\r\n respond_to do |format|\r\n flash[:success] = \"Material removido com sucesso.\"\r\n format.html { redirect_to dashboard_materials_path }\r\n format.json { head :no_content }\r\n end\r\n end",
"def materials\n files\n end",
"def onMaterialRefChange(materials, material)\n end",
"def update\n @project = Project.find(params[:project_id])\n @material_procurement = @project.material_procurements.find(params[:id])\n @material_procurement.material = @project.materials.find_by_id(params[:material_procurement][:material_id])\n\n respond_to do |format|\n if @material_procurement.update_attributes(params[:material_procurement].except(:material_id))\n format.html { redirect_to [@project, @material_procurement], notice: 'Material procurement was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @material_procurement.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.66627777",
"0.65781474",
"0.61721826",
"0.6014381",
"0.5985374",
"0.5942441",
"0.590904",
"0.58551633",
"0.5833826",
"0.5802574",
"0.5786202",
"0.57150567",
"0.5705983",
"0.56958604",
"0.56693405",
"0.566086",
"0.56494504",
"0.56472915",
"0.563557",
"0.5635382",
"0.5635382",
"0.5635382",
"0.5635382",
"0.5635382",
"0.5623059",
"0.56048304",
"0.5563164",
"0.5559253",
"0.55574954",
"0.5557381",
"0.553117",
"0.5509502",
"0.5489533",
"0.548024",
"0.546745",
"0.5461082",
"0.5457213",
"0.5448908",
"0.5436267",
"0.5417",
"0.5415565",
"0.5415565",
"0.5409486",
"0.5392061",
"0.5383704",
"0.5356762",
"0.5356762",
"0.5354664",
"0.5354174",
"0.5354155",
"0.53526175",
"0.5350008",
"0.534536",
"0.53443336",
"0.5340709",
"0.533662",
"0.5329878",
"0.53233665",
"0.53184736",
"0.5317758",
"0.52963865",
"0.5290024",
"0.52827805",
"0.5281036",
"0.5275989",
"0.52541125",
"0.5250754",
"0.5250712",
"0.52478945",
"0.52478945",
"0.5233434",
"0.52328813",
"0.5230094",
"0.5217718",
"0.5216116",
"0.52083576",
"0.5203552",
"0.5194793",
"0.5189126",
"0.51869756",
"0.5174602",
"0.5174602",
"0.5174602",
"0.5170872",
"0.5169837",
"0.51681983",
"0.51681983",
"0.5165192",
"0.51648927",
"0.5158187",
"0.5157784",
"0.51518065",
"0.51466614",
"0.5143124",
"0.5133365",
"0.51319396",
"0.51297987",
"0.5128001",
"0.5127377"
] |
0.60793185
|
4
|
If a buffer needs to modify, override this method.
|
def allow_sample?(sample)
true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def monkey_patch_buffer!\n unless @buffer.respond_to? :buffer\n @buffer.class.send(:include, BufferUtil) \n end\n end",
"def buffer; end",
"def buffer; end",
"def buffer; end",
"def _buffer( the_binding )\n @_buffer = eval( \"_buf\", the_binding )\n end",
"def swithOverwrite buffer\n @frames[buffer].switchOverWrite\n end",
"def buffer_changed?\n @buffer_changed\n end",
"def buffer=(buf)\n @buffer = buf\n @snippet_loader.current_snippets.each do |snippet|\n snippet.buffer = buf\n end\n @manipulators.each { |man| man.buffer = buf }\n monkey_patch_buffer!\n @buffer\n end",
"def initialize_buffer\n @pointer = 0\n @buffer = []\n def @buffer.clear\n super\n @pointer = 0\n end\n true\n end",
"def buffer_prev\n buffer_update_info\n if @_buffer_ctr < 1\n buffer_last\n return\n end\n @_buffer_ctr -= 1 if @_buffer_ctr > 0\n x = @_buffer_ctr\n l = @_buffers[x]\n if l\n populate_buffer_from_filename x\n l = @_buffers[x]\n $log.debug \"bp calling set_content with #{l.class} \"\n set_content l, @_buffers_conf[x]\n buffer_update_position\n end\n end",
"def _set_buffer value #:nodoc:\n @repaint_required = true\n @datatype = value.class\n @delete_buffer = @buffer.dup\n @buffer = value.to_s.dup\n # don't allow setting of value greater than maxlen\n @buffer = @buffer[0,@maxlen] if @maxlen && @buffer.length > @maxlen\n @curpos = 0\n # hope @delete_buffer is not overwritten\n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos, self, :DELETE, 0, @delete_buffer) # 2010-09-11 13:01 \n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos, self, :INSERT, 0, @buffer) # 2010-09-11 13:01 \n self # 2011-10-2 \n end",
"def buffer=(buffer)\n @io = buffer\n end",
"def read_buffer; end",
"def reset_buffer(new_buf = '')\n @buf.replace new_buf\n @index = 0\n end",
"def reset_buffer(new_buf = '')\n @buf.replace new_buf\n @index = 0\n end",
"def flush_buffer; self.input_buffer = \"AAAA\"; end",
"def initialize_buffer\r\n @buffer = []\r\n @pointer = 0\r\n def @buffer.clear\r\n @pointer = 0\r\n super\r\n end\r\n end",
"def buffer(_distance_)\n raise Error::UnsupportedOperation, \"Method Geometry#buffer not defined.\"\n end",
"def buffer\n @line[@pos, @line.length - @pos] unless @line.nil?\n end",
"def reset_buffer(new_buf = '')\n @buf.replace Bytes.force_binary_encoding(new_buf)\n @index = 0\n end",
"def set_buffer(pos=nil,b=nil,offset=nil,len=nil)\n if pos.class == Fixnum && b.class.method_defined?(:j_del) && !block_given? && offset == nil && len == nil\n @j_del.java_method(:setBuffer, [Java::int.java_class,Java::IoVertxCoreBuffer::Buffer.java_class]).call(pos,b.j_del)\n return self\n elsif pos.class == Fixnum && b.class.method_defined?(:j_del) && offset.class == Fixnum && len.class == Fixnum && !block_given?\n @j_del.java_method(:setBuffer, [Java::int.java_class,Java::IoVertxCoreBuffer::Buffer.java_class,Java::int.java_class,Java::int.java_class]).call(pos,b.j_del,offset,len)\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling set_buffer(pos,b,offset,len)\"\n end",
"def clean_buffer; self.input_buffer = self.input_buffer[self.input_buffer.length-4,self.input_buffer.length-1]; end",
"def process(request_buffer=nil)\n raise NotImplementedError\n end",
"def message_buffer; end",
"def set(buffer)\n @buffer = buffer.encode('binary')\n @length = buffer.length\n @position = 0\n end",
"def buffered!(len=nil, buffer_name=:default, opts={}, &block)\n semaphore.synchronize {\n ret, still_to_get = buffer(buffer_name, opts[:type]).offset!(len)\n if still_to_get > 0\n src_data = Support::Utils.send_all_or_no_args(block, still_to_get)\n called_for = src_data.slice!(0, still_to_get)\n ret.concat(called_for)\n buffer(buffer_name).concat(src_data)\n end\n ret\n }\n end",
"def message_buffer=(buffer)\n @message_buffer = buffer\n @interaction_highline = nil\n end",
"def get_raw_buffer\n @buffer\n end",
"def buffer_info\n @buffer_info ||= BufferInfo.new\n end",
"def create_buffer(contents)\n end",
"def close_buffer; end",
"def set_active_buffer(buffer=0) \n @active_buffer = buffer unless !buffer.between?(0,@@BUFFERS)\n @file_eof = false\n Rula.log(Logger::DEBUG,\"Set active buffer to #{@active_buffer}\",self)\n end",
"def buffer=(input)\n @buffer = input\n @words = nil\n end",
"def append_buffer(buff=nil,offset=nil,len=nil)\n if buff.class.method_defined?(:j_del) && !block_given? && offset == nil && len == nil\n @j_del.java_method(:appendBuffer, [Java::IoVertxCoreBuffer::Buffer.java_class]).call(buff.j_del)\n return self\n elsif buff.class.method_defined?(:j_del) && offset.class == Fixnum && len.class == Fixnum && !block_given?\n @j_del.java_method(:appendBuffer, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::int.java_class,Java::int.java_class]).call(buff.j_del,offset,len)\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling append_buffer(buff,offset,len)\"\n end",
"def update(raw_data)\n if @policy_type == :buffer\n if @buffer.size != @buffer_size\n @buffer << raw_data\n end\n elsif @policy_type == :data\n @buffer = [raw_data]\n else\n raise \"port policy #{@policy_type} is not supported by #{self.class}\"\n end\n end",
"def source_buffer=(_arg0); end",
"def buffer\n @buffer ||= Utils::Buffer.new(config.buffer, log_header: name) do |string|\n @on_output.call(string, :header => log_header) if @on_output\n end\n end",
"def source_buffer; end",
"def source_buffer; end",
"def source_buffer; end",
"def reset!\n @buffer = buffer.reset!\n end",
"def restore_buffer(buf_was)\n @_out_buf = buf_was\n end",
"def initialize\n @buffer = ''\n end",
"def buffer=(data)\n if !@buffer || data.bytesize>@buffer.size\n free_buffer\n @buffer = FFI::MemoryPointer.new(data.bytesize, 1, false)\n end\n @buffer.put_bytes(0, data)\n @transfer[:buffer] = @buffer\n @transfer[:length] = data.bytesize\n end",
"def modify\n super\n end",
"def output_buffer; end",
"def output_buffer; end",
"def asking_buffer=(buffer)\n @asking_buffer = buffer\n @interaction_highline = nil\n end",
"def buffered\n @buffer.length\n end",
"def buffered\n @buffer.length\n end",
"def rl_extend_line_buffer(len)\r\n while (len >= @rl_line_buffer.length)\r\n @rl_line_buffer << 0.chr * DEFAULT_BUFFER_SIZE\r\n end\r\n @the_line = @rl_line_buffer\r\n end",
"def redo buffer\n @frames[buffer].redo buffer\n end",
"def block_buffer(&block)\n yield if block_given?\n BLOCK_BUFFER\n end",
"def gets_buffer(*a)\n @device.buffer\n end",
"def binding_buffer(op)\n # @buffer_lookup[op.input(ANTIBODY).sample][BINDING_BUFFER]\n op.input(BINDING_BUFFER).item\n end",
"def replace(other)\n @buffer.replace(other.buffer)\n self\n end",
"def buffer &writes\n begin\n buffer_on!\n writes.call\n ensure\n buffer_off!\n end\n flush_buffer!\n end",
"def buffer\n @buffer ||= Buffer.new(config.buffer) do |string|\n @on_output.call(string, :header => log_header) if @on_output\n end\n end",
"def save_buffer\n @_out_buf, buf_was = '', @_out_buf\n buf_was\n end",
"def buffer? \n !@_out_buf.nil?\n end",
"def shift_write_buffer\n @write_mutex.synchronize { @write_buffer.shift }\n end",
"def update_buffer(move)\n # if new command requires so\n if move == nil || move == false\n # empty each actor's buffer\n $BlizzABS.battlers.each {|actor| actor.force_move = []}\n end\n # add new command or enforce emptying whether move is reset for each actor\n $BlizzABS.battlers.each {|actor| actor.update_buffer(move == 'reset' ? nil : move)}\n end",
"def update(bytes)\n # Do nothing.\n end",
"def buffer=(buffer)\n @buffer = buffer\n return unless buffer?\n self.name = buffer.original_filename\n self.unique_key = genkey()\n end",
"def buffer(x) \n $game_player.iframes = 30 if $game_player.iframes == 0\n unless self.input_buffer[-1]==x\n self.input_buffer << x \n end\n end",
"def restore_original_value\n $log.debug \" FIELD: buffer:#{@buffer}. orig:#{@original_value}: \"\n $log.debug \" original value is null \" unless @original_value\n $log.debug \" buffer value is null \" unless @buffer\n @buffer = @original_value.dup\n # earlier commented but trying again, since i am getting IndexError in insert 2188\n # Added next 3 lines to fix issue, now it comes back to beginning.\n cursor_home\n\n @repaint_required = true\n end",
"def data_buffer\n @data_buffer ||= {}\n end",
"def on_enter\n #@original_value = getvalue.dup rescue getvalue\n @original_value = @buffer.dup # getvalue.dup rescue getvalue\n super\n end",
"def remainder_as_buffer; end",
"def exp_buffer\n result = @receive_buffer\n @receive_buffer = ''\n result\n end",
"def append!(buffer)\n @str << buffer.to_s\n self\n end",
"def append!(buffer)\n @str << buffer.to_s\n self\n end",
"def extend_buffer; $game_player.eb; end",
"def flush_buffer\n # note we must discard cancelled timer or else we never create a new timer and stay cancelled.\n if @timer\n @timer.cancel\n @timer = nil\n end\n\n to_send = nil\n @mutex.synchronize do\n unless @buffer.empty?\n to_send = @buffer\n @buffer = ''\n end\n end\n\n if to_send\n internal_send_audit(:kind => :output, :text => to_send, :category => EventCategories::NONE)\n end\n end",
"def redraw\n # this kinda stuff should be inside widget or some util class\n c = @component\n if c.is_double_buffered?\n c.set_buffer_modified\n c.buffer_to_window\n else\n # force a repaint, if not buffered object e.g scrollpane.\n $log.debug \" TP: forcing repaint of non-buffered object #{c} \"\n c.repaint_all\n c.repaint\n end\n end",
"def write_buffer(io = T.unsafe(nil)); end",
"def reset!\n @buffer = ''\n end",
"def add_to_buffer( event )\n str = event.instance_of?(::Logging::LogEvent) ?\n layout.format(event) : event.to_s\n return if str.empty?\n\n buffer << str\n flush if buffer.length >= auto_flushing || immediate?(event)\n\n self\n end",
"def buffer_size=(buffer_size)\n if buffer_size != nil && buffer_size.to_i < 1\n raise ArgumentError, \"Buffer size must be a positive integer greater than 0 or nil\"\n end\n\n @buffer_size = buffer_size != nil ? buffer_size.to_i : nil\n end",
"def actual_buffer(offset=0)\n @transfer[:buffer].get_bytes(offset, @transfer[:actual_length])\n end",
"def buffer?\n defined?(buffer_part_type)\n end",
"def buffer_initial_length()\n #This is a stub, used for indexing\n end",
"def initialize(buf_size)\n @buffer_size = buf_size\n super(buf_size)\n end",
"def modified?; end",
"def output_buffer=(_arg0); end",
"def output_buffer=(_arg0); end",
"def raw\n @buffer\n end",
"def clear\n @monitor.synchronize {\n new_buffer\n }\n end",
"def initialize(buffer_size)\n super()\n @buffer_size = buffer_size\n end",
"def prepend!(buffer)\n @str = buffer.to_s + @str\n self\n end",
"def prepend!(buffer)\n @str = buffer.to_s + @str\n self\n end",
"def load_buffer_data(key)\n @buffers[@active_buffer].set_buffer_data(key,read_file(key))\n end",
"def read\n @buffer\n end",
"def addFrameExistingBuffer buffer, line, overWrite\n cursor = Cursor.new(self, buffer.fileContent, line)\n frame = Frame.new(cursor, overWrite)\n buffer.addWorkingUser self\n @frames[buffer] = frame\n buffer.id\n end",
"def next(buffer)\r\n unless @active && @old_buffer == buffer\r\n @active = source.rebuild(buffer)\r\n end\r\n\r\n if @active\r\n @old_buffer = source.next\r\n else\r\n @old_buffer = nil\r\n end\r\n end",
"def clearBuffer() \n @buffer = \"\" ;\n end",
"def buffer_initial_length=(length)\n #This is a stub, used for indexing\n end",
"def flush_buffer\r\n data = @buffer.clone\r\n clear_buffer\r\n @uploader.queue(data) \r\n end",
"def store_buffer\n return unless buffer?\n @buffer.binmode\n @buffer.pos = 0 # TODO: なんか頭が落ちるので!\n File.open(stored_file_path, \"wb\") do |f|\n f.write(@buffer.read)\n end\n end",
"def convert_from_buffer(_tensor, _result)\n raise \"need implementation\"\n end",
"def clear_buffer\n @buffer.clear\n end"
] |
[
"0.7725814",
"0.7008587",
"0.7008587",
"0.7008587",
"0.69872695",
"0.66430175",
"0.6607979",
"0.65427816",
"0.650823",
"0.6484023",
"0.6450955",
"0.6413245",
"0.6393828",
"0.6361965",
"0.6361965",
"0.6329481",
"0.6248375",
"0.62143266",
"0.6202665",
"0.6185301",
"0.60851216",
"0.6057082",
"0.6048538",
"0.60159934",
"0.6003077",
"0.5912293",
"0.58854526",
"0.58762276",
"0.5874029",
"0.5868814",
"0.58627295",
"0.586239",
"0.58604425",
"0.5856087",
"0.584293",
"0.5840336",
"0.57991076",
"0.5781123",
"0.5781123",
"0.5781123",
"0.57215744",
"0.5696292",
"0.5685003",
"0.5673814",
"0.56733215",
"0.5639802",
"0.5639802",
"0.56369704",
"0.5630715",
"0.5630715",
"0.56266296",
"0.5619133",
"0.55935246",
"0.5561422",
"0.5561318",
"0.55580837",
"0.55532765",
"0.5551965",
"0.5546052",
"0.5528706",
"0.55173993",
"0.5508621",
"0.54980665",
"0.54957604",
"0.5484228",
"0.5472337",
"0.54709655",
"0.54686624",
"0.5464086",
"0.5461771",
"0.5439891",
"0.5439891",
"0.5439751",
"0.54246926",
"0.54216844",
"0.5406301",
"0.54002696",
"0.5394698",
"0.53912956",
"0.53862125",
"0.53769475",
"0.53734523",
"0.53706884",
"0.53615034",
"0.53534305",
"0.53534305",
"0.5353307",
"0.5351459",
"0.53506476",
"0.53391445",
"0.53391445",
"0.53365916",
"0.53348535",
"0.5328381",
"0.5326657",
"0.5322848",
"0.53165895",
"0.53163195",
"0.5312971",
"0.531238",
"0.53091174"
] |
0.0
|
-1
|
If a buffer needs to modify, override this method.
|
def enabled?
true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def monkey_patch_buffer!\n unless @buffer.respond_to? :buffer\n @buffer.class.send(:include, BufferUtil) \n end\n end",
"def buffer; end",
"def buffer; end",
"def buffer; end",
"def _buffer( the_binding )\n @_buffer = eval( \"_buf\", the_binding )\n end",
"def swithOverwrite buffer\n @frames[buffer].switchOverWrite\n end",
"def buffer_changed?\n @buffer_changed\n end",
"def buffer=(buf)\n @buffer = buf\n @snippet_loader.current_snippets.each do |snippet|\n snippet.buffer = buf\n end\n @manipulators.each { |man| man.buffer = buf }\n monkey_patch_buffer!\n @buffer\n end",
"def initialize_buffer\n @pointer = 0\n @buffer = []\n def @buffer.clear\n super\n @pointer = 0\n end\n true\n end",
"def buffer_prev\n buffer_update_info\n if @_buffer_ctr < 1\n buffer_last\n return\n end\n @_buffer_ctr -= 1 if @_buffer_ctr > 0\n x = @_buffer_ctr\n l = @_buffers[x]\n if l\n populate_buffer_from_filename x\n l = @_buffers[x]\n $log.debug \"bp calling set_content with #{l.class} \"\n set_content l, @_buffers_conf[x]\n buffer_update_position\n end\n end",
"def _set_buffer value #:nodoc:\n @repaint_required = true\n @datatype = value.class\n @delete_buffer = @buffer.dup\n @buffer = value.to_s.dup\n # don't allow setting of value greater than maxlen\n @buffer = @buffer[0,@maxlen] if @maxlen && @buffer.length > @maxlen\n @curpos = 0\n # hope @delete_buffer is not overwritten\n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos, self, :DELETE, 0, @delete_buffer) # 2010-09-11 13:01 \n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos, self, :INSERT, 0, @buffer) # 2010-09-11 13:01 \n self # 2011-10-2 \n end",
"def buffer=(buffer)\n @io = buffer\n end",
"def read_buffer; end",
"def reset_buffer(new_buf = '')\n @buf.replace new_buf\n @index = 0\n end",
"def reset_buffer(new_buf = '')\n @buf.replace new_buf\n @index = 0\n end",
"def flush_buffer; self.input_buffer = \"AAAA\"; end",
"def initialize_buffer\r\n @buffer = []\r\n @pointer = 0\r\n def @buffer.clear\r\n @pointer = 0\r\n super\r\n end\r\n end",
"def buffer(_distance_)\n raise Error::UnsupportedOperation, \"Method Geometry#buffer not defined.\"\n end",
"def buffer\n @line[@pos, @line.length - @pos] unless @line.nil?\n end",
"def reset_buffer(new_buf = '')\n @buf.replace Bytes.force_binary_encoding(new_buf)\n @index = 0\n end",
"def set_buffer(pos=nil,b=nil,offset=nil,len=nil)\n if pos.class == Fixnum && b.class.method_defined?(:j_del) && !block_given? && offset == nil && len == nil\n @j_del.java_method(:setBuffer, [Java::int.java_class,Java::IoVertxCoreBuffer::Buffer.java_class]).call(pos,b.j_del)\n return self\n elsif pos.class == Fixnum && b.class.method_defined?(:j_del) && offset.class == Fixnum && len.class == Fixnum && !block_given?\n @j_del.java_method(:setBuffer, [Java::int.java_class,Java::IoVertxCoreBuffer::Buffer.java_class,Java::int.java_class,Java::int.java_class]).call(pos,b.j_del,offset,len)\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling set_buffer(pos,b,offset,len)\"\n end",
"def clean_buffer; self.input_buffer = self.input_buffer[self.input_buffer.length-4,self.input_buffer.length-1]; end",
"def process(request_buffer=nil)\n raise NotImplementedError\n end",
"def message_buffer; end",
"def set(buffer)\n @buffer = buffer.encode('binary')\n @length = buffer.length\n @position = 0\n end",
"def buffered!(len=nil, buffer_name=:default, opts={}, &block)\n semaphore.synchronize {\n ret, still_to_get = buffer(buffer_name, opts[:type]).offset!(len)\n if still_to_get > 0\n src_data = Support::Utils.send_all_or_no_args(block, still_to_get)\n called_for = src_data.slice!(0, still_to_get)\n ret.concat(called_for)\n buffer(buffer_name).concat(src_data)\n end\n ret\n }\n end",
"def message_buffer=(buffer)\n @message_buffer = buffer\n @interaction_highline = nil\n end",
"def get_raw_buffer\n @buffer\n end",
"def buffer_info\n @buffer_info ||= BufferInfo.new\n end",
"def create_buffer(contents)\n end",
"def close_buffer; end",
"def set_active_buffer(buffer=0) \n @active_buffer = buffer unless !buffer.between?(0,@@BUFFERS)\n @file_eof = false\n Rula.log(Logger::DEBUG,\"Set active buffer to #{@active_buffer}\",self)\n end",
"def buffer=(input)\n @buffer = input\n @words = nil\n end",
"def append_buffer(buff=nil,offset=nil,len=nil)\n if buff.class.method_defined?(:j_del) && !block_given? && offset == nil && len == nil\n @j_del.java_method(:appendBuffer, [Java::IoVertxCoreBuffer::Buffer.java_class]).call(buff.j_del)\n return self\n elsif buff.class.method_defined?(:j_del) && offset.class == Fixnum && len.class == Fixnum && !block_given?\n @j_del.java_method(:appendBuffer, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::int.java_class,Java::int.java_class]).call(buff.j_del,offset,len)\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling append_buffer(buff,offset,len)\"\n end",
"def update(raw_data)\n if @policy_type == :buffer\n if @buffer.size != @buffer_size\n @buffer << raw_data\n end\n elsif @policy_type == :data\n @buffer = [raw_data]\n else\n raise \"port policy #{@policy_type} is not supported by #{self.class}\"\n end\n end",
"def source_buffer=(_arg0); end",
"def buffer\n @buffer ||= Utils::Buffer.new(config.buffer, log_header: name) do |string|\n @on_output.call(string, :header => log_header) if @on_output\n end\n end",
"def source_buffer; end",
"def source_buffer; end",
"def source_buffer; end",
"def reset!\n @buffer = buffer.reset!\n end",
"def restore_buffer(buf_was)\n @_out_buf = buf_was\n end",
"def initialize\n @buffer = ''\n end",
"def modify\n super\n end",
"def buffer=(data)\n if !@buffer || data.bytesize>@buffer.size\n free_buffer\n @buffer = FFI::MemoryPointer.new(data.bytesize, 1, false)\n end\n @buffer.put_bytes(0, data)\n @transfer[:buffer] = @buffer\n @transfer[:length] = data.bytesize\n end",
"def output_buffer; end",
"def output_buffer; end",
"def asking_buffer=(buffer)\n @asking_buffer = buffer\n @interaction_highline = nil\n end",
"def buffered\n @buffer.length\n end",
"def buffered\n @buffer.length\n end",
"def rl_extend_line_buffer(len)\r\n while (len >= @rl_line_buffer.length)\r\n @rl_line_buffer << 0.chr * DEFAULT_BUFFER_SIZE\r\n end\r\n @the_line = @rl_line_buffer\r\n end",
"def redo buffer\n @frames[buffer].redo buffer\n end",
"def block_buffer(&block)\n yield if block_given?\n BLOCK_BUFFER\n end",
"def gets_buffer(*a)\n @device.buffer\n end",
"def binding_buffer(op)\n # @buffer_lookup[op.input(ANTIBODY).sample][BINDING_BUFFER]\n op.input(BINDING_BUFFER).item\n end",
"def replace(other)\n @buffer.replace(other.buffer)\n self\n end",
"def buffer &writes\n begin\n buffer_on!\n writes.call\n ensure\n buffer_off!\n end\n flush_buffer!\n end",
"def buffer\n @buffer ||= Buffer.new(config.buffer) do |string|\n @on_output.call(string, :header => log_header) if @on_output\n end\n end",
"def save_buffer\n @_out_buf, buf_was = '', @_out_buf\n buf_was\n end",
"def buffer? \n !@_out_buf.nil?\n end",
"def shift_write_buffer\n @write_mutex.synchronize { @write_buffer.shift }\n end",
"def update_buffer(move)\n # if new command requires so\n if move == nil || move == false\n # empty each actor's buffer\n $BlizzABS.battlers.each {|actor| actor.force_move = []}\n end\n # add new command or enforce emptying whether move is reset for each actor\n $BlizzABS.battlers.each {|actor| actor.update_buffer(move == 'reset' ? nil : move)}\n end",
"def update(bytes)\n # Do nothing.\n end",
"def buffer=(buffer)\n @buffer = buffer\n return unless buffer?\n self.name = buffer.original_filename\n self.unique_key = genkey()\n end",
"def buffer(x) \n $game_player.iframes = 30 if $game_player.iframes == 0\n unless self.input_buffer[-1]==x\n self.input_buffer << x \n end\n end",
"def restore_original_value\n $log.debug \" FIELD: buffer:#{@buffer}. orig:#{@original_value}: \"\n $log.debug \" original value is null \" unless @original_value\n $log.debug \" buffer value is null \" unless @buffer\n @buffer = @original_value.dup\n # earlier commented but trying again, since i am getting IndexError in insert 2188\n # Added next 3 lines to fix issue, now it comes back to beginning.\n cursor_home\n\n @repaint_required = true\n end",
"def data_buffer\n @data_buffer ||= {}\n end",
"def on_enter\n #@original_value = getvalue.dup rescue getvalue\n @original_value = @buffer.dup # getvalue.dup rescue getvalue\n super\n end",
"def remainder_as_buffer; end",
"def exp_buffer\n result = @receive_buffer\n @receive_buffer = ''\n result\n end",
"def extend_buffer; $game_player.eb; end",
"def append!(buffer)\n @str << buffer.to_s\n self\n end",
"def append!(buffer)\n @str << buffer.to_s\n self\n end",
"def flush_buffer\n # note we must discard cancelled timer or else we never create a new timer and stay cancelled.\n if @timer\n @timer.cancel\n @timer = nil\n end\n\n to_send = nil\n @mutex.synchronize do\n unless @buffer.empty?\n to_send = @buffer\n @buffer = ''\n end\n end\n\n if to_send\n internal_send_audit(:kind => :output, :text => to_send, :category => EventCategories::NONE)\n end\n end",
"def redraw\n # this kinda stuff should be inside widget or some util class\n c = @component\n if c.is_double_buffered?\n c.set_buffer_modified\n c.buffer_to_window\n else\n # force a repaint, if not buffered object e.g scrollpane.\n $log.debug \" TP: forcing repaint of non-buffered object #{c} \"\n c.repaint_all\n c.repaint\n end\n end",
"def write_buffer(io = T.unsafe(nil)); end",
"def reset!\n @buffer = ''\n end",
"def add_to_buffer( event )\n str = event.instance_of?(::Logging::LogEvent) ?\n layout.format(event) : event.to_s\n return if str.empty?\n\n buffer << str\n flush if buffer.length >= auto_flushing || immediate?(event)\n\n self\n end",
"def buffer_size=(buffer_size)\n if buffer_size != nil && buffer_size.to_i < 1\n raise ArgumentError, \"Buffer size must be a positive integer greater than 0 or nil\"\n end\n\n @buffer_size = buffer_size != nil ? buffer_size.to_i : nil\n end",
"def actual_buffer(offset=0)\n @transfer[:buffer].get_bytes(offset, @transfer[:actual_length])\n end",
"def buffer?\n defined?(buffer_part_type)\n end",
"def buffer_initial_length()\n #This is a stub, used for indexing\n end",
"def initialize(buf_size)\n @buffer_size = buf_size\n super(buf_size)\n end",
"def modified?; end",
"def raw\n @buffer\n end",
"def output_buffer=(_arg0); end",
"def output_buffer=(_arg0); end",
"def clear\n @monitor.synchronize {\n new_buffer\n }\n end",
"def initialize(buffer_size)\n super()\n @buffer_size = buffer_size\n end",
"def prepend!(buffer)\n @str = buffer.to_s + @str\n self\n end",
"def prepend!(buffer)\n @str = buffer.to_s + @str\n self\n end",
"def load_buffer_data(key)\n @buffers[@active_buffer].set_buffer_data(key,read_file(key))\n end",
"def read\n @buffer\n end",
"def addFrameExistingBuffer buffer, line, overWrite\n cursor = Cursor.new(self, buffer.fileContent, line)\n frame = Frame.new(cursor, overWrite)\n buffer.addWorkingUser self\n @frames[buffer] = frame\n buffer.id\n end",
"def next(buffer)\r\n unless @active && @old_buffer == buffer\r\n @active = source.rebuild(buffer)\r\n end\r\n\r\n if @active\r\n @old_buffer = source.next\r\n else\r\n @old_buffer = nil\r\n end\r\n end",
"def clearBuffer() \n @buffer = \"\" ;\n end",
"def buffer_initial_length=(length)\n #This is a stub, used for indexing\n end",
"def flush_buffer\r\n data = @buffer.clone\r\n clear_buffer\r\n @uploader.queue(data) \r\n end",
"def store_buffer\n return unless buffer?\n @buffer.binmode\n @buffer.pos = 0 # TODO: なんか頭が落ちるので!\n File.open(stored_file_path, \"wb\") do |f|\n f.write(@buffer.read)\n end\n end",
"def convert_from_buffer(_tensor, _result)\n raise \"need implementation\"\n end",
"def clear_buffer\n @buffer.clear\n end"
] |
[
"0.77251905",
"0.70076716",
"0.70076716",
"0.70076716",
"0.69855905",
"0.6642355",
"0.66071886",
"0.65404665",
"0.650667",
"0.64841956",
"0.6450255",
"0.6410933",
"0.6393178",
"0.6361105",
"0.6361105",
"0.63295007",
"0.62466353",
"0.62131417",
"0.6202356",
"0.61843985",
"0.60842353",
"0.60557353",
"0.60474813",
"0.60150075",
"0.60011274",
"0.5912399",
"0.5882124",
"0.58756566",
"0.58716714",
"0.5868355",
"0.58617085",
"0.58596766",
"0.5859484",
"0.58556455",
"0.58434045",
"0.5839465",
"0.5797183",
"0.5780659",
"0.5780659",
"0.5780659",
"0.57203424",
"0.5693746",
"0.56834",
"0.56757903",
"0.56715035",
"0.56382227",
"0.56382227",
"0.5633494",
"0.5629875",
"0.5629875",
"0.5626516",
"0.56183046",
"0.5592369",
"0.55605036",
"0.5560335",
"0.5558455",
"0.5554241",
"0.5550072",
"0.55444694",
"0.552721",
"0.5517698",
"0.5508536",
"0.5499158",
"0.5492513",
"0.54838306",
"0.5471433",
"0.54691124",
"0.54686916",
"0.54641527",
"0.54604936",
"0.5439763",
"0.5438808",
"0.5438808",
"0.5424452",
"0.54222894",
"0.5406443",
"0.53989863",
"0.5395121",
"0.5388956",
"0.53852993",
"0.5375073",
"0.5371965",
"0.5368955",
"0.5363108",
"0.53535897",
"0.53516823",
"0.53516823",
"0.53512204",
"0.5348538",
"0.53379583",
"0.53379583",
"0.5335054",
"0.5334843",
"0.53272736",
"0.5325722",
"0.5321513",
"0.53150916",
"0.5314941",
"0.53113",
"0.5310944",
"0.53077495"
] |
0.0
|
-1
|
Capacity is the desired number of samples a buffer will hold. This can be user dictated via config if a feature wants. This value will be forcibly capped by the max_capacity
|
def capacity
raise NotImplementedError.new("TransactionSampleBufferBase subclasses must provide a capacity override")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def capacity\n @capacity\n end",
"def capacity\n @capacity ||= DEFAULT_CAPACITY\n end",
"def capacity\n data[:capacity]\n end",
"def input_capacity\n typical_input_capacity\n end",
"def capacity=(value)\n @capacity = value\n end",
"def available_input_capacity\n 0.0\n end",
"def capacity\n return @capacity\n end",
"def capacity\n info[:capacity]\n end",
"def pool_capacity; end",
"def capacity\n @logs.first.capacity * @logs.count\n end",
"def capacity= value\n\t\t\t\tdifference = value - @capacity\n\t\t\t\t\n\t\t\t\t# An endpoint MUST treat a change to SETTINGS_INITIAL_WINDOW_SIZE that causes any flow-control window to exceed the maximum size as a connection error of type FLOW_CONTROL_ERROR.\n\t\t\t\tif (@available + difference) > MAXIMUM_ALLOWED_WINDOW_SIZE\n\t\t\t\t\traise FlowControlError, \"Changing window size by #{difference} caused overflow: #{@available + difference} > #{MAXIMUM_ALLOWED_WINDOW_SIZE}!\"\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t@available += difference\n\t\t\t\t@capacity = value\n\t\t\tend",
"def available_output_capacity\n 0.0\n end",
"def capacity=(capacity); @receiver_impl.setCapacity capacity; end",
"def capacity=(capacity); @receiver_impl.setCapacity capacity; end",
"def max_buffer_size; end",
"def capacity\n @ole.Capacity\n end",
"def read_capacity\n options[:read_capacity] || Dynamoid::Config.read_capacity\n end",
"def read_capacity\n options[:read_capacity] || Dynamoid::Config.read_capacity\n end",
"def capacity_mode\n options[:capacity_mode] || Dynamoid::Config.capacity_mode\n end",
"def desired_capacity\n @group.desired_capacity\n end",
"def capacity\n @slots.length\n end",
"def write_capacity\n options[:write_capacity] || Dynamoid::Config.write_capacity\n end",
"def write_capacity\n options[:write_capacity] || Dynamoid::Config.write_capacity\n end",
"def set_capacity\n self.capacity ||= 100\n end",
"def capacity\n @logs.first.capacity * @logs.count\n end",
"def capacity_type\n\t\t\t\t\t:integer\n\t\t\t\tend",
"def channel_capacity\n average_channel_capacity =\n node.one_ml_node.capacity / node.one_ml_node.channelcount.to_f\n\n return 10 if average_channel_capacity < CHANNEL_CAPACITY_MIN\n return 1 if average_channel_capacity > CHANNEL_CAPACITY_MAX\n\n max_distance = CHANNEL_CAPACITY_MAX - CHANNEL_CAPACITY_MIN\n distance = CHANNEL_CAPACITY_MAX - average_channel_capacity\n\n (10.0 * distance / max_distance).ceil\n end",
"def capacity=(capacity); @sender_impl.setCapacity capacity; end",
"def maximum_capacity\n read_attribute(:maximum_capacity) || room.try(:capacity)\n end",
"def setup(capacity = MIN_SIZE)\n @capacity = capacity\n @maximum = capacity * 2\n @mask = capacity - 1\n @size = 0\n @bucket_size = 2\n @max_loop = MAX_LOOP_BASE if capacity == MIN_SIZE\n @entries = Rubinius::Tuple.new @maximum\n end",
"def remaining_capacity\n mutex.synchronize { @max_queue == 0 ? -1 : @max_queue - @queue.length }\n end",
"def node_capacity\n n = node.one_ml_node.capacity\n return 10 if n < NODE_CAPACITY_MIN\n return 10 if n > NODE_CAPACITY_MAX\n\n mid = (NODE_CAPACITY_MIN + NODE_CAPACITY_MAX) / 2.0\n max_distance = mid - NODE_CAPACITY_MIN\n distance = n - mid\n\n # The farther away the capacity devites from the middle,\n # the lower the score gets\n 10 * (distance / max_distance)\n end",
"def size\n\t\treturn @m.capacity\n\tend",
"def capacity_readable\n if current_user\n number_to_human_size(current_user.storage_capacity, precision: 4)\n end\n end",
"def max_buffer_size=(_arg0); end",
"def d_size\n @capacity / @blockSize\n end",
"def remaining_capacity\n @max_queue == 0 ? -1 : @executor.getQueue.remainingCapacity\n end",
"def maximum_queued_data_size\n super\n end",
"def capacity\n\t\t\t\t\treturn self.send(\"capacity_#{self.capacity_type.to_s}\")\n\t\t\t\tend",
"def size\n\t\t\treturn @m.capacity\n\t\tend",
"def initialize(capacity=DEFAULT_CAPACITY)\n @capacity = capacity\n @bikes = []\n end",
"def initialize(capacity = DEFAULT_CAPACITY)\n @capacity = capacity\n @bikes = []\n end",
"def cooling_based_input_capacity\n fetch(:cooling_based_input_capacity) do\n if cooling_output_conversion && cooling_output_conversion > 0\n heat_output_capacity / cooling_output_conversion\n end\n end\n end",
"def capacity( resource = :deuterium )\n\t\t@resources[ resource ][ :capacity ]\n\tend",
"def max_allocated_storage\n data[:max_allocated_storage]\n end",
"def initialize\n @max_resource_size = 10_000_000\n end",
"def initialize(options = {})\n\t\tself.capacity = options.fetch(:capacity, capacity)\n end",
"def initialize(storage=[], capacity=1)\n @storage = storage\n @DEFAULT_CAPACITY = capacity\n end",
"def heat_based_input_capacity\n fetch(:heat_based_input_capacity) do\n if heat_output_conversion && heat_output_conversion > 0\n heat_output_capacity / heat_output_conversion\n end\n end\n end",
"def get_capacity\n rpc_get_fact_direct('capacity').to_f\n end",
"def capacity_to_demand_multiplier\n 1.0\n end",
"def resource_limits; end",
"def resource_limits; end",
"def initialize(capacity = DEFAULT_CAPACITY)\n @bikes = []\n @capacity = capacity\n end",
"def capacity(person_or_type = nil)\n attribute_for_audience_with_generic(:capacity, person_or_type) do |cust_cap|\n cust_cap && cust_cap > 0\n end\n end",
"def buffer_size\n @buffer.size\n end",
"def index_capacity\n info[\"index-capacity\"]\n end",
"def setup(capacity=MIN_SIZE, max=MAX_ENTRIES, size=0)\n @capacity = capacity\n @mask = capacity - 1\n @max = max\n @size = size\n @entries = Rubinius::Tuple.new capacity\n end",
"def initialize(capacity = DEFAULT_CAPACITY)\n @bikes = []\n @capacity = capacity\n end",
"def initialize(capacity = DEFAULT_CAPACITY)\n @bikes = []\n @capacity = capacity\n end",
"def initialize(capacity = DEFAULT_CAPACITY)\n @bikes = []\n @capacity = capacity\n end",
"def capacity; @capacity ||= sheet1_b10; end",
"def set_desired_capacity capacity, options = {}\n client_opts = {}\n client_opts[:auto_scaling_group_name] = name\n client_opts[:desired_capacity] = capacity\n client_opts[:honor_cooldown] = options[:honor_cooldown] == true\n client.set_desired_capacity(client_opts)\n nil\n end",
"def ensure_capacity(vertex_capacity, index_capacity)\n @vertices = self.class.ensure_capacity_of_array(\n @vertices, vertex_capacity, VertexSpec::Array\n )\n\n @faces = self.class.ensure_capacity_of_array(\n @faces, index_capacity, FaceSpec::Array\n )\n end",
"def sample_size\n @n\n end",
"def ensure_capacity?\n additional = 0\n capacity = true\n\n if @pool.size < @min_length\n additional = @min_length - @pool.size\n elsif @queue.empty? && @queue.num_waiting >= 1\n additional = 0\n elsif @pool.size == 0 && @min_length == 0\n additional = 1\n elsif @pool.size < @max_length || @max_length == 0\n additional = 1\n elsif @max_queue == 0 || @queue.size < @max_queue\n additional = 0\n else\n capacity = false\n end\n\n additional.times do\n @pool << create_worker_thread\n end\n\n if additional > 0\n @largest_length = [@largest_length, @pool.length].max\n end\n\n capacity\n end",
"def initialize(capacity)\n @size = 0\n @capacity = capacity\n @list = DList.new\n @map = {}\n end",
"def player_capacity\n 2\n end",
"def max_size; end",
"def capacity=(capacity)\n\t\t\t\t\tself.send(\"capacity_#{self.capacity_type.to_s}=\", capacity)\n\t\t\t\tend",
"def limit\n components.fetch(:size)\n end",
"def compute_storage_capacity\n level = @buildings[@storage_building_uid] || 0\n @storage_capacity = Storage::GameData.coins_storage_capacity level\n end",
"def setup(capacity = MIN_SIZE)\n @capacity = capacity\n @mask = capacity - 1\n @size = 0\n @entries = Rubinius::Tuple.new capacity\n end",
"def electric_based_input_capacity\n fetch(:electric_based_input_capacity) do\n if electricity_output_conversion && electricity_output_conversion > 0\n electricity_output_capacity / electricity_output_conversion\n end\n end\n end",
"def specific_max_size(number); end",
"def max_size\n 1\n end",
"def buffer_initial_length()\n #This is a stub, used for indexing\n end",
"def storage_pool_size\n @storage_pool_size ||= 20\n end",
"def storage_pool_size\n @storage_pool_size ||= 20\n end",
"def __setup__(capacity=MIN_SIZE, max=MAX_ENTRIES, size=0)\n @capacity = capacity\n @mask = capacity - 1\n @max_entries = max\n @size = size\n @entries = Entries.new capacity\n end",
"def buffer_size=(value)\n @buffer_size = value\n flush\n end",
"def item_max; 64; end",
"def size\n @max_entries\n end",
"def efficiency_based_capacity\n cop_cutoff = @config.cop_cutoff || 1.0\n\n input_cap =\n total_value do\n @config.capacity[@config.efficiency_based_on]\n end\n\n input_efficiency.map do |eff|\n eff < cop_cutoff ? 0.0 : input_cap * eff\n end\n end",
"def capacity_costs\n fetch(:capacity_costs) do\n if fixed_costs_per_mw_input_capacity\n fixed_costs_per_mw_input_capacity * input_capacity\n else\n 0.0\n end\n end\n end",
"def max_consumption\n @max_consumption ||= begin\n augment = max_repeats == Float::INFINITY ? 10 : max_repeats\n self.next&.max_consumption.to_i + augment\n end\n end",
"def get_rdir_capacity\n (@block_size / INT_BYTES_) - RC_ENTRIES_START_\n end",
"def max_file_buffer; end",
"def max_file_buffer; end",
"def capacity\n\t\tcapacity = 0\n\t\trooms.all.each do |room|\n\t\t\tcapacity += room.capacity\n\t\tend\n\t\tcapacity\n\tend",
"def post_sample_size\n 300\n end",
"def initialize(weight, capacity)\n @weight, @capacity = weight, capacity\n end",
"def local_maximum_packet_size; end",
"def specific_max_size(number)\n [self.size, number].min\n end",
"def initialize(capacity = DEFAULT_CAPACITY) #the = means default\n @bike_collection = Array.new\n @capacity = capacity\n\n\n end",
"def block_size\n\t\t25\n\tend",
"def default_size\n @total_memory ? @total_memory * @weighting : nil\n end",
"def initialize(def_capacity=DEFAULT_CAPACITY)\n @bikes = []\n @def_capacity = def_capacity\n @broken_bikes = []\n end",
"def max_packets; end",
"def max_file_buffer=(bytes); end"
] |
[
"0.72650856",
"0.72281146",
"0.70058465",
"0.69601595",
"0.68685365",
"0.6824391",
"0.6810686",
"0.6744432",
"0.6648285",
"0.6466202",
"0.6442263",
"0.643262",
"0.6420256",
"0.6420256",
"0.6355884",
"0.63441414",
"0.63323355",
"0.63323355",
"0.63313586",
"0.6328554",
"0.6293871",
"0.62815315",
"0.62815315",
"0.6251644",
"0.6237182",
"0.6206562",
"0.61705273",
"0.61249655",
"0.6099053",
"0.6073713",
"0.60580444",
"0.6026935",
"0.6019958",
"0.5985894",
"0.59622246",
"0.59483683",
"0.5939254",
"0.59340084",
"0.5927343",
"0.5926525",
"0.59081566",
"0.58975977",
"0.5885534",
"0.58640224",
"0.5851175",
"0.585107",
"0.58495253",
"0.58400923",
"0.58317906",
"0.58006674",
"0.57927364",
"0.5782298",
"0.5782298",
"0.57747",
"0.5760226",
"0.57449967",
"0.5741082",
"0.57402694",
"0.5739093",
"0.5739093",
"0.5739093",
"0.57334787",
"0.57288074",
"0.57132727",
"0.5709444",
"0.5708143",
"0.5676561",
"0.5669817",
"0.56650966",
"0.56635153",
"0.56574523",
"0.56508183",
"0.56221575",
"0.5615057",
"0.5597819",
"0.558911",
"0.55815446",
"0.5573513",
"0.5573513",
"0.5562299",
"0.5560987",
"0.5510072",
"0.55085427",
"0.5489992",
"0.54758435",
"0.54755116",
"0.54734576",
"0.5467462",
"0.5467462",
"0.54508704",
"0.54488",
"0.5434479",
"0.5431467",
"0.54221904",
"0.5421541",
"0.5417385",
"0.54117835",
"0.5407935",
"0.5385162",
"0.5363363"
] |
0.7964951
|
0
|
Our default truncation strategy is to keep max_capacity worth of the longest samples. Override this method for alternate behavior.
|
def truncate_samples
@samples.sort!{|a,b| a.duration <=> b.duration}
@samples.slice!(0..-(max_capacity + 1))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def truncate(max)\n resize([max, self.length].min)\n end",
"def truncate(max)\n length = Math.min(max, length)\n self\n end",
"def reduce_max_size\n @max_size /= 2\n end",
"def truncate(max, omission = '...')\n (length > max ? self[0...max] + omission : self)\n end",
"def length_penalty\n (@options[:target].size - self.size).abs * @options[:length_penalty]\n end",
"def truncate(length)\n #This is a stub, used for indexing\n end",
"def cleanup!(max_len)\n if self.length >= max_len\n self.clear\n end\n end",
"def expand\n @max = Short::MAX_VALUE\n end",
"def specific_max_size(number); end",
"def capacity\n raise NotImplementedError.new(\"TransactionSampleBufferBase subclasses must provide a capacity override\")\n end",
"def fit_to(len, fade_frames=250)\n meant_to_be = len\n self.dps.pop(dps.count- meant_to_be) if meant_to_be < dps.count\n while meant_to_be > dps.count # too short\n self.dps.push 0\n end\n # stop the annoying popping\n if dps.count > fade_frames\n fade_frames.times do |i|\n dps[dps.count-1-i] *= i.to_f / fade_frames\n end\n end\n self\nend",
"def truncate_in_the_middle(max_len)\n r = if(max_len > 0 && length > max_len)\n half_len = max_len/2\n \"#{ self[0..half_len] } [...] #{ self[-half_len..-1] }\"\n else\n self\n end\n r\n end",
"def enforce_max_records_scan; end",
"def ltrunc(max)\n if length > max\n sub(/^.*?(.{#{max - 3}})$/, '...\\1')\n else\n self\n end\n end",
"def available_output_capacity\n 0.0\n end",
"def maximum_limit\n 100\n end",
"def truncate(max_length)\n output = deparse(@tree)\n\n # Early exit if we're already below the max length\n return output if output.size <= max_length\n\n truncations = find_possible_truncations\n\n # Truncate the deepest possible truncation that is the longest first\n truncations.sort_by! { |t| [-t.location.size, -t.length] }\n\n tree = deep_dup(@tree)\n truncations.each do |truncation|\n next if truncation.length < 3\n\n find_tree_location(tree, truncation.location) do |expr, k|\n expr[k] = { A_TRUNCATED => nil }\n expr[k] = [expr[k]] if truncation.is_array\n end\n\n output = deparse(tree)\n return output if output.size <= max_length\n end\n\n # We couldn't do a proper smart truncation, so we need a hard cut-off\n output[0..max_length - 4] + '...'\n end",
"def enforce_max_records_scan=(_arg0); end",
"def default_max_size\n [Setting[:histsize], self.size].min\n end",
"def max_items=(new_max_items)\n @max_items = new_max_items\n trim_buffer\n end",
"def truncate() end",
"def max_consumption\n @max_consumption ||= begin\n augment = max_repeats == Float::INFINITY ? 10 : max_repeats\n self.next&.max_consumption.to_i + augment\n end\n end",
"def set_maximum_queued_data_size(opts)\n opts = check_params(opts,[:sizes])\n super(opts)\n end",
"def item_max; 64; end",
"def default_limit\n 10\n end",
"def sample_length_with_overflow(tick_sample_length)\n @tracks.keys.collect {|track_name| @tracks[track_name].sample_length_with_overflow(tick_sample_length) }.max || 0\n end",
"def rekey_limit; end",
"def capacity\n @capacity ||= DEFAULT_CAPACITY\n end",
"def available_input_capacity\n 0.0\n end",
"def col_max; [(width - standard_padding) / (24 + spacing), item_max].min; end",
"def max_size=(_arg0); end",
"def truncate(decplace = 0)\n #This is a stub, used for indexing\n end",
"def max_key_width=(_arg0); end",
"def resize!\n @capacity *= 2\n new_store = StaticArray.new(@capacity)\n (0...@length).each do |idx|\n if idx < @start_idx\n new_store[idx] = @store[idx]\n else\n new_store[idx + @length] = @store[idx]\n end\n end\n @store = new_store\n @start_idx += @length\n end",
"def adjust(total_excess, total_adjustable_weighting)\n if @adjustable\n if total_adjustable_weighting == 0\n @size = MemorySize::ZERO\n else\n @size = default_size - (total_excess - excess) * @weighting / total_adjustable_weighting\n end\n end\n end",
"def resize!\n self.capacity *=2 \n new_store = StaticArray.new(capacity)\n self.length.times { |i| new_store[i] = self[i] } \n self.store = new_store\n end",
"def resize(min, max = T.unsafe(nil)); end",
"def set_capacity\n self.capacity ||= 100\n end",
"def fixed_len_array(a)\n def a.shrink\n (before, shrink_me, after) =\n Shrinkers.split_around(self, (lambda &:shrinkable?))\n next_smallest = before + [shrink_me.shrink] + after\n Shrinkers.fixed_len_array(next_smallest) #maintain this property\n end\n\n def a.shrinkable?\n any? &:shrinkable?\n end\n a\n end",
"def capacity\n @logs.first.capacity * @logs.count\n end",
"def max_size; end",
"def specific_max_size(number)\n [self.size, number].min\n end",
"def scale_to_length(new_length)\n self.scale(new_length / length)\n end",
"def pool_capacity; end",
"def normalize_size_to(integer)\n until size >= integer\n unshift 0\n end\n self\n end",
"def max_key_width; end",
"def maximum_queued_data_size\n super\n end",
"def maximum_capacity\n read_attribute(:maximum_capacity) || room.try(:capacity)\n end",
"def max_length=(new_max_length)\n @max_length = new_max_length\n chars = @text.scan(/./m)\n @text = chars[0, @max_length].join if chars.size > @max_length\n self.cursor_move_to_end if @cursor_position > chars.size\n end",
"def enlarge(growth)\r\n if @range.none?\r\n @range = 0...growth\r\n else\r\n @range = (@range.min)..(@range.max + growth)\r\n end\r\n end",
"def location_capacity_overflow\n logger.debug(\"XXXXXXXXXXXXXXXXX Imran Latif - Index Location\")\n if (self.capacity.to_i != 0 && !self.capacity.nil? && self.capacity.to_i < self.locations.count)\n errors.add(:location, \"cannot be created / updated. Have more sub-locations than capacity you are specifying right now. Please! delete and try again.\")\n end\n \n end",
"def rekey_limit=(_arg0); end",
"def post_sample_size\n 300\n end",
"def max_columns(fit = T.unsafe(nil)); end",
"def input_capacity\n typical_input_capacity\n end",
"def resize\n # TODO\n # if aray is 75% full, double the array and copy all items over\n end",
"def suggestedNumber\r\n return self.maxLength\r\n end",
"def patch_safe_limit_bytes\n patch_hard_limit_bytes / 10\n end",
"def shorten(len=20)\n self[0..len-1]\n end",
"def pad!(array, min_size, value = nil) #destructive\n if array.count >= min_size\n return array\n else\n (min_size - array.count).times do\n array << value\n end\n return array\n end\nend",
"def limit_value\n length\n end",
"def max_size\n 1\n end",
"def smart_truncate(len = 30, ending = '...')\n len = Math.max(len, 5)\n return self if self.length <= len\n s = self[0...(len-2)].reverse\n bits = s.split(/[\\s\\-,]/,2)\n s = bits.length == 2 ? bits[1] : bits[0]\n s.reverse + ending\n end",
"def try_another_size(size)\n half_size = remaining / 2 - 1\n append_size = have_size?(half_size) ? half_size : largest_sized_bucket\n\n if append_word(append_size)\n add_words_starting_size(remaining - 1)\n elsif size > 1\n add_words_starting_size(size - 1)\n end\n end",
"def write_capacity\n options[:write_capacity] || Dynamoid::Config.write_capacity\n end",
"def write_capacity\n options[:write_capacity] || Dynamoid::Config.write_capacity\n end",
"def fit_width; end",
"def resize\n return self if self.count < (self.length * 0.811105)\n # garbage collecting\n self.gc if self.respond_to? :gc\n\n sz = self.size * 2\n super(sz)\n @bitmap.resize(sz)\n self\n end",
"def capacity\n @logs.first.capacity * @logs.count\n end",
"def truncate(p0) end",
"def truncate(p0) end",
"def rpad!(target_width)\n if target_width > size and target_width > 0\n self[target_width-1] = nil\n end\n self\n end",
"def rpad!(target_width)\n if target_width > size and target_width > 0\n self[target_width-1] = nil\n end\n self\n end",
"def pad_refact!(array, min_size, value = nil)\n array.fill(value, array.length..min_size)\nend",
"def cooling_based_input_capacity\n fetch(:cooling_based_input_capacity) do\n if cooling_output_conversion && cooling_output_conversion > 0\n heat_output_capacity / cooling_output_conversion\n end\n end\n end",
"def truncate\n end",
"def local_maximum_window_size; end",
"def resize!\n dcap = @capacity * 2\n dstore = StaticArray.new(dcap)\n\n for i in 0...@length\n dstore[i] = self[i]\n end\n\n self.capacity = dcap\n self.store = dstore\n end",
"def limit\n super\n end",
"def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n else\n pad_size = min_size - array.length\n counter = 0\n while counter < pad_size\n array << value\n counter+=1\n end\n return array\n end\nend",
"def fix_row_widths\n\n fill_cells(@row_offset - 1, 0)\n\n max = 0\n\n @data.each_with_index do |row|\n max = row.length unless max >= row.length\n end\n\n @data.each_with_index do |row,idx|\n if row.length < max\n row = row + [ @base_cell_options.merge({content: ''}) ] * (max - row.length)\n @data[idx] = row\n end\n end\n\n end",
"def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n else\n diff = min_size - array.length\n diff.times do\n array << value\n end\n return array\n end\nend",
"def check_max_samples_exceeded\n # loop over each stripwell and sum the num samples in each to find total num samples\n num_samples = 0\n operations.map { |op| op.input(\"PCR\").collection }.uniq.each do |stripwell|\n num_samples = num_samples + stripwell.num_samples\n end\n if num_samples > 96\n operations.store io: \"input\", interactive: false\n raise \"The fragment analyzer can only hold 96 samples at once. This job has #{num_samples} total samples\"\n end\n num_samples\n end",
"def max_value_items(max_capacity)\n construct_max_value_table(max_capacity)\n\n @max_value_items_table.last.last\n end",
"def default_max_size; end",
"def pad_size(array, min_size)\n min_size - array.length\nend",
"def limit(value)\n merge(wbeulimit: value.to_s)\n end",
"def max_buffer_size=(_arg0); end",
"def pad!(array, min_size, value=nil) #destructive\n if min_size == 0 || array.length >= min_size\n return array\n else (min_size - array.length).times { |array, x| array << value.to_i } \n return array\n end\nend",
"def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n end\n until min_size <= array.length\n array << value\n end\n array\nend",
"def maxsize(value)\n merge(ormaxsize: value.to_s)\n end",
"def capacity= value\n\t\t\t\tdifference = value - @capacity\n\t\t\t\t\n\t\t\t\t# An endpoint MUST treat a change to SETTINGS_INITIAL_WINDOW_SIZE that causes any flow-control window to exceed the maximum size as a connection error of type FLOW_CONTROL_ERROR.\n\t\t\t\tif (@available + difference) > MAXIMUM_ALLOWED_WINDOW_SIZE\n\t\t\t\t\traise FlowControlError, \"Changing window size by #{difference} caused overflow: #{@available + difference} > #{MAXIMUM_ALLOWED_WINDOW_SIZE}!\"\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t@available += difference\n\t\t\t\t@capacity = value\n\t\t\tend",
"def pad(array, min_size, value = nil) #non - destructive\n array_modified = []\n if min_size <= array_modified.length\n array_modified = array.map { |x| x }\n elsif min_size == 0\n array_modified = array.map { |x| x }\n else\n array_modified = array.map { |x| x }\n (min_size - array_modified.length).times {\n array_modified.push(value)\n }\n return array_modified\n end\nend",
"def pad(obj, max, pd=nil)\n i = (max - obj.size)\n obj + [pd] * (i < 0 ? 0 : i)\n end",
"def pad!(array, min_size, value = nil) #destructive\n array << value while min_size > array.length\n array\nend",
"def scale(max_size, desired_capacity)\n client.update_auto_scaling_group(auto_scaling_group_name: asg_name, max_size: max_size, desired_capacity: desired_capacity)\n end",
"def buffer_initial_length()\n #This is a stub, used for indexing\n end",
"def pad!(array, min_size, value = nil) #destructive\n if array.length < min_size\n (min_size - array.length).times { array.push(value) }\n end\n return array\nend",
"def pad!(array, min_size, value = nil) \n array.fill(value, array.length...min_size) unless min_size <= array.length\n array\nend",
"def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n else\n index = array.length\n while index < min_size\n array[index] = value\n index += 1\n end\n end\n return array\nend"
] |
[
"0.65088516",
"0.63382155",
"0.61215913",
"0.5840665",
"0.5728863",
"0.56309325",
"0.56064284",
"0.55611795",
"0.5530185",
"0.5523246",
"0.5455481",
"0.5452657",
"0.54229337",
"0.54226035",
"0.54155016",
"0.54083043",
"0.54032636",
"0.540153",
"0.5399925",
"0.5399512",
"0.53955513",
"0.5393511",
"0.53913075",
"0.5383868",
"0.53772825",
"0.5373674",
"0.53617674",
"0.5349541",
"0.5349054",
"0.5344646",
"0.5331112",
"0.5328865",
"0.5262072",
"0.52421904",
"0.5225036",
"0.5216313",
"0.52149963",
"0.52126867",
"0.51999855",
"0.5198527",
"0.5198292",
"0.5193043",
"0.51910526",
"0.51886886",
"0.5182631",
"0.51801586",
"0.5175135",
"0.5162782",
"0.51533914",
"0.51509553",
"0.5150949",
"0.5147738",
"0.5147504",
"0.514632",
"0.51452667",
"0.51161224",
"0.51153535",
"0.51116514",
"0.5100479",
"0.50896347",
"0.5086714",
"0.5082193",
"0.5081416",
"0.5079308",
"0.507286",
"0.507286",
"0.5071387",
"0.5069261",
"0.506439",
"0.5063059",
"0.50628436",
"0.50594026",
"0.50594026",
"0.5048399",
"0.5042817",
"0.50417155",
"0.504032",
"0.5019144",
"0.5019052",
"0.50186884",
"0.50114065",
"0.5006233",
"0.5001704",
"0.49983293",
"0.499547",
"0.49948934",
"0.49945754",
"0.49933586",
"0.499155",
"0.49846184",
"0.49812776",
"0.4976901",
"0.49707386",
"0.49605194",
"0.49583277",
"0.4956411",
"0.4956294",
"0.49552682",
"0.49544913",
"0.4953569"
] |
0.7334056
|
0
|
If a buffer needs to modify an added sample, override this method. Bounds checking, allowing samples and truncation belongs elsewhere.
|
def add_sample(sample)
@samples << sample
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allow_sample?(sample)\n true\n end",
"def add_sample(sample)\n samples << sample\n end",
"def postprocess_sampled_data(data, desired_samples, drawing_area_width)\n if data.length > desired_samples\n resample_data(data, desired_samples)\n end\n \n data\n end",
"def merge!(old_samples)\n self.synchronize do\n old_samples.each { |s| @samples.append(s) }\n end\n end",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element #updates existing array buffer\n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element # Mutates the caller \n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def truncate_samples\n @samples.sort!{|a,b| a.duration <=> b.duration}\n @samples.slice!(0..-(max_capacity + 1))\n end",
"def add(sample)\n raise 'Samples must be accumulated in time order' unless sample.id > @last_id\n @last_id = sample.id\n # do first-time synchronization if necessary\n at = sample.created_at\n synch(at) unless @bin_boundary\n # are we still in the same bins?\n if at.to_i >= @bin_boundary then\n # which bin boundaries does this sample cross?\n crossing_depth = @@levels.times do |level|\n code = BinnedSample.bin(at,level)\n break(level) if code==@level_acc[level].code\n # advance this bin's integrator\n @level_acc[level].advance\n # save this bin now\n @level_acc[level].save\n # fold this bin's contents into its enclosing bins\n fold level\n # reset this bin to track a new interval\n @level_acc[level].reset code\n end\n # auto-save bins at levels >= crossing_depth when ever a bin\n # at level >= @@auto_save_threshold rolls over\n if crossing_depth > @@auto_save_threshold and crossing_depth < @@levels-1 then\n crossing_depth.upto(@@levels-1) do |level|\n @level_acc[level].save true\n end\n end\n # update the level-0 bin boundary\n @bin_boundary = BinnedSample.interval_for_code(@level_acc[0].code).end.to_i\n end\n # add this sample to our level-0 bin\n values = sample.values_as_array\n @level_acc[0].add(1,values)\n end",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > mas_buffer_size\n buffer\nend",
"def sample_without_replacement(sample=1)\n if @data.respond_to? :sample_without_replacement\n @data.sample_without_replacement sample\n else\n raw_sample_without_replacement(sample)\n end\n end",
"def next_pitch\n @window = @source.next_window\n @sample = @window.sample\n\n shifts = limited_samples.map{|x| x[:index]}\n return nil if shifts.size < 2\n\n # What is this doing?\n @sample.pop( @sample.size - shifts.last )\n @sample.shift( shifts.first )\n shifts.pop\n\n (shifts.size.to_f / @sample.size.to_f) * @window.rate\n end",
"def has_sample?\n sample_width.is_a?(Integer)\n end",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > max_buffer_size\n buffer\n end",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def capacity\n raise NotImplementedError.new(\"TransactionSampleBufferBase subclasses must provide a capacity override\")\n end",
"def current_sample=(sample_num)\n if sample_num > @no_samples or sample_num < 0\n return false\n end\n # 4 bytes for each paramter, 4 for the time. This bundle sample_num times,\n # plus the header length is the byte position of the end of that sample \n position = (@no_params * 4 + 4) * sample_num + @header_length\n \n @file.seek(position)\n @current_sample = sample_num\n end",
"def rolling_buffer2(input_array, max_buffer_size, new_element)\r\n buffer = input_array + [new_element]\r\n buffer.shift if buffer.size > max_buffer_size\r\n buffer\r\nend",
"def sample_with_replacement(sample=1)\n if @data.respond_to? :sample_with_replacement\n @data.sample_with_replacement sample\n else\n valid = indexes(*Daru::MISSING_VALUES).empty? ? self : reject_values(*Daru::MISSING_VALUES)\n vds = valid.size\n (0...sample).collect { valid[rand(vds)] }\n end\n end",
"def check_sample_rate(target, modify_parameters = {}, source_info = {})\n if modify_parameters.include?(:sample_rate)\n sample_rate = modify_parameters[:sample_rate].to_i\n\n # source_info sample_rate_hertz should match modify_parameters original_sample_rate if both are supplied\n if source_info.include?(:sample_rate) &&\n modify_parameters.key?(:original_sample_rate) &&\n source_info[:sample_rate].to_i != modify_parameters[:original_sample_rate].to_i\n raise Exceptions::InvalidSampleRateError, \"Sample rate of audio file #{source_info[:sample_rate]} \" \\\n \"not equal to given original sample rate #{modify_parameters[:original_sample_rate]}\"\n end\n\n original_sample_rate = if source_info.include?(:sample_rate)\n source_info[:sample_rate].to_i\n elsif modify_parameters.key?(:original_sample_rate)\n modify_parameters[:original_sample_rate]\n end\n\n format = File.extname(target)\n format[0] = '' #remove dot character from extension\n\n valid_sample_rates = AudioBase.valid_sample_rates(format, original_sample_rate)\n\n unless valid_sample_rates.include?(sample_rate)\n raise Exceptions::InvalidSampleRateError, \"Sample rate #{sample_rate} requested for \" \\\n \"#{format} not in #{valid_sample_rates}\"\n end\n\n end\n end",
"def reset!\n @samples_lock.synchronize do\n @last_sample = nil\n @sample_buffers.each { |sample_buffer| sample_buffer.reset! }\n end\n end",
"def reset!\n @samples_lock.synchronize do\n @last_sample = nil\n @sample_buffers.each { |sample_buffer| sample_buffer.reset! }\n end\n end",
"def rolling_buffer2(input_array, max_buffer_size, new_element)\n buffer = input_array + [new_element]\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer2(input_array, max_buffer_size, new_element)\n buffer = input_array + [new_element]\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def rolling_buffer2(input_array, max_buffer_size, new_element)\n buffer = input_array + [new_element]\n buffer.shift if buffer.size >= max_buffer_size\n buffer\nend",
"def sample?\n return true unless sampling\n sampler.sample?\n end",
"def monkey_patch_buffer!\n unless @buffer.respond_to? :buffer\n @buffer.class.send(:include, BufferUtil) \n end\n end",
"def rolling_buffer2(input_array, max_buffer_size, new_element)\n buffer = input_array + [new_element]\n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def rolling_buffer2(input_array, max_buffer_size, new_element)\n buffer = input_array + [new_element]\n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def sampled?\n span = this_span\n if span\n span.sampled\n else\n trace_options & 0x01 != 0\n end\n end",
"def update!(**args)\n @sample_errors = args[:sample_errors] if args.key?(:sample_errors)\n end",
"def should_sample?(header_obj:, recorder:, sampling_req:, **args)\n # check outside decision\n if i = header_obj.sampled\n !i.zero?\n # check sampling rules\n elsif recorder.sampling_enabled?\n recorder.sampler.sample_request?(sampling_req)\n # sample if no reason not to\n else\n true\n end\n end",
"def sample(at, value)\n @current += value\n prune_samples(at)\n @samples << [at, @current]\n save_rate(at)\n end",
"def check_datapoints_buffer\n save_datapoints if datapoints.size >= @datapoint_buffer_size\n end",
"def sample?\n raise 'Not implemented'\n end",
"def emit? line\n rand < Settings.sampling_fraction\n end",
"def fails_threshold?\n return false if sample_size < options.sample_threshold\n\n failure_rate >= options.rate_threshold\n end",
"def buffer_changed?\n @buffer_changed\n end",
"def sampled(sample_rate)\n yield unless sample_rate < 1 and rand > sample_rate\n end",
"def clean_buffer; self.input_buffer = self.input_buffer[self.input_buffer.length-4,self.input_buffer.length-1]; end",
"def silence(frames, val = 0)\n d=WaveData.new(Array.new(frames, val))\n self+d if frames > 0\n self\nend",
"def test_should_sample_evenly\n buffer = NewRelic::Agent::SampledBuffer.new(5)\n results = []\n\n 10000.times do\n buffer.reset\n 10.times { |i| buffer << i }\n results << buffer.to_a\n end\n\n (0...10).each do |v|\n num_results_including_v = results.select { |r| r.include?(v) }.size\n assert_in_delta(0.5, num_results_including_v.to_f / results.size, 0.05)\n end\n end",
"def set_hint_by_sample_data(data)\n hint = data.amrita_generate_hint\n set_hint(hint)\n end",
"def sample\n\t\t\tself[*@mask.sample]\n\t\tend",
"def <<(sample)\n self.put(sample)\n self\n end",
"def _set_buffer value #:nodoc:\n @repaint_required = true\n @datatype = value.class\n @delete_buffer = @buffer.dup\n @buffer = value.to_s.dup\n # don't allow setting of value greater than maxlen\n @buffer = @buffer[0,@maxlen] if @maxlen && @buffer.length > @maxlen\n @curpos = 0\n # hope @delete_buffer is not overwritten\n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos, self, :DELETE, 0, @delete_buffer) # 2010-09-11 13:01 \n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos, self, :INSERT, 0, @buffer) # 2010-09-11 13:01 \n self # 2011-10-2 \n end",
"def update(sample)\n now = Time.new\n elapsed = now - @time\n @sum += sample\n if elapsed > 1.0\n @value = newValue elapsed, @sum/elapsed\n @time = now\n @sum = 0.0\n end\n end",
"def sampled?\n @sampled\n end",
"def sample_length_with_overflow(tick_sample_length)\n @tracks.keys.collect {|track_name| @tracks[track_name].sample_length_with_overflow(tick_sample_length) }.max || 0\n end",
"def sample1=(sample1)\n if !sample1.nil? && sample1.to_s.length > 1024\n fail ArgumentError, 'invalid value for \"sample1\", the character length must be smaller than or equal to 1024.'\n end\n\n @sample1 = sample1\n end",
"def buffer(_distance_)\n raise Error::UnsupportedOperation, \"Method Geometry#buffer not defined.\"\n end",
"def samples; end",
"def samples; end",
"def add(arr)\n init_member(arr.count) if @sample_count == 0\n update_mean_and_r([arr])\n end",
"def can_subsample?\n if self.points < SUBSAMPLE_THRESHOLDS.min || self.subsampled\n false\n else\n # check if there are any data arrays belonging to this cluster that have a subsample threshold & annotation\n !self.find_subsampled_data_arrays.any?\n end\n end",
"def buffer_initial_length=(length)\n #This is a stub, used for indexing\n end",
"def buffered!(len=nil, buffer_name=:default, opts={}, &block)\n semaphore.synchronize {\n ret, still_to_get = buffer(buffer_name, opts[:type]).offset!(len)\n if still_to_get > 0\n src_data = Support::Utils.send_all_or_no_args(block, still_to_get)\n called_for = src_data.slice!(0, still_to_get)\n ret.concat(called_for)\n buffer(buffer_name).concat(src_data)\n end\n ret\n }\n end",
"def send\n # discard if sampling rate says so\n if @libhoney.should_drop(self.sample_rate)\n @libhoney.send_dropped_response(self, \"event dropped due to sampling\")\n return\n end\n\n self.send_presampled()\n end",
"def update(raw_data)\n if @policy_type == :buffer\n if @buffer.size != @buffer_size\n @buffer << raw_data\n end\n elsif @policy_type == :data\n @buffer = [raw_data]\n else\n raise \"port policy #{@policy_type} is not supported by #{self.class}\"\n end\n end",
"def update!(**args)\n @sample_rate = args[:sample_rate] if args.key?(:sample_rate)\n end",
"def buffer_initial_length()\n #This is a stub, used for indexing\n end",
"def send\n # discard if sampling rate says so\n if @libhoney.should_drop(sample_rate)\n @libhoney.send_dropped_response(self, 'event dropped due to sampling')\n return\n end\n\n send_presampled\n end",
"def buffer(x) \n $game_player.iframes = 30 if $game_player.iframes == 0\n unless self.input_buffer[-1]==x\n self.input_buffer << x \n end\n end",
"def sample_is?(number)\n @shot_sample == number\n end",
"def samples( nsamples, &block )\n return self.trigger( nsamples, :sample, &block )\n end",
"def convert!(new_format)\n @samples = convert_buffer(@samples, @format, new_format)\n @format = new_format\n self\n end",
"def my_array_modification_method!(source, thing_to_modify)\r\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\r\nend",
"def initialize_buffer\n @pointer = 0\n @buffer = []\n def @buffer.clear\n super\n @pointer = 0\n end\n true\n end",
"def shift_write_buffer\n @write_mutex.synchronize { @write_buffer.shift }\n end",
"def on_finish(span) # rubocop:disable Metrics/AbcSize\n return unless span.context.trace_flags.sampled?\n\n lock do\n n = spans.size + 1 - max_queue_size\n spans.shift(n) if n.positive?\n spans << span\n @condition.signal if spans.size > max_queue_size / 2\n end\n end",
"def sample2=(sample2)\n if !sample2.nil? && sample2.to_s.length > 1024\n fail ArgumentError, 'invalid value for \"sample2\", the character length must be smaller than or equal to 1024.'\n end\n\n @sample2 = sample2\n end",
"def apply_on_volume(iInputData, oOutputData, iIdxBeginSample, iIdxEndSample, iUnitDB)\n prepareFunctionUtils\n lCFunction = @FunctionUtils.createCFunction(@Function, iIdxBeginSample, iIdxEndSample)\n lIdxBufferSample = iIdxBeginSample\n iInputData.each_raw_buffer(iIdxBeginSample, iIdxEndSample) do |iInputRawBuffer, iNbrSamples, iNbrChannels|\n prepareVolumeUtils\n oOutputData.pushRawBuffer(@VolumeUtils.applyVolumeFct(lCFunction, iInputRawBuffer, iInputData.Header.NbrBitsPerSample, iInputData.Header.NbrChannels, iNbrSamples, lIdxBufferSample, iUnitDB))\n lIdxBufferSample += iNbrSamples\n end\n end",
"def subsample_thresholds_required\n SUBSAMPLE_THRESHOLDS.select {|sample| sample < self.points}\n end",
"def processSample(x)\r\n @v_n_1, @v_n_2 = @koef*@v_n_1 - @v_n_2 + x, @v_n_1\r\n @cntSamples += 1\r\n\r\n if @cntSamples == @n\r\n @cntSamples = 0\r\n \r\n return dBm(@koef, @v_n_1, @v_n_2, @n)\r\n end\r\n\r\n nil\r\n end",
"def add_samples_to_collection(samples, to_collection, add_column_wise: false)\n samples.map! do |fv|\n unless fv.is_a?(Sample)\n fv = fv.sample\n end\n fv\n end\n\n slots_left = to_collection.get_empty.length\n raise 'Not enough space in in collection' if samples.length > slots_left\n\n if add_column_wise\n add_samples_column_wise(samples, to_collection)\n else\n to_collection.add_samples(samples)\n end\n to_collection\n end",
"def buffer=(input)\n @buffer = input\n @words = nil\n end",
"def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend"
] |
[
"0.5963213",
"0.56874555",
"0.56216115",
"0.55630696",
"0.55279404",
"0.5517108",
"0.55160487",
"0.5475028",
"0.54514503",
"0.53746283",
"0.53689736",
"0.5332063",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5319155",
"0.5304861",
"0.5304861",
"0.5304861",
"0.5304861",
"0.5304861",
"0.5304861",
"0.5304861",
"0.5304861",
"0.5304861",
"0.5304861",
"0.52968204",
"0.5286655",
"0.5219137",
"0.5214442",
"0.5212885",
"0.5181506",
"0.5181506",
"0.51436913",
"0.51436913",
"0.51436913",
"0.5138477",
"0.513631",
"0.5123164",
"0.51231176",
"0.51220185",
"0.5105253",
"0.50695956",
"0.5053699",
"0.50509924",
"0.5037696",
"0.5025667",
"0.49948332",
"0.49940854",
"0.49859795",
"0.4980345",
"0.4966747",
"0.4957096",
"0.4952678",
"0.49400523",
"0.49360827",
"0.4906577",
"0.49031278",
"0.48991928",
"0.4895513",
"0.488139",
"0.48784038",
"0.48579857",
"0.48579857",
"0.48483992",
"0.48460472",
"0.48353344",
"0.48203468",
"0.4798554",
"0.478913",
"0.47883445",
"0.4786961",
"0.47722405",
"0.47661096",
"0.47635865",
"0.4759584",
"0.47346142",
"0.47163078",
"0.47009212",
"0.4700105",
"0.46958128",
"0.4685971",
"0.46812207",
"0.4679882",
"0.46781465",
"0.46779066",
"0.46652675",
"0.46535707",
"0.46535707"
] |
0.5775565
|
1
|
Make a filename from the outside safe for use as a file on our system.
|
def sanitizeFilename(fn)
fn.gsub(/[^-A-Za-z0-9_.]/, "_")[0,80]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def filesystem_safe_name\n name.\n gsub(ReservedCharacters) {|sub| '%%%02X' % sub.ord }.\n gsub(ReservedFilenameRegexp) {|sub| sub.gsub(/[^.]/) {|c| '%%%02X' % c.ord } }\n end",
"def safe_filepath\n filename.gsub!(/[\\?<>\\\\:\\*\\|\":]/, '_')\n full_path = File.join(root_path, filename)\n if(File.exists? full_path) && file_inside_root?(full_path)\n return full_path\n else\n raise 'Disallowed file requested'\n end\n end",
"def path_to_safe_filename(path)\n path = '/' if path == ''\n normalize_path(path).gsub('/', '?').gsub(/[ :]/, '_')\n end",
"def safe_filename( filename )\n ret = filename\n\n # remove commas\n ret = ret.gsub( /,/, '' )\n\n # remove colons\n ret = ret.gsub( /:/, '' )\n\n # change spaces to underscores\n ret = ret.gsub( / /, '_' )\n\n return ret\n end",
"def sanitize_filename(s)\n return '' if s.nil?\n s.chars.map{ |c| c.ord < 32 || c.ord > 126 ? '' : ([34, 42, 47, 58, 60, 62, 63, 92, 124].include?(c.ord) ? '_' : c) }.join\nend",
"def to_actual_filename!\n filename = to_actual_filename\n replace(filename) if filename\n end",
"def safe_filename(str)\n return render(str).gsub(\" \", \"_\")\n end",
"def sanitized_filename(filename)\n filename.strip.tap do |name|\n # NOTE: File.basename doesn't work right with Windows paths on Unix\n # get only the filename, not the whole path\n name.sub! /\\A.*(\\\\|\\/)/, ''\n # Finally, replace all non alphanumeric, underscore\n # or periods with underscore\n name.gsub! /[^\\w\\.\\-]/, '_'\n end\n end",
"def filename\n sanitize(original_filename) if original_filename\n end",
"def sanitize_filename\n name = self.strip\n #--- get only the filename, not the whole path\n name.gsub! /^.*(\\\\|\\/)/, ''\n\n #--- Finally, replace all non alphanumeric, underscore or periods with underscore\n name.gsub! /[^\\w\\.\\-]/, '_'\n return name\n end",
"def safe_file_name(filename)\n basename = File.basename(filename)\n all_ascii = true\n basename.each_byte do |c|\n if c>=128\n all_ascii = false\n break\n end\n end\n\n\n if(all_ascii)\n yield(filename)\n else\n new_file_name = File.dirname(filename) + '/' + (0...8).map{ ('a'..'z').to_a[rand(26)] }.join + File.extname(filename)\n FileUtils.cp(filename,new_file_name)\n yield(new_file_name)\n FileUtils.rm(new_file_name)\n end\n end",
"def sanitize_filename(filename)\n @original_filename = filename\n # TODO: replace with GenericFile?\n StashEngine::DataFile.sanitize_file_name(filename)\n end",
"def filename\n \"#{secure_token(10)}.#{file.extension}\" if original_filename.present?\n end",
"def filename\n \"#{secure_token}.#{file.extension}\" if original_filename.present? \n end",
"def sanitize_as_filename\n self.gsub(/^.*(\\\\|\\/)/, '').transliterate.downcase.gsub(/[^a-z0-9\\. ]/, ' ').strip.gsub(/[ ]+/, '-')\n end",
"def filename\n \"#{secure_token}.#{file.extension}\" if original_filename.present?\n end",
"def filename\n \"#{secure_token}.#{file.extension}\" if original_filename.present?\n end",
"def filename\n \"#{secure_token}.#{file.extension}\" if original_filename.present?\n end",
"def filename\n \"#{secure_token}.#{file.extension}\" if original_filename\n end",
"def sanitize_filename(value)\n # get only the filename, not the whole path\n just_filename = value.gsub(/^.*(\\\\|\\/)/, '')\n # Finally, replace all non alphanumeric, underscore or periods with underscore\n just_filename.gsub(/[^\\w\\.\\-]/,'_') \n end",
"def filename\n @filename = \"#{secure_token}_#{split_extension(original_filename)}.#{file.extension}\" if original_filename.present?\n end",
"def sanitize(file_name, replacement=\"_\")\n # See http://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words\n return file_name.gsub(/[\\/|\\0|\\\\\\?%\\*:\"<>]/, replacement)\n end",
"def filename\n \"#{original_filename}+#{secure_token}.#{file.extension}\" if original_filename.present?\n end",
"def sanitize_filename(filename)\n filename.strip.gsub(/[^0-9A-Za-z.\\-]|\\s/, '_')\n end",
"def sanitize_file_path(filename, base_path)\n # Resolve absolute path.\n path = File.expand_path(\"#{base_path}/#{filename}\")\n logger.info(\"Resolving file download: #{filename}\\n => #{base_path}/#{filename}\\n => #{path}\") unless logger.nil?\n\n # Deny ./../etc/passwd and friends.\n # File must exist, be readable, and not be a directory, pipe, etc.\n #logger.info \"tests: regexp #{path =~ /^#{File.expand_path(base_path)}/}\"\n #logger.info \"tests: readable #{File.readable?(path)}\"\n #logger.info \"tests: file #{File.file?(path)}\"\n raise MissingFile, \"couldn't read #{filename}\" unless\n path =~ /^#{File.expand_path(base_path)}/ and\n File.readable?(path) and\n File.file?(path)\n\n return path\n end",
"def filename_cleaner\n @options[:filename_cleaner] || FilenameCleaner.new(@options[:restricted_characters])\n end",
"def sanitize_filename(file_name)\r\n\t\tjust_filename = File.basename(file_name)\r\n\t\tjust_filename.sub(/[^\\w\\.\\-]/, '_')\r\n\tend",
"def filename\n \"#{secure_token(10)+File.extname(original_filename)}\" if original_filename.present?\n end",
"def sanitize_filename(filename)\n filename.gsub(/.*[\\/\\\\]/, '')\n end",
"def sanitize_filename(filename)\n filename.gsub(/.*[\\/\\\\]/, '')\n end",
"def sanitize_filename(filename)\n filename.gsub(/.*[\\/\\\\]/, '')\n end",
"def sanitize_filename(filename)\n filename.gsub(/.*[\\/\\\\]/, '')\n end",
"def safe_filename(id, suffix = \"\")\n filename = \"#{id}_#{Time.now.getutc}_#{suffix}\"\n filename.gsub(/\\s+/, '_').gsub(/[^0-9A-Za-z_\\.]/, '')\n end",
"def sanitize_filename(filename)\n fn = filename.split(/(?<=.)\\.(?=[^.])(?!.*\\.[^.])/m)\n fn.map! { |s| s.gsub /[^a-z0-9\\-]+/i, '_' }\n return fn.join '.'\nend",
"def filename\n @name ||= \"#{timestamp}-#{secure_token(8)}.#{file.extension}\" if original_filename.present?\n end",
"def url_safe_name\n name == '/' ? \"root-dir--#{file_type}\" : \"#{name}--#{file_type}\"\n end",
"def sanitizeForPath(str)\n # Code from (modified) http://gavinmiller.io/2016/creating-a-secure-sanitization-function/\n # Bad as defined by wikipedia:\n # https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words\n badChars = [ '/', '\\\\', '?', '%', '*', ':', '|', '\"', '<', '>', '.', ' ' ]\n badChars.each do |c|\n str.gsub!(c, '_')\n end\n str\nend",
"def file(name)\n if name.start_with?('/')\n File.new(name)\n elsif name.start_with?('~')\n File.new(name.gsub('~', \"#{ENV['HOME']}\"))\n else\n File.new(File.join(sandbox, name))\n end\n end",
"def normalize_filename\n self.filename = Pathname.normalize_path(filename)\n end",
"def safe_backup_name( filename )\n file = filename\n orig_file = filename\n index = 1\n while File.exists?(file)\n index = index + 1\n file = \"#{File.basename(orig_file, '.*')}-#{index}#{File.extname(orig_file)}\"\n end\n file\n end",
"def clean_filename\n if filename.present?\n cleaned_filename = cleaned_basename = basename.gsub(/[^a-z0-9\\-_]/i, '-')\n cleaned_filename = \"#{cleaned_basename}.#{extension.downcase}\" if extension\n self.filename = cleaned_filename\n end\n end",
"def filename\n @name ||= ActiveSupport::SecureRandom.hex\n\t\"#{@name}#{File.extname(original_filename).downcase}\" if original_filename\n end",
"def sanitizeForPath(str)\n # Code from (modified) http://gavinmiller.io/2016/creating-a-secure-sanitization-function/\n # Bad as defined by wikipedia:\n # https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words\n bad_chars = ['/', '\\\\', '?', '%', '*', ':', '|', '\"', '<', '>', '.', ' ']\n bad_chars.each do |c|\n str.gsub!(c, '_')\n end\n str\nend",
"def sanitized\n @filename.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: \"�\").strip.tr(\"\\u{202E}%$|:;/\\t\\r\\n\\\\\", \"-\")\n end",
"def proper_filename(file)\n file.gsub(/[^\\w]/,'_')\n end",
"def filename() @fn.dup end",
"def get_valid_file_name(iFileName)\n if (defined?(prohibited_file_names_chars) != nil)\n return iFileName.gsub(/[#{Regexp.escape(prohibited_file_names_chars)}]/, '_')\n else\n return iFileName\n end\n end",
"def to_filename(filename, size)\n filename.gsub! /^.*(\\\\|\\/)/, ''\n filename.gsub!(/[^0-9A-Za-z.\\-]/, '') \n filename.downcase.slice! 0..size\nend",
"def fix_filename\n unless self.filename.blank?\n self.filename.sub!(/^.*\\/([^\\/]*)$/, '\\1')\n self.filename += '.torrent' unless self.filename =~ /\\.torrent$/\n end\n end",
"def filename\n # byebug\n \"#{secure_token}.jpg\" if original_filename.present?\n end",
"def fileable\n tr(' ', '_').downcase\n end",
"def sanitize(filename)\r\n # Bad as defined by wikipedia: https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words\r\n # Also have to escape the backslash\r\n bad_chars = [ '/', '\\\\', '?', '%', '*', ':', '|', '\"', '<', '>', '.', ' ' ]\r\n bad_chars.each do |bad_char|\r\n filename.gsub!(bad_char, '_')\r\n end\r\n filename.gsub!(/[éèë]/i, 'e')\r\n filename.gsub!(/[âà]/i, 'a')\r\n filename.gsub!(/[ïìî]/i, 'i')\r\n filename.gsub!(/[ùû]/i, 'u')\r\n filename\r\nend",
"def normalize_filename\n self.name = Pathname.normalize_filename(name)\n end",
"def generate_filename(filename)\n\t\t# Just some entropy to prevent collisions... not trying\n\t\t# to protect any information.\n\t\tfilename = \"#{filename}:#{SecureRandom.hex(10)}:#{Time.now}\"\n\n\t\tdigest = Digest::SHA256.new\n\t\treturn digest.hexdigest filename\n\tend",
"def sanitize_filename(filename)\n filename.split(/\\\\|\\//)[-1]\n end",
"def sanitize(name)\n name = name.scrub\n name = name.tr(\"\\\\\", \"/\") # work-around for IE\n name = File.basename(name)\n name = name.gsub(sanitize_regexp, \"_\")\n name = \"_#{name}\" if name =~ /\\A\\.+\\z/\n name = \"unnamed\" if name.size.zero?\n name.mb_chars.to_s\n end",
"def confirm_filename(filename)\n filename.gsub!(/[<>:\"\\/\\\\|?*]/) { \"\" }\n end",
"def create_file_name(name)\r\n if name.match(/(.*)\\.([^\\.]*)/)\r\n fname, fext = $1, $2\r\n else\r\n fname, fext = name, \"dat\"\r\n end\r\n fname = fname.slugerize\r\n fext = fext.slugerize\r\n hash = Time.now.usec % 814949\r\n return \"#{hash.to_s(16)}_#{fname}.#{fext}\"\r\n end",
"def sanitize(name)\n name = name.force_encoding(Encoding::UTF_8)\n name = name.gsub(\"\\\\\", \"/\") # work-around for IE\n name = File.basename(name)\n name = name.gsub(sanitize_regexp, \"_\")\n name = \"_#{name}\" if name =~ /\\A\\.+\\z/\n name = \"unnamed\" if name.size == 0\n return name.mb_chars.to_s\n end",
"def filename(name)\n @filename = name.downcase.strip.gsub(' ', '-')\n end",
"def randomize_filename\n extension = File.extname(asset_file_name).downcase\n self.asset.instance_write(:file_name, \"#{SecureRandom.hex.first(16)}#{extension}\")\n end",
"def awful_file_name\n (((0x00..0x7f).to_a - [0x00, 0x0a, 0x2b, 0x2f]).map { |n| n.chr }).join + '.txt'\n end",
"def backup filename=@app_file_path\n require 'fileutils'\n FileUtils.cp filename, \"#{filename}.org\"\n end",
"def tmp_filename(user = current_user)\n \"#{ENCLOSURE_PATH}tmp_#{user.login}\"\n end",
"def sanitizeFilePath(path)\n path = path.gsub(/[^-a-z A-Z0-9_.\\/]/, '_').split(\"/\").map { |part|\n part.sub(/^\\.+/, '_').sub(/\\.+$/, '_')\n }.join('/')\nend",
"def filename\n if super.present?\n \"#{secure_token}.#{file.extension}\"\n end\n end",
"def randomize_file_name\n extension = File.extname(passport_file_name).downcase\n passport.instance_write(:file_name, \"deep-space#{extension}\")\n end",
"def filename\n return @filename if @filename\n name.downcase.gsub(/\\W/, '_').squeeze('_')\n end",
"def sanitize_file_name_as_name\n sanitized_name_array = name.split('.')\n sanitized_name_array.pop if sanitized_name_array.length > 1\n self.name = sanitized_name_array.join('.').tr('-_', ' ').split.map(&:capitalize)*' '\n end",
"def canonical_file\n root + FILENAME\n end",
"def file(filename)\n check_file! filename\n\n File.new(filename)\n end",
"def file_name(name)\n name.to_s.gsub(/-/, \"_\").underscore\n end",
"def fix_name(title)\n result = String.new( title )\n # Replace all invalid characters\n for substitution in $INVALID_CHARS_FOR_FILENAME\n result.gsub!(substitution[0], substitution[1])\n end\n result\nend",
"def canonicalize\n FilePath.new(File.expand_path(to_s))\n end",
"def filename(name)\n # Reemplaza letras con acentos y ñ\n filename = name.gsub('á','a').gsub('é','e').gsub('í','i').gsub('ó','o').gsub('ú','u').gsub('ñ','n').downcase\n return filename\nend",
"def tmpnam(filename)\n m = filename.match(/(X*)$/)\n \n retnam = filename.dup\n \n if m[1]\n mask = \"\"\n m[1].length.times { mask += VALID_TMPNAM_CHARS[rand(52)].chr }\n retnam.sub!(/(X*)$/, mask) \n end\n\n return retnam\n end",
"def safe_filename(info = @info)\n [track_fnum(info),\n artist_fname(info),\n track_fname(info),\n file_suffix(info)].join('.')\n end",
"def filename\n if original_filename\n uuid = UUIDTools::UUID.md5_create(UUIDTools::UUID_DNS_NAMESPACE, original_filename)\n extname = File.extname(original_filename)\n return \"#{uuid}#{extname}\"\n end\n end",
"def generate_file_name\n file_name = attachment.instance_read(:file_name).slugged_filename\n attachment.instance_write :file_name, file_name\n end",
"def original_filename; end",
"def filepath(filename)\n path = Pathname.new(\"#{filename}.#{@format}\")\n if @dir\n Dir.mkdir(@dir) unless Dir.exist?(@dir)\n path = Pathname.new(@dir) + path\n end\n\n path.to_s\n end",
"def full_filename_fu(filename)\n version_prefix = \"#{version_name}_\"\n filename = filename.gsub(version_prefix, \"\")\n ext = nil\n basename = filename.gsub /\\.\\w+$/ do |s|\n ext = s; ''\n end\n \"#{basename}_#{version_name}#{ext}\"\n end",
"def busted?(filename)\n f = File.basename(filename)\n /\\A(.*\\/)?[a-z0-9]{6}_[a-zA-Z0-9\\-_]+\\.[a-zA-Z0-9]+\\z/.match?(f)\n end",
"def clean_filename(filename)\n valid_filename_regexp = /[\\s+\\\\\\/*?:\\\"<>|]/\n filename.gsub(valid_filename_regexp, '')\n end",
"def file_name\n # file = full_name\n # file = file.gsub('::', '/')\n # file = file.gsub('#' , '/')\n # file = file.gsub('.' , '-')\n # #file = File.join(output, file + '.html')\n # file\n WebRI.entry_to_path(full_name)\n end",
"def filename\n if original_filename\n \"#{model.name.parameterize}-#{secure_token(8)}.#{file.extension}\"\n end\n end",
"def filename\n original_filename.try(:gsub, '+', '-')\n end",
"def make_filename(filename)\n ### Making the filename\n bname=File.basename(filename,\".xml\")\n dname=File.dirname(filename)\n part=Array.new\n part=dname.split(\"/\")\n tmp1=String.new\n if (!(part.empty?)) then \n part.each{|ex| if (ex=~/^[0-9]/) then tmp1=ex end}\n end\n if (!(tmp1.empty?)) then \n newfilename=bname+\"_\"+tmp1\n else \n newfilename = bname\n end\n return newfilename\n end",
"def filename\n \"#{secure_token}.mp4\" if original_filename.present?\n end",
"def prepare_filename(candidate=filename)\n candidate\n end",
"def filename\n if original_filename.present?\n \"#{model.story.slug}-#{secure_token}.#{file.extension}\"\n end\n end",
"def get_correct_name(file_name, user_address)\n ext = File.extname(file_name) # get file extension\n base_name = File.basename(file_name, ext) # get file name without extension\n name = base_name + ext.downcase # get full file name\n index = 1\n\n while File.exist?(storage_path(name, user_address)) # if the file with such a name already exists in this directory\n name = base_name + ' (' + index.to_s + ')' + ext.downcase # add an index after its base name\n index = index + 1\n end\n\n name\n end",
"def clean_filename\n doc_file_name.gsub!(' ', '_')\n end",
"def filename=(value)\n @old_filename = full_filename unless filename.nil? or @old_filename\n write_attribute :filename, sanitize_filename(value)\n end",
"def fit_to_filesystem(candidate)\n return candidate if candidate.bytesize <= MIN_PATH_MAX\n ext = File.extname(candidate)\n base = File.basename(candidate, ext)\n tmp = Dir.tmpdir\n loop do\n begin\n candidate = base + ext\n try_file = File.join(tmp, candidate)\n FileUtils.touch try_file\n FileUtils.rm try_file\n return candidate\n rescue Errno::ENAMETOOLONG\n if base.length > 0\n base.chop!\n retry\n else\n raise\n end\n end\n end\n end",
"def get_file_path(filename)\n File.join(__dir__, filename).freeze\n end",
"def display_filename\n filename = self._internal_display_filename\n\n # Sometimes filenames have e.g. %20 in - no point butchering that\n # (without unescaping it, this would remove the % and leave 20s in there)\n filename = CGI.unescape(filename)\n\n # Remove weird spaces\n filename = filename.gsub(/\\s+/, \" \")\n # Remove non-alphabetic characters\n filename = filename.gsub(/[^A-Za-z0-9.]/, \" \")\n # Remove spaces near dots\n filename = filename.gsub(/\\s*\\.\\s*/, \".\")\n # Compress adjacent spaces down to a single one\n filename = filename.gsub(/\\s+/, \" \")\n filename = filename.strip\n\n return filename\n end",
"def file_name(s)\n s.gsub(/[\\s\\\\\\/]/, '_')\n end",
"def temp_file_from_name(file_name)\n File.join(@temp_dir, file_name).to_s\n end",
"def save filename = nil\n filename = find_free_name filename\n save! filename\n end"
] |
[
"0.7398633",
"0.70158803",
"0.6917455",
"0.6733096",
"0.67037296",
"0.6700798",
"0.6695681",
"0.6695257",
"0.666186",
"0.6641997",
"0.6637534",
"0.6609923",
"0.6583505",
"0.65704876",
"0.6535614",
"0.65172595",
"0.65172595",
"0.65172595",
"0.651545",
"0.65094024",
"0.6450596",
"0.6431418",
"0.6408747",
"0.63663524",
"0.6363584",
"0.6325807",
"0.63009375",
"0.62974304",
"0.6255008",
"0.6255008",
"0.6255008",
"0.6255008",
"0.62473196",
"0.62214077",
"0.61856395",
"0.61770517",
"0.6160678",
"0.6145673",
"0.6139205",
"0.6135294",
"0.6133512",
"0.6120049",
"0.61134005",
"0.6110042",
"0.610163",
"0.6098903",
"0.6092335",
"0.6087304",
"0.6086289",
"0.608517",
"0.6073693",
"0.60732967",
"0.6045471",
"0.6036136",
"0.6021944",
"0.60017604",
"0.5996494",
"0.59826875",
"0.5979429",
"0.5976785",
"0.59682477",
"0.59661645",
"0.5955283",
"0.5952458",
"0.5942418",
"0.59381175",
"0.5910217",
"0.5908494",
"0.5901487",
"0.5899148",
"0.5896246",
"0.58948946",
"0.588155",
"0.587439",
"0.5870343",
"0.5868446",
"0.58666617",
"0.58604556",
"0.5851965",
"0.58391637",
"0.58126676",
"0.58059204",
"0.5800827",
"0.5776875",
"0.57626384",
"0.5762116",
"0.57603794",
"0.5759661",
"0.5753485",
"0.57450527",
"0.5744355",
"0.5741408",
"0.57365054",
"0.5727603",
"0.5723223",
"0.57228124",
"0.5720857",
"0.57192963",
"0.57173693",
"0.5713695"
] |
0.65287256
|
15
|
Take a DepositItemInput and make a UCI record out of it. Note that if you pass existing UCI data in, it will be retained if Elements doesn't override it. NOTE: UCI in this context means "UC Ingest" format, the internal metadata format for eScholarship.
|
def uciFromInput(input, ark)
uci = Nokogiri::XML("<uci:record xmlns:uci='http://www.cdlib.org/ucingest'/>").root
# Top-level attributes
uci[:id] = ark.sub(%r{ark:/?13030/}, '')
uci[:dateStamp] = DateTime.now.iso8601
uci[:peerReview] = input['isPeerReviewed'] ? "yes" : "no"
uci[:state] = 'new'
uci[:stateDate] = DateTime.now.iso8601
input[:type] and uci[:type] = convertPubType(input[:type])
input[:pubRelation] and uci[:pubStatus] = convertPubRelation(input[:pubRelation])
input[:contentVersion] and uci[:externalPubVersion] = convertFileVersion(input[:contentVersion])
input[:embargoExpires] and uci[:embargoDate] = input[:embargoExpires]
# Special pseudo-field to record feed metadata link
input[:sourceFeedLink] and uci.find!('feedLink').content = input[:sourceFeedLink]
# Author and editor metadata.
input[:authors] and transformPeople(uci, "author", input[:authors])
if input[:contributors]
transformPeople(uci, "editor", input[:contributors].select { |contr| contr[:role] == 'EDITOR' })
transformPeople(uci, "advisor", input[:contributors].select { |contr| contr[:role] == 'ADVISOR' })
end
# Other top-level fields
input[:sourceName] and uci.find!('source').content = input[:sourceName].sub("elements", "oa_harvester")
uci.find!('title').content = input[:title]
input[:abstract] and uci.find!('abstract').content = input[:abstract]
(input[:fpage] || input[:lpage]) and convertExtent(uci, input)
input[:keywords] and convertKeywords(uci, input[:keywords])
uci.find!('rights').content = convertRights(input[:rights])
input[:grants] and convertFunding(uci, input[:grants])
uci.find!('customCitation').content = input[:customCitation]
# Things that go inside <context>
contextEl = uci.find! 'context'
contextEl.build { |xml|
input[:units] and assignSeries(xml, input[:units])
input[:localIDs] and convertLocalIDs(uci, xml, input[:localIDs]) # also fills in top-level doi field
input[:issn] and xml.issn(input[:issn])
input[:isbn] and xml.isbn(input[:isbn]) # for books and chapters
input[:journal] and xml.journal(input[:journal])
input[:proceedings] and xml.proceedings(input[:proceedings])
input[:volume] and xml.volume(input[:volume])
input[:issue] and xml.issue(input[:issue])
input[:issueTitle] and xml.issueTitle(input[:issueTitle])
input[:issueDate] and xml.issueDate(input[:issueDate])
input[:issueDescription] and xml.issueDescription(input[:issueDescription])
input[:issueCoverCaption] and xml.issueCoverCaption(input[:issueCoverCaption])
input[:sectionHeader] and xml.sectionHeader(input[:sectionHeader])
input[:orderInSection] and xml.publicationOrder(input[:orderInSection])
input[:bookTitle] and xml.bookTitle(input[:bookTitle]) # for chapters
input[:externalLinks] and convertExtLinks(xml, input[:externalLinks])
input[:ucpmsPubType] and xml.ucpmsPubType(input[:ucpmsPubType])
input[:dateSubmitted] and xml.dateSubmitted(input[:dateSubmitted])
input[:dateAccepted] and xml.dateAccepted(input[:dateAccepted])
input[:datePublished] and xml.datePublished(input[:datePublished])
}
# Content and supp files
if input[:contentLink] || input[:suppFiles]
uci.find!('content').build { |xml|
input[:contentLink] and addContent(xml, input)
(input[:suppFiles] or input[:dataAvailability]) and addSuppFiles(xml, input)
}
end
# Things that go inside <history>
history = uci.find! 'history'
input[:sourceName] and history[:origin] = input[:sourceName].sub("elements", "oa_harvester")
history.at("escholPublicationDate") or history.find!('escholPublicationDate').content = Date.today.iso8601
history.at("submissionDate") or history.find!('submissionDate').content = Date.today.iso8601
history.find!('originalPublicationDate').content = input[:published]
# All done.
return uci
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def upc\n upc_code = params[:upc]\n redirect_to root_url, alert: 'Not a valid UPC' and return unless upc_code\n @item = Item.code_find_or_create_by(upc_code)\n redirect_to root_url, alert: 'No product matches found' and return unless @item.errors.empty?\n redirect_to add_item_to_cart_path(@item.id) and return\n end",
"def add_to_base(item)\n info = validate_article(item)\n\n return unless info\n\n arti_author = item.author.delete(\"\\n\")\n unless add_author = Author.find_by(name: arti_author)\n add_author = Author.create(name: arti_author)\n end\n final = Article.new(author: add_author,\n title: item.title.delete(\"\\n\"),\n source: Source.find_by(name: TeRssImporter.source_name),\n summary: info[1],\n image: nil,\n link: item.link,\n date_of_publication: info[0])\n\n return unless final.save\n add_tags(final, %w(business finance economist))\n end",
"def create_line_item_from_inventory_item inventory_item, qty, payable_party, billable_party, include_price_in_expense, include_price_in_revenue, notes\n\n [\n # Vendor\n LineItem.create(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Item\",\n :sku => inventory_item.sku, :name => inventory_item.name_vendor, :quantity => qty,\n :unit_price_expense => inventory_item.cogs,\n :tax_rate_expense => 0,\n :payable_party => payable_party,\n :include_price_in_expense => include_price_in_expense,\n :inventory_item => inventory_item, :notes => notes),\n\n # Account\n LineItem.create(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Item\",\n :sku => inventory_item.sku, :name => inventory_item.name_public, :quantity => qty,\n :unit_price_revenue => calculate_sell_price_from_inventory_item(inventory_item),\n :billable_party => billable_party,\n :include_price_in_revenue => include_price_in_revenue,\n :inventory_item => inventory_item, :notes => notes)\n ]\n end",
"def citeproc_item\n item = CiteProc::Item.new(id: @doc.uid, type: 'article-journal')\n\n unless @doc.authors.empty?\n item.author = CiteProc::Names.new\n @doc.authors.each do |a|\n item.author << CiteProc::Name.new(a.citeproc)\n end\n end\n\n item.title = @doc.title if @doc.title\n item.container_title = @doc.journal if @doc.journal\n item.issued = CiteProc::Date.new(Integer(@doc.year)) if @doc.year\n item.volume = @doc.volume if @doc.volume\n item.issue = @doc.number if @doc.number\n item.page = @doc.pages if @doc.pages\n\n item\n end",
"def add_to_base(item)\n info = validate_article(item)\n\n return unless info\n\n arti_author = item.author.delete(\"\\n\")\n unless add_author = Author.find_by(name: arti_author)\n add_author = Author.create(name: arti_author)\n end\n final = Article.new(author: add_author,\n title: item.title.delete(\"\\n\"),\n source: Source.find_by(name: BbRssImporter.source_name),\n summary: item.description.delete(\"\\n\"),\n image: info[1],\n link: item.link,\n date_of_publication: info[0])\n\n return unless final.save\n add_tags(final, [item.category.content.delete(' '), 'music', 'billboard'])\n end",
"def create_line_item_from_inventory_item inventory_item, qty, payable_party, billable_party, include_price_in_expense, include_price_in_revenue, notes\n # Vendor\n l1 = LineItem.create!(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Item\",\n :sku => inventory_item.sku, :name => inventory_item.name_vendor, :quantity => qty,\n :unit_price_expense => inventory_item.cogs,\n :tax_rate_expense => 0,\n :payable_party => payable_party,\n :include_price_in_expense => include_price_in_expense,\n :inventory_item => inventory_item, :notes => notes, :event => self)\n\n # Account\n l2 = LineItem.create!(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Item\",\n :sku => inventory_item.sku, :name => inventory_item.name_public, :quantity => qty,\n :unit_price_revenue => calculate_sell_price_from_inventory_item(inventory_item),\n :billable_party => billable_party,\n :include_price_in_revenue => include_price_in_revenue,\n :inventory_item => inventory_item, :notes => notes, :event => self)\n\n l1.opposing_line_item = l2\n l2.opposing_line_item = l1\n l1.save\n l2.save\n\n [l1, l2]\n end",
"def create\n @item = Item.new(item_params)\n vendor = Vendor.find(item_params[:vendor_id])\n @item.build_vendor(:id => vendor.id)\n @item.save!\n @current_item = @item\n @items = Item.all\n end",
"def item\n IITEncoder.new(@ole.Item)\n end",
"def create\n @item = Item.new(item_params)\n @item.department_id = current_user.department_id\n if item_params[:tagid].upcase.strip == \"AUTO\"\n @item.tagid = Item.tagid(item_params[:category_id], item_params[:sub_category_id], item_params[:purchased_at_date])\n end\n @item.tagid = @item.tagid.upcase\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def scan(item)\n items << CheckoutItem.new(item)\n end",
"def create\n if params[:item].present?\n # TODO - see impact\n @item = Item.new(params[:item])\n @item.user_id = current_user.id if current_user.present?\n\n # TODO Commented shipping information because of REQUIREMENT CHANGE (https://www.pivotaltracker.com/story/show/62299176)\n \n # @item.bring_it_to_you = params[:item][:bring_it_to_you] if params[:item][:bring_it_to_you].present?\n # @item.come_and_get_it = params[:item][:come_and_get_it] if params[:item][:come_and_get_it].present?\n # @item.lets_meet_up = params[:item][:lets_meet_up] if params[:item][:lets_meet_up].present?\n # @item.come_to_you = params[:item][:come_to_you] if params[:item][:come_to_you].present?\n # @item.come_to_me = params[:item][:come_to_me] if params[:item][:come_to_me].present?\n # @item.done_remotely = params[:item][:done_remotely] if params[:item][:done_remotely].present?\n # @item.ship_it = params[:item][:ship_it] if params[:item][:ship_it].present?\n # @item.lets_meet_service = params[:item][:lets_meet_service] if params[:item][:lets_meet_service]\n\n if @item.user.nil? and params[:user_id] and params[:user_id] != ''\n @item.user_id = params[:user_id]\n end\n if not @item.user_id.present? and session[:guest_user_id].to_i > 0\n @item.user_id = session[:guest_user_id].to_i\n end\n # if params[:multi_trade] and params[:multi_trade] == \"on\"\n # @item.is_single_tradeya = false\n # end\n if params[:item][:tod_id].blank?\n @item.exp_date = Item.get_expiry_date_for_tod\n @item.status = \"LIVE\"\n else\n @item.tod = false\n @item.status = \"ACTIVE\"\n end\n respond_to do |format|\n if ((params[:captcha] and params[:item][:tod_id]) or params[:item][:tod_id].nil?) and not @item.user_id.blank?\n if @item.desc == \"Add more details about your good or service here...\" then @item.desc = \"\" end\n if @item.save\n\n # sbx tracking pixel fire\n if current_user.tracking_infos.where(affiliate:'sbx').present?\n Resque.enqueue(FireTrackingPixelJob, current_user.id, 'post')\n end\n\n chk = false\n # Case 1 - Old Offer - edit\n\n # Case 2 - New Tradeya/Offer but item selected from dropdown\n if params[:item][:selected_item_id].to_i > 0 or params[:item][:have].to_i > 0\n create_new = true\n # Create new record for item photos\n end\n # Case 3 - New Tradeya/Offer\n if params[:item_photos].present?\n photos = JSON.parse(params[:item_photos])\n if photos and photos.count > 0\n photos.each_with_index do |photo,index|\n existing_ph = ItemPhoto.find(photo[\"id\"])\n if create_new and existing_ph.item_id.present?\n ph = ItemPhoto.new\n ph.photo = existing_ph.photo\n ph.width = existing_ph.width; ph.height = existing_ph.height;\n ph.crop_x = existing_ph.crop_x; ph.crop_y = existing_ph.crop_y;\n ph.crop_w = existing_ph.crop_w; ph.crop_h = existing_ph.crop_h;\n else\n ph = existing_ph\n end\n if ph.present?\n ph.item_id = @item.id\n if index == 0\n ph.main_photo = true\n end\n ph.save\n chk = true\n end\n end\n end\n end\n if params[:item_videos].present?\n videos = JSON.parse(params[:item_videos])\n if videos and videos.count > 0\n videos.each do |video|\n existing_vi = ItemVideo.find(video[\"id\"])\n if create_new and existing_vi.item_id.present?\n vi = ItemVideo.new\n vi.video = existing_vi.vi\n else\n vi = existing_vi\n end\n if vi.present?\n vi.item_id = @item.id\n vi.save\n chk = true\n end\n end\n end\n end\n # TODO - read below and make it like below\n\n # if params[:file_type] == \"photo\"\n # if params[:item][:item_photo] and params[:item][:item_photo][:id] and params[:item][:item_photo][:id].to_i > 0\n # ip = ItemPhoto.find(params[:item][:item_photo][:id])\n # ip.item_id = @item.id\n # ip.save\n # chk = true\n # elsif params[:item][:item_photo]\n # if params[:item][:item_photo][:photo]\n # o = ItemPhoto.new(params[:item][:item_photo])\n # o.item_id = @item.id\n # o.save\n # chk = true\n # end\n # end\n # elsif params[:file_type] == \"video\"\n # if params[:item][:item_video] and params[:item][:item_video][:id] and params[:item][:item_video][:id].to_i > 0\n # o = ItemVideo.find(params[:item][:item_video][:id])\n # o.item_id = @item.id\n # o.save\n # chk = true\n # elsif params[:item][:item_video]\n # if params[:item][:item_video][:video]\n # o = ItemVideo.new(params[:item][:item_video])\n # o.item_id = @item.id\n # o.save\n # chk = true\n # end\n # end\n # end\n\n if not chk and params[:item][:selected_item_id].to_i > 0\n itm = Item.find(params[:item][:selected_item_id])\n if itm.item_videos and itm.item_videos.count > 0\n o = ItemVideo.new\n if File.exist?(itm.item_videos[0].video.path)\n o.video = File.open(itm.item_videos[0].video.path)\n else\n o.video_from_url(itm.item_videos[0].video.url)\n end\n o.item_id = @item.id\n o.save\n elsif itm.item_photos and itm.item_photos.count > 0\n o = ItemPhoto.new\n if File.exist?(itm.item_photos[0].photo.path)\n o.photo = File.open(itm.item_photos[0].photo.path)\n else\n o.photo_from_url(itm.item_photos[0].photo.url)\n end\n o.item_id = @item.id\n o.save\n end\n end\n\n # if params[:item_wants] and params[:item_wants].present?\n # os = JSON.parse(params[:item_wants])\n # os.each do |iwa|\n # o = ItemWant.new\n # o.title = iwa[0]\n # o.category_id = iwa[1]\n # o.desc = iwa[2]\n # o.item = @item\n # o.user = current_user\n # o.save\n # end\n # end\n if params[:item][:have].present?\n Have.create(:item_id => params[:item][:have].to_i,:user_id => current_user.id )\n end\n\n flash[:notice] = \"item created\"\n # Send mail when item created\n if (InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins)\n if (@item.user.items.count == 1)\n ItemMailer.item_added_first(@item.id,@item.user.id).deliver\n elsif (@item.user.items.count < 6)\n ItemMailer.item_added(@item.id,@item.user.id).deliver\n end\n # Activity Feed\n @item.create_activity key: @item.id, owner: @item.user, recipient: @item.user\n end\n\n\n if params[:item][:tod_id] # check if the request is coming from an offer or just item\n trade = Trade.new(:item_id => params[:item][:tod_id].to_i, :offer_id => @item.id, :status => 'ACTIVE')\n trade.save!\n if params[:item][:tod] and params[:item][:tod] == \"1\"\n offer_as_tod = Item.new\n offer_as_tod.title = @item.title\n offer_as_tod.desc = @item.desc\n offer_as_tod.tod = true\n offer_as_tod.exp_date = Item.get_expiry_date_for_tod\n offer_as_tod.category_id = @item.category_id\n offer_as_tod.user_id = @item.user_id\n offer_as_tod.status = 'INCOMPLETE'\n offer_as_tod.is_single_tradeya = @item.is_single_tradeya\n if offer_as_tod.save\n session[:offer_as_tod] = offer_as_tod.id\n chk = false\n if params[:file_type] == \"photo\"\n if params[:item][:item_photo]\n if params[:item][:item_photo] and params[:item][:item_photo][:id] and params[:item][:item_photo][:id].to_i > 0\n ip = ItemPhoto.find(params[:item][:item_photo][:id])\n o = ItemPhoto.new\n if File.exist?(ip.photo.path)\n o.photo = File.open(ip.photo.path)\n else\n o.photo_from_url(ip.photo.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n elsif params[:item][:item_photo]\n if params[:item][:item_photo][:photo]\n o = ItemPhoto.new(params[:item][:item_photo])\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n end\n end\n end\n elsif params[:file_type] == \"video\"\n if params[:item][:item_video] and params[:item][:item_video][:id] and params[:item][:item_video][:id].to_i > 0\n iv = ItemVideo.find(params[:item][:item_video][:id])\n o = ItemVideo.new\n if File.exist?(iv.video.path)\n o.video = File.open(iv.video.path)\n else\n o.video_from_url(iv.video.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n elsif params[:item][:item_video]\n if params[:item][:item_video][:video]\n o = ItemVideo.new(params[:item][:item_video])\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n end\n end\n end\n\n if not chk and params[:archive_id].present?\n o = ItemVideo.new\n o.video_from_url(@url)\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n end\n\n if not chk and params[:item][:selected_item_id].to_i > 0\n itm = Item.find(params[:item][:selected_item_id])\n if itm.item_videos and itm.item_videos.count > 0\n o = ItemVideo.new\n if File.exist?(itm.item_videos[0].video.path)\n o.video = File.open(itm.item_videos[0].video.path)\n else\n o.video_from_url(itm.item_videos[0].video.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n else\n o = ItemPhoto.new\n if File.exist?(itm.item_photos[0].photo.path)\n o.photo = File.open(itm.item_photos[0].photo.path)\n else\n o.photo_from_url(itm.item_photos[0].photo.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n end\n end\n if session[:guest_user_id].to_i > 0\n session[:guest_offer_as_tod] = true\n end\n end\n else\n session[:guest_user_id] = nil\n session[:is_guest_user] = nil\n end\n\n # Alert.add_2_alert_q(ALERT_TYPE_TRADEYA, NEW_OFFER_ON_TRADEYA, trade.item.user.id, nil, trade.id)\n\n # if InfoAndSetting.sm_on_o_made then EventNotificationMailer.offer_is_made(trade).deliver end\n if InfoAndSetting.sm_on_o_made and trade.item.user.notify_received_offer then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_OFFER_MADE, trade.item.user.id, {:trade_id => trade.id}) end\n # if InfoAndSetting.sm_on_trd_live and params[:item][:tod] == '1' then EventNotificationMailer.tradeya_is_live(@item).deliver end\n # if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins?(MAIL) and params[:item][:tod] == '1' then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n #if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins and params[:item][:tod] == '1' then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n\n # if offer is submitted from new offer flow, id and title of offer is needed\n if params[:new_offer_flow].present? and params[:item][:is_tod].present? and (params[:item][:is_tod] == 'false') and current_user\n session[:new_offer_title] = @item.title\n session[:new_offer_id] = @item.id\n else\n session[:item_saved_offer] = true\n end\n finished(\"make_offer_form\")\n # if current_user and !current_user.showed_onboarding\n # format.html { redirect_to profile_url }\n # else\n format.html { redirect_to item_path(Item.find(params[:item][:tod_id])) }\n # end\n else\n session[:guest_user_id] = nil\n session[:is_guest_user] = nil\n # Alert.add_2_alert_q(ALERT_TYPE_TRADEYA, TRADEYA_LIVE, @item.user.id, @item.id)\n\n # if InfoAndSetting.sm_on_trd_live then EventNotificationMailer.tradeya_is_live(@item).deliver end\n # if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins?(MAIL) then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n #if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n\n # if not session[:ipad_mini_contest].nil? and session[:ipad_mini_contest] = 5\n # format.html{ redirect_to contest_url}\n # else\n\n if params[:item][:offer_for]\n if params[:item][:offer_for].include? \"?\"\n format.html { redirect_to my_offers_item_path(Item.find(params[:item][:offer_for]))+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html { redirect_to my_offers_item_path(Item.find(params[:item][:offer_for]))+ \"?item_saved=\" + @item.id.to_s}\n end\n elsif params[:item][:referer_page]\n session[:have_saved] = params[:item][:referer_page]\n if params[:item][:referer_page].include? \"?\"\n format.html {redirect_to params[:item][:referer_page]+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html {redirect_to params[:item][:referer_page]+ \"?item_saved=\" + @item.id.to_s}\n end\n elsif params[:item][:have_add_page]\n if params[:item][:have_add_page].include? \"?\"\n format.html {redirect_to params[:item][:have_add_page]+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html {redirect_to params[:item][:have_add_page]+ \"?item_saved=\" + @item.id.to_s}\n end\n elsif params[:item][:referer_browse_page]\n if params[:item][:referer_browse_page].include? \"?\"\n format.html {redirect_to params[:item][:referer_browse_page]+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html {redirect_to params[:item][:referer_browse_page]+ \"?item_saved=\" + @item.id.to_s}\n end\n else\n # session[:item_saved] = {:title => @item.title, :url => item_path(@item)}\n format.html { redirect_to new_item_path + \"?item_saved=\" + @item.id.to_s }\n end\n # format.html { redirect_to @item.item_url }\n # end\n end\n else\n format.html { redirect_to new_item_path }\n end\n else\n if params[:item][:tod_id]\n format.html { redirect_to item_path(Item.find(params[:item][:tod_id])) }\n else\n format.html { redirect_to new_item_path }\n end\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to new_item_path }\n end\n end\n end",
"def set_item(item_id, item_description, quantity, \n item_unit_cost_base, item_unit_cost, \n product_deposit_unit_cost,\n category_supplement_1_unit_cost,\n category_supplement_2_unit_cost,\n category_supplement_3_unit_cost)\n\n transaction do\n # Updates the item\n self.item_id = item_id\n self.item_description = item_description\n if product = ::Yito::Model::Booking::BookingCategory.get(item_id)\n product_customer_translation = product.translate(shopping_cart.customer_language)\n self.item_description_customer_translation = (product_customer_translation.nil? ? item_description : product_customer_translation.name)\n else\n self.item_description_customer_translation = item_description\n end\n # Update the quantity\n self.update_quantity(quantity)\n # Update the cost\n self.update_item_cost(item_unit_cost_base, \n item_unit_cost, \n product_deposit_unit_cost,\n category_supplement_1_unit_cost,\n category_supplement_2_unit_cost,\n category_supplement_3_unit_cost)\n end\n\n end",
"def create_item(index)\n item = @data[index]\n rect = item_rect(index, true)\n \n ucItem = UCItem.new(self, item, rect)\n ucItem.active = enable?(item)\n \n if $game_party.newest_items.include?(item)\n ucItem.cItemName.font.color = Color.new_item_color\n ucItem.cItemNumber.font.color = Color.new_item_color\n end\n \n return ucItem\n end",
"def add_to_base(item)\n info = validate_article(item)\n\n return unless info\n arti_author = item.source.content.delete(\"\\n\")\n unless add_author = Author.find_by(name: arti_author)\n add_author = Author.create(name: arti_author)\n end\n final = Article.new(author: add_author,\n title: item.title.delete(\"\\n\"),\n source: Source.find_by(name: HsRssImporter.source_name),\n summary: item.description.delete(\"\\n\"),\n image: info[1],\n link: item.link,\n date_of_publication: info[0])\n return unless final.save\n add_tags(final, 'breaking')\n end",
"def set_consumable_item\n @consumable_item = ConsumableItem.find(params[:id])\n end",
"def updateInvoiceItem(invItem, projectId, description, rate, quantity, currency)\n\t\tinvItem.project_id = projectId\n\t\tinvItem.name = description\n\t\tinvItem.rate = rate\n\t\tinvItem.currency = currency\n\t\tinvItem.quantity = quantity\n\t\tinvItem.amount = invItem.rate * invItem.quantity\n\t\tinvItem.modifier_id = User.current.id\n\t\tinvItem.save()\n\t\tinvItem\n\tend",
"def add_item_cmd\n puts(\"upc: \")\n upc = gets.chomp\n puts(\"number: \")\n number = gets.chomp.to_i\n new_item(upc, number)\n end",
"def add_item_cmd\n puts(\"upc: \")\n upc = gets.chomp\n puts(\"number: \")\n number = gets.chomp.to_i\n new_item(upc, number)\n end",
"def create_pre_invoice_item(tariff, pre_invoice_id, subcode, price, quantity, measure, tax_type_id, discount_pct, user_id, d)\n PreInvoiceItem.create(\n pre_invoice_id: pre_invoice_id,\n code: tariff.try(:billable_item).try(:billable_concept).try(:code),\n description: d + tariff.try(:billable_item).try(:billable_concept).try(:name),\n tariff_id: tariff.id,\n price: price,\n quantity: quantity,\n tax_type_id: tax_type_id,\n discount_pct: discount_pct,\n discount: 0.0,\n product_id: nil,\n subcode: subcode,\n measure_id: measure,\n created_by: user_id)\n end",
"def create_item(fund_hash)\n item = Hash.new\n puts \"Please enter item [name]\"\n item_name = gets.chomp\n item[:name] = item_name\n system('cls')\n\n puts \"Please enter item [description]\"\n item_description = gets.chomp\n item[:description] = item_description\n system('cls')\n\n # Here the block of code will insure the user enters numbers using techniques from regular expressions (regex)\n item_target = 0\n loop do\n puts \"Please enter item [target]\"\n input_target = gets.chomp\n if input_target.to_i.to_s != input_target\n system(\"clear\")\n puts \"Please input numbers only!\"\n sleep(2)\n system(\"clear\")\n else\n item_target = input_target.to_i\n break\n end\n end\n\n item[:target] = item_target\n system('cls')\n item_balance = 0\n item[:balance] = item_balance\n\n item_percentage = item_balance / (item_target / 100.0)\n item[:percentage] = item_percentage\n\n puts \"Please enter item importance [1 = low] [10 = high]\"\n item_importance = gets.chomp.to_i\n item[:importance] = item_importance\n\n item[:balance] = 0;\n\n fund_hash[:list].push(item)\n\n # This is the method to get the items individual balance\n update_all_items_formula(fund_hash[:list])\n write_fund_hash(fund_hash)\n\n system('cls')\n return fund_hash\n end",
"def item_create\n @brief = Brief.find(params[:brief_id])\n @brief_vendor = @brief.brief_vendors.find_by_org_id(@cur_user.org_id)\n invalid_op unless @brief_vendor\n @brief_vendor.items << Item.new(params[:item]){|r|r.kind = params[:kind]}\n redirect_to vendor_show_brief_path(@brief)\n end",
"def input(inputItem)\n @input = inputItem\n end",
"def create\n @user = User.find_by(id: params[:user_id])\n @outfit = Outfit.new(outfit_params)\n # @outfit.items <<\n @outfit.user_id = @user.id\n respond_to do |format|\n if @outfit.save\n format.html { redirect_to user_outfits_path, notice: 'Outfit was successfully saved.' }\n format.json { render :show, status: :created, location: @outfit }\n else\n format.html { render :new }\n format.json { render json: @outfit.errors, status: :unprocessable_entity }\n end\n end\n # set all the stuff in cameo where the the outfit_id = nil to be this new id\n Cameo.all.where(outfit_id: nil).update_all(\"outfit_id\" => @outfit.id)\n end",
"def ict3_params\n params.require(:ict3).permit(:Item, :Total, :Coverage_in_percentage)\n end",
"def create\n @item = Item.new(item_params)\n @item.image_url='receipt.jpg'\n puts current_account.accountable_id\n puts current_account.id\n if current_account && current_account.accountable_type == \"Employee\"\n @item.employee = current_account.accountable\n \n \n @item = @cart.add_item(@item)\n respond_to do |format|\n if @item.save\n format.html { redirect_to( company_index_path) }\n @item.update(employee_id: current_account.accountable_id)\n @item.update(actual_expense_date: item_params[:actual_expense_date])\n @item.update(amount: item_params[:amount])\n @item.update(expense_type: item_params[:expense_type])\n\n if item_params[:department] == \"QA\"\n @item.update(department: 1)\n elsif item_params[:department] == \"RnD\"\n @item.update(department: 2)\n else\n @item.update(department: 3)\n end\n\n if item_params[:expense_type] == 'Travel'\n @item.update(expense_type: \"Travel\")\n puts \"\\nTravel\\n\"\n elsif item_params[:expense_type] == 'Taxi'\n @item.update(expense_type: \"Taxi\")\n puts \"\\nTaxi\\n\"\n elsif item_params[:expense_type] == 'Lodging'\n @item.update(expense_type: \"Lodging\")\n puts \"\\nLodging\\n\"\n elsif item_params[:expense_type] == 'Food'\n @item.update(expense_type: \"Food\")\n puts \"\\nFood\\n\"\n else\n @item.update(expense_type: \"Other\")\n puts \"\\nOther\\n\\n\"\n end\n \n\n else\n format.html { render :new }\n format.json { render json: @taf_item.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create_item(iid, itypes, params={})\n params.merge!(default_params)\n params['pio_iid'] = iid\n format_itypes(itypes, params)\n extract_latlng(params)\n extract_startend(params)\n @connection.post(:items, params).body\n end",
"def purchase_item_params\n params.require(:item).permit(:item, :denomination, :sides, :colour, :user_id)\n end",
"def build_registration_item(reg_item)\n unless reg_item.nil? || has_expense_item?(reg_item)\n registrant_expense_items.system_managed.build(expense_item: reg_item)\n end\n end",
"def initialize(user, item, params)\r\n @id = item.id\r\n self.user = user\r\n self.item = item\r\n item.state = :auction\r\n self.name = item.name\r\n self.description = params[:description]\r\n self.image = ImageHelper.save params[:image], settings.public_folder + \"/images/items\"\r\n self.minimal = params[:minimal].to_i\r\n self.increment = params[:increment].to_i\r\n self.bid = []\r\n self.current_price = 0\r\n self.rank_one=nil\r\n self.rank_two=nil\r\n date = params[:date]\r\n year = date[6..9].to_i\r\n month = date[3..4].to_i\r\n day = date[0..1].to_i\r\n time = params[:time]\r\n hour = time.split(\":\").first.to_i\r\n min = time.split(\":\").last.to_i\r\n\r\n self.due_date = Time.local(year, month, day, hour, min, 0)\r\n\r\n self.overlay.add_auction(self)\r\n end",
"def item\n IITSource.new(@ole.Item)\n end",
"def item_params\n params.require(:item).permit(:tagid, :rfid, :category_id, :sub_category_id, :weight, :description, :purchased_at_date, :vendor_id, :warranty_time, :lifetime_until, :serial, :sku, :price, :owner, :last_seen, :service_interval, :tagged, :status_id, :lup, :ancestry, :parent_id, :tag_list, :make, :model, :warranty_time, :life_time, :unit_id, :owner_id, :into_use, :ip, :inspection_interval, :item, :memo, :lup_inc, :search, :department_id, :user_id, :terminate_at_eol)\n end",
"def create_item_from(order_item, lot_code = nil, expires_at = nil, amount = nil)\n transfer_items.create!(\n order_item: order_item,\n product: order_item.product,\n lot_code: lot_code || order_item.lot_code,\n expires_at: expires_at,\n amount: amount || order_item.waiting\n )\n end",
"def consume (workitem)\n\n DataMapper.repository(@dm_repository) do\n\n kf = if @key_field and expstorage and @key_field.match(/\\$\\{[^\\}]+\\}/)\n Ruote.dosub(@key_field, expstorage[workitem.fei], workitem)\n elsif @key_field\n workitem.fields[@key_field]\n else\n nil\n end\n\n kf = kf ? kf.to_s : nil\n\n @dm_workitem_class.from_ruote_workitem(\n workitem, :store_name => @store_name, :key_field => kf)\n end\n end",
"def create\n @item = BudgetItem.new(params[:budget_item])\n\n respond_to do |format|\n if @item.save\n flash[:notice] = 'Item was successfully created.'\n format.html { redirect_to(@item) }\n format.xml { render :xml => @item, :status => :created, :location => @item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new_invoice_item(invoice, i)\n invoice_item = SupplierInvoiceItem.new\n if i.class.name == 'ReceiptNoteItem'\n invoice_item.receipt_note_id = i.receipt_note_id\n invoice_item.receipt_note_item_id = i.id\n else\n invoice_item.purchase_order_id = i.purchase_order_id\n invoice_item.purchase_order_item_id = i.id\n end\n invoice_item.supplier_invoice_id = invoice.id\n invoice_item.product_id = i.product_id\n invoice_item.code = i.code\n invoice_item.description = i.description\n invoice_item.quantity = i.balance\n invoice_item.price = i.price\n invoice_item.discount_pct = i.discount_pct\n invoice_item.discount = i.discount\n invoice_item.tax_type_id = i.tax_type_id\n invoice_item.work_order_id = i.work_order_id\n invoice_item.project_id = i.project_id\n if !i.charge_account_id.blank?\n invoice_item.charge_account_id = i.charge_account_id\n else\n invoice_item.charge_account_id = ChargeAccount.expenditures(i.project_id).first.id\n end\n invoice_item.created_by = current_user.id if !current_user.nil?\n return invoice_item\n end",
"def import_item(item)\n Art.create({\n name: gateway.art_name(item),\n creator: gateway.art_creator(item),\n image: gateway.art_image(item),\n description: gateway.art_description(item),\n source: gateway.art_source,\n source_link: gateway.art_source_link(item),\n additional_images: gateway.art_additional_images(item),\n category: Category.find_or_create_by(name: gateway.art_category(item)),\n creation_date: gateway.art_release_date(item)\n })\n end",
"def create_item(item_request_body, opts = {})\n data, _status_code, _headers = create_item_with_http_info(item_request_body, opts)\n data\n end",
"def item_by_name\n IITEncoder.new(@ole.ItemByName)\n end",
"def create_inventory_item(to_be_created_inventory_item_params, state)\n return_params = Hash.new(0)\n begin\n if in_it = InventoryItem.create!(\n location: Location.find(to_be_created_inventory_item_params[:location_id]),\n item: Item.find(to_be_created_inventory_item_params[:item_id]),\n inventory_item_state: InventoryItemState.find_by(name: state),\n inventory_item_condition: InventoryItemCondition.find(to_be_created_inventory_item_params[:inventory_item_condition_id]),\n quantity: to_be_created_inventory_item_params[:count])\n else\n return_params[:errors] = inventory_item.errors.full_messages\n in_it = nil\n end\n rescue\n puts \"there is a problem in creating inventory item in Committed state for Item: #{item.name} \"\n end\n return_params[:inventory_item] = in_it\n return return_params\n end",
"def refine_item_outlook(item)\n the_item = {id: item.id, title: item.title, description: item.description, category: Category.find(item.category_id).value, \n price: \"%.2f\" % item.price, seller_name: Seller.find(item.seller_id).name, seller_longitude: Seller.find(item.seller_id).longitude,\n seller_latitude: Seller.find(item.seller_id).latitude, status: Status.find(item.status_id).value, published_date: item.published_date}\n end",
"def put_item_in_inventory(input)\n\n if find_item_by_id(input).canBePickedUp\n unless @inventory.include?(input)\n @inventory << input\n slow_type(\"\\nYou have picked up the #{find_item_by_id(input).name}.\")\n end\n\n else\n slow_type(\"You cannot pick up this item\")\n end\n end",
"def update\n @asset_item = AssetItem.find(params[:id])\n ori_amount = @asset_item.amount\n\n respond_to do |format|\n if @asset_item.update_attributes(params[:asset_item])\n auto_create_or_update_asset_item_detail( @asset_item.id, @asset_item.amount, ori_amount ) if ori_amount != @asset_item.amount\n flash[:notice] = 'AssetItem was successfully updated'\n format.html { redirect_to(asset_items_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @asset_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def ukp_rec2(ukpi)\n n = ukpi[:n]\n c = ukpi[:c]\n items = ukpi[:items].clone\n\n g = Array.new(c+1, nil)\n d = Array.new(c+1, n-1)\n sort_items_by_profitability!(items)\n\n ukp_aux2(items, c, g, d)\n\n g\nend",
"def link_output_item(operation:, sample:, item:)\n fv = FieldValue.new(\n name: \"Primer Set\",\n child_item_id: item.id,\n child_sample_id: sample.id,\n role: \"output\",\n parent_class: \"Operation\",\n parent_id: operation.id,\n field_type_id: operation.output(\"Primer Set\").field_type.id\n )\n fv.save\n end",
"def create_cancel_transaction\n\t\tcancel_input = Input.new\n\t\tcancel_input.amount = self.amount * -1\n\t\tcancel_input.cancel_id = self.id\n\t\tcancel_input.status = \"cancel_input\"\n\n\t\tself.status = \"cancelled\"\n\t\tif self.article\t\n\t\t\tself.article.status = \"\"\t\t# El articulo ya no esta ni vendido ni alquilado\n\t\tend\n\t\tself.comission_cash = '-' + self.comission_cash\n\t\tself.save\n\t\treturn cancel_input\n\tend",
"def build_item_price_update_request(attrs={})\n ItemPriceUpdateRequest.new(attrs.merge({:udi_auth_token=>@udi_auth_token, :http_biz_id=>@http_biz_id}))\n end",
"def create\n @item = Item.new(params[:item])\n @item.budget = Budget.find params[:budget_id]\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to after_save_redirection_path, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def operation_item_params\n params.require(:operation_item).permit(:budget_category_id, :article_id, :operation_id, :title, :amount, :amount_type)\n end",
"def add_item(order_id, item_sku, price, quantity, name = nil, category = nil, utmhid = random_id)\n check_account_params\n hey(item_params(order_id, item_sku, name, category, price, quantity, utmhid))\n end",
"def add_item(item)\n fail \"An items id should initially be nil, but was #{item.id}\" unless (item.id == nil)\n fail \"An item must have an owner when added to the system.\" if (item.owner == nil)\n item.id = @item_id_count\n @items.store(@item_id_count, item)\n @item_id_count += 1\n end",
"def item_transaction(item, character)\n \n case item.class.name\n\n when \"Weapon\"\n item.inventory = character.inventory\n character.inventory.weapons << item\n when \"Armor\"\n item.inventory = character.inventory\n character.inventory.armors << item\n when \"Potion\"\n item.character = character\n character.potions << item\n else\n \"Error\"\n end\n character.update(:gold => (character.gold - item.cost))\n end",
"def create\n #params[:item][:description] = ActionController::Base.helpers.sanitize(params[:post][:body], :attributes => 'abbr alt cite datetime height href name src title width rowspan colspan rel')\n @item = @course.items.build(params[:item])\n respond_to do |format|\n if @item.save\n @item.update_attributes(:due_date => @item.due_date - DateTime.now.utc_offset) # Rails doesn't do this automatically!\n format.html { redirect_to(course_item_url(@item.params), :notice => 'Item was successfully created.') }\n format.xml { render :xml => @item, :status => :created, :location => @item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_oai_item_id\n\t\t#literal specifies that it should be in the form of...<oai:itemID>...</oai:itemID>\n \t\tself.add_relationship :oai_item_id, \"oai:gcu.ac.uk:\" + self.pid, :literal => true\n\tend",
"def save_items_data\n @parsed[\"order_items\"].each do |i| \n external_code = i['item']['id']\n item = Item.find_or_create_by(external_code: external_code)\n item.order_id = @order.id\n item.external_code = i['item']['id']\n item.name = i['item']['title']\n item.price = i['unit_price']\n item.quantity = i['quantity']\n item.total = i['full_unit_price']\n @subItems = []\n item.save\n end\n end",
"def to_audit_item(attribute = :created_at)\n if attribute == :created_at\n t = created_at\n message = \"#{name} signed up!\"\n elsif attribute == :updated_at\n t = updated_at\n message = \"#{name} updated their profile\"\n end\n AuditItem.new(self, t, 'company', message, \"companies/#{id}\")\n end",
"def create_item(index)\n actor = @data[index]\n rect = item_rect(index)\n \n ucItem = UCCharacterGraphic.new(self, Rect.new(rect.x+9,rect.y+9,30,30), actor,\n 0, 255, 0, PARTY_CONFIG::CHARS_FACING_DIRECTION)\n \n if actor != nil && actor.party_locked\n ucItem.cCharGraphic.opacity = 125\n end\n \n return ucItem\n end",
"def item_params\n params.require(:item).permit(:order_id, :name, :total_amount, :amount_calculated, :reserve, :maturity, :active, :category_id, :interval_id, :key_words, :account_id, :external_account, :budget, :savings_id, :parent_id, :user_id)\n end",
"def intitem_params\n params.require(:intitem).permit(:merchant_id, :inttype_id, :mid, :month, :card_type, :transactions, :volume)\n end",
"def create\n\n @item = Item.new(item_params)\n #@item.user_id = current_user.id \n if !@item.buyitnow \n @item.qty = 1; \n end\n if @item.seq.blank? \n @item.seq = Item.maximum(\"seq\") + 1\n else \n @items = @item.auction.items.all\n @items.each do |i|\n if i.seq >= @item.seq \n i.seq += 1 \n end\n end\n end\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def brief_vendor_add_item\n brief = Brief.find(params[:brief_id])\n brief_vendor = brief.brief_vendors.find_by_org_id(params[:vendor_id])\n brief_vendor.items << Item.new{|r| r.parent_id = params[:item_id]}\n\n redirect_to(cheil_brief_vendor_items_path(params[:brief_id],params[:vendor_id])) \n end",
"def get_input\n input = DefaultInput.new\n # basic input\n input.buying_price.base = self.buying_price\n input.selling_price.base= self.selling_price\n input.deposit.base = self.deposit\n input.interest.base = self.interest\n input.tenure.base = self.tenure\n input.holding_period.base= self.holding_period\n\n # advance input\n input.sell_transaction_cost.base = self.sell_transaction_cost\n input.purchase_transaction_cost.base = self.purchase_transaction_cost\n input.rental.base= self.rental\n input.rental_period.min = self.rental_start\n input.rental_period.max = self.rental_end\n\n return input\n end",
"def create\n @item = Item.new(purchase_item_params)\n\n item_cost = 2\n\n # if params[:item] == \"coin\" || params[:item] == :coin\n # @item = current_user.items.create(item: params[:item], denomination: params[:denomination])\n # elsif params[:item] == \"die\" || params[:item] == :die\n # item_cost = @item.sides\n # @item = current_user.items.create(item: params[:item], sides: params[:sides], colour: params[:colour])\n # end\n\n alert_text = \"Purchase alert: \"\n if @item.item == \"coin\" || @item.item == :coin\n if @item.sides || @item.sides != 0\n alert_text += \"Ignored number of sides '#{@item.sides}' when purchasing the coin. \"\n end\n if @item.colour || @item.colour != nil || @item.colour != \"\"\n alert_text += \"Ignored colour '#{@item.colour}' when purchasing the coin. \"\n end\n @item = current_user.items.create(purchase_coin_params)\n elsif @item.item == \"die\" || @item.item == :die\n if @item.denomination\n alert_text += \"Ignored denomination '#{@item.denomination}' when purchasing the die. \"\n end\n item_cost = @item.sides\n @item = current_user.items.create(purchase_die_params)\n end\n\n # @item = current_user.items.create(purchase_item_params)\n\n if !item_cost\n alert_text += \"Purchase refused - Please input a number of sides for the die you want to purchase.\"\n flash.now[:alert] = \"#{alert_text}\"\n render :new\n elsif current_user.gems < item_cost\n alert_text += \"Purchase refused - You don't have enough gems. The item costs #{item_cost}, but you only have #{current_user.gems} gems.\"\n flash.now[:alert] = \"#{alert_text}\"\n render :new\n else\n respond_to do |format|\n if @item.save\n current_user.gems -= item_cost\n current_user.save\n\n format.html { redirect_to purchaseitems_path, notice: 'Item was successfully purchased.', alert: alert_text }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new, alert: alert_text }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create_item(index)\n actor = @data[index]\n rect = item_rect(index, true)\n \n ucChar = UCFormationCharFace.new(self, actor, rect)\n \n return ucChar\n end",
"def item_params\n params.require(:item).permit(:category,\n :sku,\n :us_name,\n :us_price,\n :us_currency,\n :jp_name,\n :jp_price,\n :jp_currency,\n :usPercentChange,\n :jpPercentChange)\n end",
"def new_from_item(item, options = {})\n cart_item = item.send(self.to_s.tableize).build(options)\n cart_item.attributes.map {|attribute| attribute if item.respond_to?(attribute[0].to_s) && !attribute[0].to_s.include?(\"_at\") }.compact.each {|attribute| cart_item.send(\"#{attribute[0]}=\", item.send(attribute[0].to_s))}\n # TODO Add a callback\n cart_item\n # TODO Add a callback\n end",
"def create_line_item_from_inventory_item_id inventory_item_id, qty, include_price_in_expense, include_price_in_revenue, notes\n # Inventory item\n inventory_item = InventoryItem.find(inventory_item_id)\n new_line_items = create_line_item_from_inventory_item(\n inventory_item, qty,\n inventory_item.vendor, account,\n include_price_in_expense, include_price_in_revenue, notes)\n line_items.push(new_line_items)\n new_line_items\n end",
"def create\n @item = \"Vger::Resources::#{params[:item][:item_type]}\".constantize.new(params[:item])\n respond_to do |format|\n if @item.save\n format.html { redirect_to suitability_item_path(@item), notice: 'Suitability Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_line_item_from_inventory_item_id inventory_item_id, qty, include_price_in_expense, include_price_in_revenue, notes\n # Inventory item\n inventory_item = InventoryItem.find(inventory_item_id)\n line_items.push(create_line_item_from_inventory_item(\n inventory_item, qty,\n inventory_item.vendor, account,\n include_price_in_expense, include_price_in_revenue, notes))\n end",
"def create_item(data_bag, item_name, data = {}, metadata = {})\n item = ::SecureDataBag::Item.new(metadata)\n item.raw_data = { 'id' => item_name }.merge(data)\n item.data_bag data_bag\n item\n end",
"def usdollar()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Usdollar::UsdollarRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def create_cve_vuln(vuln_def_id, finding, asset_attributes)\n # then create each vuln for this asset\n vuln_attributes = {\n \"scanner_identifier\" => vuln_def_id,\n \"scanner_type\" => \"Bitsight\",\n \"details\" => JSON.pretty_generate(finding),\n \"created_at\" => finding[\"first_seen\"],\n \"last_seen_at\" => finding[\"last_seen\"],\n \"status\" => \"open\"\n }\n \n # set the port if it's available \n if finding[\"details\"]\n vuln_attributes[\"port\"] = \"#{finding[\"details\"][\"dest_port\"]}\".to_i \n end\n\n # def create_kdi_asset_vuln(asset_id, asset_locator, args)\n create_kdi_asset_vuln(asset_attributes, vuln_attributes)\n\n vd = {\n \"scanner_type\" => \"Bitsight\",\n \"scanner_identifier\" =>\"#{vuln_def_id}\",\n \"cve_identifiers\" => \"#{vuln_def_id}\"\n }\n \n create_kdi_vuln_def(vd)\n end",
"def create\n @item = Item.new(item_params)\n @item.owner_id = current_user.id\n @item.purchased = 0\n @uploaded_io = params[:item][:uploaded_file]\n File.open(Rails.root.join('public', 'images', @item.filename), 'wb') do |file|\n file.write(@uploaded_io.read)\n end\n if @item.save\n redirect_to @item, notice: 'Item was successfully created.'\n else\n render :new\n end\n end",
"def saveFCInvoiceItem(scheduledEntry)\n\t\tinvItem = @invoice.invoice_items.new()\n\t\titemDesc = \"\"\n\t\tif scheduledEntry.account_project.account.account_billing\n\t\t\titemDesc = scheduledEntry.account_project.project.name + \" - \" + scheduledEntry.milestone\n\t\telse\n\t\t\titemDesc = scheduledEntry.milestone\n\t\tend\n\t\tinvItem = updateInvoiceItem(invItem, scheduledEntry.account_project.project_id, itemDesc, scheduledEntry.amount, 1, scheduledEntry.currency)\n\t\tinvItem\n\tend",
"def create_item(index)\n actor = @data[index]\n rect = item_rect(index)\n \n ucItem = UCCharacterGraphic.new(self, Rect.new(rect.x+9,rect.y+9,30,30), actor,\n 0, 255, 0, PARTY_CONFIG::CHARS_FACING_DIRECTION)\n \n if actor != nil && actor.reserve_locked\n ucItem.cCharGraphic.opacity = 125\n end\n \n return ucItem\n end",
"def create\n @budget = Budget.find(params[:budget_id])\n @proposed_item = @budget.proposed_items.build(proposed_item_params)\n\n respond_to do |format|\n if @proposed_item.save\n format.html { redirect_to @budget, notice: 'Proposed item was successfully created.' }\n format.json { render :show, status: :created, location: @proposed_item }\n else\n format.html { render :new }\n format.json { render json: @proposed_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def buy\n @character = Character.find(params[:id])\n errors = findErrors(item_params)\n if errors.length < 1 && canAfford?(item_params[:cost].to_f, @character)\n @character.gp -= item_params[:cost].to_f\n @item = Item.new\n @item.cost = item_params[:cost]\n @item.name = item_params[:name]\n @item.save\n association = CharacterItem.new\n association.character_id = @character.id\n association.item_id = @item.id\n association.save\n @character.save\n redirect_to @character, notice: 'Item Was Purchased succesfully'\n else\n errors.length > 0 ? flash[:errors] = errors[0] : flash[:errors] = \"Whoops! this item costs #{item_params[:cost]} GP\n But you have #{@character.gp}\"\n @item = Item.new(item_params)\n render 'purchase_item/new'\n end\n end",
"def item_m999(item)\n m999 = MARC::DataField.new('999', '9', '1')\n m999.append(MARC::Subfield.new('i', item.inum_trunc))\n m999.append(MARC::Subfield.new('l', item.location_code))\n m999.append(MARC::Subfield.new('s', item.status_code))\n m999.append(MARC::Subfield.new('t', item.itype_code))\n m999.append(MARC::Subfield.new('c', item.copy_num.to_s))\n m999.append(MARC::Subfield.new('o', item.checkout_total.to_s))\n m999.append(MARC::Subfield.new('h', item.holds.length.to_s))\n\n if item.due_date\n m999.append(MARC::Subfield.new('d', item.due_date.strftime('%F %T%:::z')))\n end\n\n item.barcodes.each do |barcode|\n m999.append(MARC::Subfield.new('b', barcode))\n end\n item.callnos(value_only: false).each do |f|\n # write [marc_tag][ind1][ind2] with indicator blanks => '#'\n if f[:marc_tag]\n tag = f[:marc_tag]\n ind1 = f[:marc_ind1].tr(' ', '#')\n ind2 = f[:marc_ind2].tr(' ', '#')\n m999.append(MARC::Subfield.new('p', \"#{tag}#{ind1}#{ind2}\"))\n end\n m999.append(MARC::Subfield.new('q', f[:field_content]))\n end\n item.volumes.each do |volume|\n m999.append(MARC::Subfield.new('v', volume))\n end\n # this writes public notes (tag==z) to subfield n\n item.public_notes.each do |public_note|\n m999.append(MARC::Subfield.new('n', public_note))\n end\n m999\n end",
"def create_item(index)\n item = @data[index]\n rect = item_rect(index)\n \n ucItem = UCVictoryItem.new(self, item, rect)\n \n return ucItem\n end",
"def invert_item(item)\n item_fq = item.fq.symbolize_keys\n item_value = item_fq.delete(pivot[0].to_sym)\n item_fq = item_fq.merge(item.field.to_sym => item.value).slice(*pivot.map(&:to_sym))\n PivotValue.new(value: item_value, fq: item_fq)\n end",
"def set_budgetitem\n @budgetitem = Budgetitem.find(params[:id])\n end",
"def get_item\n \n if active_character\n item = Item.find(params[:item][:id])\n position = params[:item][:container_position]\n \n # swap any existing item in same position\n prev_item = active_character.inventory.find(:first, :conditions => {:container_position => position})\n \n if item.owner == active_character\n if prev_item\n prev_item.container_position = item.container_position\n prev_item.save\n end\n \n item.container_position = position\n item.save\n elsif item.owner == active_character.area\n area = active_character.area\n \n if prev_item\n prev_item.owner = area\n prev_item.save\n \n render_to_area area do |page|\n page.call :addEvent, \"#{h current_user} has dropped #{h prev_item.name}!\"\n page.call 'game.updateDisplayable', prev_item.css_id, prev_item.left, prev_item.top\n end\n end\n \n item.owner = active_character\n item.container_position = position\n item.save\n # Update all clients in area\n render_to_area area do |page|\n page.call :addEvent, \"#{h active_character.name} has picked up #{h item.name}!\"\n page.call :got_item, item.css_id, active_character.id\n end\n end\n end\n \n render :nothing => true\n end",
"def add_item(item, amount)\n # Check if the Entity already has that item\n # in the inventory. If so, just increase\n # the amount.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n # If not already in the inventory, push a Couple.\n @inventory.push(Couple.new(item, amount))\n end",
"def use_item(item, entity)\n index = has_item(item)\n if index\n actual_item = inventory[index].first\n actual_item.use(self, entity)\n remove_item(actual_item) if actual_item.consumable\n else\n print NO_SUCH_ITEM_ERROR\n end\n end",
"def item_params\n \tparams.require(:item).permit(:name, :cupboard_id, :borrowable, :item_quantity)\n end",
"def item_by_persistent_id\n IITSource.new(@ole.ItemByPersistentID)\n end",
"def make_citizen_from_account(account)\n Citizen.find_or_create(\n :account_id => account.id,\n :entity_id => self.root_entity.id\n )\n end",
"def buy_item(item_to_buy, user)\r\n fail \"only users can buy items in behalve of an organisation\" if (user.organisation)\r\n fail \"only users that are part of #{self.name} can buy items for it\" unless (is_member?(user))\r\n fail \"would exceed #{user.email}'s organisation limit for today\" unless within_limit_of?(item_to_buy, user)\r\n fail \"not enough credits\" if item_to_buy.price > self.credits\r\n fail \"Item not in System\" unless (DAOItem.instance.item_exists?(item_to_buy.id))\r\n\r\n old_owner = item_to_buy.owner\r\n\r\n #Subtracts price from buyer\r\n self.credits = self.credits - item_to_buy.price\r\n #Adds price to owner\r\n old_owner.credits += item_to_buy.price\r\n #decreases the limit of the buyer\r\n @member_limits[user.email].spend(item_to_buy.price) unless self.limit.nil? || is_admin?(user)\r\n\r\n item_to_buy.bought_by(self)\r\n end",
"def purchase_item(item, seller_id, buyer_id)\n seller = User.new(seller_id)\n buyer = User.new(buyer_id)\n @conn.watch([\"market\", buyer.id]) do\n fund = @conn.hget(buyer.id, \"fund\")\n price = @conn.zscore(\"market\", seller.item_id(item))\n\n if price && price <= fund.to_i\n @conn.multi do |multi|\n multi.hincrby(buyer.id, \"fund\", -price.to_i)\n multi.hincrby(seller.id, \"fund\", price.to_i)\n multi.zrem(\"market\", seller.item_id(item))\n multi.sadd(buyer.inventory_id, item)\n end\n else\n @conn.unwatch\n end\n end\n end",
"def get_economic_categories_from_budget_items_list(items)\n def count_different_descriptions(items)\n items.map{|i| i[:description]}.uniq.count\n end\n\n # First, group items by economic concept\n buckets = {}\n items.each do |item|\n concept = item[:economic_concept]\n next if concept.nil? or concept.empty?\n next if concept.length > 4 # Budget item\n # Note: We don't need economic categories for budget items (concept length==5), they are \n # just items belonging to a heading. At one point the obstacle to this was distinguishing \n # heading subtotals from the items themselves in the output files, but we've sorted that \n # out through a new 'budget item' column in the output (see below).\n\n buckets[concept] = [] if buckets[concept].nil? \n buckets[concept].push item\n end\n\n # Then, for each bucket, decide whether we need to tag the economic concept\n categories = {}\n buckets.each do |concept, items|\n if count_different_descriptions(items) > 1 # We need to tag the concept\n # We expect this to happen only for headings\n if concept.length < 3\n puts \"Warning: inconsistent descriptions for article or chapter #{concept}!\"\n end\n\n # Create a category for each item, and modify the items to point to them\n items.each do |item|\n tagged_concept = \"#{concept}/#{get_entity_id(item[:section], item[:service])}\"\n item[:economic_concept] = tagged_concept\n categories[tagged_concept] = item[:description]\n end\n else\n categories[concept] = items.first[:description] # Pick the first, they're all the same\n end\n end\n categories\nend",
"def ncr_item_params\n params.require(:ncr_item).permit(:external_id, :category, :item_name, :description, :variation_types, :variations, :barcode, :track_inventory, :prompt_for_price, :unit_cost, :price, :sold_by_weight_measure, :tax_category, :available_for_sale_on_pos, :available_for_sale_online, :online_item_name, :package_cost, :units_per_package, :primary_vendor, :units_on_hand, :modified_by_1, :modifier_group_1_external_id, :modified_by_2, :modifier_group_2_external_id, :modified_by_3, :modifier_group_3_external_id, :modified_by_4, :modifier_group_4_external_id, :modified_by_5, :modifier_group_5_external_id)\n end",
"def buy_item (item, character)\n \n if item.inventory == nil \n if character.gold >= item.cost\n item_transaction(item, character)\n \"you bought #{item.name}!\"\n else\n \"you don't have enough money\"\n end\n else\n \"Your character already has this item in their invetory\"\n end\n end",
"def item\n IITTrack.new(@ole.Item)\n end",
"def buy_item(user, item)\r\n if(self.has_enough_money(item) and user.has_item(item))\r\n self.get_item(user, item)\r\n self.pay_amount(user, item.get_price)\r\n else\r\n #transaction not possible\r\n end\r\n end",
"def attach_item(item)\r\n equal_item = self.check_for_equal_item(item.name,item.price,item.description)\r\n if equal_item == nil\r\n self.items << item\r\n item.owner = self\r\n item.deactivate\r\n else\r\n equal_item.quantity += item.quantity\r\n equal_item.deactivate\r\n item.delete\r\n end\r\n end",
"def proposed_item_params\n params.require(:proposed_item).permit(:name, :comment, :cost, :quantity, :amount, :category, :budget_id)\n end",
"def tia_item_params\n params.require( :tia_item ).permit( :account_id, :description, :comment, :prio, :status, :due_date, :res_date, :archived )\n end",
"def contract_item_params\n params.require(:contract_item).permit(:contract_id, :prod_type_id, :product_id)\n end",
"def applied_workitem\n\n @awi ||= Ruote::Workitem.new(h.applied_workitem)\n end",
"def verificate_item_params\n params.require(:verificate_item).permit(:account_id, :description, :debit, :credit, :result_unit_id, :tax_code_id)\n end",
"def accident_item_params\n params.require(:accident_item).permit(:insurance_id, :industry_id, :employee_number, :quota, :started_at, :stopped_at, :line_item_attributes => [:user_id, :price, :quantity, :name, :telephone, :code_number, :enterprise_name, :province, :city, :district, :location, :zipcode, :lock_version], :insurance_business_attributes => [:name, :telephone, :code_number, :enterprise_name, :province, :city, :district, :location, :zipcode])\n end"
] |
[
"0.5255674",
"0.5139402",
"0.50545406",
"0.5048498",
"0.48972556",
"0.48949417",
"0.48896214",
"0.48467955",
"0.4815196",
"0.48040518",
"0.48013783",
"0.47662178",
"0.47616273",
"0.47544327",
"0.46931592",
"0.4686183",
"0.4678388",
"0.4678388",
"0.46566775",
"0.46551114",
"0.4647822",
"0.46461132",
"0.46348011",
"0.4612831",
"0.46083358",
"0.4590755",
"0.4583559",
"0.45742777",
"0.4571821",
"0.4558663",
"0.45341027",
"0.45318264",
"0.45296457",
"0.45296046",
"0.4528197",
"0.45229897",
"0.45209154",
"0.45098752",
"0.4491405",
"0.44715047",
"0.44636807",
"0.44612595",
"0.44519967",
"0.44470227",
"0.44405648",
"0.4431752",
"0.44307974",
"0.44305062",
"0.4427172",
"0.4420475",
"0.4404803",
"0.43821993",
"0.43731654",
"0.43659207",
"0.43640828",
"0.43624425",
"0.43546775",
"0.43521065",
"0.43448842",
"0.434388",
"0.4343306",
"0.43338618",
"0.43336824",
"0.43333322",
"0.4332205",
"0.43312284",
"0.433074",
"0.43301582",
"0.43287992",
"0.4327271",
"0.43203852",
"0.43202665",
"0.43192223",
"0.43176466",
"0.4314127",
"0.43109187",
"0.43106392",
"0.43036732",
"0.43030307",
"0.4299763",
"0.42988655",
"0.42972374",
"0.4296169",
"0.42929286",
"0.4292273",
"0.4290095",
"0.42897227",
"0.4286212",
"0.42840368",
"0.4280339",
"0.42706627",
"0.4268051",
"0.42662394",
"0.4266179",
"0.42618296",
"0.42566973",
"0.42561266",
"0.42543256",
"0.42531112",
"0.4251845"
] |
0.5917898
|
0
|
url is something like:
|
def load_spreadsheet(opts)
if opts[:url]
@session.spreadsheet_by_key parse_gdoc_url_for_key(opts[:url])
elsif opts[:key]
@session.spreadsheet_by_key(opts[:key])
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def URI(url); end",
"def url\n \t@url.to_s\n end",
"def url\n end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def link() url; end",
"def link() url; end",
"def url\n end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_); end",
"def url\n uri.to_s\n end",
"def to_s; @url; end",
"def url\n puts url\n \"article/#{url}\"\n puts \"right\"\n end",
"def url\n @url\n end",
"def url\n @url.to_s\n end",
"def get(url); end",
"def url\n uri.to_s\n end",
"def url_for(string); end",
"def url\n @url\n end",
"def url\n @url\n end",
"def to(url); end",
"def url\n uri\n end",
"def url\n uri\n end",
"def reg_url; /(.+)/; end",
"def reg_url; /(.+)/; end",
"def url\n match(/URL\\s+:\\s+(.+)/)\n end",
"def get_url\n @url\n end",
"def url\n ''\n end",
"def relative_url(input); end",
"def url_for(url) url end",
"def geturl() \n\t\treturn self.response.geturl()\n end",
"def to_param\n url\n end",
"def url_content\n urn\n end",
"def original_url; end",
"def url_content\n url(:content)\n end",
"def sub_url (p)\n res = (p != \"\") ? \"http://\" + request.host + \":3000\" + p.sub(\"/execute/\", \"/rest2/\") : p\n end",
"def url_arg url\r\n if url.instance_of?(String) then url else exactize(@view.url_for(url).gsub('amp;', '')) end\n end",
"def url\n data['url']\n end",
"def my_url\n url 'my'\n end",
"def url\n @url ||= value.split(/\\s+/).detect { |v| v =~ %r{\\A[a-z0-9]+:\\S+}i } || value\n end",
"def url\n params.require(:url)\n end",
"def url\n @url ||= params['url']\n end",
"def to_s\n url\n end",
"def url\n @parser.request_url\n end",
"def path\r\n url.gsub(/https?:\\/\\/[^\\/]+\\//i, '').scan(/([^&]+)/i).first().first()\r\n end",
"def static_url(url); \"url('#{url}')\"; end",
"def url_template; end",
"def url_template; end",
"def original_url\n url\n end",
"def normalize_url(url); end",
"def resolved_uri; end",
"def url\n raise\n end",
"def u(str)\n str.to_url\nend",
"def url\n self.name\n end",
"def url; (page.url rescue ''); end",
"def url; (page.url rescue ''); end",
"def consume_url; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def baseurl; end",
"def baseurl=(_arg0); end",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def get_url\n Nokogiri::HTML(open(@url))\n end",
"def website_url; website end"
] |
[
"0.7945686",
"0.7736013",
"0.7718381",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7540599",
"0.7540599",
"0.75220567",
"0.7470215",
"0.7470215",
"0.7470215",
"0.7470215",
"0.7470215",
"0.7470215",
"0.7470215",
"0.7326098",
"0.72327286",
"0.7223666",
"0.7197767",
"0.71909165",
"0.71899337",
"0.7189771",
"0.7179765",
"0.7179406",
"0.7147439",
"0.7147439",
"0.7135144",
"0.7085631",
"0.7085631",
"0.7084404",
"0.7084404",
"0.7077738",
"0.70412236",
"0.7041177",
"0.70043445",
"0.7003018",
"0.6995818",
"0.6989197",
"0.698091",
"0.6975702",
"0.6949137",
"0.69442165",
"0.6940079",
"0.6904706",
"0.6858312",
"0.6847878",
"0.68375134",
"0.68313986",
"0.68164057",
"0.6802602",
"0.6795571",
"0.6775784",
"0.6772291",
"0.6772291",
"0.6769952",
"0.6765819",
"0.6762998",
"0.67627305",
"0.6747623",
"0.67407405",
"0.6732399",
"0.6732399",
"0.67323565",
"0.67283523",
"0.67283523",
"0.67283523",
"0.67283523",
"0.67283523",
"0.67283523",
"0.67283523",
"0.67283523",
"0.67283523",
"0.67283523",
"0.67283523",
"0.67283523",
"0.6709869",
"0.6694802",
"0.6686586",
"0.6686586",
"0.6686586",
"0.6686586",
"0.6686586",
"0.66685367",
"0.6666532"
] |
0.0
|
-1
|
returns a string for key
|
def parse_gdoc_url_for_key(url)
u = URI.parse(url)
key = CGI.parse(u.query)['key'][0]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_s\n key.to_s\n end",
"def full_key\n [name, key].join(\"/\")\n end",
"def to_s\n @real_key\n end",
"def key\n @key ||= name.to_s\n end",
"def key_name\n data[:key_name]\n end",
"def to_s\n self.key\n end",
"def key\n @key.id2name\n end",
"def key\n \"#{@@PREFIX}#{@name.gsub(\" \",\"-\")}\"\n end",
"def key\n (key_name || name).to_sym\n end",
"def key(name = nil)\n \"#{@id}:#{name}\"\n end",
"def full_key(namespace, key)\n \"#{namespace}:#{key}\"\n end",
"def keyname(key)\n\t\t@keynames[key]\n\tend",
"def to_string(key)\n const_get(key) if key\n end",
"def key_for(key)\n key.is_a?(String) ? key : serialize(key)\n end",
"def key_for(key)\n key.is_a?(String) ? key : serialize(key)\n end",
"def key_name(key)\n key.to_s.index(SPACE_RE) ? \"\\\"#{key}\\\"\" : key\n end",
"def getKey; @args.map { |a| a.to_s }.join(':').to_sym end",
"def key\n to_a[0..(num_key_fields-1)].join(\"-\")\n end",
"def to_simple_key(key)\n key\n end",
"def key\n \"#{@type}{#{@title}}]\"\n end",
"def key\n name.underscore.tr('/', '_').to_sym\n end",
"def key_for(key)\n key_parts = []\n key_parts << @namespace if @namespace && @namespace.length > 0\n \n # Gracefully handles arrays passed here as well, due to the flatten\n key_parts << key\n key_parts.flatten.join ':'\n end",
"def key\n key = self.name\n key = Economic::Support::String.demodulize(key)\n key = Economic::Support::String.underscore(key)\n key.intern\n end",
"def key_field\n 'key'\n end",
"def key\n \"#{@@PREFIX}#{@type}-#{@version.gsub(\".\",\"-\")}\"\n end",
"def key_for(resource_name)\n [prefix, resource_name].join\n end",
"def key\n @key\n end",
"def key\n @key\n end",
"def key\n return \"#{user}\"\n end",
"def key(*args)\n args.join(\":\")\n end",
"def to_key; end",
"def get_string(key)\n get(key, \"Z\")\n end",
"def get_key\n @key = Base64.decode64('MzRlZTc5ODMtNWVlNi00MTQ3LWFhODYtNDQzZWEwNjJhYmY3NzQ0OTNkNmEtMmExNS00M2ZlLWFhY2UtZTc4NTY2OTI3NTg1Cg==')\n end",
"def key\n @key\n end",
"def key\n @key\n end",
"def key\n return @key\n end",
"def key\n return @key\n end",
"def key\n @key or raise MissingKey\n end",
"def getKey; argSetTextual.to_sym end",
"def key\n attributes[:key]\n end",
"def key_name\n \"#{prefix}:#{@id}\"\n end",
"def key\n attributes['key'] or raise NoKeySpecified\n end",
"def string(key) # :nodoc:\n Tree.string_table[key.to_s]\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def namespaced_key(key)\n \"#{@namespace}_#{key}\"\n end",
"def key\n store_as.to_s\n end",
"def key_path\n @key_path\n end",
"def to_s\n user_key\n end",
"def to_s\n user_key\n end",
"def make_key(type, name)\n \"%#{type}%#{name}\"\n end",
"def format_key(key)\n key.to_s.gsub(\"-\",\"_\")\n end",
"def key\n name = self.class.name.split(\"::\").last\n Util.underscore(name).to_sym\n end",
"def read_key; end",
"def get_cache_key(user, key)\n return \"%06d:%s\" % [user.id, key]\n end",
"def key\n key = config[:key] || flags.last.sub(/\\A--?/, '')\n key = key.tr '-', '_' if underscore_flags?\n key.to_sym\n end",
"def to_s\n key = self.key.dup\n modifiers = self.modifiers.dup\n if modifiers.include?(\"S\")\n modifiers.delete(\"S\")\n key.upcase!\n end\n\n if modifiers.empty?\n @@key_to_readable[key] ? \"<#{@@key_to_readable[key]}>\" : key\n else\n \"<\" + modifiers.map { |modifier| modifier + \"-\" }.join + (@@key_to_readable[key] || key) + \">\"\n end\n end",
"def key_symbol\n @key\n end",
"def key\n params.k\n end",
"def key \n path\n end",
"def key\n `return #{self}.__key__ || #{nil};`\n end",
"def key(*args)\n args.compact.join(\"/\")\n end",
"def current_key_prefix(search_type)\n Base64.urlsafe_encode64(\"#{search_type.chr}\\0#{@key_id.chr}\")\n end",
"def key\n instance_variables\n .collect { |variable| instance_variable_get(variable) }\n .join\n end",
"def key=(value)\n @key = value.to_s\n end",
"def map_key(key)\n key\n end",
"def key\n raise 'Not implemented'\n end",
"def key\n raise 'Not implemented'\n end",
"def symbolyze_key(key)\n key.to_sym rescue key\n end",
"def get_key record\n record\n end",
"def stringified_keys; end",
"def key\n @attributes[:key]\n end",
"def key\n @attributes[:key]\n end",
"def default_key_format(key)\n key\n end",
"def hash_key(key)\n key.downcase\n end",
"def name_key\n return base_key + \".name\"\n end",
"def version_key(key)\n return \"#{key}_v#{VERSION}\"\n end",
"def as_string(key)\n with_input_io(key) do |io|\n io.read\n end\n end",
"def from_simple_key(key)\n key\n end",
"def full_key(relative_key)\n \"#{@root}/#{relative_key}\"\n end",
"def to_param\n key\n end",
"def key_pair_name\n\n # return the key_pair_name if one is already generated\n return @key_pair_name if @key_pair_name\n\n # generate on from a random string of 10 upper and lowercase letters\n o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten\n @key_pair_name = (0..10).map { o[rand(o.length)] }.join\n return @key_pair_name\n\n end",
"def alternate_key(key)\n case key\n when String then key.to_sym\n when Symbol then key.to_s\n end\n end",
"def raw key\n\t\t\tcase key\n\t\t\twhen :name\n\t\t\t\treturn @name\n\t\t\twhen :start_time\n\t\t\t\treturn @start_time\n\t\t\twhen :end_time\n\t\t\t\treturn @end_time\n\t\t\tend\n\t\tend",
"def qualified_key\n [@env.namespace.to_s, @key].reject(&:empty?).compact.join('.')\n end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end"
] |
[
"0.819309",
"0.8070051",
"0.7871787",
"0.7828393",
"0.7810379",
"0.77917576",
"0.7728263",
"0.77043295",
"0.76748455",
"0.7671681",
"0.7649763",
"0.76262105",
"0.75948733",
"0.7559358",
"0.7559358",
"0.7494856",
"0.74742633",
"0.7446051",
"0.74334306",
"0.7408465",
"0.7405108",
"0.7403129",
"0.7381133",
"0.73654246",
"0.72791725",
"0.7272764",
"0.72553825",
"0.72553825",
"0.7224327",
"0.7202503",
"0.7198632",
"0.7198513",
"0.7163105",
"0.7145367",
"0.7145367",
"0.7139965",
"0.7139965",
"0.7125311",
"0.71145755",
"0.7088078",
"0.7079228",
"0.7078491",
"0.70684785",
"0.7058248",
"0.7058248",
"0.70537084",
"0.70223033",
"0.7011295",
"0.69947374",
"0.69947374",
"0.6966846",
"0.69629085",
"0.6958838",
"0.69519687",
"0.69484645",
"0.69462156",
"0.6938139",
"0.6937058",
"0.6936709",
"0.6921575",
"0.6919659",
"0.69081664",
"0.6905178",
"0.69013655",
"0.689965",
"0.68976444",
"0.6896536",
"0.6896536",
"0.68931574",
"0.6890676",
"0.6882526",
"0.687515",
"0.687515",
"0.6850966",
"0.68471485",
"0.68457985",
"0.6835465",
"0.6828485",
"0.6825081",
"0.68190724",
"0.681821",
"0.68169457",
"0.6815823",
"0.6815362",
"0.68126005",
"0.68078953",
"0.68078953",
"0.68078953",
"0.68078953",
"0.68078953",
"0.68078953",
"0.68078953",
"0.68078953",
"0.68078953",
"0.68078953",
"0.68078953",
"0.68078953",
"0.68078953",
"0.68078953",
"0.68078953",
"0.68078953"
] |
0.0
|
-1
|
sets up the table structure
|
def init_podunk_table(gsheet, opts={})
opts[:connection] = self
Table.new(gsheet.rows, opts)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize_table; end",
"def bootstrap\n sql = 'CREATE TABLE IF NOT EXISTS states(uuid VARCHAR(128) PRIMARY KEY,'\n sql << ' id INTEGER, name VARCHAR(128), deploy_id VARCHAR(128), timestamp INTEGER,'\n sql << ' missing INTEGER, state VARCHAR(128), hyperv VARCHAR(128))'\n\n @db.execute(sql)\n\n sql = 'CREATE TABLE IF NOT EXISTS settings(key VARCHAR(128) PRIMARY KEY,'\n sql << ' value VARCHAR(128))'\n\n @db.execute(sql)\n end",
"def start_table\r\n n = @char_set.length\r\n t_size = @size\r\n create_table(@char_set, '', n, t_size)\r\n end",
"def create_tables\n self.conn.exec(\n File.read(\"./lib/creating_tables.txt\")\n \n )\n end",
"def setup_tables(&block)\n return nil unless block_given?\n self.class_eval(&block)\n self.table_settings \n end",
"def initialize_flag_definitions_table\n # start drop this later\n if connection.tables.include?(FlagDefTableName) && !connection.columns(FlagDefTableName).detect{|x|x.name=='id'}\n connection.drop_table FlagDefTableName\n end\n # end drop this later\n \n unless connection.tables.include?(FlagDefTableName)\n connection.create_table FlagDefTableName.to_sym do |t|\n t.column \"model\", :string, :limit => 100\n t.column \"position\", :integer\n t.column \"flag_name\", :string, :limit => 100\n t.column \"flag_type\", :text, :limit => 6\n t.column \"default\", :boolean, :default => false\n end\n connection.add_index FlagDefTableName, [\"model\"], :name => \"by_model\"\n puts \"Flag definitions table created...OK\"\n else\n #puts \"Flag definitions table found...OK\"\n end\n end",
"def prepare_table(element)\n name=element.attributes[\"name\"]\n oid=SNMPPass.oid2num(element.attributes[\"oid\"])\n\n # Read index and columns\n indexes=element.elements[\"row/linkage\"].elements.collect(\"index\") {|index| index.attributes[\"name\"]}\n columns=element.elements[\"row\"].elements.collect(\"column\") do\n |column|\n column_name=column.attributes[\"name\"]\n column_oid=column.attributes[\"oid\"]\n column_id=SNMPPass.oid2num(column_oid).last\n\n $DEBUG.puts \"TABLE: #{name} NAME: #{column_name} ID #{column_id}, OID: #{column_oid}\"\n\n #column_desc=column.elements[\"description\"].text.gsub(/^[[:blank:]\\n]*/,\"\").gsub(/[[:blank:]\\n]*$/,\"\")\n type=prepare_type(column.elements[\"syntax\"], column_name)\n [column_name,column_id,type]\n end\n\n @indexes[name]=indexes\n @columns[name]=columns\n\n table=DynamicTree.new(oid){|op, *roid| dynamic_tree_callback(name, op, *roid) }\n add_node(table)\n end",
"def setup\n current_user = options[:currentuser]\n all_flag = options[:allflag]\n if current_user.percentcompleteenabled\n table = Table([:description, :goaltype_label, :datecompleted, :created_date, :last_updated_date, :percentcomplete]) do |t|\n if all_flag\n current_user.goals.find(:all).each {|g| t << g.report_record()}\n else\n current_user.goals.find(:all).each {|u| t << u.report_record unless u.datecompleted != nil}\n end\n end\n \n table.rename_columns(:description => \"Description\",\n :goaltype_label => \"Goal Type\",\n :datecompleted => \"Date Completed\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\",\n :percentcomplete => \"Percent Complete\")\n\n else\n table = Table([:description, :goaltype_label, :datecompleted, :created_date, :last_updated_date]) do |t|\n if all_flag\n current_user.goals.find(:all).each {|g| t << g.report_record()}\n else\n current_user.goals.find(:all).each {|u| t << u.report_record unless u.datecompleted != nil}\n end\n end\n\n table.rename_columns(:description => \"Description\",\n :goaltype_label => \"Goal Type\",\n :datecompleted => \"Date Completed\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\")\n\n \n end\n\n self.data = table\n end",
"def create_schema\n puts \"Preparing table\"\n\n \tquery = <<-QUERY\n \t\tCREATE TABLE tasks (\n \t\t\tid INTEGER PRIMARY KEY,\n \t\t\ttitle TEXT NOT NULL,\n \t\t\tdescription TEXT,\n \t\t\tcompleted TEXT\n \t\t);\n \tQUERY\n db.execute(\"DROP TABLE IF EXISTS tasks;\")\n \tdb.execute(query)\n\n puts \"Table creation completed!\"\n\n end",
"def table; end",
"def table; end",
"def table; end",
"def table; end",
"def create_tables!\n migrate(:up)\n end",
"def initialize\n @table = {}\n end",
"def resetUntappdTable\n @db.execute \"DROP TABLE IF EXISTS #{@untappdTable};\"\n @db.execute <<-SQL\n CREATE TABLE \"#{@untappdTable}\" (\n id float,\n name varchar(40),\n brewery varchar(60),\n beer_label varchar(40),\n abv float,\n ibu float,\n style varchar(40),\n description varchar(60),\n rating_score float,\n rating_count float\n );\n SQL\n end",
"def _table; @table end",
"def init_database\n\t\tif(!@DB.table_exists?(:events))\n\t\t\t@DB.create_table :events do\n\t\t\t\tprimary_key :id\n\t\t\t\tString :name\n\t\t\t\tString :description\n\t\t\t\tString :date\n\t\t\tend\n\t\tend\n\n\t\tif(!@DB.table_exists?(:timeslots))\n\t\t\t@DB.create_table :timeslots do\n\t\t\t\tString :time\n\t\t\t\tString :parent_table\n\t\t\t\tString :parent_id\n\t\t\tend\n\t\tend\n\n\t\tif(!@DB.table_exists?(:attendees))\n\t\t\t@DB.create_table :attendees do\n\t\t\t\tprimary_key :id\n\t\t\t\tString :name\n\t\t\t\tString :parent_id\n\t\t\tend\n\t\tend\n\tend",
"def build_tables\n @db.exec(%q[\n CREATE TABLE IF NOT EXISTS breeds(\n id serial NOT NULL PRIMARY KEY,\n breed varchar(30),\n price integer\n )])\n\n @db.exec(%q[\n CREATE TABLE IF NOT EXISTS puppies(\n id serial NOT NULL PRIMARY KEY,\n breed varchar(30),\n name varchar(30),\n age integer,\n created_at timestamp NOT NULL DEFAULT current_timestamp\n )])\n\n @db.exec(%q[\n CREATE TABLE IF NOT EXISTS requests(\n id serial NOT NULL PRIMARY KEY,\n breed text,\n status text,\n created_at timestamp NOT NULL DEFAULT current_timestamp\n )])\n end",
"def create_table!\n raise InvalidTableDefinition.new \"#{ self.name } has invalid table configuration\" unless model_table_config_is_valid?\n TinyDyno::Adapter.create_table(create_table_request)\n end",
"def createTables \n createUserTable\n createTaskTable\n createProjectTable\n end",
"def new_table(name, field_defs, encrypt, record_class)\r\n # Header rec consists of last record no. used, delete count, and\r\n # all field names/types. Here, I am inserting the 'recno' field\r\n # at the beginning of the fields.\r\n header_rec = ['000000', '000000', record_class, 'recno:Integer',\r\n field_defs].join('|')\r\n\r\n header_rec = 'Z' + encrypt_str(header_rec) if encrypt\r\n\r\n begin\r\n fptr = open(File.join(@db.path, name.to_s + @db.ext), 'w')\r\n fptr.write(header_rec + \"\\n\")\r\n ensure\r\n fptr.close\r\n end\r\n end",
"def initialize_table\n @total_rows.times do |row|\n row_array = Array.new(@total_columns, \"\")\n @reconstructed_table.push(row_array)\n end\n end",
"def create\n begin\n puts \"Creating...\"\n ActiveRecord::Schema.define do\n #create_table :test_relations do |table|\n # table.column :test_case_id, :integer\n # table.column :test_collection_id, :integer\n #end\n create_table :defaults do |table|\n table.column :configuration_id, :integer\n end\n\n\n # Project configuration\n create_table :configurations do |table|\n table.column :name, :string\n table.column :server, :string\n table.column :devkey, :string\n table.column :smtp_host, :string\n table.column :smtp_recipient, :string\n table.column :project, :string # aka prefix\n table.column :vm_user, :string\n table.column :vm_password, :string\n table.column :ssh_key_path, :string\n table.column :ssh_key_pw, :string\n table.column :base_path, :string\n table.column :output_path, :string\n table.column :public_options, :string\n end\n\n\n # A test collection is a collection of test, defined by project, testplan and build\n create_table :test_collections do |table|\n table.column :project, :string\n table.column :project_id, :string\n table.column :plan, :string\n table.column :plan_id, :string\n #table.column :build, :string\n #table.column :testrun_id, :string\n #table.column :test_cases, :string\n end\n\n create_table :test_cases do |table|\n table.column :urgency, :string\n table.column :name, :string\n table.column :file, :string\n table.column :external_id, :string\n table.column :platform_id, :string\n table.column :test_collection_id, :string\n\n end\n\n end\n\n rescue ActiveRecord::StatementInvalid\n # Table already created\n puts \"Setup already done. Destroy tables first before creating\"\n end\n\n\n end",
"def create_tables\n create_mirrors\n create_users\n create_user_tokens\n create_products\n create_users_products\n create_versions\n create_dependencies\n create_access_keys\n end",
"def initialize (num_legs) #You can put specific table material in initialize\n\t\t@tabletop = []\n\t\t@num_legs = num_legs\n\tend",
"def generate_table_def_table()\r\n table_def_name = \"table_definitions\"\r\n\r\n # If the table doesn't already exist, create it\r\n puts \"Creating table definition table (#{table_def_name}) if it doesn't exist.\" if @enable_debug_logging\r\n db_column_size_limits = @db_column_size_limits\r\n @db.transaction(:retry_on => [Sequel::SerializationFailure]) do\r\n @db.create_table?(table_def_name.to_sym) do\r\n String :tableName, :primary_key => true, :size => db_column_size_limits[:tableName]\r\n String :kappSlug, :size => db_column_size_limits[:kappSlug]\r\n String :formSlug, :size => db_column_size_limits[:formSlug]\r\n String :formName, :size => db_column_size_limits[:formName]\r\n end\r\n end\r\n end",
"def create_fund_table\n Bsf::Scraper.db.create_fund_table\n end",
"def prepare_schema\n begin\n ActiveRecord::Schema.define do\n # a twobot instance\n create_table :twobots do |t|\n t.string :name\n t.string :status, :null => false, :default => \"active\"\n end\n add_index :twobots, :name\n \n # has many twitter searches\n create_table :searches do |t|\n t.integer :twobot_id, :null => false\n t.string :query, :null => false\n t.integer :last_twid, :null => false, :default => 0\n t.timestamp :last_run\n t.integer :last_result_count\n t.integer :total, :default => 0\n end\n add_index :searches, :query\n \n # a search has many actions\n create_table :actions do |t|\n t.integer :search_id, :null => false\n t.text :code\n end\n \n # cache of tweets\n create_table :tweets do |t|\n t.integer :twid, :null => false\n t.string :from_user\n t.string :to_user\n t.integer :from_user_id\n t.integer :to_user_id\n t.string :text\n t.string :profile_image_url\n t.timestamp :created_at\n end\n add_index :tweets, :twid\n end\n rescue\n end\n end",
"def initDb\n @db.create_table! :tasks do\n primary_key :id\n Integer :created\n Integer :changed\n Integer :wake\n Integer :completed\n Integer :status\n String :title\n String :path\n String :data, :text=>TRUE\n end\n\n @db.create_table! :locks do\n Integer :id, :primary_key=>TRUE\n Integer :locked\n end\n end",
"def initialize_db_schema\n @db.exec(\n 'create table if not exists nodes\n (\n id SERIAL PRIMARY KEY,\n host VARCHAR(256) UNIQUE,\n last_seen TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n current_report INTEGER\n );\n\n create table if not exists collections\n (\n id SERIAL PRIMARY KEY,\n collection VARCHAR(256) NOT NULL,\n archived BOOL DEFAULT FALSE\n );\n\n create table if not exists reports\n (\n id SERIAL PRIMARY KEY,\n node_id INTEGER NOT NULL,\n file_handle INTEGER,\n status INTEGER NOT NULL,\n collection INTEGER NOT NULL,\n time TIMESTAMP NOT NULL,\n resources_changed INTEGER NOT NULL,\n resources_failed INTEGER NOT NULL,\n resources_total INTEGER NOT NULL,\n runtime REAL NOT NULL,\n new_report BOOL DEFAULT FALSE,\n FOREIGN KEY (node_id) REFERENCES nodes (id),\n FOREIGN KEY (collection) REFERENCES collections(id)\n );\n\n create table if not exists schemaversion\n (\n id SERIAL PRIMARY KEY,\n complete BOOL DEFAULT FALSE,\n comment VARCHAR(256) NOT NULL\n );\n create table if not exists reportdata\n (\n id SERIAL PRIMARY KEY,\n report bytea\n );\n '\n )\n end",
"def ensure_table\n # Check if table exists\n if !@db.tables || !@db.tables.include?(table_name)\n log(\"Creating Table #{table_name}\")\n adaptor_name = @adaptor.adaptor_name\n @db.create_table(table_name) do\n # guid id\n column :id, String, :unique => true, :null => false, :primary_key => true\n\n # When using underscore notation on a field that does not exist, the\n # data will be stored in extra.\n if adaptor_name == 'postgres'\n # Use jsonb\n column :extra, 'json'\n else\n column :extra, String\n end\n end\n # TODO: there's some issue with @db.schema and no clue why, but I\n # have to run this again to get .schema to work later.\n @db.tables\n end\n end",
"def create_initial_table_in_database\n\n if ScraperWiki.show_tables()[\"swdata\"] == nil\n\n ScraperWiki.sqliteexecute(\"CREATE TABLE 'swdata' ('date_scraped' text, 'description' text, 'info_url' text, 'council_reference' text, 'address' text, 'comment_url' text, 'page_content' text)\");\n\n end\n\nend",
"def create_initial_table_in_database\n\n if ScraperWiki.show_tables()[\"swdata\"] == nil\n\n ScraperWiki.sqliteexecute(\"CREATE TABLE 'swdata' ('date_scraped' text, 'description' text, 'info_url' text, 'council_reference' text, 'address' text, 'comment_url' text, 'page_content' text)\");\n\n end\n\nend",
"def init_table\n\t$table = Array.new($height) { Array.new($width, '.')}\nend",
"def resetCrawlerTable\n @db.execute \"DROP TABLE IF EXISTS #{@crawlerTable};\"\n @db.execute <<-SQL\n CREATE TABLE \"#{@crawlerTable}\" (\n name varchar(40),\n price float,\n quantity varchar(20),\n url varchar(50),\n location varchar(40),\n style varchar(50)\n );\n SQL\n end",
"def create_initial_table_in_database\n if ScraperWiki.show_tables()[\"swdata\"] == nil\n ScraperWiki.sqliteexecute(\"CREATE TABLE 'swdata' ('date_scraped' text, 'description' text, 'info_url' text, 'council_reference' text, 'address' text, 'comment_url' text, 'page_content' text)\");\n end\nend",
"def create_initial_table_in_database\n if ScraperWiki.show_tables()[\"swdata\"] == nil\n ScraperWiki.sqliteexecute(\"CREATE TABLE 'swdata' ('date_scraped' text, 'description' text, 'info_url' text, 'council_reference' text, 'address' text, 'comment_url' text, 'page_content' text)\");\n end\nend",
"def setup\n current_user = options[:currentuser]\n all_flag = options[:allflag]\n if current_user.percentcompleteenabled\n table = Table([:description, :category_label, :created_date, :last_updated_date, :percentcomplete]) do |t|\n if all_flag\n current_user.tasks.find(:all).each {|u| t << u.report_record() }\n else\n completed_category = current_user.category.find(:all, :conditions => [\n \"label = 'Completed'\"\n ])\n current_user.tasks.find(:all).each {|u| t << u.report_record unless u.category_id == completed_category[0].id}\n end\n end\n table.rename_columns(:description => \"Description\",\n :category_label => \"Task Category\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\",\n :percentcomplete => \"Percent Complete\")\n else\n table = Table([:description, :category_label, :created_date, :last_updated_date]) do |t|\n if all_flag\n current_user.tasks.find(:all).each {|u| t << u.report_record() }\n else\n completed_category = current_user.category.find(:all, :conditions => [\n \"label = 'Completed'\"\n ])\n current_user.tasks.find(:all).each {|u| t << u.report_record unless u.category_id == completed_category[0].id}\n end\n end\n table.rename_columns(:description => \"Description\",\n :category_label => \"Task Category\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\")\n end\n \n self.data = table\n end",
"def set_table(params = {})\n @table = Table.new(params)\n @table.palette = @palette\n end",
"def setup_news_table\n ActiveRecord::Schema.define do\n # drop_table :news if table_exists? :news\n create_table :news do |table|\n table.column :title, :string\n table.column :category, :string\n table.column :pub_date, :string\n table.column :from_site, :string\n table.column :image, :text\n table.column :video, :string\n table.column :text, :text\n end\n end\n end",
"def set_table_def\n @table_def = TableDef.find(params[:id])\n end",
"def setup\n setup_connection\n\n unless tables.count == 0\n puts \"Aborting! Job already has tables attached. Setup requires a new job.\"\n return\n end\n source_tables = source_connection.tables\n source_tables = source_tables.reject { |table| \n exclude_table_names.include?(table) || table.starts_with?('tmp_') \n }\n\n source_tables.each do |table_name|\n copy_table_schema(table_name)\n end\n\n puts \"Done setup!\"\n puts \"Warning! Table settings have been guessed but you can do extra configuration such as setting the insert_only flag on tables to further increase speed of loading.\"\n end",
"def create_table\n ActiveRecord::Migration.create_table(table_name) do |t|;end;\n end",
"def createTable\n\t\tstm = @db.prepare \"CREATE TABLE IF NOT EXISTS leituras (\n\t\t\t\tIDCLIENTE INT NOT NULL,\n\t\t\t\tIDSENSOR INT NOT NULL,\n\t\t\t\tVALUE INT NOT NULL,\n\t\t\t\tGPSX INT NOT NULL,\n\t\t\t\tGPSY INT NOT NULL,\n\t\t\t\tTIMESTAMP TEXT NOT NULL\n\t\t\t);\"\n\n\t\trs = stm.execute\n\t\trs.close\n\tend",
"def tnTableCreation(tableName)\n pk_list = @pkList.join(',')\n pk_list = \"#{pk_list},branch_name,node_name\"\n q = QueryBuilder.create_tbl(tableName, pk_list, \"select #{@pkSelect}, 0 as test_id,''::varchar(30) as node_name, ''::varchar(30) as branch_name, ''::varchar(5) as type from #{@fTable} f where 1 = 0\")\n # pp q\n DBConn.exec(q)\n\n # q=\"ALTER TABLE #{tableName} add column test_id int, add column node_name varchar(30), add column branch_name varchar(30), add column type varchar(5);\"\n # DBConn.exec(q)\n # pk=@pkList.join(',')\n # # add index\n # q=\"create index ix_#{tableName}t on #{tableName} (#{pk},branch_name);\"\n # pp q\n # DBConn.exec(q)\n end",
"def createStakeholderTable\n @Handle.execute( @StakeholderSchema ) \n end",
"def tables\n sanity_check\n @handle.tables\n end",
"def generate_tables\n create_characters\n create_kiosks\n create_traps\n create_buttons\n end",
"def create(structure_, data_={})\n Table.new(structure_, data_)\n end",
"def table\n end",
"def set_table\n @table = Table.find(params[:id])\n end",
"def initialize config\n connect config\n create_table_if_not_exists!\n end",
"def create_structure\n # Create variables table\n @db.execute(\"create table if not exists variables(key varchar(255) PRIMARY KEY, value TEXT);\");\n\n # Create quotes table\n @db.execute(\"create table if not exists quotes (id INTEGER PRIMARY KEY, quote TEXT);\")\n\n # Remember NSFW links\n @db.execute(\"create table if not exists nsfwlink_status (id INTEGER PRIMARY KEY, user VARCHAR(15), nsfw TINYINT DEFAULT 0);\")\n\n # Allow polls\n @poll_db.execute(\"create table if not exists polls (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, user VARCHAR(30), question VARCHAR(255), date TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL)\")\n\n # Voting alternatives for polls\n @poll_db.execute(\"create table if not exists answers (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, poll_id INTEGER REFERENCES polls(id), number INTEGER, answer VARCHAR(255));\")\n\n # Votes for polls\n @poll_db.execute(\"create table if not exists votes (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, usermask VARCHAR(255), poll_id INTEGER REFERENCES polls(id), answer_id INTEGER REFERENCES answers(id));\")\n\n\n if @debug == true\n puts \"Should have created tables by now\"\n end\n end",
"def CreateTables()\n\n #Products/Items .. Description of products\n @@db.execute \"CREATE TABLE IF NOT EXISTS Product(item_id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT NOT NULL, desciption TEXT);\"\n\n #Inventory - to keep track of products currently in the store,\n @@db.execute \"CREATE TABLE IF NOT EXISTS Inventory(item_id INTEGER NOT NULL PRIMARY KEY,price NUMERIC NOT NULL,quantity INTEGER ,extraNotes TEXT);\"\n\n # customer's shopping cart... items that customer chose\n @@db.execute \"CREATE TABLE IF NOT EXISTS Basket(item_id INTEGER NOT NULL PRIMARY KEY, quantity INTEGER);\"\n end",
"def set_up_table_view\n self.table_view\n _table_view = self.create_table_view_from_data(self.table_data)\n adjusted_frame = self.view.bounds\n adjusted_frame.size.width = app_delegate.panels.leftVisibleWidth\n _table_view.frame = adjusted_frame\n self.view = UIView.new\n self.view.addSubview(_table_view)\n end",
"def createProjectTable\n @Handle.execute( @ProjectSchema ) \n end",
"def set_table\n @table = Table.find(params[:id])\n end",
"def set_table\n @table = Table.find(params[:id])\n end",
"def set_table\n @table = Table.find(params[:id])\n end",
"def set_table\n @table = Table.find(params[:id])\n end",
"def set_table\n @table = Table.find(params[:id])\n end",
"def set_table\n @table = Table.find(params[:id])\n end",
"def set_table\n @table = Table.find(params[:id])\n end",
"def set_table\n @table = Table.find(params[:id])\n end",
"def set_table\n @table = Table.find(params[:id])\n end",
"def spawn_tables\n\t# pseudo-migration / schema\n\tif !FeedEntry.table_exists?\n\t\tprint \"Creating feed entry table...\\n\"\n\t\tActiveRecord::Base.connection.create_table(:feed_entries) do |t|\n\t\t\tt.column :name, :string\n\t\t\tt.column :content, :string\n\t\t\tt.column :url, :string\n\t\t\tt.column :guid, :string\n\t\t\tt.column :published_at, :datetime\n\t\t\tt.column :feed_id, :integer\n\t\tend\n\tend\n\tif !Feed.table_exists?\n\t\tprint \"Creating feed table...\\n\"\n\t\tActiveRecord::Base.connection.create_table(:feeds) do |t|\n\t\t\tt.column :url, :string\n\t\tend\n\tend\n\tif !Blacklist.table_exists?\n\t\tprint \"Creating blacklist table...\\n\"\n\t\tActiveRecord::Base.connection.create_table(:blacklists) do |t|\n\t\t\tt.column :word, :string\n\t\tend\n\tend\nend",
"def create\n if @db.table_info(METADATA_TABLE_NAME).empty?\n stmt = \"CREATE TABLE #{METADATA_TABLE_NAME} (key VARCHAR(1024), val VARCHAR(8192), env VARCHAR(255))\"\n @db.execute(stmt)\n end\n\n if @db.table_info(RUN_HISTORY_TABLE_NAME).empty?\n stmt = \"CREATE TABLE #{RUN_HISTORY_TABLE_NAME} (name VARCHAR(1024), outcome VARCHAR(16), env VARCHAR(255), time DATETIME)\"\n @db.execute(stmt)\n\n index_stmt = \"CREATE INDEX index_run_history ON #{RUN_HISTORY_TABLE_NAME} (time DESC)\"\n @db.execute(index_stmt)\n end\n\n if @db.table_info(DISABLED_MONITOR_TABLE_NAME).empty?\n stmt = \"CREATE TABLE #{DISABLED_MONITOR_TABLE_NAME} (name VARCHAR(1024), env VARCHAR(255))\"\n @db.execute(stmt)\n end\n\n if @db.table_info(MONITOR_INFO_TABLE_NAME).empty?\n stmt = \"CREATE TABLE #{MONITOR_INFO_TABLE_NAME} (name VARCHAR(1024), description VARCHAR(8192))\"\n @db.execute(stmt)\n end\n end",
"def create_table_structure(columns_to_include)\n if @table_created\n @columns.each do |column|\n begin\n ActiveRecord::Schema.add_column(@new_table_name, column[:name], column[:type]) if (columns_to_include.blank? or columns_to_include.include? column[:name])\n rescue\n puts \"Couldnt add field #{column[:name].downcase}\"\n end\n end\n ActiveRecord::Schema.add_column(@new_table_name,\"the_geom\", :geometry,:null => false)\n ActiveRecord::Schema.add_index(@new_table_name,\"the_geom\",:spatial => true)\n end\n end",
"def create_table_structure(columns_to_include)\n if @table_created\n @columns.each do |column|\n begin\n ActiveRecord::Schema.add_column(@new_table_name, column[:name], column[:type]) if (columns_to_include.blank? or columns_to_include.include? column[:name])\n rescue\n puts \"Couldnt add field #{column[:name].downcase}\"\n end\n end\n ActiveRecord::Schema.add_column(@new_table_name,\"the_geom\", :geometry,:null => false)\n ActiveRecord::Schema.add_index(@new_table_name,\"the_geom\",:spatial => true)\n end\n end",
"def init_table(layer, stat) # returns self\n tbl = Table.new(layer, stat)\n if stat[:data_ver].to_i > 0\n ___create_tbl(tbl)\n ___real_mode(stat, tbl)\n else\n ___dummy_mode(stat, tbl)\n end\n self\n end",
"def settable\n @settable ||= %i[text_field file_field textarea checkbox select_list]\n end",
"def prepare_schema\n tables = [];ActiveRecord::Base.connection.execute(\"show tables\").each{|t| tables << t[0].strip}\n \n ActiveRecord::Schema.define do\n App.log.info(\"preparing schema\")\n \n unless tables.include?(\"services\")\n # a service entry\n begin\n create_table :services do |t|\n t.string :name\n t.string :status, :null => false, :default => \"active\"\n end\n add_index :services, :name\n rescue\n App.log_exception\n end\n end\n \n unless tables.include?(\"queries\")\n begin\n # queries\n create_table :queries do |t|\n t.string :query \n t.column :last_twid, :bigint, :null => false, :default => 0\n t.timestamp :last_run\n t.integer :last_result_count\n t.string :status, :default => 'active', :null=> false\n end\n add_index :queries, :query\n rescue\n App.log_exception\n end\n end\n \n unless tables.include?(\"tweets\")\n begin\n # cache of tweets\n create_table :tweets do |t|\n t.column :twid, :bigint, :null => false\n t.string :from_user\n t.string :to_user\n t.integer :from_user_id\n t.integer :to_user_id\n t.string :text\n t.string :profile_image_url\n t.timestamp :created_at\n end\n add_index :tweets, :twid\n rescue\n App.log_exception\n end\n end\n \n end # define schema\n end",
"def create_tables_mysql()\n\n\t\tdbrows = @database.query <<-SQL\n\t\tCREATE TABLE IF NOT EXISTS invoices (\n\t\t\torganization VARCHAR(255),\n\t\t\tupdated DATE,\n\t\t\tamount FLOAT,\n\t\t\tamount_outstanding FLOAT,\n\t\t\tdiscount FLOAT,\n\t\t\tinvoice_id VARCHAR(255),\n\t\t\tnumber VARCHAR(255) UNIQUE PRIMARY KEY,\n\t\t\tmatter VARCHAR(255),\n\t\t\tstatus VARCHAR(255),\n\t\t\tdate DATE\n\t\t\t);\n\t\t\tSQL\n\n\t\t\tdbrows = @database.query <<-SQL\n\t\t\tCREATE TABLE IF NOT EXISTS invoice_lines (\n\t\t\t\tline_id INTEGER,\n\t\t\t\t_order INTEGER,\n\t\t\t\tnumber VARCHAR(255),\n\t\t\t\tinvoice_id VARCHAR(255),\n\t\t\t\tdescription TEXT,\n\t\t\t\tamount FLOAT,\n\t\t\t\tfirst_expense_id INTEGER,\n\t\t\t first_time_entry_id TEXT,\n\t\t\t\tline_item_date VARCHAR(255),\n\t\t\t\tperson VARCHAR(512),\n\t\t\t\tname VARCHAR(255),\n\t\t\t\tunit_cost FLOAT,\n\t\t\t\tquantity FLOAT,\n\t\t\t\ttype VARCHAR(255),\n\t\t\t\tmatter VARCHAR(255),\n\t\t\t\tupdated DATE\n\t\t\t\t);\n\t\t\t\tSQL\n\t\t## Add code here if you end up making additional tables\n\n\t\tdbrows = @database.query <<-SQL\n\t\tCREATE TABLE IF NOT EXISTS projects (\n\t\t\tmatter VARCHAR(255) UNIQUE,\n\t\t\tname VARCHAR(255),\n\t\t\tproject_id VARCHAR(255),\n\t\t\thour_budget FLOAT\n\t\t\t);\n\t\t\tSQL\n\t\tdbrows = @database.query('DELETE FROM projects;')\n\n\t\tdbrows = @database.query <<-SQL\n\t\tCREATE TABLE IF NOT EXISTS time_entries (\n\t\t\ttime_entry_id INTEGER UNIQUE,\n\t\t\tstaff_id INTEGER,\n\t\t\tproject_id VARCHAR(255),\n\t\t\ttask_id INTEGER,\n\t\t\thours FLOAT,\n\t\t\tdate DATE,\n\t\t\tnotes TEXT,\n\t\t\tbilled INTEGER\n\t\t);\n\t\tSQL\n\t\tdbrows = @database.query('DELETE FROM time_entries;')\n\n\t\tdbrows = @database.query <<-SQL\n\t\tCREATE TABLE IF NOT EXISTS staff (\n\t\t\tperson VARCHAR(512),\n\t\t\tfirst_name VARCHAR(255),\n\t\t\tlast_name VARCHAR(255),\n\t\t\tstaff_id INTEGER,\n\t\t\trate FLOAT\n\t\t);\n\t\tSQL\n\t\tdbrows = @database.query('DELETE FROM staff;')\n\n\t\tdbrows = @database.query <<-SQL\n\t\tCREATE TABLE IF NOT EXISTS contractor (\n\t\t\tname VARCHAR(255),\n\t\t\tcontractor_id INTEGER,\n\t\t\trate FLOAT\n\t\t);\n\t\tSQL\n\t\tdbrows = @database.query('DELETE FROM contractor;')\n\n\t\tdbrows = @database.query <<-SQL\n\t\t\t-- estimates from Contractors\n\t\t\tCREATE OR REPLACE VIEW unbilled_contractor_time AS\n\t\t\t\tSELECT projects.matter, contractor.name as person, SUM(time_entries.hours * contractor.rate) as estimated\n\t\t\t\tFROM time_entries\n\t\t\t\tINNER JOIN projects ON projects.project_id = time_entries.project_id\n\t\t\t\tINNER JOIN contractor ON contractor.contractor_id = time_entries.staff_id\n\t\t\t\tWHERE projects.matter <> '' AND time_entries.billed = 0\n\t\t\t\tGROUP BY projects.matter, person\n\t\t\t;\n\t\t\tSQL\n\n\t\t\t#UNBILLED STAFF TIME view\n\t\tdbrows = @database.query <<-SQL\n\t\t-- Estimates from Staff\n\t\t\tCREATE OR REPLACE VIEW unbilled_staff_time AS\n\t\t\t\t\tSELECT projects.matter, staff.person, SUM(time_entries.hours * staff.rate) as estimated\n\t\t\t\t\tFROM time_entries\n\t\t\t\t\tINNER JOIN projects ON projects.project_id = time_entries.project_id\n\t\t\t\t\tINNER JOIN staff ON staff.staff_id = time_entries.staff_id\n\t\t\t\t\tWHERE projects.matter <> '' AND time_entries.billed = 0\n\t\t\t\t\tGROUP BY projects.matter, staff.person\n\t\t\t\t\tORDER BY projects.matter, staff.person\n\t\t\t\t\t;\n\n\t\t\tSQL\n\n\t\t#UNBILLED ALL TIME TEMP view\n\t\tdbrows = @database.query <<-SQL\n\t\t\tCREATE OR REPLACE VIEW unbilled_all_time_temp AS\n\t\t\t\t\tSELECT * FROM unbilled_staff_time\n\t\t\t\t\tUNION\n\t\t\t\t\tSELECT * FROM unbilled_contractor_time;\n\t\t\tSQL\n\n\t\t#UNBILLED ALL TIME view\n\t\tdbrows = @database.query <<-SQL\n\t\t\t-- All unbilled time\n\t\t\t\tCREATE OR REPLACE VIEW unbilled_all_time AS\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM unbilled_all_time_temp\n\t\t\t\t\tGROUP BY unbilled_all_time_temp.matter, unbilled_all_time_temp.person\n\t\t\t\t;\n\t\t\t\tSQL\n\n\t\t#mysql version\n\t\t#INVOICES GROUP view\n\t\tdbrows = @database.query <<-SQL\n\t\t\tCREATE OR REPLACE VIEW invoices_grouped AS\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tinvoices.organization\n\t\t\t\t\t\t, invoices.matter\n\t\t\t\t\t\t, SUM((CASE WHEN status <> 'draft' THEN invoices.amount ELSE 0 END)) AS lifetime_billed\n\t\t\t\t\t\t, SUM((CASE WHEN YEAR(invoices.date) = YEAR(NOW()) THEN\n\t\t\t\t\t\t\t(CASE WHEN status <> 'draft' THEN invoices.amount ELSE 0 END)\n\t\t\t\t\t\t\tELSE 0 END)) as ytd_billed\n\t\t\t\t\t\t, SUM((CASE WHEN status = 'draft' THEN invoices.amount ELSE 0 END)) as draft_invoices\n\t\t\t\t\t\t, SUM((CASE WHEN status <> 'draft' THEN invoices.amount_outstanding ELSE 0 END)) as outstanding\n\t\t\t\t\tFROM invoices\n\t\t\t\t\tGROUP BY invoices.organization, invoices.matter;\n\t\t\tSQL\n\n\t\t#ORGNAMES view\n\t\tdbrows = @database.query <<-SQL\n\t\t\tCREATE OR REPLACE VIEW orgnames AS\n\t\t\t\tSELECT DISTINCT invoices_grouped.organization, unbilled_all_time.matter\n\t\t\t\tFROM unbilled_all_time\n\t\t\t\tLEFT OUTER JOIN invoices_grouped ON SUBSTR(invoices_grouped.matter,1,4) = SUBSTR(unbilled_all_time.matter,1,4);\n\t\t\tSQL\n\n\t\tdbrows = @database.query <<-SQL\n\t\t\t-- Build a deconstructed invoice from the line items\n\t\t\tCREATE OR REPLACE VIEW apportioned_invoices AS\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\tinvoices.organization\n\t\t\t\t\t\t\t, invoices.updated\n\t\t\t\t\t\t\t, (invoice_lines.amount - (invoice_lines.amount * invoices.discount/100)) as amount\n\t\t\t\t\t\t\t, (invoices.amount_outstanding/invoices.amount) * (invoice_lines.amount - (invoice_lines.amount * invoices.discount/100)) as amount_outstanding\n\t\t\t\t\t\t\t, invoices.discount\n\t\t\t\t\t\t\t, invoices.invoice_id\n\t\t\t\t\t\t\t, invoices.number\n\t\t\t\t\t\t\t, invoices.matter\n\t\t\t\t\t\t\t, invoices.status\n\t\t\t\t\t\t\t, invoices.date\n\t\t\t\t\t\t\t, (CASE WHEN invoice_lines.person = '' OR invoice_lines.person IS NULL THEN 'no name found' ELSE invoice_lines.person END) as person\n\t\t\t\t\t\t\t, invoice_lines.type\n\t\t\t\t\t\tFROM invoice_lines\n\t\t\t\t\t\tLEFT OUTER JOIN invoices ON invoices.invoice_id = invoice_lines.invoice_id\n\t\t\t\t\t\t;\n\t\t\tSQL\n\n\t\tdbrows = @database.query <<-SQL\n\t\t\tCREATE OR REPLACE VIEW apportioned_invoices_grouped AS\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tapportioned_invoices.organization\n\t\t\t\t\t\t, apportioned_invoices.matter\n\t\t\t\t\t\t, apportioned_invoices.person\n\t\t\t\t\t\t, SUM((CASE WHEN apportioned_invoices.status <> 'draft' THEN apportioned_invoices.amount ELSE 0 END)) AS lifetime_billed\n\t\t\t\t\t\t, SUM((CASE WHEN YEAR(apportioned_invoices.date) = YEAR(NOW()) THEN\n\t\t\t\t\t\t\t(CASE WHEN apportioned_invoices.status <> 'draft' THEN apportioned_invoices.amount ELSE 0 END)\n\t\t\t\t\t\t\tELSE 0 END)) as ytd_billed\n\t\t\t\t\t\t, SUM((CASE WHEN apportioned_invoices.status = 'draft' THEN apportioned_invoices.amount ELSE 0 END)) as draft_invoices\n\t\t\t\t\t\t, SUM(unbilled_all_time.estimated) AS estimated\n\t\t\t\t\t\t, SUM((CASE WHEN apportioned_invoices.status <> 'draft' THEN apportioned_invoices.amount_outstanding ELSE 0 END)) as outstanding\n\t\t\t\t\tFROM apportioned_invoices\n\t\t\t\t\tLEFT OUTER JOIN unbilled_all_time ON apportioned_invoices.matter = unbilled_all_time.matter AND apportioned_invoices.person = unbilled_all_time.person\n\t\t\t\t\tGROUP BY apportioned_invoices.organization, apportioned_invoices.matter, apportioned_invoices.person;\n\t\t\t\t\t;\n\t\t\t\tSQL\n\n\t\t#UNBILLED ALL TIME WITH ORGS view\n\t\tdbrows = @database.query <<-SQL\n\t\t\t-- need to fix up matters\n\t\t\tCREATE OR REPLACE VIEW unbilled_all_time_with_orgs AS\n\t\t\t\t\tSELECT (CASE WHEN orgnames.organization <> '' THEN orgnames.organization ELSE 'unknown organization' END) as organization, unbilled_all_time.person, unbilled_all_time.matter, unbilled_all_time.estimated\n\t\t\t\t\tFROM unbilled_all_time\n\t\t\t\t\tLEFT OUTER JOIN orgnames ON orgnames.matter = unbilled_all_time.matter\n\t\t\t\t;\n\t\t\tSQL\n\n\t\tdbrows = @database.query <<-SQL\n\t\t\tCREATE OR REPLACE VIEW dashboard_detailed AS\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tapportioned_invoices_grouped.organization\n\t\t\t\t\t\t, apportioned_invoices_grouped.matter\n\t\t\t\t\t\t, apportioned_invoices_grouped.person\n\t\t\t\t\t\t, apportioned_invoices_grouped.lifetime_billed\n\t\t\t\t\t\t, apportioned_invoices_grouped.ytd_billed\n\t\t\t\t\t\t, apportioned_invoices_grouped.outstanding\n\t\t\t\t\t\t, apportioned_invoices_grouped.draft_invoices\n\t\t\t\t\t\t, (CASE WHEN unbilled_all_time_with_orgs.estimated IS NULL THEN 0 ELSE unbilled_all_time_with_orgs.estimated END) as estimated\n\t\t\t\t\t\t, (apportioned_invoices_grouped.lifetime_billed + apportioned_invoices_grouped.draft_invoices + (CASE WHEN unbilled_all_time_with_orgs.estimated IS NULL THEN 0 ELSE unbilled_all_time_with_orgs.estimated END)) as all_spend\n\t\t\t\t\tFROM apportioned_invoices_grouped\n\t\t\t\t\tLEFT OUTER JOIN unbilled_all_time_with_orgs ON unbilled_all_time_with_orgs.matter = apportioned_invoices_grouped.matter AND unbilled_all_time_with_orgs.person = apportioned_invoices_grouped.person\n\t\t\t\t\tUNION\n\t\t\t\t\t-- Find the other half of the FULL OUTER JOIN\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tunbilled_all_time_with_orgs.organization\n\t\t\t\t\t\t, unbilled_all_time_with_orgs.matter\n\t\t\t\t\t\t, unbilled_all_time_with_orgs.person\n\t\t\t\t\t\t, 0 as lifetime_billed\n\t\t\t\t\t\t, 0 as ytd_billed\n\t\t\t\t\t\t, 0 as outstanding\n\t\t\t\t\t\t, 0 as draft_invoices\n\t\t\t\t\t\t, unbilled_all_time_with_orgs.estimated\n\t\t\t\t\t\t, unbilled_all_time_with_orgs.estimated as all_spend\n\t\t\t\t\tFROM unbilled_all_time_with_orgs\n\t\t\t\t\tLEFT OUTER JOIN apportioned_invoices_grouped ON apportioned_invoices_grouped.matter = unbilled_all_time_with_orgs.matter AND apportioned_invoices_grouped.person = unbilled_all_time_with_orgs.person\n\t\t\t\t\tWHERE apportioned_invoices_grouped.matter IS NULL;\n\t\t\t\t;\n\t\t\tSQL\n\n\n\n\t\t\t#DASHBOARD view\n\t\t\tdbrows = @database.query <<-SQL\n\t\t\t\tCREATE OR REPLACE VIEW dashboard AS\n\t\t\t\t\tSELECT\n\t\t\t\t\t \torganization\n\t\t\t\t\t , matter\n\t\t\t\t\t , SUM(lifetime_billed) as lifetime_billed\n\t\t\t\t\t , SUM(ytd_billed) as ytd_billed\n\t\t\t\t\t , SUM(outstanding) as outstanding\n\t\t\t\t\t , SUM(draft_invoices) as draft_invoices\n\t\t\t\t\t , SUM(estimated) as estimated\n\t\t\t\t\t , SUM(all_spend) as all_spend\n\t\t\t\t\tFROM dashboard_detailed\n\t\t\t\t\tGROUP BY matter\n\t\t\t\t;\n\t\t\tSQL\n\tend",
"def create_all_skills_tbl\n\t\t\tq_rows = @player_data_db.execute <<-SQL\n\t\t\t\tCREATE TABLE IF NOT EXISTS all_skills (\n\t\t\t\t\tid INTEGER PRIMARY KEY,\n\t\t\t\t\tdb_name varchar(30),\n\t\t\t\t\tname varchar(30),\n\t\t\t\t\tdescrip varchar(255),\n\t\t\t\t\tsp_cost int,\n\t\t\t\t\td_dmg int,\n\t\t\t\t\tp_dmg float,\n\t\t\t\t\tmh_dmg float,\n\t\t\t\t\ta_pen int,\n\t\t\t\t\ts_class varchar(10)\n\t\t\t\t\t\t\n\t\t\t\t);\n\t\t\tSQL\n\t\tend",
"def create_table\n connection.create_table table_name do |t|\n t.string :record_class_name, :null => false\n t.integer :record_id, :null => false\n t.boolean :is_delete, :null => false, :default => false\n t.datetime :run_at, :null => false\n t.integer :priority, :null => false, :default => 0\n t.integer :lock, :null => true\n t.string :error, :null => true, :limit => 4000\n t.integer :attempts, :null => false, :default => 0\n end\n\n connection.add_index table_name, :record_id\n connection.add_index table_name, [:run_at, :record_class_name, :priority], :name => \"#{table_name}_run_at\"\n end",
"def create_table(name, &block)\n DB.drop_table? name if @opts.drop_tables?\n DB.create_table? name.to_sym, &block\n info \"Setup database table: #{name}\"\n end",
"def create_table\n raise \"Need to implement abstract method.\" \n end",
"def create_table objects, columns, title, date_param = nil, nosort = false\n\t\tcurr_user = current_user\n\t\n\t\tid_to_names = [\"trip_id\",\"destination_id\",\"bus_id\"]\n\t\ttimes = [\"depart_time\",\"arrive_time\",\"return_time\"]\n\t\tdates = [\"date\",\"start\",\"expiry\",\"offset_date\",\"start_date\",\"end_date\",\"created_at\",\"updated_at\"]\n\t\tno_management = [\"permissions\", \"roles\"]\n\t\tmanagement_headers = [\"updated_by\",\"created_at\",\"updated_at\"]\n\t\t\n\t\thtml = \"\"\n\t\thtml << '<h1>'.html_safe\n\t\thtml << title\n\t\t\n\t\thtml << '</h1>'.html_safe\n\t\t\n\t\thtml << '<table class=\"admin_table\">'.html_safe\n\t\t\n\t\thtml << '<tr class=\"tr_header\">'.html_safe\n\t\tcolumns.each do |col|\n\t\t\t\n\t\t\tcol_title = col\n\t\t\t\n\t\t\tif col.include? '_id' then col_title = col.split('_id')[0] end\n\t\t\t\n\t\t\tif management_headers.include? col\n\t\t\t\tif curr_user.has_permission? :management\n\t\t\t\t\thtml << '<th>'.html_safe\n\t\t\t\t\tif !nosort \n\t\t\t\t\t\thtml << sort_table(col, col_title.humanize, date_param).html_safe\n\t\t\t\t\telse\n\t\t\t\t\t\thtml << col_title.humanize\n\t\t\t\t\tend\n\t\t\t\t\thtml << '</th>'.html_safe\n\t\t\t\tend\n\t\t\telse\n\t\t\t\thtml << '<th>'.html_safe\n\t\t\t\tif !nosort \n\t\t\t\t\thtml << sort_table(col, col_title.humanize, date_param).html_safe\n\t\t\t\telse\n\t\t\t\t\thtml << col_title.humanize\n\t\t\t\tend\n\t\t\t\thtml << '</th>'.html_safe\n\t\t\tend\n\t\t\t\n\t\tend\n\t\t\n\t\t# Show Column\n\t\thtml << '<th></th>'.html_safe\n\t\t\n\t\t# Edit Column\n\t\tif (curr_user.has_permission? :admin) || (!(no_management.include? objects[0].class.name.tableize) && (curr_user.has_permission? :management))\n\t\t\thtml << '<th></th>'.html_safe\n\t\tend\n\t\t\n\t\t# Destroy Column\n\t\tif curr_user.has_permission? :admin\n\t\t\thtml << '<th></th>'.html_safe\n\t\tend\n\t\t\n\t\thtml << '</tr>'.html_safe\n\t\t\n\t\ti = 0\n\t\tobjects.each do |obj|\n\t\t\tif i.even?\n\t\t\t\thtml << '<tr class=\"tr_alt_1\">'.html_safe\n\t\t\telse\n\t\t\t\thtml << '<tr class=\"tr_alt_2\">'.html_safe\n\t\t\tend\n\t\t\t\tcolumns.each do |col|\n\t\t\t\t\t\n\t\t\t\t\tif id_to_names.include? col\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\tcol = col.split('_id')[0]\n\t\t\t\t\t\thtml << (link_to obj.send(col).id.to_s + \": \" + obj.send(col).name, obj.send(col)).html_safe\n\t\t\t\t\telsif col == \"user_id\" || col == \"updated_by\"\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\tcol = col.split('_id')[0]\n\t\t\t\t\t\tif obj.send(col)\n\t\t\t\t\t\t\thtml << (link_to obj.send(col).userid, obj.send(col)).html_safe\n\t\t\t\t\t\tend\n\t\t\t\t\telsif col == \"id\"\n\t\t\t\t\t\thtml << '<td class=\"td_links\">'.html_safe\n\t\t\t\t\t\thtml << obj.send(col).to_s\n\t\t\t\t\telsif col == \"weekday\"\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\thtml << Date::DAYNAMES[obj.send(col)]\n\t\t\t\t\telsif times.include? col\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\thtml << obj.send(col).strftime(\"%I:%M %p\")\n\t\t\t\t\telsif dates.include? col\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\thtml << obj.send(col).strftime(\"%B %d, %Y\")\n\t\t\t\t\telsif col.include? \"_id\"\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\tcol = col.split('_id')[0]\n\t\t\t\t\t\tif obj.send(col)\n\t\t\t\t\t\t\thtml << (link_to obj.send(col).id.to_s, obj.send(col)).html_safe\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\thtml << obj.send(col).to_s\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\thtml << '</td>'.html_safe\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# Show Column\n\t\t\t\thtml << '<td class=\"td_links\">'.html_safe\n\t\t\t\thtml << (link_to \"Show\", obj).html_safe\n\t\t\t\thtml << '</td>'.html_safe\n\t\t\t\t\n\t\t\t\t# Edit Column\n\t\t\t\tif (curr_user.has_permission? :admin) || (!(no_management.include? objects[0].class.name.tableize) && (curr_user.has_permission? :management))\n\t\t\t\t\thtml << '<td class=\"td_links\">'.html_safe\n\t\t\t\t\thtml << (link_to \"Edit\", \"/\" + obj.class.name.tableize + \"/\" + obj.id.to_s + \"/edit\").html_safe\n\t\t\t\t\thtml << '</td>'.html_safe\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# Destroy Column\n\t\t\t\tif curr_user.has_permission? :admin\n\t\t\t\t\thtml << '<td class=\"td_links\">'.html_safe\n\t\t\t\t\thtml << (link_to \"Destroy\", obj, :confirm => 'Are you sure?', :method => :delete).html_safe\n\t\t\t\t\thtml << '</td>'.html_safe\n\t\t\t\tend\n\t\t\n\t\t\thtml << '</tr>'.html_safe\n\t\t\ti = i + 1\n\t\tend\n\t\t\n\t\thtml << '</table>'.html_safe\n\t\t\n\t\thtml.html_safe\n\tend",
"def initialize_columns\n @columns = []\n valid_table = table.alias('valid_taxon_names')\n\n @columns.push({ header: 'ro', projected: rank_over(table, valid_table) })\n\n @columns.push({header: 'taxon_name_id', projected: table[:id].as('taxon_name_id') } )\n @columns.push({header: 'cached_valid_taxon_name_id', projected: table[:cached_valid_taxon_name_id].as('cached_valid_taxon_name_id') } )\n @columns.push({header: 'cached', projected: table[:cached].as('cached') } )\n @columns.push({header: 'cached_author_year', projected: table[:cached_author_year].as('cached_author_year') } )\n @columns.push({header: 'cached_is_valid', projected: table[:cached_is_valid].as('cached_is_valid') } )\n\n if fieldsets.include?('observations')\n @columns.push({header: 'otu_id', projected: otu_table[:id].as('otu_id') } )\n @columns.push({header: 'otu_name', projected: otu_table[:name].as('otu_name')} )\n end\n end",
"def createTaskTable\n @Handle.execute( @TaskSchema ) \n end",
"def createUserTable\n @Handle.execute( @UserSchema ) \n end",
"def before_load\n data_class.rebuild_table\n super\n end",
"def create_table_def\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 5 )\n return_value = CreateTableDefReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n column20 = nil\n pk_definition21 = nil\n\n\n begin\n # at line 31:3: ( column | pk_definition )\n alt_5 = 2\n look_5_0 = @input.peek( 1 )\n\n if ( look_5_0 == ID )\n alt_5 = 1\n elsif ( look_5_0 == PRIMARY_KEY )\n alt_5 = 2\n else\n raise NoViableAlternative( \"\", 5, 0 )\n end\n case alt_5\n when 1\n root_0 = @adaptor.create_flat_list\n\n\n # at line 31:5: column\n @state.following.push( TOKENS_FOLLOWING_column_IN_create_table_def_180 )\n column20 = column\n @state.following.pop\n @adaptor.add_child( root_0, column20.tree )\n\n when 2\n root_0 = @adaptor.create_flat_list\n\n\n # at line 32:5: pk_definition\n @state.following.push( TOKENS_FOLLOWING_pk_definition_IN_create_table_def_186 )\n pk_definition21 = pk_definition\n @state.following.pop\n @adaptor.add_child( root_0, pk_definition21.tree )\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\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 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 ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 5 )\n\n end\n \n return return_value\n end",
"def make_table(options={})\n get_table(options).rows\n end",
"def show_create_table(db, table)\n end",
"def prepare\n super\n\n # open the database.\n if File.exist?(@options['DATABASE'])\n @db = ::SQLite3::Database.open(@options['DATABASE'])\n else\n @db = ::SQLite3::Database.new(@options['DATABASE'])\n end\n @db.results_as_hash = true\n\n tables = @db.execute('SELECT name FROM sqlite_master WHERE type=\"table\" AND name=\"tblMessages\" ORDER BY name')\n if tables.length == 0\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblMessages (\n mID integer primary key,\n mStatus char(5),\n mTime datetime,\n mText varchar(255))\n )\n\n @db.execute( tbl_def )\n end\n\n tables = @db.execute('SELECT name FROM sqlite_master WHERE type=\"table\" AND name=\"tblOptions\" ORDER BY name')\n if tables.length == 0\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblOptions (\n oID integer primary key,\n oType varchar(255),\n oInstance varchar(255),\n oOption varchar(255),\n oValue TEXT)\n )\n\n @db.execute( tbl_def )\n end\n\n tables = @db.execute('SELECT name FROM sqlite_master WHERE type=\"table\" AND name=\"tblProcedures\" ORDER BY name')\n if tables.length == 0\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblProcedures (\n pID integer primary key,\n pTime datetime,\n pProc varchar(255))\n )\n\n @db.execute( tbl_def )\n\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblSteps (\n sID integer primary key,\n pID integer,\n sLabel varchar(255),\n sCommand TEXT,\n sFinal TEXT)\n )\n\n @db.execute( tbl_def )\n\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblParameters (\n pID integer primary key,\n sID integer,\n pLabel varchar(255),\n pValue varchar(255),\n pConstraint varchar(255))\n )\n\n @db.execute( tbl_def )\n\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblComparisons (\n cID integer primary key,\n pID integer,\n sID1 integer,\n sID2 integer,\n cRelationship varchar(255))\n )\n\n @db.execute( tbl_def )\n end\n\n tables = @db.execute('SELECT name FROM sqlite_master WHERE type=\"table\" AND name=\"tblResults\" ORDER BY name')\n if tables.length == 0\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblResults (\n rID integer primary key,\n rTime datetime,\n rTestId integer,\n rProc varchar(255),\n rProcId integer,\n rApp varchar(255))\n )\n\n @db.execute( tbl_def )\n\n tbl_def = %q( CREATE TABLE IF NOT EXISTS tblResultData (\n dID integer primary key,\n rID integer,\n dStep varchar(255),\n dStepId integer,\n dStatus varchar(255),\n dType varchar(255),\n dData TEXT)\n )\n\n @db.execute( tbl_def )\n end\n\n tables = @db.execute('SELECT name FROM sqlite_master WHERE type=\"view\" AND name=\"qryResults\" ORDER BY name')\n if tables.length == 0\n tbl_def = %q( CREATE VIEW IF NOT EXISTS qryResults AS\n SELECT R.rTestId As qTestId, R.rProc As qProc, R.rProcId As qProcId, R.rApp As qApp,\n D.dStep As qStep, D.dStepId As qStepId, D.dStatus As qStatus, D.dType As qType, D.dData As qData\n FROM tblResults As R, tblResultData As D\n WHERE D.rID = R.rID\n )\n\n @db.execute( tbl_def )\n\n tbl_def = %q( CREATE VIEW IF NOT EXISTS qryComparisons AS\n SELECT R.rTestId As qTestId, R.rProc As qProc, R.rProcId As qProcId, C.cRelationship As qRelationship,\n D1.dStep As qStep1, D1.dStepId As qStepId1, D1.dStatus As qStatus1, D1.dType As qType1, D1.dData As qData1,\n D2.dStep As qStep2, D2.dStepId As qStepId2, D2.dStatus As qStatus2, D2.dType As qType2, D2.dData As qData2\n FROM tblComparisons As C, tblResults As R, tblResultData As D1, tblResultData As D2\n WHERE C.pID = R.rProcID AND C.sID1 = D1.dStepId AND C.sID2 = D2.dStepId\n )\n\n @db.execute( tbl_def )\n end\n end",
"def set_table_size\n @table_x = @table_reversed[0].size\n @table_y = @table_reversed.size\n end",
"def load_table_heading(conn, builder, table)\n primary_key_columns = []\n builder.heading{\n columns = conn.schema(table, {:reload => true})\n columns.each do |name, info|\n #puts info.inspect\n \n # find attribute definition\n defn = {:domain => dbtype_to_ruby_type(info),\n :mandatory => !info[:allow_null] }\n unless info[:ruby_default].nil?\n defn[:default] = info[:ruby_default]\n end\n \n # mark primary key columns\n if primary_key_columns and info[:primary_key]\n primary_key_columns << name \n end\n \n # build the attribute\n builder.attribute(name, defn)\n end\n }\n primary_key_columns\n end",
"def create(data_={})\n Table.new(self, data_)\n end",
"def create_table( table_name, options = {}, &block )\n super( table_name, options, &block )\n @connection.schema.load_table( table_name.to_s )\n end",
"def setup\n executeSQL(CREATE_ASSERTED_STATEMENTS_TABLE % @internedId)\n executeSQL(CREATE_ASSERTED_TYPE_STATEMENTS_TABLE % @internedId)\n executeSQL(CREATE_QUOTED_STATEMENTS_TABLE % @internedId)\n executeSQL(CREATE_NS_BINDS_TABLE % @internedId)\n executeSQL(CREATE_LITERAL_STATEMENTS_TABLE % @internedId)\n \n # Create indicies\n {\n asserted_table => {\n \"#{@internedId}_A_termComb_index\" => %w(termComb),\n \"#{@internedId}_A_s_index\" => %w(subject),\n \"#{@internedId}_A_p_index\" => %w(predicate),\n \"#{@internedId}_A_o_index\" => %w(object),\n \"#{@internedId}_A_c_index\" => %w(context),\n },\n asserted_type_table => {\n \"#{@internedId}_T_termComb_index\" => %w(termComb),\n \"#{@internedId}_T_member_index\" => %w(member),\n \"#{@internedId}_T_klass_index\" => %w(klass),\n \"#{@internedId}_T_c_index\" => %w(context),\n },\n literal_table => {\n \"#{@internedId}_L_termComb_index\" => %w(termComb),\n \"#{@internedId}_L_s_index\" => %w(subject),\n \"#{@internedId}_L_p_index\" => %w(predicate),\n \"#{@internedId}_L_c_index\" => %w(context),\n },\n quoted_table => {\n \"#{@internedId}_Q_termComb_index\" => %w(termComb),\n \"#{@internedId}_Q_s_index\" => %w(subject),\n \"#{@internedId}_Q_p_index\" => %w(predicate),\n \"#{@internedId}_Q_o_index\" => %w(object),\n \"#{@internedId}_Q_c_index\" => %w(context),\n },\n namespace_binds => {\n \"#{@internedId}_uri_index\" => %w(uri),\n }\n }.each_pair do |tablename, indicies|\n indicies.each_pair do |index, columns|\n executeSQL(\"CREATE INDEX #{index} on #{tablename} ('#{columns.join(', ')}')\")\n end\n end\n end",
"def create_table\n unless table_exists?\n key_options = connection.internal_string_options_for_primary_key\n\n connection.create_table(table_name, id: false) do |t|\n t.string :key, key_options\n t.string :value\n t.timestamps\n end\n end\n end",
"def build_table_body\n body =\n if data.column_names && !data.column_names.empty?\n data\n else\n data[1..-1]\n end\n body.each { |row| build_md_row(output, row) }\n end",
"def create_tables\n x = 1\n table_count = (all_guests.length / table_size_limit.to_f).ceil\n while x <= table_count\n Table.create(table_number: x, table_size_limit: table_size_limit, event_id: id)\n x += 1\n end\n end",
"def rebuild(table); end",
"def create_table(table_name)\n # translate into pinyin, then to symbol\n table = trans_pinyin(table_name).to_sym\n DB.create_table table do\n primary_key :id\n String :mid, :unique=>true\n DateTime :created_timestamp\n String :content, :text => true\n String :source\n String :user_id\n String :user_name\n String :user_gender\n Integer :user_status_count\n Integer :user_fansNum\n end\n return table\nend",
"def simulation_setup(table)\n table.raw.each { |row|\n case row[0].downcase\n when 'simulation name'\n simulation_name.set row[1]\n when 'number of runs'\n number_of_runs.set row[1]\n when 'number of subjects'\n number_of_subjects.set row[1]\n when 'number of sites'\n number_of_sites.set row[1]\n else\n raise \"Field name was not found.\"\n end\n }\n save.click\n end",
"def on_table(params = {})\n table = Yummi::Table::new params\n table.data = self\n return table\n end",
"def setup\n begin\n create_campaign_table_if_not_exist\n seed_data\n rescue Exception => e\n raise \"Database setup failed with error #{e}\"\n ensure\n @connection.close\n end\n end",
"def init_conn_table(table_name)\n # Create destination table\n sql = <<SQL\ndrop table if exists #{table_name};\ncreate table #{table_name} (\n day timestamp, \n id int,\n value int,\n dw_created timestamp,\n dw_updated timestamp\n );\nSQL\n conn.run(sql)\n return conn\n end"
] |
[
"0.7133207",
"0.67908645",
"0.6688479",
"0.6685495",
"0.6668918",
"0.6592868",
"0.65927255",
"0.6570841",
"0.6537456",
"0.6498126",
"0.6498126",
"0.6498126",
"0.6498126",
"0.6484169",
"0.64773256",
"0.64678484",
"0.6423183",
"0.6410907",
"0.63890564",
"0.6388926",
"0.6357414",
"0.6334748",
"0.6321515",
"0.63193774",
"0.6295659",
"0.6284717",
"0.6283918",
"0.6281546",
"0.62795264",
"0.6268985",
"0.6254785",
"0.62482023",
"0.62323487",
"0.62323487",
"0.6223441",
"0.6189908",
"0.6181683",
"0.6181683",
"0.6168407",
"0.6166045",
"0.6162979",
"0.6145162",
"0.6144025",
"0.61437875",
"0.61399084",
"0.61374706",
"0.6135885",
"0.611953",
"0.6108306",
"0.6105285",
"0.61005217",
"0.60999763",
"0.6098971",
"0.608424",
"0.6078355",
"0.60762364",
"0.60730016",
"0.6066691",
"0.6066691",
"0.6066691",
"0.6066691",
"0.6066691",
"0.6066691",
"0.6066691",
"0.6066691",
"0.6066691",
"0.60632944",
"0.6053036",
"0.6047353",
"0.6047353",
"0.6038269",
"0.6034389",
"0.6032233",
"0.60321844",
"0.602053",
"0.601812",
"0.6017681",
"0.60127527",
"0.60034174",
"0.59951824",
"0.5962876",
"0.59614724",
"0.59608626",
"0.59555286",
"0.5951606",
"0.5941148",
"0.59369266",
"0.5936741",
"0.59347475",
"0.59290624",
"0.5928482",
"0.59175175",
"0.59030944",
"0.59010303",
"0.58940524",
"0.58813626",
"0.5881288",
"0.5875411",
"0.5865271",
"0.5864318",
"0.5861006"
] |
0.0
|
-1
|
Iterating Arrays as a method
|
def print_array(arr) # define method with one parameter
i = 0 # set starting index value
while i < arr.length
puts arr[i] # Returns the value in the array at index value iteration
i += 1
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def each_method(array)\n i = 0\n while i< array.length\n yield array[i]\n i +=1\n end\nend",
"def method_2(array)\n array.each do |element|\n puts element\n end\nend",
"def explore_array(method, *arguments)\n ['a', 'b', 'c'].send(method, *arguments)\nend",
"def each &b\n\t\t@array.each(&b)\n\tend",
"def double_array(array)\n # your code here\nend",
"def custom_each(array)\r\n i = 0 \r\n while i < array.length \r\n yield array[i]\r\n i += 1\r\n end\r\nend",
"def each(array)\n for elem in array do\n yield(elem)\n end\n\n array\nend",
"def each(*args, &block)\n array.each(*args, &block)\n end",
"def each\n to_a.each\n end",
"def each\n to_a.each\n end",
"def each\n to_a.each\n end",
"def custom_each(array)\n i = 0\n while i < array.length\n yield array[i]\n i += 1\n end\nend",
"def for_each_in(array, &instructions)\n for i in 0...array.length\n instructions.call(array[i])\n end\nend",
"def my_each(array) # put argument(s) here\n i = 0\n\n while i < array.length\n yield array[i]\n i += 1\n end\n array\nend",
"def each(&block)\n @array.each(&block)\n end",
"def each(*) end",
"def each(&block)\r\n @arr.each &block\r\n end",
"def each(&block)\r\n @arr.each &block\r\n end",
"def each(&block)\n array.each(&block)\n end",
"def each(&block)\n @array.each(&block)\n end",
"def each(&block)\n @array.each(&block)\n end",
"def my_each(array)\n\t\t#array = []\n\t\tindex = 0\n\t\twhile index < array.length\n\t\t\tyield(array[index])\n\t\t\tindex += 1\n\t\tend\n\t\treturn array\n\tend",
"def my_each(array)\n i = 0\n while i < array.length\n yield(array[i])\n array[i]\n i += 1\n end\n array\nend",
"def mutliplied(array)\nend",
"def each(&blk)\r\n to_a.each(&blk)\r\n end",
"def basic_4 (array_iterate)\n array_iterate.each { |n| puts \"Item: #{n}\"}\n puts\nend",
"def my_each(array)\n i = 0\n while i < array.length\n yield array[i]\n i += 1\n end\n array\nend",
"def method_missing(method, *args, &block)\n self.array.send(method, *args, &block)\n end",
"def custom_each(array)\n i = 0\n while i < array.length\n #yield will pass this element to the block\n yield array[i] #each and single element of array iterate\n i += 1 #to stop infinite loop\n end\nend",
"def each(&blk)\n to_a.each(&blk)\n end",
"def cada2(array, &myproc)\n i = 0\n while i < array.size\n myproc.call(array[i])\n i += 1\n end\n array\nend",
"def each(&a_proc); end",
"def value(array)\n array.each { |x| puts x }\nend",
"def my_each(array) \n n = 0\n while n < array.length \n yield(array[n])\n n = n + 1 \n end\n array\nend",
"def consume_arr(y)\n y.each { |elem| puts (elem*2) }\nend",
"def consume_arr(y)\n y.each { |elem| puts (elem*2) }\nend",
"def consume_arr(y)\n y.each { |elem| puts (elem*2) }\nend",
"def iterar(arr)\n p arr_supplies.each {|supplie| p supplie}\nend",
"def each(array)\n counter = 0\n while counter < array.size do\n yield(array[counter])\n counter += 1\n end\n array\nend",
"def calls_array\n a = return_array\n a[1]\n end",
"def array_looper(array)\n\tarray.each do |a|\n\t\tputs a\n\tend\nend",
"def my_each(array)\n if block_given?\n i = 0\n while i < array.length\n yield array[i]\n i = i + 1\n end\n array\n end\nend",
"def pizzica(method_name, *method_args)\n self.map do |element|\n if element.respond_to? method_name\n element.send method_name, *method_args\n elsif element.is_a? Hash\n element[method_name]\n else\n raise ArgumentError, \"Array elements do not respond to #{method_name}.\"\n end\n end\n end",
"def iterate_proc!(&cod)\n self.each_with_index { |n, i|\n self[i] = cod.call(n)\n }\n end",
"def each(array)\n idx = 0\n while idx < array.size\n yield(array[idx]) if block_given?\n idx += 1\n end\n\n array\nend",
"def method_missing(method_name, *args, &block)\n @array.send(method_name, *args, &block)\n end",
"def test_each_is_a_method_on_arrays\n assert_equal true, [].methods.include?(as_name(:each))\n end",
"def each(&blk)\n (0..@size-1).each { |i| blk.call(self.[](i)) }\n end",
"def method_missing(method_name, *args, &block)\n @array.send(method_name, *args, &block)\n end",
"def sum_using_each(array)\n end",
"def each()\n self.to_a.each { |elt| yield elt }\n end",
"def each_pair(*) end",
"def each\n yield self[0]\n yield self[1]\n end",
"def hello(array)\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i += 1\n end\n collection\nend",
"def hello(array)\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i += 1\n end\n collection\nend",
"def hello(array)\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i += 1\n end\n collection\nend",
"def each\n unless @array.empty?\n @array.size.times do |i|\n yield @array[i]\n end\n end\n end",
"def iterArr\r\n arr = [1, 3, 5, 7, 9]\r\n arr.each{|i| puts i}\r\nend",
"def double_all array\n array.map { |i| i*2 }\nend",
"def print_elements(input_array)\n # TODO\nend",
"def each(array)\n index = 0\n\n while index < array.size\n element = array[index]\n yield element\n index += 1\n end\n \n array\nend",
"def map(arr) # creating our own map method\n\tnewArr = [] # declaring an empty array to push our results inside\n\tarr.each do |i| # run the block of code to iterate inside each elements in an array\n\t\tnewArr << yield(i) # push the modified elements inside our newArr []\n\tend\n\tnewArr\nend",
"def iterate(expected, meth=:each, *args)\n\t\tlambda { |obj|\n\t\t\tt = []\n\t\t\tobj.__send__(meth, *args) { |v| t << v }\n\t\t\tt == expected\n\t\t}\n\tend",
"def method_map(arr, meth,*args)\n arr.map {|e| e.send(meth,*args) }\n end",
"def sum_array(array)\n # Your code here\nend",
"def each\n @arr.each do |n|\n yield(n)\n end\n end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def look_and_say(array)\n\nend",
"def some_method (testing)\n\tputs testing.map {|num| num**3} # method 1\nend",
"def a_method\n [1, 2, 3].each do |num|\n puts num * 2\n end\nend",
"def each(arr)\n counter = 0\n \n while counter < arr.length\n yield(arr[counter])\n counter += 1\n end\n \n arr\nend",
"def iterArr\n arr = [1, 3, 5, 7, 9]\n arr.each{|i| puts i}\nend",
"def each(&block)\n to_a.each(&block)\n end",
"def each(&b) \n @data.each(&b) \n end",
"def each(&block)\n to_a.each(&block)\n end",
"def each(arr)\n ndx = 0\n while ndx < arr.size do\n yield(arr[ndx])\n ndx += 1\n end\n arr\nend",
"def print_arr_1(arr)\n arr.each do |idx|\n puts el\n end\nend",
"def print_array(array)\n (length(array)).times do |i|\n print array[i]\n end\n # raise NotImplementedError\nend",
"def guests(*array)\r\n array.each { |guest| puts guest }\r\nend",
"def each\n (0...size).each {|i| yield(self[i])}\n nil\n end",
"def each\n if block_given?\n @array.each do |e|\n yield e\n end\n end\n end",
"def print_array(array)\n length(array).times do |index|\n puts array[index]\n end\n # raise NotImplementedError\nend",
"def list(array)\n array.each do |x|\n puts x\n end\nend",
"def my_collect(array) # put argument(s) here\n # code here\n i = 0\n result = []\n\n while i < array.size\n\n result << yield(array[i])\n i += 1\n end\nresult\nend",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def campiona(*method_names)\n self.map do |element|\n method_names.map do |method_name|\n if element.respond_to? method_name\n element.send method_name\n elsif element.is_a? Hash\n element[method_name]\n else\n raise ArgumentError, \"Array elements do not respond to #{method_name}.\"\n end\n end\n end\n end"
] |
[
"0.7475319",
"0.73420703",
"0.71562105",
"0.7032782",
"0.6956302",
"0.68995607",
"0.68725187",
"0.68366116",
"0.6793016",
"0.6793016",
"0.6793016",
"0.67750037",
"0.6769126",
"0.6744369",
"0.6726113",
"0.67214924",
"0.65871596",
"0.65871596",
"0.6543277",
"0.6538401",
"0.6538401",
"0.65330184",
"0.65081084",
"0.64920247",
"0.64917904",
"0.64914316",
"0.64873224",
"0.64866894",
"0.64704424",
"0.64680976",
"0.64656895",
"0.64580494",
"0.6449842",
"0.64467865",
"0.64206386",
"0.64206386",
"0.64206386",
"0.641409",
"0.64128333",
"0.64052737",
"0.6375564",
"0.6373565",
"0.63620317",
"0.63582855",
"0.63422525",
"0.6314465",
"0.63121575",
"0.62985843",
"0.62976104",
"0.62939286",
"0.627983",
"0.6278629",
"0.62740594",
"0.62736785",
"0.62736785",
"0.62736785",
"0.6261929",
"0.6259187",
"0.6237607",
"0.6220337",
"0.62142575",
"0.62123907",
"0.62122756",
"0.6211572",
"0.62109476",
"0.62046754",
"0.62036777",
"0.62036777",
"0.62036777",
"0.62036777",
"0.62036777",
"0.62036777",
"0.62036777",
"0.62036777",
"0.62036777",
"0.62036777",
"0.62036777",
"0.61912435",
"0.61858934",
"0.61853594",
"0.61779726",
"0.6175293",
"0.61692744",
"0.6168883",
"0.61681145",
"0.61519295",
"0.6146108",
"0.6138553",
"0.61265653",
"0.61231154",
"0.6121934",
"0.6120253",
"0.6115715",
"0.61038494",
"0.61031556",
"0.61031556",
"0.61031556",
"0.61031556",
"0.61031556",
"0.61031556",
"0.60927534"
] |
0.0
|
-1
|
Calls method with 1 argument
|
def doubler(numbers)
doubled_nums = [] # Creates empty array to store double nums
i = 0
while i < numbers.length
old_elem = numbers[i] # Creates temporary variable to hold number for each iteration
new_elem = old_elem * 2 # Multiplies old element by two and saves to new variable
doubled_nums << new_elem
i += 1 # Iterates upwards
end
return doubled_nums
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def call(method, args)\n send(method, *args)\n end",
"def call(*args); end",
"def call(*args)\n __call__( args )\n end",
"def call(*) end",
"def call(*) end",
"def method(arg0)\n end",
"def method(arg0)\n end",
"def call( *args )\n raise NotImplementedError\n end",
"def call(*args)\n instance.call(*args)\n end",
"def method_missing method, *args, &block\n if args.size > 1\n raise ArgumentError.new \"wrong number of arguments (#{args.size} for 0..1)\"\n end\n\n args.push({}) if args.size == 0\n\n call method.to_s, args[0]\n end",
"def call(*)\n raise NotImplementedError\n end",
"def _perform(args); end",
"def call() end",
"def call_method(method_name, params=nil)\n if params.nil?\n self.method(method_name).call\n else\n self.method(method_name).call(params)\n end\n end",
"def method_missing(method, params={})\n call(method, params)\n end",
"def meth(*args)\n\n\n\nend",
"def call(data)\n object.send(method, data)\n end",
"def call(*arguments, **options)\n\t\t\tif options?\n\t\t\t\t@instance.send(@name, *arguments, **options)\n\t\t\telse\n\t\t\t\t# Ignore options...\n\t\t\t\t@instance.send(@name, *arguments)\n\t\t\tend\n\t\tend",
"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 meth(arg1)\nend",
"def method(a, *b)\r\n\tb\r\nend",
"def perform(*args); end",
"def _call_of(method)\n proc{ |*args| send(method, *args) }\n end",
"def method(param1, options = {})\n\tend",
"def meth(arg1,arg2)\nend",
"def meth(arg1,arg2)\nend",
"def call_method(method, *args)\n @api_client.public_send(method, *args)\n end",
"def call\n @func[*@args]\n end",
"def dispatch(*_arg0); end",
"def call(object); end",
"def call(method, *args) rpc_execute(method, *args) end",
"def call(method, args = [])\n @runtime_class.lookup(method, args.length).call(self, args)\n end",
"def call(*args)\n self.exec(*args)\n end",
"def method_missing method, *args, &block\n if args.size > 1\n raise ArgumentError.new \"wrong number of arguments (#{args.size} for 0..1)\"\n end\n\n args.push({}) if args.size == 0\n\n method = method.to_s.split('_').inject([]){ |b,e| b.push(b.empty? ? e : e.capitalize) }.join\n\n call(method, args[0])\n end",
"def meth(\n\n\n\n *args)\n\nend",
"def meth(*args)\n args.shift\nend",
"def call(method, arguments)\n # Like a typical class base runtime model, we store\n # methods in the class of the object.\n @awesome_class.lookup(method).call(self, arguments)\n end",
"def call(method, *args)\n return send_request(method, args)\n end",
"def invoke(name, args)\n\t\tself.class.invoke_instance_method(self, name, args)\n\tend",
"def meth(\n **\n ); end",
"def method(*a, b)\r\nend",
"def invoke; end",
"def call(*args)\n ensure_context_not_missing\n\n args = args.take(arity)\n\n if method?\n context.send(callee, *args)\n else\n context.instance_exec(*args, &callee)\n end\n end",
"def meth **options\nend",
"def meth **options\nend",
"def call(*params)\n self.send :test, *params\n end",
"def method(arg_1, arg_2)\n p arg_1\n p arg_2\nend",
"def call\n end",
"def myMethod1(arg0,*arg1)\n print arg0\n print arg1\nend",
"def call(args = {})\n new.call(args)\n end",
"def call!(*args)\n new(*args).call!\n end",
"def call(method, *args)\n self.class.rpc_execute(method, *args)\n end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def method_missing(name, *args)\n\t\t\tcall name, *args\n\t\tend",
"def call(method, *arguments)\n connection.call(method, *arguments)\n end",
"def invoke_instance_method(hself, name, args)\n\t\t\t@instance_methods[name].call(hself, args)\n\t\trescue ArgumentError => e\n\t\t\traise \"Failed to call #{name} on #{hself.inspect} with #{args.inspect} due to:\\n#{e}\"\n\t\tend",
"def call_rpc(method, params: [])\n @api.send(method, *params)\n end",
"def foo (a, b)\n a.call(b)\nend",
"def meth(arg, *args)\n [arg, args]\nend",
"def call(*command); end",
"def run_one_method(klass, method_name, reporter); end",
"def method=(_arg0); end",
"def method=(_arg0); end",
"def method=(_arg0); end",
"def BlocksAndMethods(&argumento)\n\targumento.call\nend",
"def call(target)\n target.public_send(@name, *@arguments)\n end",
"def excel_call(method, *args)\n @excel.Application.Run(method.to_s, *args)\n end",
"def call\n end",
"def call(*args)\n instance_exec(*correct_arg_arity(block.arity, args), &block)\n end",
"def method_missing(*args)\n send(*args)\n end",
"def method_missing(method, *args)\n Call.new(self, method, args)\n end",
"def method(p0) end",
"def call\n access = RIGHTS[method] # Checking access permissions for perform corresponding ACTION\n raise NoAccessError.new(access) unless @permissions[access] # Raising Custom error if no access granted\n\n send(@method) # Calling method from @method\n end",
"def call\n access = RIGHTS[method] # Checking access permissions for perform corresponding ACTION\n raise NoAccessError.new(access) unless @permissions[access] # Raising Custom error if no access granted\n\n send(@method) # Calling method from @method\n end",
"def method(arg1, arg2)\n p arg1\n p arg2\nend",
"def invoking\n end",
"def method(x, y)\n x * y\nend",
"def method_missing(name, *args)\n\t\t\tcall(name, *args)\n\t\tend",
"def my_method(*x)\n puts \">>>START\"\n x.each { |x| x.call }\n puts \">>>> END\"\nend",
"def my_function(param)\n param.call\n end",
"def run(*args)\n end",
"def process_action(method_name, *args); end",
"def call\n\n\tend",
"def call\n\n\tend",
"def send_action(*_arg0); end",
"def method(*a)\r\n\ta\r\nend",
"def first_argument(method)\n\n\n\n # 215:7: argument[method]\n argument(method)\n\n\n\n\n end"
] |
[
"0.77558124",
"0.77541155",
"0.74915016",
"0.72631276",
"0.72631276",
"0.72164166",
"0.72164166",
"0.7130901",
"0.70469326",
"0.70057976",
"0.69117576",
"0.6884915",
"0.6873748",
"0.6868988",
"0.68608147",
"0.68527955",
"0.684637",
"0.682998",
"0.682344",
"0.682344",
"0.682344",
"0.682344",
"0.682344",
"0.682344",
"0.682344",
"0.682344",
"0.6804091",
"0.6799467",
"0.67541796",
"0.6750573",
"0.6737869",
"0.66863",
"0.66863",
"0.66804713",
"0.66688",
"0.66628575",
"0.6656157",
"0.6644728",
"0.6633879",
"0.65957904",
"0.6582634",
"0.65605813",
"0.6551812",
"0.65406334",
"0.6523221",
"0.649032",
"0.6486993",
"0.6485556",
"0.6480546",
"0.6475817",
"0.64706266",
"0.64706266",
"0.64643204",
"0.64610374",
"0.6454426",
"0.64536965",
"0.6450042",
"0.64489603",
"0.6433512",
"0.6433189",
"0.6433189",
"0.6433189",
"0.6433189",
"0.6433189",
"0.6433189",
"0.6433189",
"0.6433189",
"0.6426494",
"0.6424344",
"0.6409128",
"0.6398137",
"0.63829625",
"0.6378626",
"0.6363275",
"0.6346822",
"0.6338146",
"0.6338146",
"0.6338146",
"0.6329669",
"0.6328749",
"0.6325896",
"0.6318899",
"0.63163507",
"0.6310642",
"0.6305022",
"0.6304385",
"0.6293027",
"0.6293027",
"0.6266552",
"0.62596744",
"0.62530696",
"0.625279",
"0.62501776",
"0.624088",
"0.6240659",
"0.6239923",
"0.6237671",
"0.6237671",
"0.6237196",
"0.62354",
"0.62349164"
] |
0.0
|
-1
|
REmember to print your method call YELL PROBLEM Write a method yell(words) that takes in an array of words and returns a new array where every word from the original array has an exclamation point after it.
|
def yell(words) # DEFINE METHOD WITH ONE PARAM
i = 0 # SET FIRST INDEX VALUE
new_array = [] # CREATE AN EMPTY ARRAY
while i < words.length # WHILE LOOP THAT CHECKS IF I IS LESS THAN THE ARRAY LENGTH
old_ele = words[i] # VARIABLE TO STORE INDEXED VALUE OF ARRAY
exclamations = old_ele + "!" # VARIABLE THAT CONCATENATES EXCLAMATION TO END OF INDEX ARRAY VALUE
new_array << exclamations # SHOVELS IT INTO END OF ARRAY VARIABLE
i += 1 # INCREMENT OF ONE ITERATION
end
return new_array # RETURNS FINAL VALUE OF NEWLY CREATED ARRAY
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def yell(words)\n words.map{|word| word + \"!\"}\nend",
"def yell(words)\n newArr = []\n i = 0\n while i<words.length\n newWord = words[i] + \"!\"\n newArr << newWord\n i += 1\n end\n return newArr\n end",
"def yell(words)\n new_words = []\n words.each {|word| new_words << word + \"!\" }\n new_words\nend",
"def yell(words)\n\tnewWords = []\n\tfor i in 0..words.length-1\n newWord = words[i] + \"!\"\n \tnewWords << newWord\n end\n return newWords\nend",
"def yell(words)\n\twords_bang = []\n\n\ti = 0\n\twhile i < words.length\n\t\twords_temp = words[i]\n\t\twords_new = words_temp + '!'\n\n\t\twords_bang << words_new\n\n\t\ti += 1\n\tend\n\t\n\treturn words_bang\nend",
"def yell(words)\n\tnew_words = []\n\n\ti = 0\n\twhile i < words.length\n\t\twords[i] += \"!\"\n\t\tnew_words << words[i]\n\t\ti += 1\n end\n\t\n\treturn new_words\nend",
"def yell(words)\n i = 0\n while i < words.length\n words[i] = words[i] + \"!\"\n i+= 1\n end\n return words\nend",
"def yell(words)\n new = []\n\n i = 0\n\n while i < words.length\n old_word = words[i]\n new_word = old_word + '!'\n new << new_word\n i += 1\n end\n\n return new\nend",
"def yell(words)\n\ti = 0\n while i < words.length\n words[i] = words[i] + \"!\"\n i += 1\n end\n return words\nend",
"def yell(words)\n i = 0\n new_words = []\n while i < words.length\n new_words << words[i] + '!'\n i += 1\n end\n return new_words\nend",
"def yell(words)\n yelling = []\n \n i = 0\n while i < words.length\n yelling << words[i] +\"!\"\n \n i += 1\n end\n \n return yelling\nend",
"def yell(words)\n i = 0\n new_arr = []\n while i < words.length\n loud_words = words[i] + '!'\n new_arr << loud_words\n i += 1\n end\n return new_arr\nend",
"def yell_happily(words)\r\n words + \"!!!\" + \" :)\"\r\n end",
"def yell(arr)\n result = [];\n i = 0;\n while i < arr.length\n result[i] = arr[i] + '!';\n i += 1;\n end\n return result\nend",
"def yell_happily(words)\r\n words + \"!!!\" + \" :)\"\r\n end",
"def yell(words)\n words = words + \"!!\"\n puts words\nend",
"def yeller(words) # words is var of an array of strings\n loud_arr = [] # empty array for strings\n i = 0 # the indice counter starting @ 0\n while i < words.length\n word = words[i] # can't store indice of an int, so keep value of the int \"which is string\"\n loud_word = (word + \"!\") # concat \"!\" to string store the result new word for each iteration\n loud_arr << loud_word # shovel result into the array\n i += 1 # next iteration\n end\n return loud_arr\n puts loud_arr\nend",
"def yell_sentence(sent)\n\twords = sent.split(\" \")\n \tnew_words = words.map{ |word| word.upcase + \"!\"}\n \treturn new_words.join(\" \")\nend",
"def alternate_words(sentence) #Not clear why failing test because exact same output\n\tarray = sentence.split(' ')\n\t\n\tnew_array = []\n\tarray.length.times {|index| new_array << array[index] if index.even?}\n\tnew_array.map! {|element| element.gsub(/\\p{P}(?<!')/, \"\")}\n\treturn new_array\nend",
"def yell_sentence(sent)\n # yell = sent.split(\" \")\n # yell = yell.map { |char| char.upcase + \"!\" }\n # return yell.join(\" \")\n return sent.split.map { |char| char.upcase + \"!\" }.join(\" \")\nend",
"def alternate_words(sentence)\n #creates an array with all these symbols as elements\n #iterates throuch each element and makes new sentence\n #equal to the substitution of each of the element\n #which is being iterated in the array\n '!@$#%^&*()-=_+[]:;,./<>?\\\\|'.split(//).each do |char|\n sentence = sentence.gsub(char, ' ')\n end\n #new array called words, made out of splitting\n #string at every \" \" instance\n words = sentence.split\n #new empty array\n #pushes even indexed words into new array\n solution = []\n words.each_with_index do |word, index|\n solution << word if index.even?\n end\n solution\nend",
"def yell_sentence(sent)\n return sent.split.map { |word| word.upcase + \"!\"}.join(\" \")\nend",
"def scream(words)\n words = words + \"!!!\"\n puts words \nend",
"def alternate_words(sentence) #Define the method\n '!@$#%^&*()-=_+[]:;,./<>?\\\\|'.split(//).each { |char| sentence = sentence.gsub(char, ' ') } #Substitutes any punctuation in string with a space\n words = sentence.split #Splits the sentence string into an array called words\n answer = [] #Creates a new array for the answer\n words.each_with_index do |word, index| #Loops on each word with an index\n answer << word if index.even? #Appends to the array if the index value is even\n end #Ends the loop\n answer #Returns the answer array\nend",
"def scream(words)\n\n\twords = words + \"!!!\"\n\n puts words\n\nend",
"def scream(words) \n\t\twords = words + \"!!!!\" \n\t\treturn\n\t\tputs words \n\tend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\n end",
"def scream(words)\n words = words + \"!!!!\"\n puts words\n end",
"def scream(words)\n words = words + \"!!!!\"\n return words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return words\nend",
"def make_a_sentence(words)\n words.join(' ') + \"!\"\nend",
"def yell(word)\n return word.upcase + \"!\"\nend",
"def censor(string, array)\n new_words = (string.split).map do |word|\n if array.include?(word.downcase)\n star_vowels(word)\n else\n word\n end\n end\n\n new_words.join(\" \")\nend",
"def scream(words)\n\twords = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n\twords = words + \"!!!!\"\n\treturn\n\tputs words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\n end",
"def scream(words)\n words = words + \"!!!!!\"\n words\nend",
"def alternate_words(sentence)\n\tnew = []\n \n'!@$#%^&*()-=_+[]:;,./<>?\\\\|'.split(//).each do |x|\n sentence = sentence.gsub(x, ' ')\n end\n \n var = sentence.split() \n var.each_with_index {|x,y| new.push x if y.even?}\n\treturn new\nend",
"def scream(words)\n\twords = words + \"!!!!\"\nend",
"def scream(words)\n\twords = words + \"!!!!\"\n\tputs words\n\treturn\nend",
"def scream(words)\n words += \"!!!!\"\n puts words\nend",
"def scream(words)\n\twords = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n puts words + \"!!!!\"\nend",
"def alternate_words(sentence)\n\n # put exclude characters in an array\n to_exclude ='! @ $ # % ^ & * ( ) - = _ + [ ] : ; , . / < > ? \\ |'.split(\" \")\n\n # replace those characters with space\n arr_count = 0\n while arr_count < to_exclude.length\n to_exclude.each { |sign| sentence = sentence.gsub(sign, \" \") }\n arr_count += 1\n end\n\n # put the words in an array\n words = sentence.split(\" \")\n\n # let's alternate\n count = 0\n result = []\n while count < words.length do\n result << words[count] if count.even?\n count += 1\n end\n result\nend",
"def censor(sentence, array)\n\nend",
"def yell word4\n word4.upcase + \"!\"\nend",
"def mask_article(str, words_array)\n new_str = str\n words_array.each do |word|\n new_str.gsub! word, strike(word) if new_str.include? word\n end\n\n new_str\nend",
"def scream(words)\n words = words + '!!!!'\nend",
"def strange_words(words)\n i = 0\n new_array = []\n new_string = \"\"\n\n while i < words.length\n\n \tnew_string = words[i]\n\n if (words[i].length < 6 ) && !(new_string[0] == \"e\") || (new_string[0] == \"e\") && !(words[i].length < 6 )\n new_array << words[i] \n end\n i += 1\n end\n return new_array\n\nend",
"def scream(words)\n words = words + '!!!!'\n puts words\nend",
"def scream(words)\n words = words + '!!!!'\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\n return\nend",
"def whisper_words(words)\nreturn words.map{ |elem| elem.downcase + \"...\"}\nend",
"def add_bang(array)\n # TODO: Take an array of strings and return a new array with \"!\" appended to each string.\n # You should use Enumerable#map\n array.map do |element|\n element+\"!\"\n end\nend",
"def scream(words)\n words = words + \"!!!!\"\n return puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def summon_captain_planet(arr)\n arr.map {|word| word.capitalize + \"!\"}\nend",
"def alternate_words(string)\n\n\tunwanted = [\"!\",\"@\",\"$\",\"#\",\"%\",\"^\",\"&\",\"*\",\"(\",\")\",\"-\",\"=\",\"_\",\"+\",\"[\",\"]\",\":\",\";\",\",\",\".\",\"/\",\"<\",\">\",\"?\",\"|\"]\n\tcounter = 0\n\tnew_str_arr = Array.new \n\n\tunwanted.each do |symbol|\n\t\tstring = string.gsub(symbol,\" \")\n\tend\n\tarray_str = string.split(\" \");\n\n\twhile counter < array_str.length do \n\t\tif counter.even?\n\t\t\tnew_str_arr.push(array_str[counter])\n\t\tend\t\n\tcounter += 1\t\n\tend\n\t\n\treturn new_str_arr\n\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\n return words\nend",
"def scream_d(words)\n words = words + \"!!!!!\"\n #return\n #puts words\nend",
"def scream(words)\n words = words + \"!!!!!\"\n puts words\nend",
"def scream(words) # Edited to output to STDOUT, returns nil (the last statement is 'puts words')\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\r\n words = words + \"!!!!\"\r\n return\r\n puts words\r\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\nend",
"def scream(words)\n words = words + \"!!!!\"\nend",
"def scream(words)\n words = words + \"!!!!\"\nend",
"def scream(words)\n words = words + \"!!!!\"\nend",
"def scream(words)\n words = words + \"!!!!\"\nend",
"def scream words\n words = words + '!!!!'\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\n\t#words\nend",
"def alternate_words(sentence)\n alt_words=[]\n sentence.split(/[ \\!\\@\\$\\#\\%\\^\\&\\*\\(\\)\\-\\=\\_\\+\\[\\]\\:\\;\\,\\.\\/\\<\\>\\?\\\\\\|]/).reject {|word| word == \"\"}.each_with_index do |word, i|\n alt_words << word if i.even?\n end\n alt_words\nend",
"def add_bang(array)\n array.map {|string| string+\"!\"}\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend"
] |
[
"0.826867",
"0.82177955",
"0.8172636",
"0.81165105",
"0.8102291",
"0.8082906",
"0.80328226",
"0.801409",
"0.7976287",
"0.79433",
"0.78415424",
"0.7798243",
"0.7561543",
"0.7532299",
"0.75265366",
"0.7297072",
"0.7051282",
"0.7010715",
"0.6745765",
"0.6722094",
"0.6645795",
"0.6638541",
"0.6590758",
"0.65487224",
"0.65340346",
"0.6486087",
"0.6475587",
"0.6475587",
"0.6465173",
"0.6465173",
"0.6465173",
"0.64540726",
"0.64471185",
"0.644243",
"0.6437874",
"0.6413395",
"0.64069676",
"0.639881",
"0.63975656",
"0.639418",
"0.6386712",
"0.6385173",
"0.6372977",
"0.63712394",
"0.63499075",
"0.6349354",
"0.63384545",
"0.63303524",
"0.63300186",
"0.6325948",
"0.63231176",
"0.63231176",
"0.6314604",
"0.6313761",
"0.6311082",
"0.6303954",
"0.6283522",
"0.62753385",
"0.62753385",
"0.62753385",
"0.62753385",
"0.62753385",
"0.62753385",
"0.62753385",
"0.62753385",
"0.62741095",
"0.6260128",
"0.6249146",
"0.62483925",
"0.62472266",
"0.62366587",
"0.6227006",
"0.6223529",
"0.6222142",
"0.6222142",
"0.6222142",
"0.6222142",
"0.6222142",
"0.6216291",
"0.62092227",
"0.620072",
"0.619892",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297",
"0.61981297"
] |
0.82064646
|
2
|
=> ["code!", "is!", "cool!"]
|
def element_times_index(numbers)
i = 0 # i represents to the index current index always
new_array = []
while i < numbers.length # We cant do less than or equal to here
new_array << numbers[i] * i # You can shovel directly into a new array
i += 1
end
return new_array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def yell(words)\n words.map{|word| word + \"!\"}\nend",
"def whisper_words(words)\nreturn words.map{ |elem| elem.downcase + \"...\"}\nend",
"def yell(words)\n\twords_bang = []\n\n\ti = 0\n\twhile i < words.length\n\t\twords_temp = words[i]\n\t\twords_new = words_temp + '!'\n\n\t\twords_bang << words_new\n\n\t\ti += 1\n\tend\n\t\n\treturn words_bang\nend",
"def whisper_words(words)\r\n return words.map { |ele| ele.downcase + \"...\" }\r\nend",
"def yell(words)\n new_words = []\n words.each {|word| new_words << word + \"!\" }\n new_words\nend",
"def whisper_words(words)\n\treturn words.map {|word| word.downcase + \"...\"}\nend",
"def yell(words)\n newArr = []\n i = 0\n while i<words.length\n newWord = words[i] + \"!\"\n newArr << newWord\n i += 1\n end\n return newArr\n end",
"def yell(words)\n yelling = []\n \n i = 0\n while i < words.length\n yelling << words[i] +\"!\"\n \n i += 1\n end\n \n return yelling\nend",
"def yell(words)\n\tnew_words = []\n\n\ti = 0\n\twhile i < words.length\n\t\twords[i] += \"!\"\n\t\tnew_words << words[i]\n\t\ti += 1\n end\n\t\n\treturn new_words\nend",
"def whisper_words(words)\n return words.map { |word| word.downcase + \"...\" }\nend",
"def array_sentences(str)\n sentences = str.split('.')\n sentences.map! do |sent|\n sent.split('?').map! do |sent2|\n sent2.split('!')\n end\n end\n sentences.flatten\nend",
"def whisper_words(words)\n return words.map { |word| word.downcase + \"...\" }\nend",
"def yell(words)\n i = 0\n new_arr = []\n while i < words.length\n loud_words = words[i] + '!'\n new_arr << loud_words\n i += 1\n end\n return new_arr\nend",
"def yeller(words) # words is var of an array of strings\n loud_arr = [] # empty array for strings\n i = 0 # the indice counter starting @ 0\n while i < words.length\n word = words[i] # can't store indice of an int, so keep value of the int \"which is string\"\n loud_word = (word + \"!\") # concat \"!\" to string store the result new word for each iteration\n loud_arr << loud_word # shovel result into the array\n i += 1 # next iteration\n end\n return loud_arr\n puts loud_arr\nend",
"def summon_captain_planet(arr)\n arr.map {|word| word.capitalize + \"!\"}\nend",
"def non_opt_words(current)\n output = []\n (0..(current.length-1)).each do |index|\n ('a'..'z').each do |let|\n test_word = current.clone\n test_word[index] = let\n output << test_word if legal_word?(test_word)\n end\n end\n output.uniq\nend",
"def yell(words)\n i = 0\n new_words = []\n while i < words.length\n new_words << words[i] + '!'\n i += 1\n end\n return new_words\nend",
"def silly_talk(sent)\n vowels = \"aeiou\"\n return_array = []\n sent.split(\" \").each do |word|\n if vowels.include?(word[-1])\n return_array << word + word[-1] \n else\n word.each_char.with_index do |char, idx|\n vowels.include?(char) ? (return_array) : () \n end\n end\n word.each_char \n end\nend",
"def get_letters(game)\n game.letters.split(\"\").reject{|letter| game.word.upcase.include?(letter)}.join(\" \")\nend",
"def whisper_words(words)\n\treturn words.map { |word| word.downcase + \"...\" }\nend",
"def yell(words)\n\tnewWords = []\n\tfor i in 0..words.length-1\n newWord = words[i] + \"!\"\n \tnewWords << newWord\n end\n return newWords\nend",
"def words\n []\n end",
"def yell_sentence(sent)\n return sent.split.map { |word| word.upcase + \"!\"}.join(\" \")\nend",
"def filter_repeated_character_strings(arr)\nend",
"def text\n map(&:text).join\n end",
"def specialities(characters)\n # initialize empty array\n result = []\n\n #iterate through characters\n characters.each do |character_hash|\n phrase = character_hash[:name]+\"'s specialty is to \" + character_hash[:specialty].upcase\n result << phrase\n end\n\n return result\n\nend",
"def get_all_letters_in_array_of_words(array)\n array.join.split(\"\").sort \nend",
"def add_bang(array)\n array.map {|string| string+\"!\"}\nend",
"def words\n %w(this array has five words)\nend",
"def add_bang(array)\n\tarray.map {|string| string + \"!\"}\nend",
"def yell_happily(words)\r\n words + \"!!!\" + \" :)\"\r\n end",
"def yell_sentence(sent)\n # yell = sent.split(\" \")\n # yell = yell.map { |char| char.upcase + \"!\" }\n # return yell.join(\" \")\n return sent.split.map { |char| char.upcase + \"!\" }.join(\" \")\nend",
"def get_all_letters_in_array_of_words(array)\n array.join.split('').sort\nend",
"def words\n split(/[^a-z0-9_.-]+/i)\n end",
"def awesomesauced(strings)\n index = 0\n awesomesauced_array = []\n\n while index < strings.length\n awesomesauced_array << strings[index]\n if index != strings.length - 1\n awesomesauced_array << \"awesomesauce\"\n end\n index += 1\n end\n awesomesauced_array\nend",
"def summon_captain_planet(array)\n array.collect { |word| word.capitalize + \"!\" }\nend",
"def get_all_letters_in_array_of_words(array)\n result = []\n array.each do |x|\n for a in 0..(x.length-1) do\n result.push(x[a]) if !result.include?(x[a])\n end\n end\n result.sort\nend",
"def my_extra_words\n ['extra', 'words', 'here', 'too']\n end",
"def make_array\n @phrase_string.downcase.split(WORD_SPLIT).reject(&:empty?)\n end",
"def arr_word_list(pos)\n pos.flatten!\n pos.each{|e| e.strip!}\n str_res = pos.uniq.join(', ')\n return str_res\n end",
"def censor(string, array)\n new_words = (string.split).map do |word|\n if array.include?(word.downcase)\n star_vowels(word)\n else\n word\n end\n end\n\n new_words.join(\" \")\nend",
"def get_all_letters_in_array_of_words(array)\n\tn =['cat', 'dog', 'fish']\n\tcharacters = n.map { | animal | animal.chars }\n\tcharacters.flatten.sort\nend",
"def yell_happily(words)\r\n words + \"!!!\" + \" :)\"\r\n end",
"def add_bang(array)\n # TODO: Take an array of strings and return a new array with \"!\" appended to each string.\n # You should use Enumerable#map\n array.map do |element|\n element+\"!\"\n end\nend",
"def awesomesauce_infusion(strings)\n i = 0\n infused_strings = []\n strings.length.times do\n infused_strings << strings[i]\n if i < strings.length - 1\n infused_strings << \"awesomesauce\"\n end\n i += 1\n end\n return infused_strings\nend",
"def incl_letter(array, letter)\n fin_array = []\n array.each do |value|\n if value.include? (letter)\n fin_array.push(value)\n end\n end\n p fin_array\nend",
"def yell(words)\n i = 0\n while i < words.length\n words[i] = words[i] + \"!\"\n i+= 1\n end\n return words\nend",
"def yell(words)\n new = []\n\n i = 0\n\n while i < words.length\n old_word = words[i]\n new_word = old_word + '!'\n new << new_word\n i += 1\n end\n\n return new\nend",
"def o_words(sentence)\n \n arr=sentence.split(\" \").select {|word| word.include?(\"o\")}\n\nend",
"def hipsterfy(sentence) \n sentence = sentence.split(\" \")\n arr = []\n sentence.each do |word|\n result = word.gsub(/[aeiou](?!.*[aeiou])/, '') # Negative Lookahead Regex\n arr << result\n end\n arr.join(\" \")\nend",
"def baseball_team_lists\n [\"A's\", \"Tigers\", \"Stars\"] #Simple ruby array\nend",
"def yell_sentence(sent)\n\twords = sent.split(\" \")\n \tnew_words = words.map{ |word| word.upcase + \"!\"}\n \treturn new_words.join(\" \")\nend",
"def sentence_to_array (string)\n string_split = string.split('.')\n string_split.map! do |words|\n words.split('!') \n end\n string_split.flatten!\n\n string_split.map! do |words|\n words.split('?') \n end\n string_split.flatten\nend",
"def resume_to_array(text)\n result = text\n result.gsub!(\",\",\"\")\n result.gsub!(\"(\",\"\")\n result.gsub!(\")\",\"\")\n result.gsub!(\"[\",\"\")\n result.gsub!(\"]\",\"\")\n result.downcase!\n return result.split\nend",
"def missing_letters(string)\n\n result = []\n\n (\"a\"..\"z\").each do |ch|\n result << ch if string.downcase.include?(ch) == false\n\n end\n result\nend",
"def yell(words)\n\ti = 0\n while i < words.length\n words[i] = words[i] + \"!\"\n i += 1\n end\n return words\nend",
"def spell_out (foo)\n foo.downcase.split(\"\").join(\"-\")\n end",
"def hashtagify(sentence, tags)\n result_array = Array.new\n sentence.split(\" \").each do |word|\n if sentence.include?(\"!\") || sentence.include?(\".\")\n result_array.push(punctuation_in_word(word, tags))\n else\n if tags.include?(word.downcase)\n result_array.push(\"#\" + word)\n else\n result_array.push(word)\n end\n end\n end\n result_array.join(\" \")\nend",
"def spell_out strings\n strings.downcase.split(\"\").join(\"-\")\nend",
"def words\n @content.split\n end",
"def words\n @content.split\n end",
"def awesomesauced(strings)\n length_of_array = strings.length\n new_array = []\n index = 0\n\n while index < length_of_array\n new_array << strings[index]\n\n if index != length_of_array - 1\n new_array << \"awesomesauce\"\n end\n\n index += 1\n end\n\n return new_array\nend",
"def spinWords(string)\r\n \r\n var= string.split(' ') #[\"Hey\", \"fellow\", \"warriors\"]\r\n finalarry=[]\r\n var.each do |x|\r\n arry= x.split('') \r\n if arry.count >= 5\r\n finalarry << arry.reverse\r\n else\r\n finalarry<< arry\r\n end\r\n\r\n \r\n end\r\n \r\n lastarry=[]\r\n finalarry.each do |y|\r\n lastarry << y.join(\"\")\r\n \r\n end\r\n \r\n result= lastarry\r\n p result.join(' ')\r\n\r\n\r\n \r\n \r\nend",
"def letter_list(equation)\n equation.gsub(/[^A-Z]/, '').chars.uniq\n end",
"def awesomesauced(strings)\n index = 0\n length_of_array = strings.length\n awesomesauced_array = []\n\n while index < length_of_array\n awesomesauced_array << strings[index]\n if index != length_of_array - 1\n awesomesauced_array << \"awesomesauce\"\n end\n index += 1\n end\n p awesomesauced_array\nend",
"def words\n message.split\n end",
"def make_a_sentence(words)\n words.join(' ') + \"!\"\nend",
"def yell(words) # DEFINE METHOD WITH ONE PARAM\n \n i = 0 # SET FIRST INDEX VALUE\n \n new_array = [] # CREATE AN EMPTY ARRAY\n \n while i < words.length # WHILE LOOP THAT CHECKS IF I IS LESS THAN THE ARRAY LENGTH\n old_ele = words[i] # VARIABLE TO STORE INDEXED VALUE OF ARRAY\n exclamations = old_ele + \"!\" # VARIABLE THAT CONCATENATES EXCLAMATION TO END OF INDEX ARRAY VALUE\n new_array << exclamations # SHOVELS IT INTO END OF ARRAY VARIABLE\n i += 1 # INCREMENT OF ONE ITERATION\n\n end\n return new_array # RETURNS FINAL VALUE OF NEWLY CREATED ARRAY\n \n\nend",
"def remove_w_words(sentence)\r\n\r\n arr = [] # empty array created\r\n x = sentence.split(\" \")\r\n\r\n i = 0\r\n while i < x.length # iteration starts to check \"w\" in each word\r\n arr << x[i] if x[i][0] != \"w\" # words w/o \"w\" collected\r\n i += 1\r\n end\r\n\r\n arr.join(\" \") # result\r\nend",
"def filter_words_with_letter array, letter\n array.filter_map{ |value| value if value.include? letter }\nend",
"def contain_a(array)\n new_array = [ ]\n array.each do |word|\n if word.include?(\"a\") == true\n then new_array << word\n end\n end\n new_array\nend",
"def initial_consonants\n \n @@sentence.map { |word|\n if word.start_with?('a','e','i','o','u','A','E','I','O','U') \n \"\" \n else \n consonant_blend = word.split /([aeiou].*)/\n consonant_blend[0]\n\n end\n }\n end",
"def word_unscrambler(str, words)\n str = str.split('').sort.join('')\n possible = []\n words.map do |word|\n sort_word = word.split('').sort.join('')\n possible << word if word_c == str\n end\n return possible\nend",
"def split(text)\n text.downcase.scan(WORDS).uniq\n end",
"def find_modules(text)\n modules = []\n\n KEYWORDS.each do |keyword|\n modules << text.select{|x| x.start_with? \"#{keyword} \"}\n end\n\n return modules.flatten!\nend",
"def translate code, translation = \"\"\n\n # recursion base case:\n #\n # return an array containing the translation if the code has\n # a size of 0\n return [translation.downcase] if code.size.zero?\n\n words = []\n\n # check all possible matches to the code\n LETTERS.each do |letter|\n if code[letter.pattern]\n\n # recurse on untranslated portion of the code\n # and new translation\n # add results to our array at this level of recursion\n words += translate code.sub(letter.pattern,''),translation+letter.letter\n end\n end\n\n return words\n\nend",
"def internally_screaming\n people = [\"Taylor Swift\", \"Carly Rae Jeppsen\", \"Justin Bieber\"]\n\n people.map do |name|\n \"#{name} is bad at music\"\n end\n \nend",
"def get_word_from_context(context)\r\n words = []\r\n\r\n context.split(\" \").each do |word|\r\n if word[-1] == \".\" or word[-1] == \",\" or\r\n word[-1] == \"?\" or word[-1] == \"!\" or\r\n word[-1] == \":\" \r\n\r\n word = word[0..-2]\r\n end\r\n\r\n words << word unless word.size < 3\r\n end\r\n\r\n words\r\nend",
"def suffix_array text\n sufs = {}\n 0.upto(text.length - 1){|i| sufs[text[i..text.length]] = i}\n lexo_sufs = sufs.keys.sort\n array = []\n lexo_sufs.each{|s| array << sufs[s]}\n array\nend",
"def yell_at_patrons\n yelled_at_patrons = []\n patrons.each do |patron|\n yelled_at_patrons << patron.upcase\n end\n return yelled_at_patrons\n end",
"def make_list(text)\n\traw_text_array = text.split(\" \")\n\treturn raw_text_array\nend",
"def get_keywords\n titles.map do |title|\n title.split(\" \")\n end\n end",
"def ordered_vowel_words(words)\n\n result = []\n words.each do |word|\n result << word if ordered_vowel_word?(word)\n end\n\n result\nend",
"def word_unscrambler(str, words)\n str_letters = str.split(\"\").sort\n\n res = []\n words.each do |word|\n word_letters = word.split(\"\").sort\n res << word if str_letters == word_letters\n end\n\n res\nend",
"def non_unique_letters(string)\n string.chars.reduce([]) do |array,letter|\n if string.count(letter) > 1 && array.include?(letter) == false && letter != \" \"\n array << letter\n else\n array\n end\n end\nend",
"def words\n @phrase.split(/[^A-Za-z0-9']+/)\n end",
"def pirates_say_arrrrrrrrr(string)\n\tarray_1 = string.downcase.split\"\"\n\tarray_2 = []\n\nloop do \n\tarrr = array_1.index(\"r\")\n\tbreak if arrr == nil\n\tarray_1.delete_at(arrr)\n\tarray_2 << array_1[arrr]\n\t\nend\n\narray_2.join\n\nend",
"def silly_syllables(sentence)\n new_arr = []\n sent_arr = sentence.split(' ')\n vowels = 'aeiou'\n sent_arr.each do |word|\n if word.chars.count {|el| vowels.include?(el)} < 2\n new_arr << word\n else\n start = word.chars.index {|el| vowels.include?(el)}\n finish = word.chars.reverse.index {|el| vowels.include?(el)}\n finish_index = word.chars.length - finish - 1\n new_arr << word[start..finish_index]\n end\n\n end\n new_arr.join(' ')\nend",
"def one_word_names(list)\n own = list.select do |c|\n c[:name].include?(\" \") == false\n end\n return own\nend",
"def find_a(things)\n new_array = []\n things.each do |thing|\n if thing.start_with?(\"a\")\n new_array << thing\n end\n end\n new_array\nend",
"def crunch(words)\n words.split.map! do|word|\n word.squeeze\n end.join(' ')\nend",
"def filter_repeated_character_strings(arr)\n results = []\n\n index = 0\n arr.each do |word|\n char_index = 0\n main_char = \"\"\n other_char = false\n\n word.chars.each do |char|\n char_index += 1\n\n if char_index == 1\n main_char = char\n end\n if main_char != \"\" && char == main_char\n if char_index == word.length && other_char == false\n results.insert(index, word)\n\n index += 1\n end\n else\n other_char = true\n end\n end\n end\n\n return results\nend",
"def yell(arr)\n result = [];\n i = 0;\n while i < arr.length\n result[i] = arr[i] + '!';\n i += 1;\n end\n return result\nend",
"def word_with_letter arr, letter\n arr.select { |x| x.include? (letter)}\nend",
"def fivv_buzz(str)\n # array of desired words\n # split string into words (only needed if taking in a string, skip for array.)\n # iterate over words, check that the word starts with e AND is shorter than 6 characters.\n buzzed_words = []\n words = str.split(' ')\n words.each do |word|\n if 'eE'.include?(word[0]) && word.length < 6 \n # (word[0] == 'e' || word[0] == 'E') && word.length < 6\n buzzed_words << word\n end\n end\n return buzzed_words\nend",
"def test(b)\n b.map! {|letter| \"I like the letter: #{letter}\"}\nend",
"def all_words\n result = []\n tagged_words.each do |word|\n result << word[0] unless is_punctuation([ word[0], word[1] ])\n end\n result\n end",
"def find_a (array)\n new_array=[]\n array.select{|word| \n word.start_with?(\"a\") \n }\nend",
"def pig_it text\n text.split(' ').map do |word|\n if word == \"?\" || word == \"!\" || word == \".\" || word == \",\"\n word\n else\n (word[1..(word.length-1)] + word[0] + \"ay\")\n end\n end.join(' ')\nend",
"def words\n reject { |arg| arg.index('-') == 0 }\n end",
"def summon_captain_planet(array)\n array.map! {|command| command.capitalize + \"!\"}\nend"
] |
[
"0.6505465",
"0.6394712",
"0.6342969",
"0.6210279",
"0.61674124",
"0.61049163",
"0.6087833",
"0.6036144",
"0.6019176",
"0.6014929",
"0.6005572",
"0.5982568",
"0.59821266",
"0.59723264",
"0.5958852",
"0.5948041",
"0.593246",
"0.5907912",
"0.5904128",
"0.5873415",
"0.5865522",
"0.5851162",
"0.5842461",
"0.58340377",
"0.58021355",
"0.57981265",
"0.57972413",
"0.5793122",
"0.57803446",
"0.5766403",
"0.5759961",
"0.57510495",
"0.5747245",
"0.5746759",
"0.5746446",
"0.57436424",
"0.5739776",
"0.57240665",
"0.5720193",
"0.5689415",
"0.56890535",
"0.56869936",
"0.5686196",
"0.5677556",
"0.56713784",
"0.5654188",
"0.5647564",
"0.5638137",
"0.5636282",
"0.56359553",
"0.5635179",
"0.5634398",
"0.5632905",
"0.5627545",
"0.5627459",
"0.56208944",
"0.56194663",
"0.56187403",
"0.56092507",
"0.56027824",
"0.56027824",
"0.559723",
"0.558827",
"0.5585154",
"0.55824274",
"0.5577208",
"0.5575391",
"0.5565441",
"0.5562999",
"0.55620396",
"0.55563444",
"0.55475545",
"0.55459654",
"0.5540662",
"0.55311054",
"0.55229366",
"0.5520743",
"0.55141854",
"0.54952294",
"0.5494496",
"0.5491577",
"0.5485645",
"0.54852015",
"0.5481379",
"0.54750305",
"0.5473867",
"0.5472738",
"0.54654306",
"0.5462489",
"0.5462228",
"0.54609174",
"0.54535955",
"0.5448825",
"0.5447671",
"0.54457617",
"0.54365945",
"0.54319304",
"0.5423496",
"0.5420306",
"0.54137385",
"0.54135436"
] |
0.0
|
-1
|
=> [0, 1, 2, 3, 4, 5] EVEN NUMS Write a method even_nums(max) that takes in a number max and returns an array containing all even numbers from 0 to max
|
def even_nums(max)
i = 0
even = []
while i <= max
if i % 2 == 0
even << i
end
i += 1
end
return even
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def even_nums(max)\n result = []\n\tfor i in 0..max\n \tif i % 2 == 0 \n result << i\n end\n end\n return result\nend",
"def even_nums(max)\n\tnums = []\n \n\ti = 0\n\twhile i <= max\n\t\tif i % 2 == 0\n\t\t\tnums << i\n\t\tend\n\t\ti += 1\n end\n \n\treturn nums\nend",
"def even_nums(max)\n i = 0\n evens = []\n while i <= max\n\tif i % 2 == 0\n evens << i\n end\n i += 1\n end\n return evens\nend",
"def even_nums(max)\n newArr = []\n i = 0\n while i <= max\n if i % 2 == 0\n newArr << i\n end\n i+=1\n end\n return newArr\n end",
"def even_nums(max)\n even_array = []\n \n i = 0\n while i <= max\n if i % 2 == 0\n even_array << i\n end\n \n i +=1\n end\n \n return even_array\nend",
"def even_nums(max)\n even_arr = []\n i = 0\n\n while i <= max\n if i % 2 == 0\n even_arr << i\n end\n i += 1\n end\n return even_arr\nend",
"def even_nums(max)\n evens = []\n \n i = 0\n while i <= max\n if i % 2 == 0\n evens << i\n end\n \n i += 1\n end\n \n return evens\nend",
"def even_nums(max)\n\tnew_arry = []\n \tcount = 0\n while count <= max\n new_arry << count\n count += 2\n\n end\n return new_arry\nend",
"def even_nums(max)\n print (0..max).step(2).to_a\nend",
"def even_nums(max) # max is some int\n new_arr = [] # initialize new array\n i = 0 # indice counter @ 0\n\n while i <= max # while i is less than or equal to the given int\n if i % 2 == 0 # if i is not divisible by 0\n new_arr << i # add the number into the new array\n end\n\n i += 1\n end\n return new_arr\nend",
"def even_nums(max)\n new_arr = []\n i = 0\n while i <= max\n #if the number is even, then add to the array\n if i % 2 == 0\n new_arr << i\n end\n i += 1\n end\n print new_arr\nend",
"def even_numbers_less_than num\n even_array = []\n for number in 0...num\n if number % 2 == 0\n even_array.push(number)\n end\n end\n return even_array\nend",
"def get_even_numbers_from_array(numbers)\n even_numbers = []\n\n for number in numbers\n\n if number.even? == true\n even_numbers << number\n end\n \n end\n\n return even_numbers\nend",
"def even_numbers_less_than num\n array_for_even_numbers = []\n for i in 0...num\n if i % 2 == 0\n array_for_even_numbers.push(i)\n end\n end\n return array_for_even_numbers\n\nend",
"def even_numbers_less_than num\n # i = 0\n # even_numbers = []\n # while i < num\n # even_numbers.push i\n # i += 2\n # end\n # return even_numbers\n\n array = []\n (0...num).each do |i|\n if i%2 == 0\n array.push i\n end\n end\n return array\nend",
"def even_numbers_less_than num\n # set up empty array to place all even numbers\n array = []\n for i in 0...num\n # if even add that value to the array\n if(i % 2 == 0)\n array.push(i)\n end\n end\n return array\nend",
"def even_numbers_less_than num\n array = []\n for i in 0...num\n if i % 2 == 0\n array.push(i)\n end\n end\n array\nend",
"def even_numbers_less_than num\n even_numbers_array = []\n i=0\nwhile i<num do\n even_numbers_array.push(i)\n i+=2\nend\n return even_numbers_array\nend",
"def evil_even_numbers(array_of_numbers)\n result = []\n for number in array_of_numbers\n result.push(number) if(number % 2 == 0)\n end\n \n return result \nend",
"def get_evens(arr)\n even_array = []\n arr.each{|int| even_array.push(int) if int % 2 == 0}\n even_array\nend",
"def even_numbers(num_array)\n\tnum_array.select! { |num| num.even? }\nend",
"def evenNumbers(n)\n arr = Array.new\n i = 1\n\n while arr.length < n\n i = i + 1\n if i % 2 == 0\n arr << i\n end\n end\n\n puts \"#{arr.length} and #{arr}\"\nend",
"def odd_range(min, max)\n\tarr = []\n \tfor i in min..max\n if i % 2 != 0 \n arr << i\n end\n end\n return arr\n \nend",
"def even_int(integers)\n\teven_num = []\n\tfor i in 0..integers.length()-1\n\t\tif integers[i].even?\n\t\t\teven_num << integers[i]\n\t\telse \n\t\t\tnext\n\t\tend\n\tend\n\treturn even_num\nend",
"def even_numbers(lottery_n)\n even_nums = []\n for num in lottery_n\n even_nums.push(num) if num%2 == 0\n end\n return even_nums\nend",
"def even_numbers(array)\n array.select{ |num| num.even? }\n\n # TODO: Return the even numbers from a list of integers.\n # You should use Enumerable#select\nend",
"def odd_range(min, max)\n new_arr = []\n i = min\n while i <= max\n if i % 2 != 0\n new_arr << i\n end\n i += 1\n end\n return new_arr\nend",
"def odd_range(min, max)\n new_array = []\n i = min\n\n while i <= max\n if i % 2 != 0\n new_array << i\n end\n i += 1\n end\n\n return new_array\nend",
"def odd_range(min, max)\n\tarry = []\n \ti = min\n while i <= max\n if i % 2 == 0\n else\n arry << i\n end\n i += 1\n end\n return arry\nend",
"def odd_range(min, max)\n odd_array = []\n\n i = min\n while i <= max\n if !(i % 2 == 0)\n odd_array << i\n end\n i += 1\n end\n return odd_array\nend",
"def even_index_nums(array)\n counter = 0\n even_index_array = []\n \n loop do\n break if counter == array.length\n \n current_element = array[counter]\n \n if counter % 2 == 0\n even_index_array << current_element\n end\n \n counter += 1\n end \n even_index_array\nend",
"def even_numbers(num_array)\n\n\tnum_array.select! do |num|\n\t\tnum % 2 == 0\n\tend\n\n\tnum_array\n\nend",
"def even_numbers_less_than num\n\tnumber_array = []\n\t(0...num).each do |number|\n\t\tnumber.even?\n\tend\nend",
"def even_numbers_less_than(num)\n array = (0...num).to_a\n array.select { |x| x if x.even? }\nend",
"def odd_range(min, max)\n newArr = []\n i = min\n while i <= max\n if i % 2 != 0\n newArr << i\n end\n i += 1\n end\n return newArr\n end",
"def odd_range(min, max)\n odd_numbers = []\n \n i = min\n while i <= max\n if i % 2 == 1\n odd_numbers << i\n end\n \n i += 1\n end\n \n return odd_numbers\nend",
"def get_even_fib(max_num)\n\tnum1 = 1\n\tnum2 = 2\n\tcurrent_num = num2\n\teven_fib = []\n\twhile(num2 < max_num)\n\t\tif (num2 % 2 == 0)\n\t\t\teven_fib.push num2\n\t\tend\n\t\tcurrent_num = num2\n\t\tnum2 = num1 + num2\n\t\tnum1 = current_num\n\tend\n\teven_fib\nend",
"def even_numbers_less_than num\n\t# array_of_nums = []\n\t# i = 0\n\t# while i < num\n\t# \tarray_of_nums.push(i)\n\t# \t# array_of_nums.delete_if &:odd?\n\t# \ti += 2\n\t# end\n\t# array_of_nums\n\t(0...num).select { |numbers| numbers.even? }\nend",
"def odd_range(min, max) # Define method with 2 params\n \n i = min # since we are being to ask to start with first param we set i to start at min; the first param\n new_array = [] # Create an empty array to shovel values into\n \n while i <= max # Sets condition\n \n if i % 2 != 0 # If statement that uses an expression to determine if number is NOT an even number, odd numbers will always equal 1, but you can also put not equal to 0. Logical expression\n new_array << i # Shovel not even number value screened by above condition into array\n end # End of if loop\n \n i += 1 # Increments each iteration by one\n end # End of method\n return new_array # Returns array values after end of method\n\nend",
"def even_numbers_less_than num\n array=[]\n i = 0\n begin\n if (i % 2 == 0)\n array.push (i)\n end\n i+=1\n end while ( i < num)\n array\nend",
"def odd_range(min, max)\n\trange = []\n \n\ti = min\n\twhile i <= max\n\t\tif i % 2 != 0\n\t\t\trange << i\n\t\tend\n \ti += 1\n end\n\n\treturn range\nend",
"def odd_range(min, max)\n odds = []\n index = min \n \n while index <= max\n if index % 2 == 1 \n odds << index \n end \n index += 1 \n end \n \n return odds \n \nend",
"def even_index_nums(array)\n even_index_array = []\n \n array.each_with_index do |element, index|\n if index.even?\n even_index_array << element\n end\n end\n even_index_array\nend",
"def odd_range(min, max)\n\trange = []\n \ti = min \n \t\n \twhile i <= max\n if i % 2 != 0\n range << i\n end\n \n i += 1 \n end\n\treturn range\nend",
"def evenities1(array)\n index = 1\n even_array = []\n while index < array.length\n even_array << array[index]\n index += 2\n end\n even_array\nend",
"def evens(arr)\n even_indices = []\n index = 1\n\n while index < arr.length\n even_indices << arr[index]\n index += 2\n end\n even_indices\nend",
"def find_evens(numbers)\n even = []\n numbers.each do |number|\n even.push number if number.even?\n end\n even\nend",
"def odd_array(numbers)\n odd_value = []\n \n numbers.each_with_index do |value, idx|\n odd_value << value if idx.even?\n end\n odd_value\nend",
"def odd_range(min, max)\n odds = []\n i = min\n while i <= max\n if i % 2 == 1\n odds << i\n end\n i += 1\n end\n return odds\n end",
"def odd_range(min, max)\n newArr = []\n\n while min <= max\n newArr << min if min % 2 == 1\n min += 1\n end\n return newArr\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 select_even_nums(arr)\n arr.select(&:even?)\nend",
"def even_numbers_less_than num\n\t(0...num).reduce [] do |evens, number|\n\n\t\tif number%2 == 0\n\t\t\tevens.push number\n\t\tend\n\n\t\tevens\n\tend\nend",
"def evenlists(array)\n even = []\n j = 0\n while array.count >= j \n even << array[j]\n j +=2\n end \n p even\nend",
"def evens(array)\n index = 1\n even_array = []\n while index < array.size\n even_array << array[index]\n index += 2\n end\n p even_array\nend",
"def even_numbers_less_than num\n\na =\t[]\n# for i in 0..num do \n# \t\tif i % 2 == 0 then\n# \t\t\treturn a.insert(i)\n# \t\tend \n# \tend \n# \treturn a;\n\nfor i in 0...num do \n\tif i.even?\n\t\ta.push(i)\n\tend\n\tend \n\treturn a\nend",
"def crazy_nums(max)\n nums = [] # store result\n i = 0\n count = 0\n \n while i < max\n if(i % 3 == 0) && (i % 5 == 0)\n \n elsif (i % 3 == 0) || (i % 5 == 0)\n nums[count] = i\n count = count + 1\n end\n i = i + 1\n end\n return nums \nend",
"def odd_numbers(array)\n end",
"def even_numbers_less_than num\n\t(0...num).select do |number|\n\t\tnumber.even?\n\tend\nend",
"def odd_integers(array)\nend",
"def primes(max)\n array = []\n i = 2\n while i < max.abs\n if is_prime?(i)\n array << i\n end\n i += 1\n end\n array\nend",
"def select_every_even arr\n ans = []\n arr.each_with_index do |item, i|\n if i%2 == 0 \n ans.push item\n end\n end\n ans\nend",
"def odd_num\n y = []\n [*1..255].map do |i| \n if i % 2 != 0\n y << i\n end\n end\n y\nend",
"def find_even(array)\nend",
"def only_even(arr)\n\tnumsOnly = arr.select { |num| num.is_a? Integer } \n\toddOnly = numsOnly.select { |num| num % 2 != 0 }\n\treturn oddOnly.sort()\nend",
"def select_evens(array)\n output_array = []\n\n array.each do |number|\n if number % 2 == 0\n output_array << number\n end\n end\n\n return output_array\nend",
"def evens(arr)\n counter = 1\n even_places = []\n while counter < arr.size\n even_places << arr[counter]\n counter += 2\n end\n even_places\nend",
"def oddities(int_array)\n index = 0\n odds = []\n\n while index < int_array.size\n odds.push(int_array[index])\n index += 2\n end\n odds\nend",
"def even_fibonacci_array\n @even_array = []\n @fibon_array.each do |i|\n if i % 2 == 0\n @even_array.push i\n else\n end\n end\n @even_array\n end",
"def odd_range(min, max)\n (min..max).select{|num| !(num.even?) }\nend",
"def evens_below(integer)\n integer = integer - 1\n array = []\n integer.downto(0) do |i|\n if i % 2 == 0\n array << i\n end\n end \n p array\nend",
"def oddities2(arr)\n index = 0\n result = []\n loop do\n break if index >= arr.size\n result << arr[index]\n index += 2\n end\n result\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 get_evens(array)\n\t\n\tevens = array.select { |num| num.even? }\n\t\nend",
"def arr_even_square()\n [1, 3, 4, 5, 12, 23].each {|num|\n if num % 2 === 0\n puts num\n end\n }\nend",
"def select_even_numbers(array)\n array.select{|x| x % 2 == 0}\nend",
"def oddities(arr)\n counter = 0\n return_array = []\n loop do\n return_array << arr[counter]\n counter += 2\n break if counter >= arr.size\n end\n return_array.compact\nend",
"def sum(max)\n new_term = 0\n sequence = [1, 2]\n while new_term < max\n new_term = sequence[-1] + sequence[-2]\n sequence << new_term\n end\n sequence.pop\n p sequence\n p sequence.select(&:even?).sum\nend",
"def get_loop_even(num)\n (0..num).each { |x| x if (x%2==0)}\nend",
"def even_num_array(numbers)\n puts \"The original array is #{numbers}\"\n\tnumbers = numbers.select {|n| n.even? } \n\tputs \"The modified array is #{numbers}\"\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 square_nums(max)\n idx = max / 2\n while idx * idx > max\n idx -= 1\n end\n return idx\nend",
"def evenies(array)\n even_array = []\n array.each_with_index { |e, idx| even_array << e if idx.odd? }\n even_array\nend",
"def eveness(array)\n new_array = []\n index = 1\n while index < array.size\n new_array << array[index]\n index += 2\n end\n new_array\nend",
"def evensum(num)\n array = [1, 2]\n first = 1\n second = 2\n\n until array.last > num\n array << (first + second)\n first = second\n second = array.last\n end\n array.pop\n array.select {|x| x.even?}.reduce(:+)\nend",
"def get_evens(arr)\n arr.select { |x| x.even? }\nend",
"def num(num1, num2)\n (num1..num2).each do |i|\n puts i if i.even?\n end\nend",
"def oddArray\n\tarr=[]\n\tarr.push((1..255).find_all{|x| x % 2 != 0})\n\tputs arr\nend",
"def oddities(array)\n new_array = []\n array.each_with_index { |num, idx| new_array << num if idx.even? }\n new_array\nend",
"def sum_of_even(input_array)\n\teven_array = []\n\tinput_array.each do |number|\n\t\tif number%2 == 0\n\t\t\teven_array.push(number)\n\t\tend\n\tend\n\treturn even_array.inject(:+)\nend",
"def oddities(array)\n\n result = [] # empty array to push each item in the array to.\n index = 0 # creates a counter called index\n\n while index < array.size\n result << array[index] # array index is the number in the array.\n index += 2 # += 2 iterates over and returns even items.\n end\n result # again with loops put the result outside of the loop.\nend",
"def even_numbers(array)\n\n unless array.is_a?(Array)\n # would be raise Argument error exception anyway, just for illustrate\n raise ArgumentError\n end\n\n if array.length == 0\n raise StandardError.new(\"Too few elements\")\n end\n\n array.find_all { |el| el.to_i % 2 == 0 }\n\nend",
"def even_num_rec(n)\n n = (0...n).to_a if n.is_a? Integer\n if n == []\n []\n else\n [n[0] * 2] + even_num_rec(n[1..-1])\n end\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 first_even(array_of_numbers)\n even_number_array = []\n array_of_numbers.each do |num| \n if num % 2 == 0\n even_number_array << num\n end\n end\n even_number_array[0]\nend",
"def oddities(array)\n result = []\n index = 0\n\n loop do\n result << array[index]\n index += 2\n break if index >= array.size\n end\n\n result\nend",
"def odd_int(integers)\n\todd_num = []\n\tfor i in 0..integers.length()-1\n\t\tif integers[i].even?\n\t\t\tnext\n\t\telse \n\t\t\todd_num << integers[i]\n\t\tend\n\tend\n\treturn odd_num\nend",
"def all_numbers_even?(nums)\n nums.all { |num| num.even? }\n end",
"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 get_squares(first_number, last_number)\n n = (first_number..last_number).to_a\n squares = []\n n.each do |i|\n if i % 2 == 0\n squares << i\n end\n end\n return squares\nend"
] |
[
"0.9112309",
"0.9052321",
"0.8976567",
"0.896618",
"0.8920272",
"0.89127636",
"0.89072543",
"0.8524075",
"0.8500073",
"0.8495281",
"0.8315231",
"0.7784933",
"0.7777802",
"0.77590245",
"0.7720529",
"0.75907725",
"0.75417733",
"0.74574524",
"0.74352",
"0.74346256",
"0.741943",
"0.7408798",
"0.7391516",
"0.738809",
"0.73647183",
"0.73641115",
"0.7352214",
"0.7307391",
"0.7294099",
"0.72833306",
"0.72829413",
"0.72814834",
"0.7242169",
"0.7229716",
"0.72158635",
"0.7204911",
"0.7201269",
"0.71693325",
"0.7159688",
"0.7088745",
"0.7083075",
"0.70637745",
"0.70489824",
"0.6995259",
"0.69867647",
"0.6966915",
"0.6963553",
"0.69622135",
"0.69280064",
"0.6915589",
"0.69151866",
"0.68859404",
"0.6850849",
"0.6842354",
"0.68348855",
"0.6799336",
"0.67759365",
"0.674543",
"0.67406416",
"0.6720106",
"0.6716257",
"0.6704276",
"0.66977936",
"0.66851455",
"0.66793716",
"0.6664739",
"0.66499394",
"0.6647883",
"0.6644615",
"0.66302663",
"0.66005564",
"0.6595783",
"0.65937203",
"0.6587342",
"0.6578279",
"0.6573305",
"0.65666074",
"0.65522724",
"0.65346164",
"0.65336394",
"0.65282726",
"0.6514862",
"0.6508577",
"0.6508201",
"0.6505768",
"0.6503912",
"0.64986074",
"0.64837575",
"0.64818347",
"0.6479455",
"0.64767426",
"0.6473743",
"0.6471718",
"0.64585686",
"0.6453028",
"0.64389473",
"0.6436865",
"0.64234656",
"0.64231783",
"0.6420535"
] |
0.88621944
|
7
|
=> [0, 2, 4] ARRAY CHALLENGE Write a method range(min, max) that takes in two numbers min and max. The function should return an array containing all numbers from min to max inclusive.
|
def range(min, max)
i = min
new_array = [] # The reason this is here and not in while loop is because we would be setting it to an empty array at the beginning of every instance and it would return the last iteration value of i.
while i <= max
new_array << i # Shovels each iteration of i in to array
i += 1 # Goes up by one
end
return new_array # Self explanatory
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def range(min, max)\n \tarr = []\n\tfor i in min..max\n arr << i\n end\n return arr\nend",
"def range(min, max)\n\trange = []\n\n\ti = min\n\twhile i <= max\n\t\trange << i\n\t\ti += 1\n end\n \n\treturn range\nend",
"def range(min, max)\n range_array = []\n\n i = min\n while i <= max\n range_array << i\n i += 1\n end\n return range_array\nend",
"def range(min, max)\n newArr = []\n i = min\n while i <= max\n newArr << i\n i +=1\n end\n return newArr\n end",
"def range(min, max)\n new_arr = []\n i = min\n while i <= max\n new_arr << i\n i += 1\n end\n return new_arr\n end",
"def range(min, max)\n arr = []\n\n while min <= max\n arr << min\n min += 1\n end\n return arr\nend",
"def range(min, max)\n nums = []\n \n i = min\n while i <= max\n nums << i\n \n i += 1\n end\n \n return nums\n end",
"def range(min, max)\n newArray = []\n i = min\n while i <= max\n newArray << i\n \ti += 1 \n end\n return newArray\n\nend",
"def range(min, max)\n # # return [] if end < start\n # if its the last one, 1, using start and end\n\n return [] if max <= min\n\n range(min, max - 1) << max - 1\n # ^ treat it like it is the same data type as base case, so treat it like an array, <<, .map\n\n # [min] + range(min + 1, max - 1)\n # ^ num ^ same data type our base case\nend",
"def range(min, max)\n new_arr = []\n\n i = min\n while i <= max\n new_arr << i\n i = i + 1 \n end\n\n return new_arr\nend",
"def range(min, max)\n\ti = min\n \tarry = []\n while i <= max\n arry << i\n i += 1\n end\n return arry\n\nend",
"def range(min, max)\n minMax = []\n i = min\n while i <= max\n minMax << i\n i += 1\n end\n return minMax\n end",
"def range(min, max)\n return [] if max <= min\n range(min, max - 1) << max - 1\n\n end",
"def range(min, max)\n return [] if max < min\n range(min, max - 1) << max\nend",
"def range(min, max)\n nums = []\n \n i = min\n while i <= max\n nums << i\n \n i += 1\n end\n \n return nums\nend",
"def range(min, max)\n\tprint (min..max).to_a\nend",
"def range(min, max) # takes some smaller num and then a larger num\n range_arr = [] # initialize new array\n i = min # indice counter @ whatever the first number passed in is\n\n firstnum = min # store val of first num\n lastnum = max # store val of last num\n \n while i <= max\n range_arr << i\n i += 1\n end\n return range_arr\nend",
"def range(min, max)\n all_numbers = []\n \n i = min\n while i <= max\n all_numbers << i\n \n i += 1\n end\n \n return all_numbers\nend",
"def range(start_num, end_num)\n # one line version\n # (start_num...end_num).to_a\n\n # version 2\n exclusive_range = []\n (start_num...end_num).each do |num|\n exclusive_range << num\n end\n exclusive_range\nend",
"def range(start, ending)\n return [] if start >= ending - 1\n retu_arr = range(start, ending - 1)\n retu_arr << ending - 1\nend",
"def range(min, max)\n nums = []\n\n i = min\n while i <= max\n nums << i\n\n i += 1\n end\n\n return nums\nend",
"def range(arr)\n\nend",
"def range(arr)\n arr.max - arr.min\nend",
"def range(arr)\n arr.max - arr.min\nend",
"def range(arr)\n max = arr.max\n min = arr.min\n\n max - min\nend",
"def range1(min, max)\n # Base Case / Inductive Step\n return [] if max <= min\n\n range1(min, max - 1) << max - 1\nend",
"def to_range\n min .. max\n end",
"def range(start, ending)\n return [] if start >= ending\n\n return [start] + range(start + 1, ending)\nend",
"def range(min, max)\n #new_arr = []\n\n i = min\n while i <= max\n new_arr = [] # initialized\n new_arr << i\n i = i + 1 \n end\n\n return new_arr\nend",
"def range(arr)\narr.max - arr.min\nend",
"def create_range(num)\n (1..num).to_a\nend",
"def range(start, ending_value)\n return [] if start > ending_value\n result = [start] + range(start + 1, ending_value)\nend",
"def range(start_num, end_num)\n range_array = []\n range_array << start_num\n\n if(start_num < end_num)\n range_array += range(start_num + 1, end_num)\n end\n\n range_array\nend",
"def range(min, max)\n return max if max < min\n range(min, max) << max\nend",
"def range(start_val, end_val)\n return [] if start_val + 1 == end_val\n nums = [start_val + 1]\n nums + range(start_val + 1, end_val)\nend",
"def loopy_range(max, step)\n numbers =[]\n for nums in (0..max)\n numbers.push(nums)\n end\n puts \"The end array is #{numbers}\"\nend",
"def rec_range(min, max)\n return [] if max == min\n [min] + rec_range(min+1, max)\nend",
"def range(arr)\n # your code goes here\n arr.max - arr.min\nend",
"def range(arr)\n # your code goes here\n arr.max - arr.min\nend",
"def range(start_num, end_num)\n return [] if end_num =< start_num\n range(start_num, end_num - 1) << end_num - 1\nend",
"def range(start,ending)\r\n return [] if ending <= start\r\n\r\n range(start, ending-1) << ending -1\r\nend",
"def reverse_range(min, max)\n\trange = []\n \n\ti = max - 1\n\twhile i > min\n\t\trange << i\n\t\ti -= 1\n end\n \n\treturn range\nend",
"def generate_range(min, max, step)\n array = []\n\n while min <= max\n\n array << min\n min += step\n end\n puts array\nend",
"def range(arr)\r\n # your code goes here\r\n\r\n arr.max - arr.min\r\nend",
"def range(start,final)\n return [] if start >= final\n return [final - 1] if start == final - 1\n\n arr = []\n result = range(start,final-1)\n arr.concat(result)\n arr.push ( final - start )\n arr\nend",
"def range(start, stop)\n return [] if stop < start\n return [stop] if start == stop\n\n [start] + range(start+1, stop)\nend",
"def range(start, ending)\n return [] if start >= ending - 1\n # retu_arr = []\n # retu_arr << start + 1\n # retu_arr.concat(range(start+1, ending))\n array = range(start+1, ending)\n array.unshift(start+1)\nend",
"def reverse_range(min, max)\n\ti = max-1\n \tarr = []\n while i > min\n\t\tarr << i\n \ti -= 1\n end\n \treturn arr\nend",
"def range(range_start, range_end)\n return [] if range_end < range_start\n return [range_end] if range_end == range_start\n result = [range_end]\n range(range_start, range_end - 1) + result\nend",
"def range(start, last)\n return [] if last < start\n range(start, last - 1) << last - 1\nend",
"def reverse_range(min, max)\n nums = []\n \n i = max - 1\n while i > min\n nums << i\n \n i -= 1\n end\n \n return nums\n end",
"def range(start, finish)\n return [] if start >= finish\n [start + 1] + range(start + 1, finish)\nend",
"def reverse_range(min, max)\n reverse_arr = []\n\n i = max -1\n while i > min\n reverse_arr << i\n i -= 1\n end\n return reverse_arr\nend",
"def odd_range(min, max)\n\trange = []\n \n\ti = min\n\twhile i <= max\n\t\tif i % 2 != 0\n\t\t\trange << i\n\t\tend\n \ti += 1\n end\n\n\treturn range\nend",
"def odd_range(min, max)\n\trange = []\n \ti = min \n \t\n \twhile i <= max\n if i % 2 != 0\n range << i\n end\n \n i += 1 \n end\n\treturn range\nend",
"def reverse_range(min, max)\n newArr = []\n i = max - 1\n while i >= min +1\n newArr << i\n i -= 1\n end\n return newArr\n end",
"def range(start, endI)\n arr = []\n if start > endI\n return []\n end\n\n if start <= endI - 1\n arr << start\n p arr\n end\n range(start + 1, endI)\n \nend",
"def reverse_range(min, max)\n\ti = max\n \tarry = []\n \twhile i > min + 1\n i -=1\n arry << i\n end\n return arry\n\nend",
"def odd_range(min, max)\n newArr = []\n\n while min <= max\n newArr << min if min % 2 == 1\n min += 1\n end\n return newArr\nend",
"def r(range)\n range.to_a\nend",
"def range(start, finish)\n #base case\n return nil if finish <= start\n return [start] if finish == start + 1 #return [0] for [0,1]\n #inductive step\n range(start, finish - 1) + [finish - 1]\nend",
"def range(start, finish)\n return [] if finish < start\n return [start] if finish - 1 == start\n range(start, finish - 1) + [finish - 1]\nend",
"def range(start,finish)\n if start == finish\n return [start]\n end\n\n prev_arr = range(start+1, finish)\n prev_arr << start\n return prev_arr\nend",
"def odd_range(min, max)\n\tarr = []\n \tfor i in min..max\n if i % 2 != 0 \n arr << i\n end\n end\n return arr\n \nend",
"def range(data)\n return (minimum(data)..maximum(data))\n end",
"def reverse_range(min, max)\n nums = []\n i = max\n while i > min\n if\n i == max\n i -= 1\n next\n end\n nums << i\n i -= 1\n end\n return nums\n end",
"def range(num1, num2)\n return [] if num2 <= num1\n range(num1, num2-1) + [num2 - 1] \nend",
"def odd_range(min, max)\n newArr = []\n i = min\n while i <= max\n if i % 2 != 0\n newArr << i\n end\n i += 1\n end\n return newArr\n end",
"def odd_range(min, max)\n\tarry = []\n \ti = min\n while i <= max\n if i % 2 == 0\n else\n arry << i\n end\n i += 1\n end\n return arry\nend",
"def get_sequence(low, high)\n (low..high).to_a\nend",
"def range(input); end",
"def odd_range(min, max)\n new_array = []\n i = min\n\n while i <= max\n if i % 2 != 0\n new_array << i\n end\n i += 1\n end\n\n return new_array\nend",
"def reverse_range(min, max)\n reverse_numbers = []\n \n i = max - 1\n while i > min\n reverse_numbers << i\n \n i -= 1\n end\n \n return reverse_numbers\nend",
"def odd_range(min, max)\n new_arr = []\n i = min\n while i <= max\n if i % 2 != 0\n new_arr << i\n end\n i += 1\n end\n return new_arr\nend",
"def odd_range(min, max)\n odd_array = []\n\n i = min\n while i <= max\n if !(i % 2 == 0)\n odd_array << i\n end\n i += 1\n end\n return odd_array\nend",
"def range_rc(start_num, end_num)\n\n return [] if end_num <= start_num\n range_rc(start_num, end_num - 1) + [end_num - 1]\nend",
"def range_numerals\n [ range(:numerals) ]\n end",
"def size_range(range)\n return [1,1] if range.nil?\n from = range.from\n to = range.to\n x = from.nil? ? 1 : from\n y = to.nil? ? TheInfinity : to\n [x, y]\n end",
"def reverse_range(min, max)\n reversed = [] \n \n index = max - 1 \n \n while index > min \n reversed << index \n index -= 1\n end \n \n return reversed \n \nend",
"def recursive_range(start_num, end_num)\n return [] if start_num >= end_num\n recursive_range(start_num, end_num-1) << end_num - 1\nend",
"def odd_range(min, max) # Define method with 2 params\n \n i = min # since we are being to ask to start with first param we set i to start at min; the first param\n new_array = [] # Create an empty array to shovel values into\n \n while i <= max # Sets condition\n \n if i % 2 != 0 # If statement that uses an expression to determine if number is NOT an even number, odd numbers will always equal 1, but you can also put not equal to 0. Logical expression\n new_array << i # Shovel not even number value screened by above condition into array\n end # End of if loop\n \n i += 1 # Increments each iteration by one\n end # End of method\n return new_array # Returns array values after end of method\n\nend",
"def max_range(array)\n \nend",
"def range( range )\n ::Vector.elements( range.to_a )\n end",
"def range(small_num, big_num)\n range = [' ']\n i = small_num\n while i <= big_num\n range << i\n i += 1\n end\n return range\nend",
"def range(start,last) # recursive Version\n return [] if start >= last\n [start] + range(start+1,last)\nend",
"def range(limits)\r\n\tnumbers = []\r\n\tfor number in (0..limits)\r\n\t\tputs \"At the top numbers are : #{number}\"\r\n\t\tnumbers.push(number)\r\n\tend\r\n\r\n\tputs \"The numbers: \"\r\n\tfor number in numbers\r\n\t\tputs number\r\n\tend\r\nend",
"def range(start, finish, step)\n return [] if start >= finish\n\n Enumerator.new do |y|\n y << start\n while (start += step) < finish\n y << start\n end\n end\n end",
"def make_array(startArrayValue, endArrayValue)\n\tresultArray = []\n\tfor i in startArrayValue..endArrayValue\n\t\tresultArray.push(i)\n\tend\n\treturn resultArray\nend",
"def reverse_range(min, max)\n new_arr = []\n\n i = max-1\n while i >= min+1 # i > min\n # reverse\n # exclude\n new_arr << i\n i -= 1\n end\n\n return new_arr\n\nend",
"def range\n min, max = span\n min..max\n end",
"def range\n @from..@to\n end",
"def odd_range(min, max)\n odds = []\n i = min\n while i <= max\n if i % 2 == 1\n odds << i\n end\n i += 1\n end\n return odds\n end",
"def restrict(value, range)\n [[value, range.first].max, range.last].min\n end",
"def range\n [@from, @to]\n end",
"def prime_range(min, max)\n\nend",
"def min_max(nums)\n\treturn [nums.min, nums.max,]\nend",
"def max_range(array)\r\n\r\n array.max - array.min # max and min methods used\r\nend",
"def range; end",
"def range; end",
"def range; end"
] |
[
"0.89293134",
"0.8709388",
"0.8692145",
"0.8656729",
"0.8631398",
"0.85065615",
"0.845822",
"0.8451943",
"0.842452",
"0.83919835",
"0.83897895",
"0.838254",
"0.8374754",
"0.8298095",
"0.8233475",
"0.82334495",
"0.82193536",
"0.813814",
"0.80861455",
"0.8065947",
"0.8041493",
"0.79543173",
"0.7937083",
"0.7937083",
"0.7934777",
"0.7904471",
"0.7870845",
"0.78628796",
"0.7842582",
"0.77929944",
"0.7780537",
"0.7732309",
"0.77078676",
"0.7702775",
"0.7701804",
"0.7688696",
"0.7673593",
"0.7637716",
"0.7637716",
"0.75753635",
"0.75642025",
"0.7563544",
"0.7563133",
"0.75481653",
"0.75473815",
"0.753317",
"0.75195664",
"0.7499842",
"0.7491115",
"0.7489684",
"0.7445519",
"0.74222183",
"0.73904103",
"0.73460835",
"0.73333263",
"0.7322387",
"0.7288219",
"0.7285402",
"0.7284534",
"0.72783655",
"0.727074",
"0.72659713",
"0.7247594",
"0.7247352",
"0.72284925",
"0.7221449",
"0.7199079",
"0.71899086",
"0.71894413",
"0.7176556",
"0.71679366",
"0.71649164",
"0.71537054",
"0.713698",
"0.71363753",
"0.7128341",
"0.7069288",
"0.7055836",
"0.70546085",
"0.70329463",
"0.7013248",
"0.70043784",
"0.7001211",
"0.69900525",
"0.69200444",
"0.6913563",
"0.6891293",
"0.68721664",
"0.68616265",
"0.685552",
"0.68553895",
"0.6831102",
"0.68286204",
"0.6827367",
"0.6788554",
"0.6782352",
"0.6773231",
"0.67686206",
"0.67686206",
"0.67686206"
] |
0.81280476
|
18
|
=> [13, 14, 15, 16, 17, 18, 19, 20] ODD RANGE CHALLENGE Write a method odd_range(min, max) that takes in two numbers min and max. The method should return an array containing all odd numbers from min to max (inclusive).
|
def odd_range(min, max) # Define method with 2 params
i = min # since we are being to ask to start with first param we set i to start at min; the first param
new_array = [] # Create an empty array to shovel values into
while i <= max # Sets condition
if i % 2 != 0 # If statement that uses an expression to determine if number is NOT an even number, odd numbers will always equal 1, but you can also put not equal to 0. Logical expression
new_array << i # Shovel not even number value screened by above condition into array
end # End of if loop
i += 1 # Increments each iteration by one
end # End of method
return new_array # Returns array values after end of method
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def odd_range(min, max)\n\trange = []\n \n\ti = min\n\twhile i <= max\n\t\tif i % 2 != 0\n\t\t\trange << i\n\t\tend\n \ti += 1\n end\n\n\treturn range\nend",
"def odd_range(min, max)\n\tarr = []\n \tfor i in min..max\n if i % 2 != 0 \n arr << i\n end\n end\n return arr\n \nend",
"def odd_range(min, max)\n odds = []\n i = min\n while i <= max\n if i % 2 == 1\n odds << i\n end\n i += 1\n end\n return odds\n end",
"def odd_range(min, max)\n\trange = []\n \ti = min \n \t\n \twhile i <= max\n if i % 2 != 0\n range << i\n end\n \n i += 1 \n end\n\treturn range\nend",
"def odd_range(min, max)\n odd_array = []\n\n i = min\n while i <= max\n if !(i % 2 == 0)\n odd_array << i\n end\n i += 1\n end\n return odd_array\nend",
"def odd_range(min, max)\n odds = []\n index = min \n \n while index <= max\n if index % 2 == 1 \n odds << index \n end \n index += 1 \n end \n \n return odds \n \nend",
"def odd_range(min, max)\n\tarry = []\n \ti = min\n while i <= max\n if i % 2 == 0\n else\n arry << i\n end\n i += 1\n end\n return arry\nend",
"def odd_range(min, max)\n newArr = []\n i = min\n while i <= max\n if i % 2 != 0\n newArr << i\n end\n i += 1\n end\n return newArr\n end",
"def odd_range(min, max)\n new_arr = []\n i = min\n while i <= max\n if i % 2 != 0\n new_arr << i\n end\n i += 1\n end\n return new_arr\nend",
"def odd_range(min, max)\n new_array = []\n i = min\n\n while i <= max\n if i % 2 != 0\n new_array << i\n end\n i += 1\n end\n\n return new_array\nend",
"def odd_range(min, max)\n odd_numbers = []\n \n i = min\n while i <= max\n if i % 2 == 1\n odd_numbers << i\n end\n \n i += 1\n end\n \n return odd_numbers\nend",
"def odd_range(min, max)\n newArr = []\n\n while min <= max\n newArr << min if min % 2 == 1\n min += 1\n end\n return newArr\nend",
"def odd_range(min, max)\n (min..max).select{|num| !(num.even?) }\nend",
"def range(min, max)\n range_array = []\n\n i = min\n while i <= max\n range_array << i\n i += 1\n end\n return range_array\nend",
"def range(min, max)\n \tarr = []\n\tfor i in min..max\n arr << i\n end\n return arr\nend",
"def range(min, max)\n\trange = []\n\n\ti = min\n\twhile i <= max\n\t\trange << i\n\t\ti += 1\n end\n \n\treturn range\nend",
"def range(start_num, end_num)\n # one line version\n # (start_num...end_num).to_a\n\n # version 2\n exclusive_range = []\n (start_num...end_num).each do |num|\n exclusive_range << num\n end\n exclusive_range\nend",
"def range(min, max)\n newArray = []\n i = min\n while i <= max\n newArray << i\n \ti += 1 \n end\n return newArray\n\nend",
"def odd_numbers(num1, num2)\n (num1..num2).select { |n| n.odd? }\nend",
"def oddNumbers(l, r)\nfirst_num = l.even? ? (l + 1) : l\n(first_num..r).step(2).to_a\nend",
"def range(min, max)\n nums = []\n \n i = min\n while i <= max\n nums << i\n \n i += 1\n end\n \n return nums\n end",
"def range(min, max)\n new_arr = []\n i = min\n while i <= max\n new_arr << i\n i += 1\n end\n return new_arr\n end",
"def range(min, max)\n newArr = []\n i = min\n while i <= max\n newArr << i\n i +=1\n end\n return newArr\n end",
"def range(min, max)\n arr = []\n\n while min <= max\n arr << min\n min += 1\n end\n return arr\nend",
"def range(min, max)\n\ti = min\n \tarry = []\n while i <= max\n arry << i\n i += 1\n end\n return arry\n\nend",
"def odd_integers(array)\nend",
"def range(min, max)\n nums = []\n \n i = min\n while i <= max\n nums << i\n \n i += 1\n end\n \n return nums\nend",
"def range(min, max)\n new_arr = []\n\n i = min\n while i <= max\n new_arr << i\n i = i + 1 \n end\n\n return new_arr\nend",
"def only_evens range\n range.select do |value|\n value.even?\n end\nend",
"def only_evens range\n range.select do |value|\n value.even?\n end\nend",
"def print_odd\n range = (1..99).to_a\n range.each do |num|\n if num % 2 == 0\n puts num\n end\n end\nend",
"def odd_numbers(array)\n end",
"def prime_range(min, max)\n\nend",
"def range(min, max)\n \n i = min\n new_array = [] # The reason this is here and not in while loop is because we would be setting it to an empty array at the beginning of every instance and it would return the last iteration value of i.\n \n while i <= max\n \n new_array << i # Shovels each iteration of i in to array\n i += 1 # Goes up by one\n end\n return new_array # Self explanatory\n\nend",
"def range(min, max) # takes some smaller num and then a larger num\n range_arr = [] # initialize new array\n i = min # indice counter @ whatever the first number passed in is\n\n firstnum = min # store val of first num\n lastnum = max # store val of last num\n \n while i <= max\n range_arr << i\n i += 1\n end\n return range_arr\nend",
"def range(min, max)\n nums = []\n\n i = min\n while i <= max\n nums << i\n\n i += 1\n end\n\n return nums\nend",
"def range(arr)\n\nend",
"def range(min, max)\n # # return [] if end < start\n # if its the last one, 1, using start and end\n\n return [] if max <= min\n\n range(min, max - 1) << max - 1\n # ^ treat it like it is the same data type as base case, so treat it like an array, <<, .map\n\n # [min] + range(min + 1, max - 1)\n # ^ num ^ same data type our base case\nend",
"def even_numbers_less_than num\n even_array = []\n for number in 0...num\n if number % 2 == 0\n even_array.push(number)\n end\n end\n return even_array\nend",
"def even_numbers_less_than num\n array_for_even_numbers = []\n for i in 0...num\n if i % 2 == 0\n array_for_even_numbers.push(i)\n end\n end\n return array_for_even_numbers\n\nend",
"def range1(min, max)\n # Base Case / Inductive Step\n return [] if max <= min\n\n range1(min, max - 1) << max - 1\nend",
"def range(min, max)\n all_numbers = []\n \n i = min\n while i <= max\n all_numbers << i\n \n i += 1\n end\n \n return all_numbers\nend",
"def even_numbers_less_than num\n array = []\n for i in 0...num\n if i % 2 == 0\n array.push(i)\n end\n end\n array\nend",
"def range(start_num, end_num)\n range_array = []\n range_array << start_num\n\n if(start_num < end_num)\n range_array += range(start_num + 1, end_num)\n end\n\n range_array\nend",
"def oddities(array)\n new_array = []\n index_range = (1..array.size-1)\n for n in index_range do \n new_array << array[n] if n.odd?\n end\n new_array\nend",
"def range(start_num, end_num)\n return [] if end_num =< start_num\n range(start_num, end_num - 1) << end_num - 1\nend",
"def even_nums(max)\n print (0..max).step(2).to_a\nend",
"def range(start_val, end_val)\n return [] if start_val + 1 == end_val\n nums = [start_val + 1]\n nums + range(start_val + 1, end_val)\nend",
"def range(num1, num2)\n return [] if num2 <= num1\n range(num1, num2-1) + [num2 - 1] \nend",
"def range(min, max)\n return [] if max < min\n range(min, max - 1) << max\nend",
"def range(start, stop)\n return [] if stop < start\n return [stop] if start == stop\n\n [start] + range(start+1, stop)\nend",
"def range(min, max)\n\tprint (min..max).to_a\nend",
"def even_nums(max)\n result = []\n\tfor i in 0..max\n \tif i % 2 == 0 \n result << i\n end\n end\n return result\nend",
"def odd_nums_r (bound=99, n=3)\n if n <= bound\n puts n\n odd_nums_r(bound, n + 1)\n end\nend",
"def range(min, max)\n minMax = []\n i = min\n while i <= max\n minMax << i\n i += 1\n end\n return minMax\n end",
"def goldbach_list(range)\n range.select { |n| n % 2 == 0 }. map { |n| goldbach(n) }\nend",
"def range(range_start, range_end)\n return [] if range_end < range_start\n return [range_end] if range_end == range_start\n result = [range_end]\n range(range_start, range_end - 1) + result\nend",
"def even_numbers_less_than num\n\t# array_of_nums = []\n\t# i = 0\n\t# while i < num\n\t# \tarray_of_nums.push(i)\n\t# \t# array_of_nums.delete_if &:odd?\n\t# \ti += 2\n\t# end\n\t# array_of_nums\n\t(0...num).select { |numbers| numbers.even? }\nend",
"def range(start, ending)\n return [] if start >= ending - 1\n retu_arr = range(start, ending - 1)\n retu_arr << ending - 1\nend",
"def range(min, max)\n return [] if max <= min\n range(min, max - 1) << max - 1\n\n end",
"def range(start, ending)\n return [] if start >= ending\n\n return [start] + range(start + 1, ending)\nend",
"def rec_range(min, max)\n return [] if max == min\n [min] + rec_range(min+1, max)\nend",
"def even_numbers_less_than num\n # i = 0\n # even_numbers = []\n # while i < num\n # even_numbers.push i\n # i += 2\n # end\n # return even_numbers\n\n array = []\n (0...num).each do |i|\n if i%2 == 0\n array.push i\n end\n end\n return array\nend",
"def odd_indexed_integers(array)\n\nend",
"def range(start,ending)\r\n return [] if ending <= start\r\n\r\n range(start, ending-1) << ending -1\r\nend",
"def even_numbers_less_than num\n # set up empty array to place all even numbers\n array = []\n for i in 0...num\n # if even add that value to the array\n if(i % 2 == 0)\n array.push(i)\n end\n end\n return array\nend",
"def generate_range(min, max, step)\n array = []\n\n while min <= max\n\n array << min\n min += step\n end\n puts array\nend",
"def odd_num\n y = []\n [*1..255].map do |i| \n if i % 2 != 0\n y << i\n end\n end\n y\nend",
"def even_numbers_less_than(num)\n array = (0...num).to_a\n array.select { |x| x if x.even? }\nend",
"def create_range(num)\n (1..num).to_a\nend",
"def range(min, max)\n return max if max < min\n range(min, max) << max\nend",
"def rand_in_range(from, to); end",
"def even_nums(max)\n i = 0\n evens = []\n while i <= max\n\tif i % 2 == 0\n evens << i\n end\n i += 1\n end\n return evens\nend",
"def get_squares(first_number, last_number)\n n = (first_number..last_number).to_a\n squares = []\n n.each do |i|\n if i % 2 == 0\n squares << i\n end\n end\n return squares\nend",
"def range(arr)\n max = arr.max\n min = arr.min\n\n max - min\nend",
"def range(min, max)\n #new_arr = []\n\n i = min\n while i <= max\n new_arr = [] # initialized\n new_arr << i\n i = i + 1 \n end\n\n return new_arr\nend",
"def range(start, ending_value)\n return [] if start > ending_value\n result = [start] + range(start + 1, ending_value)\nend",
"def even_numbers_less_than num\n even_numbers_array = []\n i=0\nwhile i<num do\n even_numbers_array.push(i)\n i+=2\nend\n return even_numbers_array\nend",
"def OverlappingRanges(arr)\n\n # code goes here\n return arr \n \nend",
"def reverse_range(min, max)\n new_arr = []\n\n i = max-1\n while i >= min+1 # i > min\n # reverse\n # exclude\n new_arr << i\n i -= 1\n end\n\n return new_arr\n\nend",
"def range(arr)\n arr.max - arr.min\nend",
"def range(arr)\n arr.max - arr.min\nend",
"def even_nums(max)\n evens = []\n \n i = 0\n while i <= max\n if i % 2 == 0\n evens << i\n end\n \n i += 1\n end\n \n return evens\nend",
"def range(start, finish)\n #base case\n return nil if finish <= start\n return [start] if finish == start + 1 #return [0] for [0,1]\n #inductive step\n range(start, finish - 1) + [finish - 1]\nend",
"def range(arr)\n # your code goes here\n arr.max - arr.min\nend",
"def range(arr)\n # your code goes here\n arr.max - arr.min\nend",
"def odd_array(numbers)\n odd_value = []\n \n numbers.each_with_index do |value, idx|\n odd_value << value if idx.even?\n end\n odd_value\nend",
"def oddNum arr\r\n puts (1..255).select {|i| i%2 != 0}\r\nend",
"def reverse_range(min, max)\n nums = []\n i = max\n while i > min\n if\n i == max\n i -= 1\n next\n end\n nums << i\n i -= 1\n end\n return nums\n end",
"def even_numbers_less_than num\n\t(0...num).select do |number|\n\t\tnumber.even?\n\tend\nend",
"def divisible_by_5_and_3\n numbers = (1..100).to_a # this will create an array from 1 to 100. Check the Range class from Ruby - https://ruby-doc.org/core-2.5.1/Range.html\nend",
"def get_sequence(low, high)\n (low..high).to_a\nend",
"def prime_range(lower_bound, higher_bound)\n Prime.each(higher_bound).select {|prime| prime >= lower_bound}\nend",
"def range(start, ending)\n return [] if start >= ending - 1\n # retu_arr = []\n # retu_arr << start + 1\n # retu_arr.concat(range(start+1, ending))\n array = range(start+1, ending)\n array.unshift(start+1)\nend",
"def oddNum arr\n puts (1..255).select {|i| i%2 != 0}\nend",
"def normalize_range(range)\n ar = range.to_a\n if ar.min > 2 # normalizacja zadanego zakresu aby zawsze zakres zaczynał się od 2\n ar += (2..ar.min-1).to_a\n ar = ar.sort\n else\n ar.delete_if { |e| e < 2 }\n end\n ar\nend",
"def get_squares(range)\n\tresult= []\n\ti= 1\n\twhile( i*i < range.end)\n\t\tresult << i*i\n\t\ti+= 1\n\tend\n\treturn result\nend",
"def range(small_num, big_num)\n range = [' ']\n i = small_num\n while i <= big_num\n range << i\n i += 1\n end\n return range\nend",
"def even_nums(max)\n\tnums = []\n \n\ti = 0\n\twhile i <= max\n\t\tif i % 2 == 0\n\t\t\tnums << i\n\t\tend\n\t\ti += 1\n end\n \n\treturn nums\nend",
"def range(arr)\r\n # your code goes here\r\n\r\n arr.max - arr.min\r\nend"
] |
[
"0.89546275",
"0.8939354",
"0.89030206",
"0.8902239",
"0.8878985",
"0.88209575",
"0.88187855",
"0.88109636",
"0.8752287",
"0.87434334",
"0.87421113",
"0.86884135",
"0.86154836",
"0.70886725",
"0.7036854",
"0.70299983",
"0.69627863",
"0.6946262",
"0.6942438",
"0.6935137",
"0.6934499",
"0.69324595",
"0.69303477",
"0.6927308",
"0.690252",
"0.6891662",
"0.6882676",
"0.6870946",
"0.6869028",
"0.68689495",
"0.6841327",
"0.677848",
"0.6753668",
"0.6753653",
"0.6750662",
"0.67311335",
"0.66968775",
"0.6674624",
"0.6659575",
"0.66524297",
"0.6602083",
"0.6600049",
"0.65687656",
"0.65572447",
"0.6555547",
"0.6555503",
"0.6551295",
"0.65504414",
"0.6538483",
"0.6535626",
"0.6525156",
"0.65134424",
"0.64894116",
"0.64774233",
"0.64720994",
"0.64623964",
"0.6438476",
"0.64360726",
"0.642926",
"0.64261675",
"0.64043516",
"0.63936216",
"0.63926065",
"0.6386025",
"0.63724035",
"0.6366565",
"0.6352865",
"0.63489574",
"0.63441014",
"0.63339174",
"0.6330991",
"0.632439",
"0.6310934",
"0.6295008",
"0.62917584",
"0.62869614",
"0.62822026",
"0.628075",
"0.6262729",
"0.6262206",
"0.6257885",
"0.6257885",
"0.62512094",
"0.6234885",
"0.6227073",
"0.6227073",
"0.62211055",
"0.621586",
"0.6215466",
"0.6214689",
"0.6209243",
"0.62082195",
"0.62061906",
"0.6200221",
"0.6199271",
"0.6194093",
"0.61847776",
"0.6180343",
"0.6177905",
"0.6173707"
] |
0.87216485
|
11
|
=> [3, 5, 7] REVERSE RANGE CHALLENGE Write a method reverse_range(min, max) that takes in two numbers min and max. The function should return an array containing all numbers from min to max in reverse order. The min and max should be excluded from the array
|
def reverse_range(min, max) # Define method
i = max - 1 # Because we are trying to reverse the order of array we have to start with the max value; minus one because it does not include min or max
new_array = [] # Create an empty array to shovel values into
while i > min # We have to start from the max value which will be in i, minus one of course, so for the loop to run i has to always be greater than min which will be the last iteration
new_array << i # Shovels the value of i into new array
i -= 1 # When we want to go up in numbers we use plus equals, since we are going down in numbers we use -=
end
return new_array # REturns new array values after the end of while loop
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def reverse_range(min, max)\n reversed = [] \n \n index = max - 1 \n \n while index > min \n reversed << index \n index -= 1\n end \n \n return reversed \n \nend",
"def reverse_range(min, max)\n newArr = []\n i = max - 1\n while i >= min +1\n newArr << i\n i -= 1\n end\n return newArr\n end",
"def reverse_range(min, max)\n reverse_arr = []\n\n i = max -1\n while i > min\n reverse_arr << i\n i -= 1\n end\n return reverse_arr\nend",
"def reverse_range(min, max)\n\trange = []\n \n\ti = max - 1\n\twhile i > min\n\t\trange << i\n\t\ti -= 1\n end\n \n\treturn range\nend",
"def reverse_range(min, max)\n new_arr = []\n\n i = max-1\n while i >= min+1 # i > min\n # reverse\n # exclude\n new_arr << i\n i -= 1\n end\n\n return new_arr\n\nend",
"def reverse_range(min, max)\n\ti = max-1\n \tarr = []\n while i > min\n\t\tarr << i\n \ti -= 1\n end\n \treturn arr\nend",
"def reverse_range(min, max)\n nums = []\n \n i = max - 1\n while i > min\n nums << i\n \n i -= 1\n end\n \n return nums\n end",
"def reverse_range(min, max)\n reverse_numbers = []\n \n i = max - 1\n while i > min\n reverse_numbers << i\n \n i -= 1\n end\n \n return reverse_numbers\nend",
"def reverse_range(min, max)\n\ti = max\n \tarry = []\n \twhile i > min + 1\n i -=1\n arry << i\n end\n return arry\n\nend",
"def reverse_range(min, max)\n nums = []\n i = max\n while i > min\n if\n i == max\n i -= 1\n next\n end\n nums << i\n i -= 1\n end\n return nums\n end",
"def reverse_range(min, max)\n # Write your code here\nend",
"def range(arr)\n arr.max - arr.min\nend",
"def range(arr)\n arr.max - arr.min\nend",
"def range(arr)\narr.max - arr.min\nend",
"def range(min, max)\n # # return [] if end < start\n # if its the last one, 1, using start and end\n\n return [] if max <= min\n\n range(min, max - 1) << max - 1\n # ^ treat it like it is the same data type as base case, so treat it like an array, <<, .map\n\n # [min] + range(min + 1, max - 1)\n # ^ num ^ same data type our base case\nend",
"def range(min, max)\n return [] if max <= min\n range(min, max - 1) << max - 1\n\n end",
"def range(arr)\n max = arr.max\n min = arr.min\n\n max - min\nend",
"def range(arr)\n # your code goes here\n arr.max - arr.min\nend",
"def range(arr)\n # your code goes here\n arr.max - arr.min\nend",
"def range(min, max)\n return [] if max < min\n range(min, max - 1) << max\nend",
"def rec_range(min, max)\n return [] if max == min\n [min] + rec_range(min+1, max)\nend",
"def range(arr)\r\n # your code goes here\r\n\r\n arr.max - arr.min\r\nend",
"def to_range\n min .. max\n end",
"def range(min, max)\n newArr = []\n i = min\n while i <= max\n newArr << i\n i +=1\n end\n return newArr\n end",
"def range(arr)\n arr.sort[-1] - arr.sort[0]\nend",
"def range(min, max)\n\trange = []\n\n\ti = min\n\twhile i <= max\n\t\trange << i\n\t\ti += 1\n end\n \n\treturn range\nend",
"def range(min, max)\n range_array = []\n\n i = min\n while i <= max\n range_array << i\n i += 1\n end\n return range_array\nend",
"def range(min, max)\n new_arr = []\n i = min\n while i <= max\n new_arr << i\n i += 1\n end\n return new_arr\n end",
"def range1(min, max)\n # Base Case / Inductive Step\n return [] if max <= min\n\n range1(min, max - 1) << max - 1\nend",
"def range(arr)\n arr = arr.sort \n return arr[arr.length-1] - arr[0]\nend",
"def range(start_num, end_num)\n return [] if end_num =< start_num\n range(start_num, end_num - 1) << end_num - 1\nend",
"def range(arr)\n # your code goes here\n arr = arr.sort\n arr.last - arr.first\nend",
"def range(min, max)\n minMax = []\n i = min\n while i <= max\n minMax << i\n i += 1\n end\n return minMax\n end",
"def range(min, max)\n \tarr = []\n\tfor i in min..max\n arr << i\n end\n return arr\nend",
"def range(start,ending)\r\n return [] if ending <= start\r\n\r\n range(start, ending-1) << ending -1\r\nend",
"def range(min, max)\n new_arr = []\n\n i = min\n while i <= max\n new_arr << i\n i = i + 1 \n end\n\n return new_arr\nend",
"def range(min, max)\n newArray = []\n i = min\n while i <= max\n newArray << i\n \ti += 1 \n end\n return newArray\n\nend",
"def range(min, max) # takes some smaller num and then a larger num\n range_arr = [] # initialize new array\n i = min # indice counter @ whatever the first number passed in is\n\n firstnum = min # store val of first num\n lastnum = max # store val of last num\n \n while i <= max\n range_arr << i\n i += 1\n end\n return range_arr\nend",
"def normalize_range(range)\n ar = range.to_a\n if ar.min > 2 # normalizacja zadanego zakresu aby zawsze zakres zaczynał się od 2\n ar += (2..ar.min-1).to_a\n ar = ar.sort\n else\n ar.delete_if { |e| e < 2 }\n end\n ar\nend",
"def get_range_by_reverse_rank(from, to, options = {})\n connection.zrange(key_label, from, to, options)\n end",
"def range(start, ending)\n return [] if start >= ending - 1\n retu_arr = range(start, ending - 1)\n retu_arr << ending - 1\nend",
"def range_rc(start_num, end_num)\n\n return [] if end_num <= start_num\n range_rc(start_num, end_num - 1) + [end_num - 1]\nend",
"def range(start, last)\n return [] if last < start\n range(start, last - 1) << last - 1\nend",
"def range(min, max)\n \n i = min\n new_array = [] # The reason this is here and not in while loop is because we would be setting it to an empty array at the beginning of every instance and it would return the last iteration value of i.\n \n while i <= max\n \n new_array << i # Shovels each iteration of i in to array\n i += 1 # Goes up by one\n end\n return new_array # Self explanatory\n\nend",
"def recursive_range(start_num, end_num)\n return [] if start_num >= end_num\n recursive_range(start_num, end_num-1) << end_num - 1\nend",
"def range(min, max)\n nums = []\n \n i = min\n while i <= max\n nums << i\n \n i += 1\n end\n \n return nums\n end",
"def range(min, max)\n\ti = min\n \tarry = []\n while i <= max\n arry << i\n i += 1\n end\n return arry\n\nend",
"def range(min, max)\n arr = []\n\n while min <= max\n arr << min\n min += 1\n end\n return arr\nend",
"def range(min, max)\n return max if max < min\n range(min, max) << max\nend",
"def range(min, max)\n nums = []\n \n i = min\n while i <= max\n nums << i\n \n i += 1\n end\n \n return nums\nend",
"def range(arr)\n\nend",
"def range(start,final)\n return [] if start >= final\n return [final - 1] if start == final - 1\n\n arr = []\n result = range(start,final-1)\n arr.concat(result)\n arr.push ( final - start )\n arr\nend",
"def range(start, finish)\n return [] if finish < start\n return [start] if finish - 1 == start\n range(start, finish - 1) + [finish - 1]\nend",
"def range(start,finish)\n if start == finish\n return [start]\n end\n\n prev_arr = range(start+1, finish)\n prev_arr << start\n return prev_arr\nend",
"def range(arr)\n # your code goes here\n sorted_arr = arr.sort\n sorted_arr.last - sorted_arr.first\nend",
"def range(range_start, range_end)\n return [] if range_end < range_start\n return [range_end] if range_end == range_start\n result = [range_end]\n range(range_start, range_end - 1) + result\nend",
"def loopy_range(max, step)\n numbers =[]\n for nums in (0..max)\n numbers.push(nums)\n end\n puts \"The end array is #{numbers}\"\nend",
"def range(start, ending)\n return [] if start >= ending\n\n return [start] + range(start + 1, ending)\nend",
"def range(min, max)\n nums = []\n\n i = min\n while i <= max\n nums << i\n\n i += 1\n end\n\n return nums\nend",
"def range(start, stop)\n return [] if stop < start\n return [stop] if start == stop\n\n [start] + range(start+1, stop)\nend",
"def range(min, max)\n\tprint (min..max).to_a\nend",
"def range(start, ending)\n return [] if start >= ending - 1\n # retu_arr = []\n # retu_arr << start + 1\n # retu_arr.concat(range(start+1, ending))\n array = range(start+1, ending)\n array.unshift(start+1)\nend",
"def range(min, max)\n all_numbers = []\n \n i = min\n while i <= max\n all_numbers << i\n \n i += 1\n end\n \n return all_numbers\nend",
"def range(start,last) # recursive Version\n return [] if start >= last\n [start] + range(start+1,last)\nend",
"def max_range(array)\r\n\r\n array.max - array.min # max and min methods used\r\nend",
"def get_range(from, to, options = {})\n if options.delete(:include_boundaries)\n connection.zrevrangebyscore(key_label, to, from, options)\n else\n connection.zrevrangebyscore(key_label, \"(#{to}\", \"(#{from}\", options)\n end\n end",
"def rec_range(start,last)\r\n return [] if last < start\r\n return [start] if start == last-1\r\n \r\n rec_range(start,last-1) << last-1\r\n\r\nend",
"def r(range)\n range.to_a\nend",
"def range(start, finish)\n #base case\n return nil if finish <= start\n return [start] if finish == start + 1 #return [0] for [0,1]\n #inductive step\n range(start, finish - 1) + [finish - 1]\nend",
"def range(start_num, end_num)\n # one line version\n # (start_num...end_num).to_a\n\n # version 2\n exclusive_range = []\n (start_num...end_num).each do |num|\n exclusive_range << num\n end\n exclusive_range\nend",
"def get_range_by_rank(from, to, options = {})\n connection.zrevrange(key_label, from, to, options)\n end",
"def range(start_num, end_num)\n range_array = []\n range_array << start_num\n\n if(start_num < end_num)\n range_array += range(start_num + 1, end_num)\n end\n\n range_array\nend",
"def get_sequence(low, high)\n (low..high).to_a\nend",
"def max_range(array)\n \nend",
"def reverse? a, min, max\n if a[0]==min||a[0]==max||a.size==1||(a.last != min && a.last != max)\n return false\n else#if a[a.size-1] != min && a[a.size-1] != max\n return true\n end\nend",
"def range(start, finish)\n return [] if start >= finish\n [start + 1] + range(start + 1, finish)\nend",
"def range(num1, num2)\n return [] if num2 <= num1\n range(num1, num2-1) + [num2 - 1] \nend",
"def range(start, ending_value)\n return [] if start > ending_value\n result = [start] + range(start + 1, ending_value)\nend",
"def zrevrange(key, start, stop, **options)\n node_for(key).zrevrange(key, start, stop, **options)\n end",
"def range(min, max)\n #new_arr = []\n\n i = min\n while i <= max\n new_arr = [] # initialized\n new_arr << i\n i = i + 1 \n end\n\n return new_arr\nend",
"def zrevrange(key, start, stop, **options); end",
"def odd_range(min, max)\n\trange = []\n \ti = min \n \t\n \twhile i <= max\n if i % 2 != 0\n range << i\n end\n \n i += 1 \n end\n\treturn range\nend",
"def reverse_number_to_start_from_right(array)\n array = array.reverse\n return array\n end",
"def zrevrange(key, start, stop, withscores: T.unsafe(nil), with_scores: T.unsafe(nil)); end",
"def generate_range(min, max, step)\n array = []\n\n while min <= max\n\n array << min\n min += step\n end\n puts array\nend",
"def odd_range(min, max)\n\trange = []\n \n\ti = min\n\twhile i <= max\n\t\tif i % 2 != 0\n\t\t\trange << i\n\t\tend\n \ti += 1\n end\n\n\treturn range\nend",
"def zrevrange(key, start, stop, options = {})\n args = [:zrevrange, key, start, stop]\n\n if options[:withscores]\n args << 'WITHSCORES'\n block = Redis::FloatifyPairs\n end\n\n call(key, args, transform: block, read: true)\n end",
"def range(start_val, end_val)\n return [] if start_val + 1 == end_val\n nums = [start_val + 1]\n nums + range(start_val + 1, end_val)\nend",
"def reverse_array(integers)\n integers.reverse \nend",
"def reverse_array(integers)\n integers.reverse\nend",
"def create_range(num)\n (1..num).to_a\nend",
"def range(start, endI)\n arr = []\n if start > endI\n return []\n end\n\n if start <= endI - 1\n arr << start\n p arr\n end\n range(start + 1, endI)\n \nend",
"def zrevrangebylex(key, max, min, limit: T.unsafe(nil)); end",
"def reverse(array)\n start = 0\n last = array.length - 1\n\n while start <= last do\n array[start], array[last] = array[last], array[start]\n start += 1\n last -= 1\n end\n\n return array\nend",
"def rslice(range, options = {})\n start, finish = range_pair(range)\n fetch_range :zrevrange, start, finish, options\n end",
"def odd_range(min, max)\n newArr = []\n i = min\n while i <= max\n if i % 2 != 0\n newArr << i\n end\n i += 1\n end\n return newArr\n end",
"def naive_range(arr, window)\n\tcurrent_max_range = nil\n\treturn arr if arr.length < window + 1\n\n # arr.each do |ele|\n # \twindowed_range = \n\n # end\n\n left = arr.take(window)\n\tright = arr.drop(window)\n\t# p left\n\t# p right\n left_range = left.max - left.min\n # debugger\n\tright_range = right.max - right.min\n\tif left_range > right_range\n\t\treturn left\n\telse\n\t\tnaive_range(right, window)\n\tend\n\nend",
"def zrevrangebylex(key, max, min, options = {})\n args = [:zrevrangebylex, key, min, max]\n\n limit = options[:limit]\n args.concat(['LIMIT'] + limit) if limit\n\n call(key, args, read: true)\n end",
"def reverse(arr)\n start_point = 0\n end_point = -1\n mid_point = arr.size / 2\n \n while start_point < mid_point\n arr[start_point], arr[end_point] = arr[end_point], arr[start_point]\n start_point += 1\n end_point -= 1\n end\n arr\nend",
"def shorten_range( range_list )\n int_range = range_list.map { |item| item.to_i }\n first_val = nil\n last_val = nil\n ret_list = []\n int_range.sort.each { |current_val|\n first_val = current_val if first_val == nil\n if last_val == nil\n # no values seen yet\n last_val = current_val\n elsif current_val == last_val + 1\n # next in sequence? ... if so then just iterate\n last_val = current_val\n else\n # not next, then close old sequence\n if first_val != last_val and last_val != nil\n ret_list.push( \"#{first_val}-#{last_val}\" )\n else\n ret_list.push( \"#{first_val}\" )\n end\n first_val = current_val\n last_val = current_val \n end\n }\n # Sequence not closed\n if first_val != nil\n if first_val != last_val and last_val != nil\n ret_list.push( \"#{first_val}-#{last_val}\" )\n else\n ret_list.push( \"#{first_val}\" )\n end\n end\n return ret_list.join(\", \")\n end"
] |
[
"0.89516217",
"0.8909612",
"0.8899485",
"0.8897072",
"0.87962884",
"0.8792103",
"0.8769101",
"0.87444884",
"0.8699591",
"0.8693999",
"0.85637313",
"0.7295437",
"0.7295437",
"0.7207642",
"0.71983993",
"0.7163555",
"0.711424",
"0.71120095",
"0.71120095",
"0.710353",
"0.70958763",
"0.705154",
"0.7035868",
"0.7024177",
"0.70014536",
"0.700055",
"0.6973519",
"0.69674194",
"0.69651127",
"0.69547135",
"0.695399",
"0.6923773",
"0.69071954",
"0.68966156",
"0.6895426",
"0.6887",
"0.68770486",
"0.6870035",
"0.68398577",
"0.68384135",
"0.68349105",
"0.68229777",
"0.68007463",
"0.679422",
"0.6792639",
"0.67842996",
"0.67650175",
"0.6762443",
"0.671301",
"0.6696993",
"0.6693906",
"0.6677587",
"0.66534036",
"0.6648808",
"0.6627829",
"0.6624761",
"0.6620914",
"0.65740955",
"0.6568562",
"0.6560232",
"0.65564364",
"0.65557194",
"0.65464836",
"0.65464246",
"0.6544117",
"0.6538011",
"0.6535916",
"0.64972687",
"0.64961284",
"0.6475532",
"0.6469236",
"0.6458065",
"0.6451171",
"0.6437856",
"0.6411031",
"0.6406758",
"0.63999826",
"0.63915527",
"0.63844883",
"0.6331351",
"0.6314196",
"0.6305298",
"0.6294247",
"0.6284738",
"0.6278126",
"0.62759995",
"0.62748367",
"0.6269397",
"0.62433714",
"0.6225021",
"0.6191754",
"0.61837196",
"0.61779886",
"0.6177129",
"0.61659884",
"0.61432415",
"0.6141829",
"0.6133876",
"0.61293226",
"0.611212"
] |
0.89373326
|
1
|
=> [6, 5, 4, 3, 2] FIRST HALF Write a method first_half(array) that takes in an array and returns a new array containing the first half of the elements in the array. If there is an odd number of elements, turn the first half including the middle element.
|
def first_half(array)
i = 0
new_array = []
while i < array.length / 2.0 # This is makes sure that the loop runs while i is less than half of the length; thus the divided by two expression. This will always include the middle element since the index value is still less than half the whole array length value.
new_array << array[i] # Array of i is important here or else it wont add the specific array value into the new array variable
i += 1
end
return new_array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def first_half(array)\n half = []\n i = 0\n max = array.length - (array.length / 2)\n while i < max\n half << array[i]\n i += 1\n end\n return half\n \n end",
"def first_half(array)\n\n new_arr = []\n even_arr = array.length / 2\n odd_arr = even_arr + 1\n \n i = 0\n \n if array.length % 2 == 0\n \t \n while i < even_arr\n \t \n \tnew_arr << array[i] \n i += 1\n \n end\n elsif array.length % 2 == 1\n \t\n\twhile i < odd_arr\n \t\n \tnew_arr << array[i]\n \ti += 1\n \n end\n \n end\n \n return new_arr\nend",
"def first_half(array)\n \ti = 0\n \tnewArray = []\n\twhile i < (array.length / 2.0)\n newArray << array[i]\n i += 1\n end\n \treturn newArray\nend",
"def first_half(array)\n\tnew_array = []\n \n\ti = 0\n\twhile i < (array.length / 2.0)\n\t\tnew_array << array[i]\n\t\ti += 1\n end\n \n\treturn new_array\nend",
"def first_half(array)\n i = 0\n newArr = []\n while i < array.length / 2.0\n newArr << array[i]\n i += 1\n end\n return newArr\n end",
"def first_half(array)\n new_array = []\n max = array.length / 2.0\n i = 0\n while i < max\n new_array << array[i]\n i += 1\n end\n\n return new_array\nend",
"def first_half(array)\n half_arr = []\n\n i = 0\n\n while i < array.length / 2.0\n half_arr << array[i]\n i += 1\n end\n return half_arr\nend",
"def first_half(array)\n elements = []\n \n i = 0\n while i <= array.length / 2.0\n elements << array[i]\n \n i += 1\n end\n \n return elements\nend",
"def first_half(arr)\n original_arr_length = arr.length/2\n split1 = arr.reverse\n first_half = []\n while (split1.length > original_arr_length)\n first_half << split1.pop \n end\n first_half.reverse\nend",
"def first_half(array)\n\ti = 0\n \tarry = []\n while i < (array.length / 2.0)\n arry << array[i]\n i += 1\n end\n return arry\nend",
"def halvsies(array)\n result = []\n size = array.size\n if size.even?\n result << first_half = array.shift(size/2)\n result << second_half = array.shift(size/2)\n else\n result << first_half = array.shift(size/2+1)\n result << second_half = array.shift(size/2)\n end\nend",
"def first_half(array)\n max = array.length / 2.0 \n puts max\n half = [] \n index = 0 \n \n while index < max\n half << array[index]\n index += 1 \n end \n \n return half\n \nend",
"def halvsies(arr)\n halfway = arr.size / 2\n halfway += 1 if arr.size.odd?\n first_half = arr[0..(halfway - 1)]\n second_half = arr[halfway..-1]\n [first_half, second_half]\nend",
"def halvsies(array)\r\n middle = (array.size / 2.0).ceil\r\n first_half = array.slice(0, middle)\r\n second_half = array.slice(middle, array.size - middle)\r\n [first_half, second_half]\r\nend",
"def halvsies(array)\n half = []\n middle = (array.length / 2.0 ).ceil\n half << array.slice(0,middle) #start, # of elements\n half << array.slice(middle, array.length) #can use middle and not middle+1 because middle equals the index of the element after middle.\n half\nend",
"def halvsies(array)\n second_half, middle_element = array.size.divmod(2)\n first_half_size = second_half + middle_element\n output_array = []\n first_half_array = []\n second_half_array = []\n\n array.each_with_index do |el, idx|\n if idx <= first_half_size - 1\n first_half_array << el\n else\n second_half_array << el\n end\n end\n\n output_array << first_half_array << second_half_array\nend",
"def halvsies(array)\n first_half = []\n second_half = []\n array.each_with_index do |elem, idx|\n if idx < (array.length/2.0).ceil\n first_half << elem\n else\n second_half << elem\n end\n end\n [first_half, second_half]\nend",
"def halvsies(arr)\n if arr.size.odd?\n first = arr[0..(arr.size/2)]\n second = arr[(arr.size/2 + 1)..-1]\n else\n first = arr[0..(arr.size/2 - 1)]\n second = arr[(arr.size/2)..-1]\n end\n final_arr = [first, second]\nend",
"def halvsies(array)\n length = array.length\n new_array = []\n\n if length.odd?\n new_array << array.first(length / 2 + 1)\n new_array << array.last(length / 2)\n else\n new_array << array.first(length / 2)\n new_array << array.last(length / 2)\n end\n\n new_array\nend",
"def halvsies(arr)\n first_half = arr.slice(0, (arr.size / 2.0).ceil)\n second_half = arr.slice(first_half.size, arr.size - first_half.size)\n [first_half, second_half]\nend",
"def halvsies(array)\n first_half = array.slice(0, (array.size / 2.0).ceil)\n [first_half, (array - first_half)]\nend",
"def halvsies(array)\n first_half = array.slice(0, (array.size / 2.0).ceil)\n second_half = array.slice(first_half.size, array.size - first_half.size)\n [first_half, second_half]\nend",
"def halvsies(array)\n first_half = array.slice(0, (array.size / 2.0).ceil)\n second_half = array.slice(first_half.size, array.size - first_half.size)\n [first_half, second_half]\nend",
"def halvsies(array)\n first_half = array.slice(0, (array.size / 2.0).ceil)\n second_half = array.slice(first_half.size, array.size - first_half.size)\n [first_half, second_half]\nend",
"def halvsies(array)\n first_half = array.slice(0, (array.size / 2.0).ceil)\n second_half = array.slice(first_half.size, array.size - first_half.size)\n [first_half, second_half]\nend",
"def halvsies(array)\n first_half = array.slice(0, (array.size / 2.0).ceil)\n second_half = array.slice(first_half.size, array.size - first_half.size)\n [first_half, second_half]\nend",
"def halvsies(array)\n first_half = []\n both_halves = []\n\n if array.size == 1 || array.size == 0\n both_halves << array\n both_halves << first_half\n elsif array.size / 2 == 0\n ((array.size) / 2).times do\n first_half << array.shift\n end\n both_halves << first_half\n both_halves << array\n else\n (((array.size - 1) / 2) + 1).times do\n first_half << array.shift\n end\n both_halves << first_half\n both_halves << array\n end\n both_halves\nend",
"def halvsies(ary)\n first_half, second_half = [], []\n return first_half, second_half if ary.empty? # handle empty array\n half = ary.length.odd? ? (ary.length / 2) + 1 : ary.length / 2\n first_half = ary[0...half]\n second_half = ary[half..-1]\n\n [first_half, second_half]\nend",
"def halvsies(original_array)\n if original_array.size.even?\n halfway = original_array.size / 2\n first_half = original_array[0, halfway]\n second_half = original_array[halfway, original_array.size - halfway]\n return [first_half, second_half]\n else\n halfway = (original_array.size / 2) + 1\n first_half = original_array[0, halfway]\n second_half = original_array[halfway, original_array.size - halfway]\n return [first_half, second_half]\n end\nend",
"def halvsies(arr)\n size = arr.size\n first_half_size = size.odd? ? (size / 2) + 1 : size / 2\n\n result_arr = []\n\n result_arr << arr.slice(0, first_half_size)\n result_arr << arr.slice(first_half_size, size / 2)\n\n result_arr\nend",
"def halvsies(array)\n if array.size.even?\n arr1 = array.slice(0, (array.size / 2))\n arr2 = array.slice(array.size / 2, array.size)\n else\n arr1 = array.slice(0, (array.size / 2) + 1 )\n arr2 = array.slice((array.size / 2) + 1, array.size)\n end \n [arr1, arr2]\nend",
"def halvsies(arr)\n middle = arr.size / 2\n cut = arr.size.even? ? middle : middle + 1\n a = arr.take(cut)\n b = arr.drop(cut)\n [a, b]\nend",
"def halvsies(arr)\n num_in_first_half = (arr.size / 2.0).ceil\n [arr[0, num_in_first_half], arr[num_in_first_half, arr.size - num_in_first_half]]\nend",
"def halvsies(arr)\n sliced_arr = []\n half = arr.length / 2.0\n if arr.size.even?\n sliced_arr << arr[0..half - 1] << arr[half..-1]\n else\n sliced_arr << arr[0..half] << arr[half+1..-1]\n end\n sliced_arr\nend",
"def halvsies(array)\n new_array = []\n array_size = array.size\n left_array_size = if array_size.odd?\n array_size / 2 + 1\n else\n array_size / 2\n end\n new_array[0] = array.slice!(0, left_array_size)\n new_array[1] = array\n # new_array[0] = array.slice(0, left_array_size)\n # new_array[1] = array.slice(left_array_size, array_size - left_array_size)\n new_array\nend",
"def halvsies(arr)\n first_half_el = (arr.size / 2.0).round - 1 \n second_half_el = arr.size == 1 ? 0 : (arr.size / 2.0).to_i * -1\n first_half = arr[0..first_half_el]\n second_half = second_half_el == 0 ? [] : arr[second_half_el..-1]\n\n halvsies = [first_half, second_half]\nend",
"def halvsies(arr)\n index = (arr.length) / 2\n if arr.length.odd?\n [arr[0..index], arr[index+1..-1]]\n else\n [arr[0..index-1], arr[index..-1]]\n end\nend",
"def halvsies(array)\n half = (array.length / 2.0).round\n [array.take(half), array.drop(half)]\nend",
"def halvsies(arr)\n middle = (arr.size/2.0).ceil\n first = arr.slice(0, middle)\n second = arr.slice(middle, arr.size - middle)\n [first, second]\nend",
"def halve array\n middle = (array.size / 2.0).round\n left = array[0..middle]\n right = array[middle..(array.size)]\n return [left,right] # explicit return for clarity :P\nend",
"def first_half(array)\n\tarr = [] # initialize arr\n \ti = 0 # start at first indice\n\n while i < (array.length / 2.0) # while indice is less than the length of the array rounded up by half\n push_this = array[i] # add corresponding item into variable \n arr << push_this # add variable into the array\n\n i += 1 # iterate next\n end\n\n return arr\nend",
"def halvsies(array)\n new_array = [[],[]]\n half_way = array.length / 2.0\n array.each_with_index do | element, index |\n if index < half_way\n new_array[0] << element\n else\n new_array[1] << element\n end\n end\n new_array\nend",
"def halvsies(array)\n half1 = array.slice(0, (array.size / 2.0).ceil)\n half2 = array.slice(half1.size, array.size - half1.size)\n [half1, half2]\nend",
"def halve array\n middle = (array.size / 2.0).round - 1\n left = array[0..middle]\n right = array[(middle+1)..(array.last)]\n [left,right]\nend",
"def halve array\n middle = (array.length / 2.0).round\n left = [0..middle]\n right = [middle..(array.last)]\n [left,right]\nend",
"def halvsies (arr)\n midpoint = (arr.size/2.0).ceil\n first_half = (0...midpoint)\n second_half = (midpoint..-1)\n\n return [arr[first_half], arr[second_half]]\nend",
"def halvsies(arr)\n arr_1 = []\n arr_2 = []\n\n if arr.size.odd?\n arr_1 = arr.shift((arr.size / 2) + 1)\n arr_2 = arr\n else\n arr_1 = arr.shift(arr.size / 2 )\n arr_2 = arr\n end\n\n [arr_1, arr_2]\nend",
"def halvsies(arr)\n \n left_array = []\n right_array = []\n middle_index = arr.size / 2\n if arr.size.even?\n left_array = arr[0...middle_index]\n right_array = arr[middle_index..-1]\n elsif\n left_array = arr[0..middle_index]\n right_array = arr[(middle_index + 1)..-1]\n end\n [left_array, right_array]\nend",
"def halvsies(array)\n result = []\n if array.size.odd?\n result << array[0..(array.size / 2)] << array[(array.size / 2 + 1)..-1]\n elsif array.size.even?\n result << array[0..((array.size / 2) - 1)] << array[(array.size / 2)..-1]\n end\n result\nend",
"def first_half(arr, n)\n if arr.length >= n * 2\n arr[0..(arr.length / 2)]\n elsif arr.length >= n + 3\n arr[0...n]\n elsif arr.length >= n\n arr[0...(arr.length - 3)]\n else\n arr \n end\n end",
"def halvsies(array)\n arr1 = []\n arr2 = []\n half_length_round_down = array.length/2\n \n index = 0\n index2 = half_length_round_down\n index2 += 1 if array.length.odd?\n \n loop do\n break if index == half_length_round_down\n arr1 << array[index]\n arr2 << array[index2]\n index += 1\n index2 += 1\n end\n \n if array.length.odd?\n arr1 << array[index]\n # because break statement is after index increases we don't have to increase it again\n end\n \n [arr1, arr2]\nend",
"def halvsies(array)\n halvs = []\n first_half_size = array.size % 2 == 0 ? array.size / 2 : array.size / 2 + 1\n halvs[0] = array[0...first_half_size]\n halvs[1] = array[first_half_size..-1]\n halvs\nend",
"def halvsies(arr)\n midpoint = arr.length.even? ? arr.length / 2 : (arr.length / 2) + 1\n arr1 = arr[0,midpoint]\n arr2 = arr[midpoint..-1]\n [arr1, arr2]\nend",
"def halvsies(arr)\n sizing = (arr.size.to_f / 2).ceil\n first, second = arr[0..sizing-1], arr[sizing.. -1]\nend",
"def halvsies(arr)\n first_halve_length = (arr.size / 2.0).round\n first_halve = arr[0, first_halve_length]\n second_halve = arr[first_halve_length, arr.size - first_halve_length]\n [first_halve, second_halve]\nend",
"def halvsies(array)\n array.partition do |e|\n array.size.even? ? array.take(array.size/2).include?(e) : array.take(array.size/2 + 1).include?(e)\n end\nend",
"def halvsies(array)\n first = []\n second = []\n \n first_of_last_array = (array.size/2.0).round(0)\n\n array.each_with_index do |num, index|\n if index < first_of_last_array\n first << num\n else\n second << num\n end\n end\n [first, second]\n\nend",
"def halvsies(arr)\n midpoint = (arr.length / 2.0).ceil\n [arr[0...midpoint], arr[midpoint..-1]]\nend",
"def halvsies(array)\n array1 = []\n array2 = []\n n = 0\n array.size.odd? ? m = 1 : m = 0\n\n (array.size / 2 + m).times do\n array1 << array[n]\n n += 1\n end\n\n (array.size / 2).times do\n array2 << array[n]\n n += 1\n end\n\n [array1, array2]\nend",
"def middle_in_array(array)\n array[array.length / 2]\nend",
"def halvsies(array)\n result = [[],[]]\n array.each_index do |i|\n if i < (array.size / 2.0)\n result[0] << array[i]\n else\n result[1] << array[i]\n end\n end\n result\nend",
"def halvsies(arr)\n if arr.size == 0 then\n return [[], []]\n else\n split_point = (arr.size / 2.0).ceil - 1\n return [arr[(0..split_point)], arr[split_point+1..arr.length-1]]\n end \nend",
"def halvsies(ary)\n ary.size.even? ? [ary[0...(ary.size/2)], ary[(ary.size/2)..-1]] : [ary[0..(ary.size/2)], ary[(ary.size/2 + 1)..-1]]\nend",
"def halvsies(arr)\n return_array = [[],[]]\n arr.each_with_index do |item, index|\n if arr.size.even?\n index < (arr.size) /2 ? return_array[0] << item : return_array[1] << item\n else\n index <= (arr.size) /2 ? return_array[0] << item : return_array[1] << item\n end\n end\n return_array\nend",
"def halvsies(arr)\n arr.partition.with_index { |_, idx| idx <= (arr.length / 2.0).ceil - 1 }\nend",
"def middle_number(array)\n if array.length == 0\n return nil\n elsif array.length % 2 == 0\n (array[array.length / 2] + array[array.length / 2] -1).to_f / 2\n else\n array[array.length / 2]\n end\nend",
"def halvsies(ar)\n ar_size = ar.size\n half_index = ar_size % 2 == 0 ? (ar_size / 2) -1: ar_size / 2\n ar.partition.with_index { |el, index| index <= half_index }\nend",
"def halvsies(arr)\n halvsies_arr1 = []\n halvsies_arr2 = []\n halves = arr.length / 2\n arr.length % 2 == 0 ? halves -= 1 : halves\n arr.each_with_index do |item, index|\n if index <= (halves)\n halvsies_arr1.push(item)\n else\n halvsies_arr2.push(item)\n end\n end\n [halvsies_arr1, halvsies_arr2]\nend",
"def stretch(arr)\n # new empty array\n new_arr = []\n # go through each element\n arr.each do |number|\n # if even, divide by two\n if number % 2 == 0\n new_arr << (number / 2)\n new_arr << (number / 2) # this isn't DRY, I think\n # if odd, subtract one, divide by two. Add one to the first half\n else\n new_arr << (((number - 1) / 2) + 1)\n new_arr << ((number - 1) / 2) # DRY-ness issue here, maybe\n # store both halves\n end\n end\n # return new array\n return new_arr\nend",
"def find_middle_array_element(array)\n\n return 0 if array.size == 1 \n if array.size.odd?\n array.size/2\n elsif array.size.even? \n (array.size/2) - 1\n end\n\nend",
"def stretch(array)\n new_arr = []\n # can assign array to an variable and do only /2 once\n for i in 0...array.length\n # if element is a even number\n if array[i] % 2 == 0\n # add 1/2 value of the element for twice into the new array\n new_arr << array[i]/2\n # if element is an odd number\n else\n new_arr << array[i]/2 + 1\n end\n new_arr << array[i]/2\n end\n return new_arr\nend",
"def halvsies(ary)\n ary.partition {|el| ary.index(el) < ((ary.size)/2.0)}\nend",
"def halvsies(ary)\r\n length = ary.size\r\n ary2 = []\r\n (length / 2).times{ ary2.unshift(ary.pop) }\r\n results = [ary, ary2]\r\nend",
"def halvsies(a)\n [a[0, (a.size / 2.0).ceil], a - a[0, (a.size / 2.0).ceil]]\nend",
"def first_even\n\t@array[0]\n\t\t#returns 30\n\t\tarray_2 = @array.split(',')\n\t\t#splits apart the original array\n\t\t\tarray_3 =[]\n\t\t\t#creates a new array, in which I can shove in whatever I want\n\t\t\t\tarray_3 << [50, 3, 5, 15, 16, 23, 42, 300, 22, 1, 55, 42, 30, 17, 77, 102, 5, 11]\n\t\t\t\t\tarray_3.flatten!\n\t\t\t\t\t\n\n\nend",
"def first_even(array_of_numbers)\n even_number_array = []\n array_of_numbers.each do |num| \n if num % 2 == 0\n even_number_array << num\n end\n end\n even_number_array[0]\nend",
"def halvsies(arr)\n arr.partition.with_index { |_, index| (arr.size / 2.0).ceil > index }\nend",
"def halvsies(arr)\n elements = (arr.length / 2.0).round\n arr.partition { |value| arr.index(value) < elements }\nend",
"def even_odd_half_of(splits)\n odd = splits.select.with_index{|_,i| (i+1) % 2 == 1}\n even = splits.select.with_index{|_,i| (i+1) % 2 == 0}\n # necessary to reverse order of 2nd half\n # otherwise someone would have to manually reverse\n # all the printed pages after having printed\n # the first half of the document.\n even.reverse!\n [odd, even]\n end",
"def left_half\n self[0...length / 2]\n end",
"def middle(list)\n if list.size%2 == 1 # odd length sorted\n return list[list.size/2]\n else # even length sorted\n return (list[list.size/2] + list [list.size / 2 -1]) / 2.0\n end \n\nend",
"def median(array)\n middle = nil\n array.sort!\n if array.length % 2 == 0\n middle = (array[array.length / 2] + array[array.length / 2 - 1]) / 2.0\n else\n middle = array[(array.length - 1) / 2]\n end\nend",
"def odds(arr)\n\tret = []\n\tarr.each_index { |i|\n\t\tif i % 2 == 1\n\t\t\tret << arr[i]\n\t\tend\n\t}\n\tret\nend",
"def middle(list)\n if list.size % 2 == 1\n #odd length lists\n return list[list.size / 2]\n else\n # even length lists\n return (list[list.size / 2] + list[list.size / 2 - 1]) / 2.0\n end\nend",
"def halvsies(ary)\n first_ary = []\n second_ary = []\n while ary.empty? == false\n first_ary << ary.shift\n break if ary.empty?\n second_ary.unshift(ary.pop)\n end\n p [first_ary, second_ary]\nend",
"def stretch(array)\n\n stretched_array = []\n\n for element in array\n if element % 2 == 0\n stretched_array << element/2\n stretched_array << element/2\n else\n stretched_array << element/2 + 1\n stretched_array << element/2\n end\n end\n\n return stretched_array\n\nend",
"def halvsies(array1)\n num = (array1.length / 2.0).ceil\n num = array1.length - num\n array2 = []\n \n loop do\n break if num == 0\n array2 << array1.pop\n num -= 1\n end\n \n big_array = [array1, array2.reverse!]\n big_array\nend",
"def halve! input\n input.slice!(input.count/2..input.count)\n input\n end",
"def oddities(array)\n new_array = []\n\n index = 0\n while index < array.size\n new_array << array[index] if index.even?\n index += 1\n end\n new_array\nend",
"def oddball(arr)\n\tnew_arr = arr.map { |n| n % 2}\n\tnew_arr.count(0) == 1 ? arr[new_arr.index(0)] : arr[new_arr.index(1)]\nend",
"def median(array)\n array_size = array.size\n midpoint = array_size / 2\n\n if array_size.odd?\n median = array[midpoint]\n else\n median = (array[midpoint] + array[midpoint - 1]) / 2.0\n end\n median\nend",
"def median(array)\n # mutate the array until the median is right in the\n # middle\n partition(array)\n # return the middle element of the array,\n # aka the median\n array[array.size / 2]\nend",
"def mod_half_even(arr, k)\n mod_half_even = 0\n mod_half_even = arr.delete_at(k / 2 - 1) if k.even?\n mod_half_even = 1 if mod_half_even.positive?\n mod_half_even\nend",
"def first_half(str)\n str[0...str.length / 2]\n end",
"def oddities(array)\n elements = []\n index = 0\n while index < array.size\n elements << array[index]\n index += 2\n end\n elements\nend",
"def merge_sort(array)\n return array if array.length < 2\n middle_idx = array.length / 2\n first_half = array.take middle_idx\n last_half = array.drop middle_idx\n\n merge_helper(merge_sort(first_half), merge_sort(last_half))\nend",
"def median(array)\n sorted = array.sort\n\n if array.length % 2 != 0\n array[array.length/2]\n else \n ((array[array.length/2] - array[(array.length/2)-2]).to_f / 2) + array[(array.length/2)-2]\n end\nend",
"def oddball(arr)\n odd = arr.select {|x| x.odd? }\n even = arr.select {|x| x.even? }\n if even.length > odd.length\n odd[0]\n else\n even[0]\n end\nend",
"def halve input\n \tinput[0...input.count/2]\n end",
"def median(array)\n middle = nil # defining the future median\n array.sort! # sorting the array. I used a destructive method for this, so that it goes to the if statement\n if array.length % 2 == 0 # if the array has an even amount, we need the average of the middle 2 elements\n middle = (array[array.length / 2] + array[array.length / 2 - 1]) / 2.0 # refer to the table below for a visual\n else\n middle = array[(array.length - 1) / 2] # if it's odd you just take the midle element\n end # don't forget to close your\nend"
] |
[
"0.8961302",
"0.8950954",
"0.8875156",
"0.88587683",
"0.88571215",
"0.88189095",
"0.8802105",
"0.8718996",
"0.86347073",
"0.86131454",
"0.85957915",
"0.85068303",
"0.8335926",
"0.8272722",
"0.827134",
"0.826673",
"0.8188495",
"0.81455004",
"0.8115913",
"0.8110046",
"0.8103419",
"0.8097262",
"0.8097262",
"0.8097262",
"0.8097262",
"0.8097262",
"0.809201",
"0.8046838",
"0.80245215",
"0.8008503",
"0.80001056",
"0.7957378",
"0.7950954",
"0.79390985",
"0.7927059",
"0.789929",
"0.78902084",
"0.7880437",
"0.7861728",
"0.7861167",
"0.7851138",
"0.7836631",
"0.783603",
"0.781702",
"0.78115624",
"0.7802706",
"0.77932274",
"0.7774209",
"0.7764011",
"0.7727823",
"0.7705491",
"0.7672647",
"0.76713973",
"0.7622859",
"0.76207894",
"0.7506996",
"0.746905",
"0.7465993",
"0.7437997",
"0.73920953",
"0.7325655",
"0.7272883",
"0.7266229",
"0.7224513",
"0.72219735",
"0.713459",
"0.7128361",
"0.7065118",
"0.70321053",
"0.6885734",
"0.68716866",
"0.6835121",
"0.683249",
"0.6813938",
"0.6777558",
"0.6776463",
"0.6768983",
"0.67466444",
"0.67255914",
"0.66858965",
"0.66678494",
"0.66119474",
"0.65694594",
"0.6547103",
"0.65318215",
"0.651855",
"0.6503646",
"0.649707",
"0.6475007",
"0.6468719",
"0.64575565",
"0.6450693",
"0.64439356",
"0.643976",
"0.64229554",
"0.64023286",
"0.6399895",
"0.6391511",
"0.6391237",
"0.63824093"
] |
0.87171954
|
8
|
FACTORS OF Write a method factors_of(num) that takes in a num and returns an array of all positive numbers less than or equal to num that can divide num.
|
def factors_of(num) # Define method with one param
i = 1 # To prevent dividing by zero start at one because of future modula expression
new_array = [] # Create and empty array to shovel numbers while they meet requirements of the if statement
while i <= num
if num % i == 0 # Parameter entered must be a factor of i since we are cycling through iterations and i is incrementing upwards
new_array << i # Shovel iterations that fulfill logical conditions
end
i += 1 # Increment up 1 at a time
end
return new_array # Prints array after while loop ends; while loop conditions are met
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def factors_of(num)\n factors = []\n \n i = 1\n while i <= num\n # if num is divided by i\n if num % i == 0\n factors << i\n end\n \n i += 1\n end\n \n return factors\n end",
"def factors_of(num)\n array = []\n i = 1\n while i <= num\n if num % i == 0\n array << i\n end\n i += 1\n end\n return array\n end",
"def factors_of(num)\n\tnewArray = []\n \tfor i in 1..num\n if num % i == 0\n \tnewArray << i\n end\n end\n return newArray\nend",
"def factors_of(num)\n i = 1\n newArr = []\n while i <= num\n if num % i == 0\n newArr << i\n end\n i += 1\n end\n return newArr\n end",
"def factors_of(num)\n factor_arr = []\n\n (1...num).reverse_each do |factor|\n if (num % factor).zero?\n factor_arr << factor\n end\n end\n\n factor_arr\nend",
"def factors(num)\n factors = Prime.prime_division(num)\n result = []\n factors.each { |factor, power| result += [factor] * power }\n result\n end",
"def factors(num)\n arr = []\n (1..num).each do |el|\n arr << el if num % el == 0\n end\n arr\nend",
"def factors_of(num)\n\tnums = []\n \n\ti = 1\n\twhile i <= num\n\t\tif num % i == 0\n\t\t\tnums << i\n end\n\t\ti += 1\n end\n \n\treturn nums\nend",
"def get_factors(num)\n factors = []\n (1..num).each do |i|\n factors << i if num % i == 0\n end\n factors\nend",
"def factors_of(num)\n \n index = 1 \n \n factors = []\n \n while index <= num\n if num % index == 0 \n factors << index \n end \n \n index += 1 \n end \n \n return factors \n \nend",
"def factors_of(num)\n divide_by = []\n \n i = 1\n while i <= num\n if num % i == 0\n divide_by << i\n end\n \n i += 1\n end\n \n return divide_by\nend",
"def factors(num)\n arr = []\n (1..num).each { |n| arr << n if num%n==0}\n return arr\nend",
"def factors_for( num )\n facts = []\n (1..(num/2)).each {|divisor| facts << divisor if (num % divisor == 0)}\n facts\nend",
"def factors_of(num)\n arr = []\n\n i = 1\n\n while i <= num\n if num % i == 0\n arr << i\n end\n i += 1\n end\n\n return arr\nend",
"def factors(num)\n arr = []\n for i in 1..num\n if num%i == 0\n arr << i\n end\n end\n arr\nend",
"def factors num\n f = Array.new # creates a new array to store factors\n 1.upto(num) do |i|\n f << i if num%i == 0\n end\n f # returns factors\nend",
"def factors_of(num)\n\ti = 1\n \tarry = []\n while i <= num\n if num % i == 0\n arry << i\n end\n\n i += 1\n end\n return arry\nend",
"def factors(num)\n factors = []\n (1..num).each do |factor|\n factors << factor if num % factor == 0\n end\n factors\nend",
"def factors(num)\n ret = []\n for i in (1..num)\n ret << i if num % i == 0\n end\n ret\nend",
"def factors(num)\n array = []\n (1..num).each do |x|\n if num % x == 0\n array << [x, num/x]\n end\n end\n array\nend",
"def factors(num)\n factors = []\n (1..num).each do |i| \n factors << i if num % i === 0\n end\n factors\nend",
"def factors(num)\n\t((1..num).select {|n| num % n == 0 } ).sort\nend",
"def find_factors(num)\n raise ArgumentError, \"num must be >= 0\" if num < 0\n return [n] if num <= 1\n result = []\n\n n = num\n if n.even?\n while n % 2 == 0\n result << 2\n n /= 2\n end\n end\n\n div = 3\n\n while (n > 1)\n while n % div == 0\n result << div\n n /= div\n end\n div += 2\n\n if (div * div > n)\n result << n\n break\n end\n end\n\n result\nend",
"def factors(num)\n factors = []\n (1..num).each do |n|\n factors << n if num % n == 0\n end\n factors\nend",
"def factors(num)\n arr = []\n (2..num).each do |ele|\n if (num % ele == 0)\n arr << ele\n end\n end\n return arr\nend",
"def factors(num)\n result = [1]\n\n (2..num).each do |el|\n result << el if num % el == 0\n end\n result\nend",
"def factors(num)\n arr = (1..num).to_a\n factored_arr = []\n i = 0\n while i < arr.length\n if num % arr[i] == 0\n factored_arr = factored_arr + arr[i]\n end\n i +=1\n end\n factored_arr\nend",
"def factors_of(num)\n new_arr = []\n\n i = 1\n while i <= num\n if num % i == 0\n new_arr << i\n else \n end \n i += 1\n end\n return new_arr\nend",
"def find_factors(number)\n factors =[]\n for i in 1..number\n factors << i if number % i == 0\n end\n factors\nend",
"def factors(num)\n factors = []\n (1..num).each do |i|\n factors << i if num % i == 0\n end\n \n factors\nend",
"def factors(num)\n answer = []\n (1...num).each {|i| answer << i if num % i == 0 }\n answer\nend",
"def factors(num)\n factors = Prime.prime_division(num)\n result = []\n factors.each { |factor, power| result += [factor] * power }\n result\nend",
"def factors_of(num)\n (1..num).select{|ele| num % ele == 0}\nend",
"def factors(num)\n factors = []\n (1..num/2).each {|n| factors << n if num % n == 0}\n factors << num\nend",
"def prime_factors num\n\tfactors = []\n\ttest_value = 2\n\twhile num > 1 do\n\t\twhile num % test_value == 0 do\n\t\t\tfactors.push num\n\t\t\tnum = num / test_value\n\t\tend\n\t\ttest_value += 1\n\tend\n\treturn factors\nend",
"def factors(num)\n return nil if num <= 0\n return [1] if num == 0\n (1..num).select { |i| (num % i) == 0 }\nend",
"def factors(num)\n result = []\n for i in 1..num\n if num % i == 0\n result << i\n end\n end\n result.sort\nend",
"def factor(num)\n\tcurrent_factor = num/2\n\tfactors = []\n\tfactors << num\n\twhile current_factor > 0\n\t\tif num%current_factor == 0\n\t\t\tfactors << current_factor\n\t\t\tcurrent_factor -= 1\n\t\telse\n\t\t\tcurrent_factor -= 1\n\t\tend\n\tend\n\t\n\treturn factors\nend",
"def old_factors(num)\n factors = []\n (1..num).each do |i|\n if num % i == 0\n factors << i\n end\n end\n factors\nend",
"def factors(num)\n array = []\n (1..num).each do |number|\n array << number if num % number == 0\n end\n array.sort!\nend",
"def factors(num)\n 1.upto(num).select { |x| num % x == 0 }\nend",
"def factors(num)\r\n factors = []\r\n sqrt = Math.sqrt(num)\r\n until num == 1\r\n\r\n factor_founded = false\r\n (2..sqrt).each do |i|\r\n if (num % i).zero?\r\n num /= i\r\n factors << i\r\n factor_founded = true\r\n break\r\n end\r\n end\r\n unless factor_founded\r\n factors << num\r\n num /= num\r\n end\r\n end\r\n return factors\r\nend",
"def factors(num)\n facs = [1]\n (2..num/2).each{|n| facs.push(n) if num % n == 0 }\n facs.push(num)\nend",
"def factors(num)\n (1..num).select { |el| num % el == 0 }\nend",
"def factors(num)\n pn = num.prime_division\n ans = []\n pn.each_index do |i|\n ans << pn[i][0]\n end\n return ans\nend",
"def factors(num)\n\n facts = []\n \n (1..num).each do |i|\n if num % i == 0\n facts << i\n end\n end\n \n return facts[-2]\nend",
"def prime_factors(num)\n\tfactors = []\n\tfactor = 2\n\tremainder = num\n\n\twhile (remainder > 1) && (factor <= num)\n\t\twhile (remainder % factor == 0)\n\t\t\tfactors << factor\n\t\t\tremainder /= factor\n\t\tend\n\n\t\tfactor += 1\n\tend\n\tfactors\nend",
"def factors(number)\n fs = [1,number]\n (2..Math.sqrt(number).to_i).each do |i|\n if number % i == 0\n fs << i\n fs << number/i unless number/i == i\n end\n end\n fs.sort\n end",
"def factors(number)\n dividend = number\n divisors = []\n while dividend == 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\n\n # number % dividend == 0 checks if the number is divisable with no remainder\n # returns the divisors array\nend",
"def factors(num)\n (1..num).select{|i| num % i == 0 }\nend",
"def factors(number)\n dividend = 1\n divisors = []\n while dividend <= number\n divisors << dividend if number % dividend == 0\n dividend += 1\n end\n divisors\nend",
"def factors(num)\n arr = [1]\n i = 1\n while i <= num\n arr << i if (num % i).zero?\n i += 1\n end\n arr.uniq.sort\nend",
"def factors(num)\n facs = []\n i = 1\n while i <= num\n if num % i == 0\n facs << i\n end\n i += 1\n end\n facs\nend",
"def factors(num)\n prime?(num) ? [1, num].uniq : [*1..num].select { |i| num % i == 0}\nend",
"def factors(num)\n (1..num).select {|x| num % x == 0 }\nend",
"def prime_factors(num)\n arr = (2..Math.sqrt(num).round).to_a\n primes = arr.each do |i|\n arr.select! {|j| j%i != 0 or j==i}\n end\n pfacts = primes.select {|i| num%i == 0}\n\n return [num] if pfacts.empty?\n return pfacts\nend",
"def factors(num)\r\n # your code goes here\r\n\r\n factors = []\r\n for i in 1 .. num\r\n if num % i == 0\r\n factors << i\r\n end\r\n end\r\n factors\r\nend",
"def factors(num)\n factors = []\n for factor in 1..num\n factors << factor if num % factor == 0\n end\n factors.sort\nend",
"def factors(num)\n (1..num).select { |n| num%n == 0}\nend",
"def factors(number)\r\n divisor = number\r\n factors = []\r\n while divisor > 0 do \r\n factors << number / divisor if number % divisor == 0\r\n divisor -= 1\r\n end \r\n factors\r\nend",
"def prime_factors(num)\n factors = factors(num)\n result = []\n factors.each do |fac|\n if prime?(fac)\n result << fac\n end\n end\n result\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n begin\n # evaluate statement on right side of shovel operator and if\n # divisor evenly divides number then add into factors array \n factors << number / divisor if number % divisor == 0\n # decrement divisor by 1\n divisor -= 1\n # stops when divisor is 0\n end until divisor == 0\n \n # return all factors in an array that divides evenly with \n # the number passed in as an argument when calling the function\n factors\nend",
"def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << (number / divisor) if ((number % divisor) == 0)\n divisor -= 1\n end\n factors\nend",
"def factors(number)\n factors = []\n divisor = number\n while divisor > 0 do\n factors << (number / divisor) if number % divisor == 0\n divisor -= 1\n end\n if divisor <= 0\n puts \"Invalid number: no 0's or negatives!\"\n else\n end\n factors\n end",
"def factors(number)\n divisor = number\n factors = []\n #begin\n\twhile divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n #end until divisor == 1\n\tend\n factors\nend",
"def factors(num)\n output_arr = []\n\n (1..num).each do |el|\n if num % el == 0\n output_arr << el\n end\n end\n\n output_arr.sort\nend",
"def prime_factors(num)\n prime_facts = []\n \n (1..num).each do |i|\n if num % i == 0 && prime?(i)\n prime_facts << i\n end\n end\n \n return prime_facts\n end",
"def factors(num)\n\n factors = []\n # iterate through all nums from 1 to num\n # add to factors if evenly divisible\n # return factors\n\n i = 1\n while i <= num\n factors << i if num % i == 0\n i += 1\n end\n\n factors\n\nend",
"def prime_factors(number)\n fs = []\n f1 = factor(number)\n return [number] if f1 == 1\n f2 = number/f1\n fs.concat(prime_factors(f1))\n fs.concat(prime_factors(f2))\n return fs\n end",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\nend",
"def factors(number)\n dividend = number\n divisors = []\n while number >= 1\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n break if dividend == 0\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while number > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors (n)\n return (1..n).select {| x | n % x == 0}.to_a\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def prime_factors(num)\n arr = []\n\tPrime.each(num) { |prime| num % prime == 0 ? arr.push(prime) : false }\n return arr\nend",
"def prime_factors(num)\n arr = []\n (1..num).each { |n| arr << n if num%n==0 && prime?(n)}\n return arr\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend",
"def factors(num)\n return nil if num < 0\n return 1 if num == 1\n (1..num).select { |n| num % n == 0}\n\n\nend",
"def prime_factors(num)\n\n if prime?(num)\n return [num]\n end\n\n primes = (2...num).to_a.select { |factor| prime?(factor) }\n\n \n \n factors = []\n\n while num > 1\n candidate = primes.shift\n\n if num % candidate == 0\n factors << candidate\n while num % candidate == 0\n num /= candidate\n end\n end\n end\n\n return factors\n \nend",
"def prime_factors(num)\n arr = factors(num)\n new_arr = []\n arr.each do |n|\n new_arr << n if prime?(n)\n end\n new_arr\nend"
] |
[
"0.86133254",
"0.8602405",
"0.85794353",
"0.85481006",
"0.83708006",
"0.8348235",
"0.8309214",
"0.829599",
"0.82940227",
"0.82782644",
"0.8276724",
"0.8270363",
"0.8234743",
"0.8226091",
"0.8210875",
"0.8193632",
"0.81910175",
"0.8189199",
"0.81800485",
"0.8176216",
"0.81565595",
"0.8156326",
"0.81502366",
"0.814564",
"0.8135137",
"0.8128693",
"0.81168413",
"0.8108457",
"0.81019735",
"0.8088762",
"0.8081874",
"0.80786335",
"0.8071028",
"0.8044848",
"0.80259544",
"0.8025391",
"0.80193514",
"0.8004272",
"0.79895157",
"0.7969109",
"0.7945917",
"0.7935345",
"0.793451",
"0.79330665",
"0.7926727",
"0.79146546",
"0.78858846",
"0.787829",
"0.7876871",
"0.78767896",
"0.78762543",
"0.78734803",
"0.78689975",
"0.7868965",
"0.7867772",
"0.7867067",
"0.7858465",
"0.78480285",
"0.78434014",
"0.78389454",
"0.78313804",
"0.7827193",
"0.7826234",
"0.7826234",
"0.7826234",
"0.7826234",
"0.7826234",
"0.7826234",
"0.7821425",
"0.7815772",
"0.7795658",
"0.77857244",
"0.7784269",
"0.7778487",
"0.7771804",
"0.775426",
"0.77492076",
"0.7740501",
"0.77366465",
"0.7727192",
"0.7724711",
"0.7724711",
"0.7724711",
"0.7724711",
"0.7724711",
"0.77241015",
"0.7718717",
"0.77150285",
"0.77150285",
"0.77150285",
"0.77150285",
"0.77150285",
"0.77150285",
"0.77150285",
"0.77150285",
"0.77150285",
"0.77112114",
"0.77040744",
"0.7703149",
"0.7694839"
] |
0.7942186
|
41
|
=> [1, 2, 4, 8, 16] Select Odds Challenge Write a method select_odds(numbers) that takes in an array of numbers and returns a new array containing the odd numbers of the original array.
|
def select_odds(numbers)
i = 0
new_array = []
while i < numbers.length
if numbers[i] % 2 != 0
new_array << numbers[i]
end
i += 1
end
return new_array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def select_odds(numbers)\n odds = []\n \n i = 0\n while i < numbers.length\n num = numbers[i]\n if num % 2 == 1\n odds << num\n end\n \n i += 1\n end\n \n return odds\n end",
"def select_odds(numbers)\n\todds = []\n \tfor i in 0..numbers.length-1\n number = numbers[i]\n if number % 2 == 1\n odds << number\n end\n end\n return odds\nend",
"def select_odds(numbers)\n i = 0\n newArr = []\n while i < numbers.length\n if numbers[i] % 2 != 0\n newArr << numbers[i]\n end\n i += 1\n end\n return newArr\n end",
"def select_odds(numbers)\n index = 0 \n \n odds = [] \n \n while index < numbers.length \n if numbers[index] % 2 != 0\n odds << numbers[index]\n end \n \n index += 1 \n end \n \n return odds \n \nend",
"def select_odds(numbers)\n array = []\n i = 0\n while i < numbers.length\n \n if numbers[i] % 2 == 1\n array << numbers[i]\n end\n i += 1\n end\n return array\n end",
"def select_odds(numbers)\n\tnums = []\n \n\ti = 0\n\twhile i < numbers.length\n\t\tif numbers[i] % 2 == 1\n\t\t\tnums << numbers[i]\n\t\tend\n\t\ti += 1\n end\n \n\treturn nums\nend",
"def select_odds(numbers)\n odds = []\n\n i = 0\n\n while i < numbers.length\n if numbers[i] % 2 == 1\n odds << numbers[i]\n end\n i += 1\n end\n\n return odds\nend",
"def select_odds(numbers)\n odd_numbers = []\n \n i = 0\n while i < numbers.length\n if numbers [i] % 2 == 1\n odd_numbers << numbers [i]\n end\n \n i += 1\n end\n \n return odd_numbers\nend",
"def select_odds(numbers)\n\tarry = []\n \ti = 0\n while i < numbers.length\n if numbers[i] % 2 == 1\n arry << numbers[i]\n end\n i += 1\n end\n return arry\nend",
"def select_odds(numbers)\n new_arr = []\n\n i = 0\n while i < numbers.length\n if numbers[i] % 2 == 1\n new_arr << numbers[i]\n else \n end\n\n i += 1\n end\n\n return new_arr\n \nend",
"def select_odds(nums)\n odds = []\n\n i = 0\n while i < nums.length\n if nums[i] % 2 == 1\n odds << nums[i]\n end\n i += 1\n end\n return odds\nend",
"def select_arr(arr)\n # select and return all odd numbers from the Array variable `arr`\n arr.select(&:odd?)\nend",
"def odd_index_nums(array)\n array.select do |num|\n current_index = array.index(num)\n \n if current_index % 2 == 1\n num\n end\n end\nend",
"def select_arr(arr)\n # select and return all odd numbers from the Array variable `arr`\n arr.select {|a| a % 2 != 0}\nend",
"def odds_only array\n array.select do |value|\n value.odd?\n end\nend",
"def odd_numbers(array)\n end",
"def square_only_odds(numbers)\n numbers.select { |x| x % 2 == 1 }.map { |x| x * x }\nend",
"def oddities_1(array)\n array.select { |element| array.index(element) % 2 == 0 }\nend",
"def odd_integers(array)\nend",
"def select_method(array)\r\n\r\n array.select{|number| number.odd?}\r\n\r\nend",
"def even_numbers(num_array)\n\n\tnum_array.select! do |num|\n\t\tnum % 2 == 0\n\tend\n\n\tnum_array\n\nend",
"def oddities(array)\n array.select.with_index { |e, i| (i + 1).odd? }\nend",
"def oddNums array\n # Go through the array and select only the integers\n numArray = array.select { |value| value.is_a?(Integer) }\n # Go through the array of integers and select the ones that are odd\n oddNumArray = numArray.select { |value| value.odd? }\n # Sort the array of odd numbers in place using the bang operator\n oddNumArray.sort!\n # Implicity return the array of odd numbers, sorted from least to greatest\nend",
"def reject_odds(array)\n\t\n\tnot_odds = array.reject { |num| num.odd?}\nend",
"def oddities(arr)\n\tarr.select.with_index { |num, index| num if index.even? }\nend",
"def even_numbers(num_array)\n\tnum_array.select! { |num| num.even? }\nend",
"def oddities(array)\n new_array = []\n index_range = (1..array.size-1)\n for n in index_range do \n new_array << array[n] if n.odd?\n end\n new_array\nend",
"def oddities(array)\n array.select.with_index { |e, idx| e if idx.even? }\nend",
"def oddities(array)\r\n array.select.with_index { |_, i| i.even? }\r\n end",
"def select_even_numbers(array)\n array.select{|x| x % 2 == 0}\nend",
"def oddities(array)\n new_array = []\n array.each_with_index do |num, index|\n new_array << num if index.odd?\n end\n new_array\nend",
"def select_evens(array)\n output_array = []\n\n array.each do |number|\n if number % 2 == 0\n output_array << number\n end\n end\n\n return output_array\nend",
"def oddities(array)\n new_array = []\n array.each_with_index { |num, idx| new_array << num if idx.even? }\n new_array\nend",
"def oddities(input_array)\n input_array.select.each_with_index { |_, i| i.even? } # => [2, 4, 6], [\"abc\"], [123], []\nend",
"def odd_numbers(num1, num2)\n (num1..num2).select { |n| n.odd? }\nend",
"def no_odds(array)\n array.delete_if(&:odd?)\nend",
"def odd_only(arr)\n arr.select{|el| el % 2 != 0}\nend",
"def select_arr(arr)\n # select and return all odd numbers from the Array variable `arr`\n arr.select { |x| x%2!=0 }\n end",
"def separate_arr_into_even_and_odd_num(arr)\n arr.select { |e| e.even? || e == odd }\nend",
"def q13\n numbers = [1, 2, 3, 4, 5]\n\n p numbers.select(&:odd?)\nend",
"def oddies(numerals, odd = true)\n odd ? numerals.select { |item| numerals.index(item).even? } : arr.select { |item| numerals.index(item).odd? } \nend",
"def square_only_odds(numbers)\n odd_array = numbers.select do |x|\n (x % 2) != 0\n end\n\n odd_array.map do |i|\n i = i**2\n end\n\nend",
"def remove_odd array\n no_odds_array = []\n array.each do |number|\n if number % 2 == 0\n no_odds_array.push(number)\n end\n end\n no_odds_array\nend",
"def select_even_nums(arr)\n arr.select(&:even?)\nend",
"def oddities(array)\n result = []\n array.select do |element|\n result << element if array.index(element).even?\n end\n result\nend",
"def odd_only arr\n arr.select{|value| value % 2 != 0}\nend",
"def even_numbers(array)\n array.select{ |num| num.even? }\n\n # TODO: Return the even numbers from a list of integers.\n # You should use Enumerable#select\nend",
"def puts_even_odd(array = [1, 2, 3, 4, 5, 6, 7, 8, 9])\n puts array.select { |el| el.even? }\n puts array.select { |el| el.odd? }\nend",
"def oddities(array)\n array.select { |a| puts a if a % 2 == 0 }\nend",
"def evenies(array)\n array.select.with_index { |e, idx| e if idx.odd? }\nend",
"def all_the_odds_each\n numbers = [1,2,3,4,5]\n odds = [] #code-smell: when you look at this... you know there's a better way of doing it...\n\n numbers.each do |number| #each will always return everything in the array\n if number.odd? \n odds << number \n end\n end\n odds\nend",
"def oddities(arr)\r\n arr2 = arr.select do |x|\r\n arr.index(x).even?\r\n end\r\n arr2\r\nend",
"def oddities(arr)\n index = 0\n arr.select do |e|\n index += 1\n index.odd?\n end\nend",
"def oddities(arry)\n arry.select { |n| n if arry.index(n).even? }\nend",
"def evens_and_odds(arr)\r\n arr.partition{ |num| num.odd?}\r\nend",
"def odds_sorted array\n odd_nums = array.select do |value|\n value.is_a?(Integer) && value.odd?\n end\n odd_nums.sort\nend",
"def oddities(array)\nselected_index = []\nindex = 0\n\n\tloop do \n\tcurrent_array = array[index]\n\t\tif index.even?\n\t\t\tselected_index << current_array\n\t\tend\n\tindex += 1\n\tbreak if index == array.size\n\tend\nselected_index\n\nend",
"def odd_numb array\n new_arr= array.select! do |value|\n value.class == Integer\n end\n new_arr.select { |value| value % 2 != 0 }.sort\nend",
"def even_num_array(numbers)\n puts \"The original array is #{numbers}\"\n\tnumbers = numbers.select {|n| n.even? } \n\tputs \"The modified array is #{numbers}\"\nend",
"def oddities(array)\n odd_array = []\n array.each_with_index do |e, idx|\n odd_array << e if idx.even?\n end\n odd_array\nend",
"def oddities(arr)\n arr.select.with_index do |_,index|\n (index + 1).odd?\n end\nend",
"def oddities(array)\nresult = []\narray.each_with_index do |value, idx|\n result << value if (idx + 1).odd?\nend\nresult\nend",
"def no_odds(arr)\n\teven_arr = []\n\tarr.each { |x| even_arr << x if x.even?}\n\treturn even_arr\nend",
"def select_every_odd(arr)\n arr.select.each_with_index { |el,idx| if idx % 2 === 1 then true end}\nend",
"def separate_array_into_even_and_odd_numbers(array)\n even_numbers = array.select {|number|number.even?} \n odd_numbers = array.select {|number|number.odd?} \n [even_numbers, odd_numbers]\nend",
"def oddities(array)\n new_array = []\n array.each_with_index { |val, idx| new_array << val if idx.even? }\n new_array\nend",
"def oddities(array)\n array.select { |element| array.index(element).even? }\nend",
"def select_every_odd arr\n ans = []\n arr.each_with_index do |item, i|\n if i%2 == 1 \n ans.push item\n end\n end\n ans\nend",
"def only_odd array\n new_array = array.select { |value| value.is_a?(Integer) && value % 2 != 0}\n p new_array.sort\nend",
"def odd_array(numbers)\n odd_value = []\n \n numbers.each_with_index do |value, idx|\n odd_value << value if idx.even?\n end\n odd_value\nend",
"def odd_order array\n array.select do |value|\n array.sort\n value.odd?\n end\nend",
"def odds_only(array)\n # seperate odd numbers .odd?\n odd_arr = array.select do |val|\n # filter out integers\n if val.is_a? Integer \n # odd numbers only\n val.odd?\n end\n end\n # sort the array\n odd_arr.sort\nend",
"def oddities(array)\n ret_array = []\n array.each_with_index do |value, index|\n if index.even?\n ret_array << value\n end\n end\n ret_array\nend",
"def oddities(array)\n array.select {|item| array.index(item).even?}\nend",
"def oddities(array)\n odd_array = []\n array.each_with_index { |e, idx| odd_array << e if idx.even? }\n odd_array\nend",
"def oddities(array)\n array.select {|element| array.index(element).even?}\nend",
"def oddities(arr)\n arr.select.with_index do |_, idx|\n idx.even?\n end\nend",
"def return_odd(input)\n input.select do |i|\n i.odd?\n end\nend",
"def double_odd_indices(numbers)\n counter = 0\n doubled_numbers = []\n\n loop do\n break if counter == numbers.size\n\n current_number = numbers[counter]\n\n current_number *= 2 if counter.odd?\n doubled_numbers << current_number\n\n counter += 1\n end\n\n doubled_numbers\nend",
"def oddities(array)\n new_array = []\n\n index = 0\n while index < array.size\n new_array << array[index] if index.even?\n index += 1\n end\n new_array\nend",
"def select_every_odd(arr)\n arr.select.with_index { |_, i| i.odd? }\nend",
"def oddities(arr)\n arr.select{ |a| arr.index(a).even? }\nend",
"def no_odds( values )\n evenOnly = []\n values.each do |i|\n if i%2 == 0\n evenOnly.push(i)\n end\n end\n return evenOnly\nend",
"def odds_and_ordered (array)\n # Use filter to take out only the odd numbers\n odd_num_array = array.select do | value |\n (value.instance_of? Integer) && (value % 2 != 0)\n end\n # Sort the array of numbers\n odd_num_array.sort { |a, b| a <=> b}\nend",
"def oddities(input)\n input.select.with_index {|_, index| index.even?}\nend",
"def oddities(array)\n return_array =[]\n array.each_with_index do |element, index|\n return_array << element if index.even?\n end\n return_array\nend",
"def select_every_odd(arr)\n arr.select.with_index { |e, i| e if i.odd? }\nend",
"def select_every_odd(arr)\n arr.each_index.select {|index| index%2!=0}.map{|index| index=arr[index]}\nend",
"def separate_array_into_even_and_odd_numbers(array)\n\ta = [1, 2, 3, 4, 5, 6, 7]\n\teven = a.select { | n | n.even? }\n\todd = a.select { | n | n.odd? }\n\tn = Array.new << even << odd\nend",
"def oddities(arr)\n # Same problem here. arr.index returns the index of the first element with that value. Do not use!\n arr.select.with_index do |elem, index|\n index % 2 == 0\n end\nend",
"def odd_nums_ascending (array)\n #map through array\n #create new array to hold numbers\n num_array = array.select do | num |\n num.class == Integer\n #chaining on select to see if number is odd\n end.select do | num |\n num.odd?\n #sort by ascending\n end.sort\n #return array\n num_array\nend",
"def square_only_odds(numbers)\n odd = []\n square = []\n numbers.each do |number|\n odd.push number if number.odd?\nend\n odd.map do |odd|\n square = odd*odd\n square\n end\nend",
"def oddities(arr)\n arr.select.with_index do |element, index|\n index.even?\n end\nend",
"def double_odd_numbers(numbers)\r\n doubled_numbers = []\r\n counter = 0\r\n\r\n loop do\r\n break if counter == numbers.size\r\n\r\n current_number = numbers[counter]\r\n current_number *= 2 if counter.odd?\r\n doubled_numbers << current_number\r\n\r\n counter += 1\r\n end\r\n\r\n doubled_numbers\r\nend",
"def oddities(init_array)\n odd_bods = []\n init_array.each_with_index do |element, index|\n odd_bods << element if index.odd?\n end\n odd_bods\nend",
"def select_even(integers)\n\nend",
"def oddNum arr\n puts (1..255).select {|i| i%2 != 0}\nend",
"def double_odd_numbers(numbers)\n doubled_numbers = []\n counter = 0\n\n loop do\n break if counter == numbers.size\n\n current_number = numbers[counter]\n current_number *= 2 if current_number.odd?\n doubled_numbers << current_number\n \n\n counter += 1\n end\n\n doubled_numbers\nend",
"def oddities(array)\n odd_element_array = []\n index = 0\n loop do\n break if index >= array.size\n odd_element_array << array[index] if index.even?\n index += 1\n end\n odd_element_array\nend",
"def oddities(array)\n new_array = []\n array.each_with_index do |element, index|\n new_array.push(element) if (index + 1).odd?\n end\n new_array\nend"
] |
[
"0.8712902",
"0.86577994",
"0.8645806",
"0.85709745",
"0.8566933",
"0.85528225",
"0.85220385",
"0.85206103",
"0.84716445",
"0.83593404",
"0.8301404",
"0.7827947",
"0.76841897",
"0.7562744",
"0.7556489",
"0.7534714",
"0.745706",
"0.742582",
"0.7416964",
"0.7403567",
"0.7392426",
"0.7391174",
"0.7384946",
"0.73589176",
"0.7357827",
"0.7348162",
"0.734619",
"0.73416173",
"0.7328514",
"0.73222315",
"0.7321506",
"0.7320138",
"0.72790897",
"0.7277738",
"0.72746086",
"0.726591",
"0.72553533",
"0.72551817",
"0.7254328",
"0.724908",
"0.724803",
"0.72414243",
"0.72411335",
"0.7234792",
"0.7230806",
"0.72304255",
"0.7217058",
"0.7204012",
"0.71998525",
"0.7185713",
"0.718503",
"0.71765304",
"0.7166092",
"0.7157329",
"0.7150694",
"0.71381795",
"0.71175456",
"0.7109068",
"0.7106085",
"0.70960665",
"0.70898324",
"0.70835394",
"0.7083108",
"0.7082029",
"0.70772517",
"0.70686626",
"0.70621705",
"0.7053657",
"0.7043092",
"0.7042107",
"0.7034228",
"0.70321375",
"0.70302105",
"0.70262015",
"0.70230854",
"0.70227563",
"0.7011192",
"0.69792825",
"0.6978494",
"0.6975812",
"0.69643956",
"0.6961377",
"0.6956574",
"0.69539994",
"0.69483685",
"0.6945464",
"0.6942096",
"0.6936792",
"0.6930176",
"0.69256616",
"0.6924173",
"0.69223547",
"0.69144833",
"0.69144166",
"0.6906562",
"0.6903772",
"0.6897737",
"0.68947357",
"0.6891623",
"0.6879819"
] |
0.83804184
|
9
|
=> [] Select Long Words Write a method select_long_words(words) that takes in an array of words and returns a new array containing all of the words of the original array that are longer than 4 characters.
|
def select_long_words(words) # Define method
i = 0 # Set starting index value
new_array = [] # Create new empty array to shovel values into
while i < words.length # Length of word argument array must be less than index value of current iteration
if words[i].length > 4 # Character length of words of index value must be greater than 4
new_array << words[i] # Words of i value then is allowed to be put into array
end
i += 1 # Increase by 1 per iteration til condition no longer logical
end
return new_array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def select_long_words(words)\n i = 0\n newArr = []\n while i < words.length\n if words[i].length > 4\n newArr << words[i]\n end\n i += 1\n end\n return newArr\n end",
"def select_long_words(words)\n\tlongWords = []\n\n\ti = 0\n\twhile i <= words.length\n\t\ttemp = words[i]\n\n\t\tif temp.length > 4\n\t\t\tlongWords << temp\n\t\tend\n\n\t\ti += 1\n\tend\n\n\treturn longWords\nend",
"def select_long_words(words)\n longWords = []\n\tfor i in 0..words.length-1\n word = words[i]\n if word.length > 4\n longWords << word\n end\n end\n return longWords\nend",
"def select_long_words(words)\n\tnew_array = []\n \n\ti = 0\n\twhile i < words.length\n\t\tif words[i].length > 4\n \t\tnew_array << words[i]\n end\n \ti += 1\n end\n \n return new_array\nend",
"def select_long_words(words)\n\ti = 0\n arry = []\n \twhile i < words.length\n if words[i].length > 4\n arry << words[i]\n end\n i += 1\n end\n return arry\nend",
"def select_long_words(words)\n long = []\n\n i = 0\n\n while i < words.length\n word = words[i]\n if word.length > 4\n long << word\n end\n i += 1\n end\n\n return long\nend",
"def select_long_words(words)\n long_words = []\n \n i = 0\n while i < words.length\n if words[i].length > 4\n long_words << words[i]\n end\n \n i += 1\n end\n \n return long_words\nend",
"def select_long_words(words)\n\n new_arr = []\n\n i = 0\n while i < words.length\n if words[i].length > 4\n new_arr << words[i]\n else \n end \n i += 1\n end \n return new_arr\n\nend",
"def long_strings(array)\n array.find_all {|i| i.length > 4}\nend",
"def filter_lengths(strings, length=5)\n big_words = []\n strings.each { |ele| big_words << ele if ele.length >= length }\n return big_words\nend",
"def long_words(words, length)\n # TODO\nend",
"def filter_lengths(strings, length = 5)\n words = []\n strings.each do |word|\n if word.length >= length\n words << word\n end\n end\n return words\nend",
"def find_long\n array = [\"dog\", \"caterpillar\", \"bee\" ]\n\n array.detect do |word|\n word.length > 3\n end\nend",
"def cut_words(length)\n @words = @words.select do |word|\n word.length == length\n end\n end",
"def keep_only_words_of_length(len)\n change_wordlist(@words.select{|word,letters| word.word.length == len })\n end",
"def filter_long_words(sentence, n)\n #your code here\n words = []\n for word in sentence.split(\" \")\n words << word if word.length > n\n end\n words\nend",
"def numbers_larger_than(num_array)\n new_array = []\n num_array.select{|word| \n if word.length > 3\n new_array.push(word)\n end\n }\n words_longer_than(new_array, new_array.length) \nend",
"def big_words(str)\n # split my string into individual words\n # loop over my words\n # check the length of each word\n # if the length of the word is >= 5, keep it. \n # else delete it.\n # return joined words\n\n words = str.split(' ')\n long_words = []\n i = 0\n while i < words.length\n if words[i].length >= 5 #=> words[i] < 5\n # words.delete_at(i) # be careful of delete_at in loops.\n long_words << words[i]\n end\n i += 1\n end\n return long_words.join(' ')\nend",
"def find_words(words, search_letters, max_word_length)\n words.select do |word| \n if word.length > max_word_length\n false\n else\n word_contained_in_letters?(word, search_letters.clone)\n end\n end.flatten.compact.sort {|a,b| a.length <=> b.length }\nend",
"def longest_words(text)\n greatest_length = unique_words(text).map { |word| word.length }.max\n unique_words(text).select do |word|\n word.length == greatest_length\n end\nend",
"def longer_than_three(arr)\n arr.select do |name|\n name.chars.count > 3\n end\nend",
"def proper_length_words\n proper_length = lambda { |line| line.length.between?(5, 12) }\n words = @file_contents.select(&proper_length)\n end",
"def long_strings(arr_long_string)\n #empty array\n more_five = []\n #iterate into how word and know its longitude\n arr_long_string.each do |string|\n if string.length >= 5\n #if its meets enter to the array\n more_five << string\n end\n end\n #return the array with the strings\n more_five\nend",
"def filter_lengths(strings, length=5)\n strings.select { |each| each.length >= length }\nend",
"def remove_long_quotes(array)\n array.select { |e| e.length <= 140 }\nend",
"def filter_lengths(strings, length=5)\n strings.select { |string| string.length >= length }\nend",
"def long_planeteer_calls(words)\n words.any? {|word| word.length > 4}\nend",
"def pick_a_word(length)\n #remove sandwich code and change into map after it gets working\n words = get_words.split(\" \")\n filtered_wrds_by_length = []\n \n words.each do |wrd| #or select method\n if wrd.size == length.to_i\n filtered_wrds_by_length << wrd\n end\n end\n\n chosen_word = filtered_wrds_by_length.sample\n\nend",
"def longest_words(validwords, longest)\n longest_words = []\n validwords.each { |word| longest_words << word if word.length == longest }\n longest_words\nend",
"def test_longest_words_1\n find = Finder.new\n find.valid_arr = [\"SUNSHINE\", \"DOG\", \"CAT\", \"JOY\", \"GREAT\", \"WEEKENDS\"] \n result = find.longest_words(8)\n expected = [\"SUNSHINE\", \"WEEKENDS\"]\n assert_equal expected, result\n end",
"def narrow_search_by_length\n self.dictionary.select { |word| word.length == self.word_length }\n end",
"def long_question (quest_arr)\n quest_arr.select { |question| question.size > 15 }\nend",
"def backwards_wording(words)\n words.select { |word| word.size >= 5 }.map { |word| word.reverse }\n end",
"def long_word_count(text)\n text.split.select {|word| word.length > 7}.count\nend",
"def get_word_list\n @word_list = @lines.reject do |line|\n line.length < 5 || line.length > 12\n end\n end",
"def longest_word(sen)\n tmp_arr = sen.split(\" \")\n tmp_longest = 0\n tmp_arr.each do |i|\n tmp_longest = i.size if i.size > tmp_longest\n end\n\n tmp_arr.select { |i| i.size == tmp_longest }.first\nend",
"def long_planeteer_calls(words)\n words.any? { |word| word.length>4}\nend",
"def collect_words_of_length\n\t\t@dictionary.select! { |el| el.length == @word_length + 1 }\n\t\tmake_smart_dictionary\n\tend",
"def oompa_loompa(array)\n\t\tarray.reject do |word|\n\t\t\tword.length > 3\n\t\tend\n\tend",
"def illegal_words\n @words.select{ |word| word.length > @width }\n end",
"def dictionary_select(length)\n @dictionary = File.readlines('dictionary.txt').map(&:chomp)\n @new_list = @dictionary.select { |word| word.length == length }\n dictionary_narrow\n end",
"def words(init, length)\n @words[init].select { |w| w.size == length }\n end",
"def long_planeteer_calls(array)\n array.any? do |word|\n word.length > 4 \n end \nend",
"def longest_string(list_of_words)\n i=0\n long_string=list_of_words[0]\n list_of_words.each do\n if list_of_words[i].length>long_string.length\n long_string=list_of_words[i]\n end\n i+=1\n end\n return long_string\nend",
"def longest_string(list_of_words)\n list_of_words.max { |a, b| a.length <=> b.length }\n end",
"def longest_word_in_array(array)\n\tn = %w(here is a bunch of words of different lengths)\n\tsorted = n.sort_by! { | word | word.length }\n\tsorted.last\nend",
"def long_planeteer_calls(array)\n array.any? { |word| word.length > 4}\nend",
"def four_words(text)\n four_words = []\n word_array = text.split(\" \")\n word_array.each do |word|\n if word.length == 4\n four_words << word\n end\n end\n four_words\nend",
"def wrap_words(s, limit)\n result = []\n words = s.split(\" \")\n\n line = []\n j = 0\n\n while j < words.size\n line << words[j]\n\n # Use join(\" \") to add space to the string\n if line.join(\" \").size > limit && line.size == 1 # When the word length is longer than the limit\n result << line.join(\" \")\n line = []\n elsif line.join(\" \").size > limit\n line.pop\n result << line.join(\" \")\n line = []\n next\n end\n\n if j == words.size - 1 && line != []# When we reach the end of the array\n result << line.join(\" \")\n end\n\n j += 1\n end\n\n p result\nend",
"def words\n @words ||= dictionary.select { |word| word.length > 3 }\n end",
"def cut_words (words, limit)\n words = words.split(\" \")\n result = \"\"\n result += words.first(limit).join(\" \")\n result += \"...\" if words.length > limit\n raw result\n end",
"def longest_word_in_array(array)\n array.max_by{|word|word.length}\nend",
"def longest_string(list_of_words)\n # Your code goes here!\nend",
"def whisper_words(words)\n\treturn words.map { |word| word.downcase + \"...\" }\nend",
"def reverse_long_words(sentence)\n temp_array = []\n sentence.split.each do |word|\n word.length > 4 ? temp_array.push(word.reverse) : temp_array.push(word)\n end\n temp_array.join(\" \")\nend",
"def long_planeteer_calls(array)\n array.any? do |word|\n word.size > 4\n end\nend",
"def longest_word_in_array(array)\n longest_word = array[0]\n array.each {|word|\n longest_word = word if longest_word.size<word.size\n }\n longest_word\nend",
"def spinWords(string)\n array_of_words = string.split(\" \")\n array_of_words.each do |word|\n if word.length >= 5\n word.reverse!\n end\n end\n return array_of_words.join(\" \")\nend",
"def long_planeteer_calls(array)\n array.any? do\n |word| word.length > 4\n end\nend",
"def words(length)\n WORDS.sample(length)\nend",
"def longest_string(list_of_words)\n longest = nil\n list_of_words.each do |words|\n if longest.nil? || longest.length < words.length\n longest = words\n end\n end\nlongest\nend",
"def longest_string(list_of_words)\n long_string = list_of_words[0]\n list_of_words.each do |measure|\n if long_string.size < measure.size\n long_string = measure\n end\n\n end\n p long_string\nend",
"def clever_octopus(arr)\n longest = \"\"\n arr.each {|el| longest = el if el.length >= longest.length}\n longest\nend",
"def longest_word_in_array(array)\n array.sort_by(&:length).reverse[0]\nend",
"def longest_word(string_of_words)\n\tas_arr = string_of_words.split(\" \")\n\tlengths = as_arr.map {|string| string.length}\n\tmax_length = lengths.max\n return as_arr.reverse.detect {|string| string.length === max_length}\nend",
"def longest_entry(words)\n return words.max_by(&:length)\n end",
"def contains_a_word_longer_than?(min_length)\n collection.any? {|word| word.length > min_length}\n end",
"def longcaps(words)\n if words.length > 10\n words.upcase\n else\n words\n end\nend",
"def shortest_word_in_array(array)\n\tn = %w(here is a bunch of words of different lengths)\n\tsorted = n.sort_by! { | word | word.length }\n\tsorted.first\nend",
"def longest_string(list_of_words)\n index = 0\n counter = 1\n if list_of_words == []\n return nil\n end\n until counter == list_of_words.length\n if list_of_words[index].length > list_of_words[counter].length\n counter += 1\n else\n index = counter\n counter += 1\n end\n end\n return list_of_words[index]\nend",
"def find_shortest_words(str)\n words = str.downcase.split(/[^a-z0-9]/)\n words = words.sort_by {|word| word.size}\n shortest = []\n\n words = words.select {|word| word.size > 0}\n\n size = words[0].size\n words.each do |word|\n break if word.size > size\n shortest << word\n end\n shortest.sort\nend",
"def long_planeteer_calls(words)\n # Your code here\n words.any? do |word|\n word.length > 4\n end\nend",
"def most_common(text, too_short: 3)\n long_enough = each_word_count(text).delete_if{ |word, count| word.length <= too_short }\n\n long_enough.select do |word, count|\n count == long_enough.values.max\n end\nend",
"def longest_string(list_of_words)\n\treturn list_of_words.max {|x,y| x.length <=> y.length}\nend",
"def whisper_words(words)\n return words.map { |word| word.downcase + \"...\" }\nend",
"def whisper_words(words)\n return words.map { |word| word.downcase + \"...\" }\nend",
"def shortest_word_in_array(array)\n array.min_by(&:length)\n # array.min_by { |x| x.length }\nend",
"def whisper_words(words)\r\n return words.map { |ele| ele.downcase + \"...\" }\r\nend",
"def long_word_count(text)\n text.split(' ').count{|word| word.length > 7}\nend",
"def longest_string(list_of_words)\n long_string = list_of_words[0]\n counter = 0\n while counter < list_of_words.length\n if long_string.length < list_of_words[counter].length\n long_string = list_of_words[counter]\n end\n counter += 1\n end\n p long_string\n #return list_of_words.sort {|x,y| y.length <=> x.length}[0]\nend",
"def clever_octopus(arr)\n longest = \"\"\n arr.each do |el|\n longest = el if el.length > longest.length\n end\n longest\nend",
"def get_words_of_length(x)\n arr = []\n self.each do |w|\n if w.length == x\n arr << w\n end\n end\n return arr\n end",
"def words_longer_than(array,num)\n new_array = []\n array.map{ |w|\n new_array.push(w.count(\"e\"))\n }\n letter_per_word(new_array, new_array.length)\nend",
"def longest_string(list_of_words)\n list_of_words.max { |a,b| a.size <=> b.size }\n\nend",
"def clever_octopus(array)\n longest = \"\"\n array.each do |fish|\n if fish.length > longest.length\n longest = fish\n end\n end\n longest\nend",
"def whisper_words(words)\n\treturn words.map {|word| word.downcase + \"...\"}\nend",
"def words_file(words)\n File.read(words).lines.select do |l|\n (3..9).cover?(l.strip.size)\n end\n end",
"def max_word_length(words)\n max_length = 0\n words.each do |word|\n word_length = word.entry.length\n max_length = word_length if max_length < word_length\n end\n max_length\nend",
"def how_many_words(text=\"I'm a cheeky monkey, dude\", num=4)\n x_words = []\n word_array = text.split(\" \")\n word_array.each do |word|\n if word.length == num\n x_words << word\n end\n end\n x_words\nend",
"def longest_string(list_of_words)\n return list_of_words[0] if list_of_words.length <= 1\n\n longest = list_of_words.pop\n trash = []\n\n list_of_words.each do |test_item|\n if test_item.length < longest.length\n trash.push test_item\n else\n trash.push longest\n longest = test_item\n end\n end\n return longest\nend",
"def longest(stringArray)\n\tlongestString = ''\n\tstringArray.each do |word|\n\t\tif word.length > longestString.length\n\t\t\tlongestString = word\n\t\tend\n\tend\n\tp longestString\nend",
"def longest_word_in_array(array)\n array.sort_by { | word | word.size }[-1]\nend",
"def threshold(text, threshold: false)\n thresh = (word_frequency(text).select { |k, v| v > 4})\n threshold ? thresh.reject {|k,v| k.length < 6} : thresh.reject {|k,v| k.length < 4}\nend",
"def get_appropriate_words(dictionary)\n\t\tnew_dictionary = []\n\t\tdictionary.each do |word|\n\t\t\tword.gsub!(\"\\r\\n\",\"\")\n\t\t\tif word.length >= 5 and word.length <= 12\n\t\t\t\tnew_dictionary << word\n\t\t\tend\n\t\tend\n\t\tnew_dictionary\n\tend",
"def test_longest_words_2\n find = Finder.new\n find.valid_arr = [\"HAPPY\"] \n result = find.longest_words(5)\n expected = [\"HAPPY\"]\n assert_equal expected, result\n end",
"def find_longest_word(string)\n array = string.split(\" \")\n p array\n array.max_by(&:length) \nend",
"def longest_string(list_of_words)\n if list_of_words.length > 0\n longest_word = list_of_words[0]\n for word in list_of_words\n if word.length > longest_word.length\n longest_word = word\n end\n end\n return longest_word\n end\nend",
"def words_of_same_length(word)\n\treturn $words[word.length]\nend",
"def longest_string(list_of_words)\n\tif list_of_words==[]\n\t\tnil\n\telse\n\t\tlist_of_words.max_by {|x| x.length}\n\tend\nend",
"def get_the_word\n words = File.readlines(\"5desk.txt\")\n words = words.map do |word|\n word.strip\n end\n words = words.select do |word|\n (word.length > 4) && (word.length < 13)\n end\n words.sample.upcase.split(\"\")\n end"
] |
[
"0.8966248",
"0.8897085",
"0.87760544",
"0.8744303",
"0.8666364",
"0.8653017",
"0.8542003",
"0.8309315",
"0.7300351",
"0.71955514",
"0.71024877",
"0.69761753",
"0.6923362",
"0.68781626",
"0.6877794",
"0.68221897",
"0.68090147",
"0.6804265",
"0.668648",
"0.667948",
"0.66296613",
"0.6585784",
"0.6570337",
"0.6557459",
"0.65431607",
"0.6444857",
"0.63441944",
"0.6336133",
"0.63341415",
"0.63339794",
"0.6323",
"0.63058835",
"0.6261442",
"0.6230307",
"0.6223442",
"0.6189099",
"0.6171953",
"0.6121002",
"0.61082345",
"0.60539746",
"0.6044313",
"0.60321593",
"0.6027004",
"0.59991324",
"0.5983003",
"0.59516627",
"0.5947233",
"0.59413046",
"0.59173334",
"0.59127045",
"0.59075433",
"0.5904859",
"0.5890416",
"0.5871752",
"0.5849269",
"0.5842222",
"0.5839021",
"0.5811849",
"0.57998514",
"0.57996094",
"0.57950205",
"0.57928765",
"0.5772679",
"0.5760516",
"0.57588714",
"0.5752012",
"0.5751099",
"0.574994",
"0.574365",
"0.57414275",
"0.5740994",
"0.57401735",
"0.57397735",
"0.57333827",
"0.5732325",
"0.57159686",
"0.5704977",
"0.5704632",
"0.5703542",
"0.5702343",
"0.57013613",
"0.56925094",
"0.56886554",
"0.5684274",
"0.56803983",
"0.56800336",
"0.5674967",
"0.566628",
"0.5655859",
"0.5654269",
"0.5653999",
"0.56486845",
"0.5636056",
"0.562926",
"0.56229347",
"0.56206185",
"0.5613577",
"0.56044084",
"0.56014675",
"0.5598261"
] |
0.78049564
|
8
|
SUM ELEMENTS CHALLENGE Write a method sum_elements(arr1, arr2) that takes in two arrays. The method should return a new array containing the results of adding together corresponding elements of the riginal arrays. You can assume the arrays have the same length.
|
def sum_elements(arr1, arr2)
i = 0
new_array = []
while i < arr1.length
new_array << arr1[i] + arr2[i]
i += 1
end
return new_array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sum_elements(arr1, arr2)\n i = 0\n newArr = []\n while i < arr1.length\n newArr << arr1[i] + arr2[i]\n i += 1\n end\n return newArr\n end",
"def sum_elements(arr1, arr2)\n\tsum_array = []\n\n\ti = 0\n\twhile i < arr1.length && i < arr2.length\n\t\ttemp = arr1[i] + arr2[i]\n\t\tsum_array << temp\n\n\t\ti += 1\n\tend\n\n\treturn sum_array\nend",
"def sum_arr(arr_1, arr_2)\n [arr_1,arr_2].transpose.map { |el| el.reduce(&:+) }\nend",
"def sum_elements(arr1, arr2)\n\ti = 0\n \tarry = []\n while i < arr1.length\n arry << arr1[i] + arr2[i]\n i += 1\n end\n return arry\nend",
"def sum_elements(arr1, arr2)\n sum = []\n i = 0\n while i < arr1.length\n num = arr1[i] + arr2[i]\n sum << num\n i += 1\n end\n sum\nend",
"def sum_elements(arr1, arr2)\n joined = []\n\n i = 0\n\n while i < arr1.length\n joined << arr1[i] + arr2[i]\n i += 1\n end\n joined\nend",
"def sum_elements(arr1, arr2)\n sum_array = []\n \n i = 0\n while i < arr1.length\n sum_array << arr1[i] + arr2[i]\n \n i += 1\n end\n \n return sum_array\nend",
"def array_addition_calc(array1, array2)\n array1.zip(array2).map &:sum \nend",
"def calculate(arr1, arr2)\n result = []\n arr1.each_with_index do |num, index|\n result << num + arr2[index]\n end\n result\nend",
"def sum_array(a1,a2)\n\t\ta3_0 = a1[0] + a2[0]\n\t\ta3_1 = a1[1] + a2[1]\n\t\treturn [a3_0, a3_1]\n end",
"def add_arrays(arr1,arr2)\n\tcount = 0\n\twhile count < arr1.length\n\t\tputs \"#{arr1[count]} + #{arr2[count]} = #{arr1[count] + arr2[count]}\"\n\t\tcount += 1\n\tend\nend",
"def numbers_sum(input_array)\n output = input_array[0] + input_array[1] # Sums the first array's input with the second array's input\n return output\nend",
"def print_sums(array_1, array_2)\n array_1.each do |num_1|\n array_2.each do |num_2|\n puts num_1 + num_2\n end\n end\nend",
"def sum_combinations(first_array, second_array)\n new_array = []\n first_array.each do |first_number|\n second_array.each do |second_number|\n new_array << first_number + second_number\n end\n end\n new_array\nend",
"def sum_two_arrays(array1, array2)\n sums = array1.zip(array2)\n sums.map! do |p|\n s = p[0] + p[1]\n if s > 26\n s -= 26\n end\n s\n end\n return sums\n end",
"def zip_sum(array, array2)\n new_arr = []\n array.length.times do |index|\n new_arr.push(array[index] + array2[index])\n end\n new_arr\nend",
"def matrix_addition (arr1, arr2)\n new_arr = []\n arr1.each.with_index do|subarr1, idx1|\n new_sub = []\n subarr1.each.with_index do |num1, idx2|\n new_sub << arr1[idx1][idx2] + arr2[idx1][idx2]\n end\n new_arr << new_sub\n end\n\n new_arr\nend",
"def sum_of_sums2(arr)\n arr.zip(arr.length.downto(1)).map { |a, b| a * b }.sum\nend",
"def two_d_sum(arr)\n sum = 0\n arr.each do | el1 |\n el1.each do | el2|\n sum = sum + el2\n end\n end\n puts\n return sum\nend",
"def two_d_sum(arr)\n\ttotal = 0\n\n\t# 1st Level: Looking at each element (these are also arrays)\n\tarr.each do |sub_arr|\n\t\t# 2nd Level: Looking at each elements of these arrays\n\t\tsub_arr.each do |ele|\n\t\t\t# add each element to the total\n\t\t\ttotal += ele\n\t\tend\n\tend\n\n\treturn total\nend",
"def simple_array_sum arr\n arr.reduce(:+)\n end",
"def matrix_addition(a1, a2)\n t = a1.zip(a2)\n t.map { |e1,e2| (e1.is_a? Array) ? matrix_addition(e1,e2) : e1+e2 }\nend",
"def sum_array(numbers)\n return numbers.sum()\nend",
"def total(array1)\n sum=0.0\n array1.each do|i|\n sum+=i\n end\n return sum\n end",
"def simpleArraySum(ar)\n ar.sum\nend",
"def simpleArraySum(ar)\n ar.sum\nend",
"def matrixAddition(a1, a2)\n t = a1.zip(a2)\n t.map { |e1,e2| (e1.is_a? Array) ? matrixAddition(e1,e2) : e1+e2 }\nend",
"def add_array_lengths(array1, array2)\n # length = 0\n # for length in array1\n # return array1.length\n # end\n # for length in array2\n # return array2.length\n # end\n # result = array1 + array2\n result = array1.length + array2.length\n return result\nend",
"def simpleArraySum(ar)\n return ar.map(&:to_i).sum\nend",
"def adds_up(array1, array2, array3)\n result = []\n sum = 0\n\n comb = (array1 + array2).combination(2).to_a\n\n comb.each do |y|\n array3.each do |z|\n if y[0] + y[1] == z\n result.push(y.push(y[0] + y[1]))\n end\n end\n end\n\nreturn result\n\nend",
"def sum_array(any_array)\n any_array.inject(:+)\n end",
"def array_sum(arr)\n arr.reduce(:+)\nend",
"def array_sum(arr)\n arr.reduce(:+)\nend",
"def add_array_lengths(array1, array2)\n return array1.length + array2.length\nend",
"def sum_array(array)\n array.sum\nend",
"def union(*arrays)\n arrays.inject { |all_elements, arr| all_elements + arr }\nend",
"def sum_array(array)\n array.sum\nend",
"def merge_arrays(first, second)\n merged = []\n longest = first.length > second.length ? first : second\n\n longest.each_with_index do |_line, index|\n merged[index] = if first[index] || second[index]\n (first[index].to_i + second[index].to_i)\n end\n end\n\n merged\n end",
"def sum_of_sums(array)\r\nend",
"def matrix_addition(matrix_1, matrix_2)\n new_matrix = Array.new(matrix_1.length) {Array.new(matrix_1.first.length)}\n new_matrix.each_with_index do |array, i1|\n array.each_with_index do |el, i2|\n new_matrix[i1][i2] = matrix_1[i1][i2] + matrix_2[i1][i2]\n end\n end\n new_matrix\nend",
"def sum_array(array)\n sum = 0\n array.each do |element|\n sum += element\n end\n sum\nend",
"def matrix_addition(matrix_1 , matrix_2)\n i = 0\n sum = []\n\n while sum.length < matrix_1.length\n arr_1 = matrix_1[i]\n arr_2 = matrix_2[i]\n\n sum << matrix_plus(arr_1, arr_2)\n\n i += 1\n\n end\n sum\nend",
"def sum_array(array)\n the_sum_of_array = array.sum\n the_sum_of_array\nend",
"def sum_array(integers)\n integers.sum\nend",
"def array_sum(arr)\n arr.reduce(:+)\n\nend",
"def sum_array(int_array)\n int_array.reduce(:+)\nend",
"def array_concat(array1, array2)\n\tarray1 + array2\nend",
"def sum_of_sums(arr)\n multipliers_arr = (1..arr.length).to_a.reverse\n arr.zip(multipliers_arr).map { |a, b| a * b }.sum\nend",
"def add_array_lengths(array1,array2)\n return array1.length+array2.length\nend",
"def sum_array (arr)\n result = 0\n arr.each do |value|\n result +=value\n end\n result\nend",
"def stack_sum(*arrays)\n return [] if arrays.empty?\n \n length = arrays.map(&:length).max\n \n (0...length).map do |i|\n arrays.reduce(0) { |sum, array| sum + array.fetch(i, 0) }\n end\n end",
"def sum_array(array)\n array.reduce(:+)\nend",
"def test_sum_array_2\n expected_sum = 32\n assert_equal expected_sum, Stats.sum(@array2)\n end",
"def matrix_addition(matrix1, matrix2)\n new_matrix = Array.new(matrix1.length) { Array.new(matrix1[0].length) }\n\n (0...matrix1.length).each do |i|\n (0...matrix1[i].length).each do |j|\n new_matrix[i][j] = matrix1[i][j] + matrix2[i][j]\n end\n end\n\n new_matrix\nend",
"def sum(array_of_integers)\n # TODO\nend",
"def two_d_sum(arr)\r\n totalSum = 0\r\n arr.each do |ele|\r\n partialSum = 0\r\n ele.each do |num|\r\n partialSum += num\r\n end\r\n totalSum += partialSum\r\n end\r\n return totalSum\r\nend",
"def sum_array_of_arrays(some_array) \n big_sum = 0 \n \n some_array.each do |x|\n big_sum = big_sum + sum_array(x)\n end\n \n big_sum\n \n end",
"def it_arr_sum(array)\r\n sum = 0\r\n array.each {|ele| sum += ele}\r\n return sum\r\nend",
"def two_d_sum(arr)\n total = 0\n\n arr.each do |sub_array|\n sub_array.each do |num|\n total += num\n end\n end\n\n return total\nend",
"def multi_dimensional_sum(arr)\n return arr.flatten.sum\nend",
"def multi_dimensional_sum(arr)\n arr.flatten.sum\nend",
"def array_concat(array_1, array_2)\n array_1+array_2\nend",
"def sum_array(array)\n # Your code here\nend",
"def two_d_sum(arr)\n\tsum = 0\n arr.each do |subArray|\n subArray.each do |i|\n sum += i\n end\n end\n return sum\nend",
"def array_sum(arr)\n\tsum = 0\n\n\t# an for each loop\n\tfor i in arr\n\t\tsum += i\n\tend\n\t\n\treturn sum\n\t\nend",
"def array_concat(array_1, array_2)\n\tnew_arr = array_1 + array_2\nend",
"def combinations(arr_one, arr_two)\n arr_join = []\n arr_one.each do |x|\n arr_two.each do |y|\n arr_join.push(x + y)\n end\n end\n print arr_join\nend",
"def sum(arr_in)\n\treturn 0 if arr_in.empty?\n\tsum = 0\n\tarr_in.each { |elem| sum += elem }\n\treturn sum\nend",
"def sum_combinations(numbers1, numbers2)\n result = []\n numbers1.each do |number1|\n numbers2.each do |number2|\n result << number1 + number2\n end\n end\n result\nend",
"def sum_combinations(numbers1, numbers2)\n result = []\n numbers1.each do |number1|\n numbers2.each do |number2|\n result << number1 + number2\n end\n end\n result\nend",
"def two_d_sum(array)\n sum = 0 \n array.each do |sub_array|\n sub_array.each do |num|\n sum += num \n end\n end\n\n sum\nend",
"def multi_dimensional_sum(array)\n array.flatten.sum\nend",
"def multi_dimensional_sum(array)\n array.flatten.sum\nend",
"def array_sum(arr)\n arr.reduce(0, :+)\nend",
"def array_sum(arr)\n arr.reduce(0, :+)\nend",
"def array_sum(arr)\n arr.reduce(0, :+)\nend",
"def simpleArraySum(ar)\n #\n # Write your code here.\n #\n ar.reduce(&:+)\nend",
"def arr_addition(arr)\n\tarr.flatten!\n\ti = 0\n\tcount = 0\n\tpairs = []\n\twhile count < arr.length\t\n\t\twhile i < arr.length\n\t\t\tj = i + 1\n\t\t\twhile j < arr.length\n\t\t\t\tif arr[count] == (arr[i] + arr[j])\n\t\t\t\t\tpairs << [arr[i],arr[j]]\n\t\t\t\tend\n\t\t\t\tj += 1\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\t\tcount += 1\n\t\ti = 0\n\tend\n\t\n\treturn pairs.uniq!\nend",
"def array_concat(array_1, array_2)\n return array_1 + array_2\nend",
"def array_concat(array_1, array_2)\n return array_1 + array_2\nend",
"def array_concat(array_1, array_2)\n array_1 + array_2\nend",
"def sum_array(array_num)\n\nend",
"def sum_of_arr(arr)\n arr.inject(:+)\nend",
"def array_sum(arr)\n return arr.reduce(0, :+)\nend",
"def add_array_numbers(array)\n result = array.sum\n # .sum cannot be used on a string, only integars and floats\n return result\nend",
"def sum(array)\n\tarray.reduce(:+)\nend",
"def array_concat(array_1, array_2)\n combined_array = array_1 + array_2\n return combined_array\nend",
"def array_concat(array_1, array_2)\n array_1 + array_2\nend",
"def matrix_addition(m1, m2)\n rows = m1.length\n cols = m1[0].length\n result = Array.new(rows) { Array.new(cols, 0)}\n (0...rows).each do |row|\n (0...cols).each do |col|\n result[row][col] = m1[row][col] + m2[row][col]\n end\n end\n \n result\nend",
"def sum_array(array)\n sum = 0\n array.each do |value|\n sum += value\n end\n sum\nend",
"def array_concat(array_1, array_2)\n\tarray_1 += array_2\nend",
"def sum_array(numbers)\n total = 0\n for number in numbers\n total = total + number\n end\n return total\nend",
"def matrix_addition(matrix1, matrix2)\n new_matrix = Array.new(matrix1.size) { [] }\n\n matrix1.each_index do |i|\n matrix1[i].each_index do |j|\n new_matrix[i] << matrix1[i][j] + matrix2[i][j]\n end\n end\n new_matrix\nend",
"def two_d_sum(arr)\ntotal = 0\n\narr.each do |sub_array|\n sub_array.each do |num|\n total += num\n end\nend\n\nreturn total\nend",
"def sum_upon_sums(array)\n\nend",
"def concat(array1, array2)\n return array1 + array2\nend",
"def matrix_addition(matrix1, matrix2)\n sum_matrix = []\n i = 0\n while i < matrix1.length\n j = 0\n row = []\n while j < matrix1[i].length\n row << matrix1[i][j] + matrix2[i][j]\n j += 1\n end\n sum_matrix << row\n i += 1\n end\n sum_matrix\nend",
"def sum(array)\n array.sum\nend",
"def sum_values(arr)\n arr.inject(:+)\n end",
"def array_concat(array_1, array_2)\n\n combined_array = array_1 + array_2\n return combined_array\n\nend"
] |
[
"0.8315299",
"0.82721746",
"0.80863374",
"0.80506027",
"0.80035174",
"0.7944498",
"0.7908413",
"0.73121536",
"0.7032691",
"0.6919748",
"0.6906139",
"0.6871124",
"0.68354064",
"0.6771543",
"0.6759266",
"0.6736558",
"0.67344266",
"0.6689309",
"0.6530208",
"0.65017974",
"0.64869004",
"0.6482264",
"0.6475393",
"0.64494956",
"0.64337546",
"0.6422517",
"0.6422425",
"0.64171827",
"0.6405755",
"0.6384689",
"0.6359179",
"0.63171035",
"0.63171035",
"0.6304358",
"0.6295473",
"0.62945527",
"0.62904125",
"0.6283635",
"0.6273195",
"0.62724066",
"0.62599117",
"0.625004",
"0.6249174",
"0.62205064",
"0.6217238",
"0.6204656",
"0.6202616",
"0.6199826",
"0.6199033",
"0.61976796",
"0.61959016",
"0.6188909",
"0.61885536",
"0.6181662",
"0.6181369",
"0.6180919",
"0.6173691",
"0.6172925",
"0.61694413",
"0.61688906",
"0.6166153",
"0.6165022",
"0.61566806",
"0.61539686",
"0.61501265",
"0.61427605",
"0.6132967",
"0.6122443",
"0.61200464",
"0.61200464",
"0.610072",
"0.6093692",
"0.6093692",
"0.60920954",
"0.60920954",
"0.60920954",
"0.6087244",
"0.60790217",
"0.6077357",
"0.6077357",
"0.6075789",
"0.60628486",
"0.60589063",
"0.60585177",
"0.6054059",
"0.60492444",
"0.60452837",
"0.60433424",
"0.6037013",
"0.60279363",
"0.6020519",
"0.601684",
"0.60137606",
"0.6006717",
"0.600603",
"0.59958625",
"0.59923285",
"0.59876716",
"0.5979378",
"0.59783626"
] |
0.7848273
|
7
|
=> ["catdog", "pizzapie", "bootcamp"] FIZZ BUZZ CHALLENEGE Write a method fizz_buzz(max) that takes in a number max and returns an array containing all numbers greater than 0 and less than max that are divisible by either 4 or 6, but not both.
|
def fizz_buzz(max) # Define method
i = 0 # Set iteration start
new_array = [] # Create array
while i < max # Set condition that determines how long loop iterates
if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)
new_array << i
end
i += 1 # Increment loop by 1
end
return new_array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fizz_buzz(max)\n\ti = 0\n\tnewArr = []\n \twhile i < max\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n newArr << i\n end\n i += 1\n end\n return newArr\nend",
"def fizz_buzz(max)\n\tnewArr = []\n i = 1\n while i < max\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n newArr << i\n end\n i += 1\n end\n return newArr\nend",
"def fizz_buzz(max)\n newArray = []\n for i in 0..max\n if (i > 0) && (i < max)\n \tif (i % 4 == 0) ^ (i % 6 == 0)\n newArray << i\n end\n end\n end\n return newArray\nend",
"def fizz_buzz(max)\n fizzed = []\n\n i = 1\n while i < max\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n fizzed << i\n end\n i += 1\n end\n\n return fizzed\nend",
"def fizz_buzz(max)\n array = []\n i = 1\n while i < max\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n array << i\n end\n i += 1\n end\n return array\n end",
"def fizz_buzz(max)\n result = [] \n (1...max).each do |num|\n if (num % 4 == 00 || num % 6 == 0) && !(num % 4 == 0 && num % 6 == 0)\n result << num\n end\n\n end\n return result\nend",
"def fizz_buzz(max)\n new_array = []\n \n i = 0\n while i <= max\n if (i % 4 == 0 && i % 6 != 0) || (i % 6 == 0 && i % 4 != 0)\n new_array << i\n end\n \n i += 1\n end\n \n return new_array\nend",
"def fizz_buzz(max)\n nums = []\n \n i = 0\n while (i < max)\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n nums << i\n end\n \n i += 1\n end\n \n return nums\n end",
"def fizz_buzz(max)\n answer = []\n i = 1\n while i < max\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n answer << i\n end\n i += 1\n end\n return answer\nend",
"def fizz_buzz(max)\n fb_arr = [];\n i = 1\n while i < max\n if !(i % 4 == 0 && i % 6 == 0) && (i % 4 == 0 || i % 6 == 0)\n fb_arr << i\n end\n i += 1\n end\n return fb_arr\nend",
"def fizzBuzz(max)\n\tarr = []\n\n\t(1...max).each do |num|\n\t\tif num % 3 == 0 && num % 5 != 0\n\t\t\tarr << num\n\t\tend\n\t\tif num % 3 != 0 && num % 5 == 0\n\t\t\tarr << num\n\t\tend\n\tend\n\n\treturn arr\nend",
"def fizz_buzz(max)\n nums = []\n\n i = 0\n while (i < max)\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n nums << i\n end\n\n i += 1\n end\n\n return nums\nend",
"def fizz_buzz(max)\n nums = []\n\n i = 0\n while (i < max)\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n nums << i\n end\n\n i += 1\n end\n\n return nums\nend",
"def fizz_buzz(max)\n nums = []\n\n i = 0\n while (i < max)\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n nums << i\n end\n\n i += 1\n end\n\n return nums\nend",
"def fizz_buzz(max)\n\ti = 1\n \tarry = []\n while i < max\n if i % 4 == 0 && i % 6 != 0 || i % 4 != 0 && i % 6 == 0\n arry << i\n end\n i += 1\n end\n return arry\nend",
"def fizz_buzz(max)\n arr = [] \n index = 1 \n \n while index < max\n if (index % 4 == 0 || index % 6 == 0) && !(index % 4 == 0 && index % 6 == 0)\n arr << index\n end \n index += 1 \n end \n \n return arr \nend",
"def fizzBuzz2(max)\n sol = []\n\n (1...max).each do |num|\n if !(num % 5 == 0 && num % 3 == 0) && (num % 5 == 0 || num % 3 == 0)\n sol << num\n end\n end\n\n sol\nend",
"def fizz_buzz(max)\n (1...max).select{|number| (number % 4 == 0 || number % 6 == 0) && !(number % 4 == 0 && number % 6 == 0)}\nend",
"def fizzBuzz(max)\n arr = []\n (1...max).each do |num|\n if num % 3 == 0 && num % 5 !==0\n arr << num\n end\n if num % 3 !== 0 && num % 5 ==0\n arr << num\n end\n puts num\n end\n return arr\nend",
"def fizz_buzz(max)\n\n new_arr=[]\n\n i = 1\n while i < max\n if i % 4 == 0 && i % 6 != 0\n new_arr << i \n\n elsif i % 6 == 0 && i % 4 != 0\n new_arr << i \n else \n end\n i += 1\n end\n\n return new_arr\nend",
"def fizzBuzz(max)\n sol = []\n\n (1...max).each do |num|\n if num % 5 == 0 && num % 3 == 0\n next\n elsif num % 5 == 0\n sol << num\n elsif num % 3 == 0\n sol << num\n end\n end\n\n sol\nend",
"def fizzbuzz(max)\n arr =[]\n (1..max).each do |n|\n if n % 3 != 0 && n % 5 != 0\n arr.push n\n else\n val = ''\n if n % 3 == 0\n val = \"fizz\"\n end\n if n % 5 == 0\n val += \"buzz\"\n end\n arr.push val\n end\n end\n arr\nend",
"def fizzbuzz\n zz_array = []\n 1.upto(100) do |num|\n if num % 3 == 0 && num % 5 == 0\n zz_array << 'FizzBuzz'\n elsif num % 3 == 0\n zz_array << 'Fizz'\n elsif num % 5 == 0\n zz_array << 'Buzz'\n else\n zz_array << num\n end\n end\n return zz_array\nend",
"def fizzbuzz(n)\n arr = []\n (1..n).each do |num|\n mod3 = (num % 3).zero?\n mod5 = (num % 5).zero?\n result = ''\n result += 'fizz' if mod3\n result += 'buzz' if mod5\n result.empty? ? arr.push(num) : arr.push(result)\n end\n arr\nend",
"def fizzbuzz\n fizzBuzzArray = Array.new\n for num in 1..100\n if num.to_f / 3.to_f == num/3 && num.to_f / 5.to_f == num/5 then\n\tfizzBuzzArray << 'FizzBuzz'\n elsif num.to_f / 3.to_f == num/3 then\n\tfizzBuzzArray << 'Fizz'\n elsif num.to_f / 5.to_f == num/5 then\n\tfizzBuzzArray << 'Buzz'\n else\n fizzBuzzArray << num\n end\n end\n fizzBuzzArray\nend",
"def fizzbuzz(n)\n array = []\n (1..n).each do |num|\n if num % 15 == 0\n array << \"fizzbuzz\"\n elsif num % 3 == 0\n array << \"fizz\"\n elsif num % 5 == 0\n array << \"buzz\"\n else\n array << num\n end\n end\n return array\nend",
"def fizzbuzz\narray = []\n\tfor i in 1..100\n\t\tif i%3 == 0 && i%5 == 0\n\t\t\tarray << 'FizzBuzz'\n\t\telsif i%3 == 0\n\t\t\tarray << 'Fizz'\n\t\telsif i%5 == 0 \n\t\t\tarray << 'Buzz'\n\t\telse\n\t\t\tarray << i\n \t\t\ti+= 1\n\t\tend\n\tend\n\t\t\treturn array\nend",
"def fizzbuzz(n)\n output_arr = []\n\n (1..n).each do |num|\n if num % 5 == 0 && num % 3 == 0\n output_arr << 'fizzbuzz'\n elsif num % 5 == 0\n output_arr << 'buzz'\n elsif num % 3 == 0\n output_arr << 'fizz'\n else\n output_arr << num\n end\n end\n\n output_arr\nend",
"def fizzbuzz\n i =0\n arr=[]\n while i<=100 do\n if i%3 ==0 && i%5==0\n\t arr.push \"FizzBuzz\"\n\n\t elsif i%3==0\n\t arr.push \"Fizz\"\n\n\t elsif i%5==0\n\t arr.push \"Buzz\"\n\t else\n\t arr.push i\n\t end\n i+=1\n end\n return arr\nend",
"def fizz_buzz_check\n @numbers.collect do |x|\n if multiple_of(15, x)\n 'FizzBuzz'\n elsif multiple_of(3, x)\n 'Fizz'\n elsif multiple_of(5, x)\n 'Buzz'\n else\n x\n end\n end\n end",
"def fizzbuzz\n\tcount = 0\n\tan_array = []\n\twhile count <100\n\t\tan_array[count] = count\n\t\tif count%5 == 0\n\t\t\tan_array[count] = 'Buzz'\n\t\tend\n\t\tif count%3 == 0\n\t\t\tif count%5 == 0\n\t\t\t\tan_array[count] = 'FizzBuzz'\n\t\t\telse\n\t\t\t\tan_array[count] = 'Fizz'\n\t\t\tend\n\t\tend\n\t\tcount +=1\n\tend\n\treturn an_array\nend",
"def super_fizzbuzz(array)\n fizzy=[]\n\tarray.each do |x| \n\t if x%3==0 && x%5==0\n\t\t fizzy << \"FizzBuzz\"\n\t elsif x%5==0\n\t\t fizzy << \"Buzz\"\n\t elsif x%3==0\n\t\t fizzy << \"Fizz\"\n\t else\n\t\t fizzy << x\n\t end\n\tend\nreturn fizzy\nend",
"def super_fizzbuzz(array)\nbuzz_array=[]\narray.map { |number| \n if number % 15 == 0\n \tbuzz_array << \"FizzBuzz\"\n elsif number % 3 == 0\n \tbuzz_array << \"Fizz\"\n elsif number % 5 == 0\n \tbuzz_array << \"Buzz\" \n else\n \tbuzz_array << number\n end\n}\nreturn buzz_array\nend",
"def fizzbuzz(n)\n result = []\n (1..n).each do |num|\n if num % 3 == 0 && num % 5 == 0\n result << \"fizzbuzz\"\n elsif num % 3 == 0\n result << \"fizz\"\n elsif num % 5 == 0\n result << \"buzz\"\n else\n result << num\n end\n end\n result\nend",
"def fizzbuzz(n)\n array = (1..n).to_a\n answer = []\n for i in array do\n if (i % 15 == 0)\n answer.push('FizzBuzz')\n elsif (i % 3 == 0)\n answer.push('Fizz')\n elsif (i % 5 == 0)\n answer.push('Buzz')\n else \n answer.push(i)\n end\n end\n answer\nend",
"def super_fizzbuzz(array)\n\tnew_arr = []\n\tarray.each do |x|\n\t\tif x % 3 == 0 && x % 5 == 0\n\t\t\tnew_arr << \"FizzBuzz\"\n\t\telsif x % 5 == 0\n\t\t\tnew_arr << \"Buzz\"\n\t\telsif x % 3 == 0\n\t\t\tnew_arr << \"Fizz\"\n\t\telse\n\t\t\tnew_arr << x\n\t\tend\n\tend\n\treturn new_arr\n\nend",
"def fizzbuzz(max_val)\n\tcurrent_number = 1\n\twhile current_number <= max_val\n\n\t\tif current_number % 3 == 0\n\t\t\tputs \"fizz\"\n\t\tend\n\t\tif current_number % 5 == 0\n\t\t\tputs \"buzz\"\n\t\tend\n\t\tif current_number % 3 != 0 && current_number % 5 != 0\n\t\t\tputs current_number\n\t\tend\n\t\tcurrent_number += 1\n\tend\nend",
"def fizzbuzz\r\n # your code goes here\r\n arr = []\r\n\r\n for i in 1 .. 30\r\n if i % 5 == 0 && i % 3 == 0\r\n arr << \"fizzbuzz\"\r\n\r\n elsif i % 3 == 0\r\n arr << \"fizz\"\r\n\r\n elsif i % 5 == 0\r\n arr << \"buzz\"\r\n\r\n else arr << i\r\n end\r\n end\r\n arr\r\nend",
"def fizzbuzz\n (1..100).map do |i|\n\tif (i % 15).zero?\n\t 'FizzBuzz'\n\telsif (i % 3).zero?\n\t 'Fizz'\n\telsif (i % 5).zero?\n\t 'Buzz'\n\telse\n\t i\n\tend\n end\nend",
"def pre_fizz(n)\n (1..n).to_a\nend",
"def fizzbuzz(n)\n numbers = []\n (1..n).each do |num|\n if num % 3 == 0\n value = (num % 5 == 0) ? \"fizzbuzz\" : \"fizz\"\n numbers << value\n elsif num % 5 == 0\n numbers << \"buzz\"\n else\n numbers << num\n end\n end\n numbers\nend",
"def super_fizzbuzz(array)\n\tarray.map! do |num|\n\t\tif num % 15 == 0\n\t\t\t\"FizzBuzz\"\n\t\telsif num % 3 == 0\n\t\t\t\"Fizz\"\n\t\telsif num % 5 == 0\n\t\t\t\"Buzz\"\n\t\telse\n\t\t\tnum\n\t\tend\n\tend\nreturn array\t\t\nend",
"def super_fizzbuzz(array)\n new_array = []\n array.each do |i|\n if i % 15 == 0\n new_array << \"FizzBuzz\"\n elsif i % 3 == 0\n new_array << \"Fizz\"\n elsif i % 5 == 0\n new_array << \"Buzz\"\n else\n new_array << i\n end\n end\n\nreturn new_array\nend",
"def super_fizzbuzz(array)\n new_array = []\n array.each do |i|\n if i % 15 == 0\n new_array << \"FizzBuzz\"\n elsif i % 3 == 0\n new_array << \"Fizz\"\n elsif i % 5 == 0\n new_array << \"Buzz\"\n else\n new_array << i\n end\n end\n\nreturn new_array\nend",
"def fizzbuzz(num1 , num2)\n result = []\n arr = (num1..num2).to_a\n arr.each do |n|\n if n % 3 == 0 && n % 5 == 0\n result << 'FizzBuzz'\n elsif n % 3 == 0\n result << 'Fizz'\n elsif n % 5 == 0\n result << 'Buzz'\n else\n result << n\n end\n end\n puts result.join(', ')\nend",
"def super_fizzbuzz(array)\n array.map! {|num| puts \"#{'Fizz' if num % 3 == 0}#{'Buzz' if num % 5 == 0}#{num if num % 5 != 0 && num % 3 != 0}\"}\nend",
"def fizz_buzz\n [*1..100].map do |num|\n if num % 5 == 0 && num % 3 == 0\n 'FizzBuzz'\n elsif num % 5 == 0\n 'Buzz'\n elsif num % 3 == 0\n 'Fizz'\n else\n num\n end\n end\nend",
"def fizz_buzz_woof(max)\n 1.upto(max).each do |x|\n if (x % 3 == 0) && (x % 5 == 0) && (x % 7 == 0)\n puts \"FizzBuzzWoof\"\n elsif (x % 3 == 0) && (x % 5 == 0)\n puts \"FizzBuzz\"\n elsif (x % 3 == 0) && (x % 7 == 0)\n puts \"FizzWoof\"\n elsif (x % 5 == 0) && (x % 7 == 0)\n puts \"BuzzWoof\"\n elsif x % 3 == 0\n puts \"Fizz\"\n elsif x % 5 == 0\n puts \"Buzz\"\n elsif x % 7 == 0\n puts \"Woof\"\n else\n puts x\n end\n end\nend",
"def fizzbuzz\n an_array = Array.new(100)\n for cnt in 1..100\n l3_rem = cnt%3\n l5_rem = cnt%5\n if l3_rem == 0 && l5_rem != 0\n an_array[cnt -1 ] = 'Fizz'\n elsif l3_rem != 0 && l5_rem == 0\n an_array[ cnt -1 ] = 'Buzz'\n elsif l3_rem == 0 && l5_rem == 0\n an_array[ cnt - 1] = 'FizzBuzz'\n else\n an_array[ cnt - 1] = cnt\n end\n end\n return an_array\nend",
"def super_fizzbuzz(array)\n\tnew_array = []\n\tarray.each do |num| \n\t\tif num % 15 == 0\n\t\t\tnew_array << \"FizzBuzz\"\n\t\telsif num % 3 == 0\n\t\t\tnew_array << \"Fizz\"\n\t\telsif num % 5 == 0\n\t\t\tnew_array << \"Buzz\"\n\t\telse \n\t\t\tnew_array << num\n\t\tend\n\tend\n\tnew_array\nend",
"def fizzbuzz(maxNumber)\n\n\tfor count in 1..maxNumber\n\t\tif count % 15 == 0 then\n\t\t\tprint \"fizzbuzz\"\n\t\telsif count % 3 == 0 then\n\t\t\tprint \"fizz\"\n\t\telsif count % 5 == 0 then\n\t\t\tprint \"buzz\"\n\t\telse\n\t\t\tprint count\n\t\tend\n\t\tprint \"\\n\"\n\tend\nend",
"def super_fizzbuzz(array)\n array.map! do |num|\n if (num % 3 == 0 && num % 5 == 0 && num % 15 == 0)\n \"FizzBuzz\"\n elsif (num % 3 == 0)\n \"Fizz\"\n elsif (num % 5 == 0)\n \"Buzz\"\n else\n num\n end\n end\n array\nend",
"def super_fizzbuzz(array)\n new_array = []\n array.each do |x|\n if x % 3 == 0 && x % 5 == 0\n new_array << \"FizzBuzz\"\n elsif x % 3 == 0\n new_array << \"Fizz\"\n elsif x % 5 == 0\n new_array << \"Buzz\"\n else\n new_array << x\n end\n end\n new_array\nend",
"def super_fizzbuzz(array)\n\tarray.collect do |i|\n \tif i % 15 == 0\n \t\t\"FizzBuzz\"\n \telsif i % 5 == 0\n \t\t\"Buzz\"\n \telsif i % 3 == 0\n \t\t\"Fizz\"\n \telse\n \t\ti\n \tend\n \tend\nend",
"def super_fizzbuzz(array)\n\tfizzbuzzed_array = []\n\tarray.each do |element|\n\t\tif element % 15 == 0\n\t\t\tfizzbuzzed_array << \"FizzBuzz\"\n\t\telsif element % 3 == 0\n\t\t\tfizzbuzzed_array << \"Fizz\"\n\t\telsif element % 5 == 0\n\t\t\tfizzbuzzed_array << \"Buzz\"\n\t\telse\n\t\t\tfizzbuzzed_array << element\n\t\tend\n\tend\n\tfizzbuzzed_array\nend",
"def fizzbuzz\n # TODO write your code here\n fizz_array = []\n\n for count in 1..100\n if (count%3 == 0 && count%5 == 0)\n fizz_array[count] = 'FizzBuzz'\n elsif count%3 == 0\n fizz_array[count] = 'Fizz'\n elsif count%5 == 0\n fizz_array[count] = 'Buzz'\n else\n fizz_array[count] = count\n end\n end\n\n fizz_array\nend",
"def super_fizzbuzz(array)\n fizzbuzz_array = []\n counter = 0\n while counter < array.length\n if array[counter] % 3 == 0 && array[counter] % 5 != 0\n fizzbuzz_array << \"Fizz\"\n elsif array[counter] % 5 == 0 && array[counter] % 3 != 0\n fizzbuzz_array << \"Buzz\"\n elsif array[counter] % 3 == 0 && array[counter] % 5 == 0\n fizzbuzz_array << \"FizzBuzz\"\n else\n fizzbuzz_array << array[counter]\n end\n counter += 1\n end\n p fizzbuzz_array\nend",
"def fizzbuzz(n)\n myary = []\n myn = 1\n (0...n).each do\n if myn % 15 == 0\n myary << \"FizzBuzz\"\n myn += 1\n elsif myn % 5 == 0\n myary << \"Buzz\"\n myn += 1\n elsif myn % 3 == 0\n myary << \"Fizz\"\n myn += 1\n else\n myary << myn\n myn += 1\n end\n end\n myary\nend",
"def fizzbuzz(num)\n collection = (1..num).to_a\n collection.each do |num|\n if (num % 3 == 0) && (num % 5 != 0)\n puts \"Fizz #{num}\"\n elsif (num % 5 == 0) && (num % 3 != 0)\n puts \"Buzz #{num}\"\n elsif (num % 3 == 0) && (num % 5 == 0)\n puts \"FizzBuzz #{num}\"\n end\n end\nend",
"def fizzbuzz(num1, num2)\n array = []\n (num1..num2).each do |num|\n if num % 3 == 0 && num % 5 == 0\n array << \"FizzBuzz\"\n elsif num % 3 == 0\n array << \"Fizz\"\n elsif num % 5 == 0\n array << \"Buzz\"\n else\n array << num\n end\n end\n puts array.join(\", \")\nend",
"def fizz_buzz_for_range(from, to)\n results = []\n (from..to).each do |n|\n results.push fizz_buzz(n)\n end\n results\n end",
"def fizzbuzz(start_num, end_num)\n new_arr = []\n (start_num..end_num).each do |num|\n case \n when (num % 3 == 0) && (num % 5 == 0)\n new_arr << \"FizzBuzz\"\n when num % 5 == 0\n new_arr << \"Buzz\"\n when num % 3 == 0 \n new_arr << \"Fizz\" \n else\n new_arr << num\n end\n end\n puts new_arr.join(', ')\nend",
"def fizz_buzz(min, max)\n (min..max).each do |number|\n puts fizz_buzz_calculator(number)\n end\nend",
"def super_fizzbuzz(array)\n\tarray = [1..100]\n\tarray.each do |num|\n\t\tif num % 3 == 0 \n\t\t\tprint \"Fizz\"\n\t\tend \n\t\tif num % 5 == 0 \n\t\t\tprint \"Buzz\"\n\t\tend \n\t\tif num % 15 == 0 \n\t\t\tprint \"FizzBuzz\"\n\t\tend \n\tend \nend",
"def fizzbuzz(num1, num2)\n array = (num1..num2).to_a\n fizzbuzz = array.map do |n|\n if n % 3 == 0 && n % 5 == 0\n 'FizzBuzz'\n elsif n % 5 == 0\n 'Buzz'\n elsif n % 3 == 0\n 'Fizz'\n else \n n\n end\n end\n fizzbuzz.join(' ')\nend",
"def super_fizzbuzz(array)\n buzz_array = []\n array.each do |x|\n if x % 3 == 0 && x % 5 != 0\n buzz_array.push(\"Fizz\")\n elsif x % 3 != 0 && x % 5 == 0\n buzz_array.push(\"Buzz\")\n elsif x % 3 == 0 && x % 5 == 0\n buzz_array.push(\"FizzBuzz\")\n else\n buzz_array.push(x)\n end\n end\n p buzz_array\nend",
"def fizzbuzz_without_modulo\n ints = []\n for i in 1..50\n ints.push(i)\n end\n\n (1..100).each do |x|\n if ints.include?(x/5.0)\n puts(ints.include?(x/3.0) ? 'fizzbuzz' : 'fizz')\n else\n puts(ints.include?(x/3.0) ? 'buzz' : x)\n end\n end\nend",
"def super_fizzbuzz(array)\n array.map! do |x|\n if x % 15 == 0\n \"FizzBuzz\"\n elsif x % 5 == 0\n \"Buzz\"\n elsif x % 3 == 0\n \"Fizz\"\n else\n x\n end\n end\nend",
"def super_fizzbuzz(array)\n array.map do |value|\n if (value % 3 == 0 && value % 5 == 0)\n 'FizzBuzz'\n elsif (value % 3 == 0)\n 'Fizz'\n elsif (value % 5 == 0)\n 'Buzz'\n else\n value\n end\n end\nend",
"def fizzbuzz(num1, num2)\n arr = Array(num1..num2).map! do |num|\n if num % 3 == 0 && num % 5 == 0\n 'FizzBuzz'\n elsif num % 3 == 0\n 'Fizz'\n elsif num % 5 == 0\n 'Buzz'\n else\n num\n end\n end.join(', ')\n print arr\nend",
"def fizzbuzz(n)\n arr = []\n (1..n).each do |i|\n case\n when (i % 3 == 0) && (i % 5 == 0) then arr << \"fizzbuzz\"\n when i % 3 == 0 then arr << \"fizz\"\n when i % 5 == 0 then arr << \"buzz\"\n else arr << i\n end\n end\n arr\nend",
"def fizzbuzz(number)\n ret = []\n ret << \"Fizz\" if number % 3 === 0\n ret << \"Buzz\" if number % 5 === 0\n ret.length === 0 ? nil : ret.join\nend",
"def fizzbuzz(starting, ending)\n result = []\n (starting..ending).each do |num|\n if num % 3 == 0 && num % 5 == 0\n result << \"FizzBuzz\"\n elsif num % 3 == 0\n result << \"Fizz\"\n elsif num % 5 == 0\n result << \"Buzz\"\n else\n result << num\n end\n end\n puts result.join(\", \")\nend",
"def fizzbuzz(num1, num2)\n numbers = num1..num2\n fizzbuzz_array = []\n numbers.each do |x|\n case\n when x % 3 == 0 && x % 5 == 0\n fizzbuzz_array << \"FizzBuzz\"\n when x % 3 == 0\n fizzbuzz_array << \"Fizz\"\n when x % 5 == 0\n fizzbuzz_array << \"Buzz\"\n else\n fizzbuzz_array << x\n end\n end\n\n p fizzbuzz_array.join(\", \")\nend",
"def fizzbuzz(num_1, num_2, range)\n # sets 1 to range (last number) where each number will do the following\n (1..range).each do |i|\n # if the remainder of each number i divided by the first number num_1 should have a zero AND\n # the remainder of each number i divided by the second number num_2 should have a zero\n if i % num_1 === 0 && i % num_2 === 0\n # then print 'fizzbuzz'\n puts 'fizzbuzz'\n # otherwise, if the remainder of number i divdied by num_1 should have a zero\n elsif i % num_1 === 0\n # then print 'fizz'\n puts 'fizz'\n # otherwise, if the remainder of number i divided by num_2 should have a zero\n elsif i % num_2 === 0\n # then print 'buzz'\n puts 'buzz'\n else\n # if all the conditions above are not met, then print the number i\n puts i\n end\n end\nend",
"def fizzbuzz(array)\n\tfor num in array\n\t\tif num % 15 == 0\n\t\t\tputs \"fizzbuzz\"\n\t\telsif num % 3 == 0\n\t\t\tputs \"fizz\"\n\t\telsif num % 5 == 0\n\t\t\tputs \"buzz\"\n\t\telse \n\t\t\tputs num.to_s\n\t\tend\n\tend\nend",
"def super_fizzbuzz(array)\n array.map {|x|\n if x % 15 == 0\n \"FizzBuzz\"\n elsif x % 3 == 0\n \"Fizz\"\n elsif x % 5 == 0\n \"Buzz\"\n else\n x\n end\n }\nend",
"def fizzbuzz(start_num, end_num)\n (start_num..end_num).map do |n|\n if n % 3 == 0 && n % 5 == 0\n 'FizzBuzz'\n elsif n % 3 == 0\n 'Fizz'\n elsif n % 5 == 0\n 'Buzz'\n else\n n\n end\n end\nend",
"def fizz_buzz(start: 1, stop: 100)\n (start..stop).to_a.map do |n|\n next 'FizzBuzz' if n % 15 == 0\n next 'Fizz' if n % 3 == 0\n next 'Buzz' if n % 5 == 0\n\n n\n end\nend",
"def fizzbuzz(max_val)\n\tcounter = 1\n\twhile (counter <=max_val)\n\t\t\n\t\tif (counter %3 ==0)\n\t\t\tputs \"fizz\"\n\t\tend \n\n\t\tif (counter %5 ==0)\n\t\t\tputs \"buzz\"\n\t\tend\n\t\tif (counter %5 !=0 && counter %3 !=0)\n\t\t\tputs counter \n\t\tend\n\n\t\t# else \n\t\t# \tputs counter \n\t\t# end\n\t\tcounter +=1\n\tend\n\nend",
"def fizzbuzz(n)\n (1..n).map do |n|\n if n%3==0 && n%5==0\n \"fizzbuzz\"\n elsif n%3==0\n \"fizz\"\n elsif n%5==0\n \"buzz\"\n else\n n\n end\n end\nend",
"def super_fizzbuzz(array)\n\tarray.map do |num| #got rid of the ! that I had in the original solution. There's no need to alter the underlying array here.\n\t\tif num % 15 == 0\n\t\t\t\"FizzBuzz\"\n\t\telsif num % 5 == 0\n\t\t\t\"Buzz\"\n\t\telsif num % 3 == 0\n\t\t\t\"Fizz\"\n\t\telse\n\t\t\tnum\n\t\tend\n\tend\nend",
"def fizzbuzz(num_1, num_2, range)\n#from integer 1 to argument range above, execute the code below for each element. variable i stands for the element in the range the program is currently using at the time.\n (1..range).each do |i|\n#conditional, if variable i modulo argument num_1 is equal to 0 AND variable i modulo argument num_2 is also equal to 0, print string \"fizzbuzz\"\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n#if the above conditional is not true, check if variable i modulo argument num_1 is equal to 0 by itself. if true, print string \"fizz\"\n elsif i % num_1 === 0\n puts 'fizz'\n#if neither of the above conditionals are true, check if variable i modulo argument num_2 is equal to 0 by itself. if true, print string \"buzz\"\n elsif i % num_2 === 0\n puts 'buzz'\n#if none of the above conditionals are found to be true, print the value of variable i (the number in the range the program was checking)\n else\n puts i\n end\n end\nend",
"def fizzbuzz(a,b)\n numbers = (a..b).to_a\n\n numbers.each do |number|\n if number % 15 == 0\n puts \"FizzBuzz\"\n elsif number % 3 == 0\n puts \"Fizz\"\n elsif number % 5 == 0\n puts \"Buzz\"\n else\n puts number\n end\n end\nend",
"def fizzBuzz\n (1..100).each do |x|\n a = []\n a << \"FizzBuzz\" if x % 15 == 0 \n a << \"Fizz\" if x % 3 == 0 \n a << \"Buzz\" if x % 5 == 0\n a << x\n puts a\n end\nend",
"def fizzbuzz(num1, num2)\n array = []\n\n num1.upto(num2) do |num|\n if (num % 3 == 0) && (num % 5 == 0)\n array << \"FizzBuzz\"\n elsif num % 5 == 0\n array << \"Buzz\"\n elsif num % 3 == 0\n array << \"Fizz\"\n else\n array << num\n end\n end\n array.join(', ')\nend",
"def fizzbuzz(num_1, num_2, range)\n#create a loop that iterates from 1 up to the value of the argument range\n# variable i gets assigned another value after each loop\n (1..range).each do |i|\n# in each iteration, if i is divided by num_1 and has 0 remainder (modulo)\n# AND if i is divided by num_2 and has 0 remainders, 'fizzbuzz' will print out\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n# if condition is not met from above, then if only i divided by num_1 has 0\n#remainder, then only print out 'fizz'\n elsif i % num_1 === 0\n puts 'fizz'\n# Or if only i divided by num_2 has 0 remainder, then only print out 'buzz'\n elsif i % num_2 === 0\n puts 'buzz'\n# if the three conditions above are not true then just print out value of i\n else\n puts i\n end\n #iterate the loop to the next value in the range\n end\n # when all values within the range are finished, end the loop\nend",
"def fizzbuzz(num1, num2)\n answer = []\n index = 0\n (num1..num2).to_a.each do |num|\n answer[index] = \"\"\n answer[index] << \"Fizz\" if num % 3 == 0\n answer[index] << \"Buzz\" if num % 5 == 0\n answer[index] << num.to_s if num % 3 !=0 && num % 5 != 0 \n index += 1\n end\n puts answer.join(\", \")\nend",
"def fizzbuzz?(x)\n x % 3 == 0 && x % 5 == 0\n end",
"def fizzbuzz_iterator range_from , range_to\n (range_from..range_to).each do |i|\n if divisible_by?(i,3) && divisible_by?(i,5)\n @fizzbuzz_array << \"FizzBuzz\"\n elsif divisible_by?(i,3)\n @fizzbuzz_array << \"Fizz\"\n elsif divisible_by?(i,5)\n @fizzbuzz_array << \"Buzz\"\n else\n @fizzbuzz_array << i\n end\n end\n end",
"def fizzbuzz\n\ty = (1..100)\n\ty.each { |x|\n\t\tif x % 3 == 0 && x % 5 == 0\n\t\t\tputs \"fizzbuzz\"\n\t\telsif x % 3 == 0\n\t\t\tputs \"fizz\"\n\t\telsif x % 5 == 0\n\t\t\tputs \"buzz\"\n\t\telse\n\t\t\tputs x\n\t\tend\n\t}\nend",
"def fizzbuzz\n\tnum_arr = Array.new(100) {|index| index+1}\n\tarr = Array.new(100) {''}\n\tnum_arr.each do |i|\n\n\t \tif i%3 == 0\n\t \t\tif i%5 == 0\n\t \t\t\tarr[i-1] = 'FizzBuzz'\n\t \t\telse\n\t \t\t\tarr[i-1] = 'Fizz'\n\t \t\tend\n\t \telsif i%5 == 0\n\t \t\tarr[i-1] = 'Buzz'\n\t \telse\n\t \t\tarr[i-1] = i.to_s\n\t \tend\n\t end\n \tarr\nend",
"def fizzbuzz(start, last)\n array = (start..last).map do |num|\n if (num % 3 == 0 && num % 5 == 0)\n 'FizzBuzz'\n elsif (num % 3 == 0)\n 'Fizz'\n elsif (num % 5 == 0)\n 'Buzz'\n else\n num.to_s \n end\n end\n puts array.join(', ')\nend",
"def fizzbuzz_iterator(range_from, range_to)\n (range_from..range_to).each do |i|\n if divisable_by_given?(i, 3) && divisable_by_given?(i, 5)\n @fizzbuzz_array << 'FizzBuzz'\n elsif divisable_by_given?(i, 3)\n @fizzbuzz_array << 'Fizz'\n elsif divisable_by_given?(i, 5)\n @fizzbuzz_array << 'Buzz'\n else\n @fizzbuzz_array << i\n end\n end\n end",
"def fizzbuzz(start_int, finish_int)\n i = start_int\n output_array = []\n\n while i <= finish_int\n if i % 3 == 0 && i % 5 == 0\n output_array << \"FizzBuzz\"\n elsif i % 3 == 0\n output_array << \"Fizz\"\n elsif i % 5 == 0\n output_array << \"Buzz\"\n else\n output_array << i\n end\n\n i += 1\n end\n output_array.join(\", \")\nend",
"def print_list(limit)\n\n 1.upto(limit) do |number|\n\n if divisible_by?(15, number)\n puts \"Fizzbuzz\"\n\n elsif divisible_by?(3, number)\n puts \"Fizz\"\n\n elsif divisible_by?(5, number)\n puts \"Buzz\"\n\n else\n puts number\n\n end\n end\nend",
"def fizzbuzz(number)\n #if the number is divisible by both 3 and 5\n if number % 3 == 0 && number % 5 == 0\n \"FizzBuzz\"\n #else div by only 3\n elsif number % 3 == 0\n \"Fizz\"\n #else div by only 5\n elsif number % 5 == 0\n \"Buzz\"\n #else nil\n end\nend",
"def fizzbuzz(num_1, num_2, range)\n# Do i for all the numbers in a range from 1 to the value that will be assigned to the variable \"range\".\n (1..range).each do |i|\n# If i divided by the value assigned to num_1 is equal to 0 and i divided by the value assigned to num_2 is equal to zero then print \"fizzbuzz\".\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n# If i divided by the value assigned to num_1 is equal to zero print \"fizz\".\n elsif i % num_1 === 0\n puts 'fizz'\n# If i divided by the value assigned to num_2 is equal to zero print \"buzz\".\n elsif i % num_2 === 0\n puts 'buzz'\n# If none of the previous conditions are true print i.\n else\n puts i\n# Ends the if/else statement.\n end\n# Ends the argument.\n end\n# Ends the method.\nend",
"def fizzbuzz(num_1, num_2, range)\n (1..range).each do |i|\n if i % num_1 === 0 && i % num_2 === 0\n puts 'fizzbuzz'\n elsif i % num_1 === 0\n puts 'fizz'\n elsif i % num_2 === 0\n puts 'buzz'\n else\n puts i\n end\n end\nend",
"def fizzbuzz(number)\n if number % 5 == 0 && number % 3 == 0\n return \"FizzBuzz\"\n end\n if number % 3 == 0\n return \"Fizz\"\n end\n if number % 5 == 0\n return \"Buzz\"\n end\nend"
] |
[
"0.8674005",
"0.862002",
"0.861987",
"0.8609624",
"0.86006236",
"0.8569152",
"0.85605323",
"0.84954715",
"0.8493324",
"0.84929466",
"0.84867674",
"0.8390373",
"0.8390373",
"0.8390373",
"0.83895755",
"0.83839566",
"0.8375027",
"0.8315841",
"0.8214323",
"0.820697",
"0.79041404",
"0.7873394",
"0.75030136",
"0.74424446",
"0.7437415",
"0.7426686",
"0.73765767",
"0.7358375",
"0.7334258",
"0.72579384",
"0.7236691",
"0.7215825",
"0.72037333",
"0.7193733",
"0.71628845",
"0.71563196",
"0.7147631",
"0.71227705",
"0.7118841",
"0.71182495",
"0.71102536",
"0.7105126",
"0.70918196",
"0.70918196",
"0.7088163",
"0.70814544",
"0.70724475",
"0.7069662",
"0.7064248",
"0.70534414",
"0.70448565",
"0.70439684",
"0.7040426",
"0.7029034",
"0.70189506",
"0.70125175",
"0.6992911",
"0.6982987",
"0.69828105",
"0.6972307",
"0.696647",
"0.69512886",
"0.6951226",
"0.6948722",
"0.69306403",
"0.6929761",
"0.692721",
"0.69261795",
"0.6902665",
"0.68989205",
"0.6894627",
"0.6893608",
"0.686627",
"0.6860726",
"0.6842027",
"0.68364626",
"0.68291783",
"0.68266475",
"0.68258536",
"0.681976",
"0.6818223",
"0.6817594",
"0.68170416",
"0.67841756",
"0.6761797",
"0.6756935",
"0.6756634",
"0.6753194",
"0.6747539",
"0.67372054",
"0.6736395",
"0.67263496",
"0.6711538",
"0.67087895",
"0.6701529",
"0.669859",
"0.66974235",
"0.66846085",
"0.66842926",
"0.66821754"
] |
0.8362696
|
17
|
Checks if the action is currently supported
|
def validate_action(label, body)
action = PaneAction.for(label)
raise ArgumentError, "Unsupported action: #{label}" unless action
action.validate(body)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def action_argument_required?\n !AVAILABLE_ACTIONS.empty?\n end",
"def available_action?(action_name); end",
"def supported?\n return false unless ALL_SUPPORTED_ACTIONS.include?(request.action_type)\n type = @type = request.action_type.to_sym\n @normalized_type = NORMALIZED_ACTION_MAP.fetch(type, type)\n return false if NON_IDEMPOTENT_TYPES[type] && !request.post?\n\n case type\n when :mtm_edit\n return false unless model.supported_action?(type, request)\n if request.id && (assoc = request.params['association'])\n return false unless model.supported_mtm_edit?(assoc, request)\n @params_association = assoc.to_sym\n end\n\n @title = \"#{model.class_name} - #{TITLE_MAP[type]}\"\n when :mtm_update\n return false unless request.id && (assoc = request.params['association']) && model.supported_mtm_update?(assoc, request)\n @params_association = assoc.to_sym\n when :association_links\n @subtype = subtype\n return false unless model.supported_action?(@subtype, request)\n when :autocomplete\n if assoc = request.id\n return false unless model.association?(assoc)\n @params_association = assoc.to_sym\n @subtype = :association\n return false unless associated_class = model.associated_model_class(@params_association)\n return false unless associated_class.autocomplete_options_for(@subtype, request)\n else\n @subtype = subtype\n return false unless model.autocomplete_options_for(@subtype, request)\n end\n else\n return false unless model.supported_action?(normalized_type, request)\n\n @title = \"#{model.class_name} - #{TITLE_MAP[@normalized_type]}\"\n end\n\n true\n end",
"def actions_available?(user)\n actions_allowable?(user)\n end",
"def action?\n action_channel.in_use?\n end",
"def available_action?(action_name)\n _find_action_name(action_name)\n end",
"def interface_supports(action)\n @interface.respond_to?(action)\n end",
"def available_actions\n fail NotImplementedError\n end",
"def supported_for_action?(field)\n return true if field['action'].nil? || @action.nil?\n return field['action'].include?(@action.to_s) if field['action'].is_a?(Array)\n\n field['action'] == @action.to_s\n end",
"def valid?(action)\n self.respond_to?(action.to_sym) && VALID_ACTIONS.include?(action)\n end",
"def can?(action)\n @allowed_fields.include? action\n end",
"def check_features\n case params[:action]\n when \"index\"\n current_features.include?('shift_index') ? true : invalid_features\n when \"new\"\n current_features.include?('shift_new') ? true : invalid_features\n when \"edit\"\n current_features.include?('shift_edit') ? true : invalid_features\n when \"destroy\"\n current_features.include?('shift_delete') ? true : invalid_features\n end\n # return true\n end",
"def action_allowed?(action_name, user)\n return false\n end",
"def valid_action?(value)\n action_names.include?(value)\n end",
"def allows?(action)\n return true if self.action == 'all'\n \n case action.to_sym\n when :new, :create\n self.action == 'create'\n when :index, :show\n self.action == 'read'\n when :edit, :update\n self.action == 'update'\n when :destroy\n self.action == 'delete'\n else # fallback: if @param action is already a CRUD action\n self.action == action\n end\n end",
"def valid_action?(name, resource = resource_class)\n disabled_actions.exclude?(name.to_s) && super\n end",
"def can?(action, feature)\n !!(get_feature(feature) =~ /#{action.to_s}/)\n end",
"def has_action?(action)\n @actions.include? action\n end",
"def allowed?\n raise NotImplementedError, 'please implement #allowed? '\\\n \"for #{self.class.name} which should decide if the action is allowed, \"\\\n 'based on the given attributes'\n end",
"def has_actions?\n if self.actions == []\n return false\n else\n return true\n end\n end",
"def valid?\n \n \n if @action.nil?\n return false\n end\n\n \n \n allowed_values = [\"DELETE\", \"EXPORT\"]\n if @action && !allowed_values.include?(@action)\n return false\n end\n \n \n \n \n if @action_date.nil?\n return false\n end\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n if @conversation_query.nil?\n return false\n end\n\n \n \n \n \n end",
"def actions?\n non_empty?(@actions)\n end",
"def allowed_to?(action, project, options={})\n \ttrue\n end",
"def special_action?\n SPECIAL_ACTIONS.include?(action.to_sym)\n end",
"def check_features\n case params[:action]\n when \"index\"\n current_features.include?('department_index') ? true : invalid_features\n when \"new\"\n current_features.include?('department_new') ? true : invalid_features\n when \"edit\"\n current_features.include?('department_edit') ? true : invalid_features\n when \"delete_multiple\"\n current_features.include?('department_delete') ? true : invalid_features\n end\n # return true\n end",
"def permit?(action)\n # then check action permissions\n case action\n when :files\n agent?\n else\n false\n end\n end",
"def action_defined?\n # ReputationThreshold.action_defined?(self.action, self.tier)\n !self.action_points.nil?\n end",
"def action_want_to_perform(arg)\r\n self.class.actions_allowed[arg]\r\n end",
"def resource_action?(resource_type, action)\n resource_check?(:actions, resource_type, action)\n end",
"def _valid_action_name?(action_name); end",
"def check_features\n case params[:action]\n when \"index\"\n current_features.include?('employee_leave_management_index') ? true : invalid_features\n when \"new\"\n current_features.include?('employee_leave_management_add') ? true : invalid_features\n when \"edit\"\n current_features.include?('employee_leave_management_edit') ? true : invalid_features\n when \"delete_multiple\"\n current_features.include?('employee_leave_management_delete') ? true : invalid_features\n when \"update_status\"\n current_features.include?('employee_leave_management_change_status') ? true : invalid_features\n end\n return true\n end",
"def action_allowed?\n case params[:action]\n when 'show', 'set_priority', 'index'\n ['Instructor',\n 'Teaching Assistant',\n 'Administrator',\n 'Super-Administrator',\n 'Student'].include?(current_role_name) &&\n ((%w[list].include? action_name) ? are_needed_authorizations_present?(params[:id], 'participant', 'reader', 'submitter', 'reviewer') : true)\n else\n ['Instructor',\n 'Teaching Assistant',\n 'Administrator',\n 'Super-Administrator'].include? current_role_name\n end\n end",
"def has_work?\n @action_name && @input && @options\n end",
"def single_actions?\n false\n end",
"def respond_to?(method, include_private = false)\n (actions(current_api).include? method) ? true : super\n end",
"def check_features\n # case params[:action]\n # when \"index\"\n # current_features.include?('feature_key') ? true : invalid_features \n # end\n return true\n end",
"def validate_action?(action)\n\t\tres = subset?([action], @action_list)\n\t\tif ! res\n\t\t\tputs \"Action #{action}, is not valid\"\n\t\tend\n\n\t return res\n\tend",
"def check_features\n case params[:action]\n when \"index\"\n current_features.include?('holiday_index') ? true : invalid_features\n when \"new\", \"create\"\n current_features.include?('holiday_new') ? true : invalid_features\n when \"edit\", \"update\"\n current_features.include?('holiday_edit') ? true : invalid_features\n when \"destroy\"\n current_features.include?('holiday_delete') ? true : invalid_features\n end\n # return true\n end",
"def can?(_action, _action_feat)\n wrapper = ActionWrapper.new(self, _action, _action_feat)\n begin\n provider = if brk_provider.is_a? Symbol then self.method(brk_provider) else brk_provider end\n wrapper.instance_eval &provider\n return false\n rescue Interrupt\n return (if wrapper.tag.nil? then true else wrapper.tag end)\n end\n end",
"def check_features\n case params[:action]\n when \"index\"\n current_features.include?('division_index') ? true : invalid_features\n when \"new\"\n current_features.include?('division_new') ? true : invalid_features\n when \"edit\"\n current_features.include?('division_edit') ? true : invalid_features\n when \"destroy\"\n current_features.include?('division_delete') ? true : invalid_features\n when \"delete_multiple\"\n current_features.include?('division_delete') ? true : invalid_features\n end\n end",
"def can_advance_with(name)\n self.available_actions.any? {|e| e.name == name }\n end",
"def action_allowed?\n current_user_has_ta_privileges?\n end",
"def action_allowed?\n current_user_has_ta_privileges?\n end",
"def allowed_to?(action)\n if action.is_a? Hash\n allowed_actions.include? \"#{action[:controller]}/#{action[:action]}\"\n else\n allowed_permissions.include? action\n end\n end",
"def action_defined?(action, tier=nil)\n if tier && !tier.accept_default_reputation_threshold\n if rate = tier.find_reputation_threshold_action_points(action)\n return !!rate.points\n end\n end\n respond_to?(action.to_sym)\n end",
"def visible_action?(name)\n true #['perform', action_name].include? name\n end",
"def supports?\n raise \"Method 'supports?' must be defined\"\n end",
"def has_action?(name)\n !!find_action_by_name(name)\n end",
"def supports?\n fail \"Method 'supports?' must be defined\"\n end",
"def supported?\n false\n end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def arguments_valid?\n ret = false\n ret = true unless (@options.action == nil)\n end",
"def action?(*action)\n \t\taction.include?(params[:action])\n \tend",
"def registration_enabled?\n configured?(:self_registration) || raise_unknown_action_error \n end",
"def determine_valid_action\n\n end",
"def action_class?\n instance_variable_defined?(:@new_resource)\n end",
"def member_action?\n member_actions.include?(action)\n end",
"def allows?(action, controller)\n return true if controller == self.resource && self.action == 'all'\n \n controller == self.resource && case action.to_s when 'new', /(create)/\n self.action == 'create'\n when 'index', /(show)/\n self.action == 'read'\n when /(edit)/, /(update)/\n self.action == 'update'\n when /(destroy)/\n self.action == 'delete'\n else # fallback: if :action is already a CRUD action\n self.action == action\n end\n end",
"def supported?(method)\n !@operations.include?(MAP.fetch(method))\n end",
"def action_method?(name)\n self.class.action_methods.include?(name)\n end",
"def respond_to?(method)\n return true if !enabled? || soap_actions.include?(method)\n super\n end",
"def invalid?\n action_enum = action rescue nil\n !action_enum || (ack_required? && !has_serial?)\n end",
"def check_options action, modes\n if modes['help']\n display_options(action)\n exit\n end\n options = action.options\n unsupported = modes.keys.select{|k| !options.has_key?(k.to_sym)}\n return if unsupported.empty?\n $stderr.puts \"Action --#{action_name action} does not support #{unsupported.size >1 ? 'these options' : 'this option'}: #{unsupported*', '}\"\n display_options(action, $stderr)\n exit 1\n end",
"def action_method?\n nil\n end",
"def action_allowed?\n if %w[edit update list_submissions].include? params[:action]\n current_user_has_admin_privileges? || current_user_teaching_staff_of_assignment?(params[:id])\n else\n current_user_has_ta_privileges?\n end\n end",
"def requires_photographer_action\n self.requests.each do |r|\n if r.state == \"action_needed\"\n return true\n end\n end\n false\n end",
"def action_defined?(action, controller)\n if registered?(controller)\n return true if storage[controller][:actions].include?(action)\n\n fail Vedeu::Error::ActionNotFound,\n \"#{action} is not registered for #{controller}.\".freeze\n\n else\n fail Vedeu::Error::ControllerNotFound,\n \"#{controller} is not registered.\".freeze\n\n end\n end",
"def can?(action, resource, options = {})\n resource = resource.model_name if resource.is_a?(Class)\n\n return false if !resources.include?(resource)\n return true if resources[resource].include?(\"all\")\n\n action = options[:special] ? action : action.acl_action_mapper\n\n resources[resource].extract_settings.include?(action)\n end",
"def last_request_update_allowed?\n action_name != \"timeout\"\n end",
"def action_blocked?(action)\n @blocked_actions.include?(action)\n end",
"def identification_required?\n !(controller_name == \"championships\" && action_name == \"show\")\n end",
"def check_features\n case params[:action]\n when \"index\"\n current_features.include?('employee_index') ? true : invalid_features\n when \"export\"\n current_features.include?('employee_export') ? true : invalid_features\n when \"new\"\n current_features.include?('employee_new') ? true : invalid_features\n when \"edit\"\n current_features.include?('employee_edit') ? true : invalid_features\n when \"delete_multiple\"\n current_features.include?('employee_delete') ? true : invalid_features\n when \"show\"\n current_features.include?('employee_detail') ? true : invalid_features\n when \"multiple_user\"\n current_features.include?('employee_user') ? true : invalid_features\n # Mutasi\n when \"mutasi\"\n current_features.include?('mutation_index') ? true : invalid_features\n # Formasi\n when \"formasi\"\n current_features.include?('formation_index') ? true : invalid_features\n # Status\n when \"status\"\n current_features.include?('status_index') ? true : invalid_features\n end\n # return true\n end",
"def check_if_user_can_perform_action_on_resources\n if @item && @item.is_a?(Typus.user_class)\n check_if_user_can_perform_action_on_user\n else\n not_allowed if admin_user.cannot?(params[:action], @resource.model_name)\n end\n end",
"def action_defined?(action, controller)\n if registered?(controller)\n return true if storage[controller][:actions].include?(action)\n\n fail Vedeu::Error::ActionNotFound,\n \"#{action} is not registered for #{controller}.\"\n\n else\n fail Vedeu::Error::ControllerNotFound,\n \"#{controller} is not registered.\"\n\n end\n end",
"def action?(*action)\n action.include?(params[:action])\n end",
"def action?(*action)\n action.include?(params[:action])\n end",
"def check_if_user_can_perform_action_on_resource\n resource = params[:controller].remove_prefix.camelize\n not_allowed if admin_user.cannot?(params[:action], resource, { :special => true })\n end",
"def action_defined?(action, controller)\n if registered?(controller)\n return true if storage[controller][:actions].include?(action)\n\n raise Vedeu::Error::ActionNotFound,\n \"#{action} is not registered for #{controller}.\"\n\n else\n raise Vedeu::Error::ControllerNotFound,\n \"#{controller} is not registered.\"\n\n end\n end",
"def action_method?(name); end",
"def only_action_instances?\n only? :action_instances\n end",
"def supported?\n !!@supported_proc.call\n end",
"def can? action, service\n allowed_actions = [ALL]\n allowed_actions << decode_action(action)\n permission_index = MasasService.position(service)\n\n allowed_actions.include?(permissions_store[permission_index])\n end",
"def can! action, object\n can?(action, object) || raise(ActiveModel::ActionNotAllowed, action)\n end",
"def collection_action?\n collection_actions.include?(action)\n end",
"def available?(params)\n unavailability_reasons(params).empty?\n end",
"def store_action?(action)\n %w(AddCard AddCardWithUniqueReference RemoveCard).include? action\n end",
"def can? action, &block\n @action = action.to_s.sub('?','') + '?'\n @action = @action.to_sym\n\n # pre check\n raise RuntimeError, 'Method name not allowed' if %w(can).index(@action)\n raise NoMethodError, %[Policy check \"#{action}\" not found in #{self.class}] unless respond_to?(@action)\n\n call &block\n end",
"def requestable?\n (ill? || available? || recallable? ||\n processing? || on_order? || offsite? || ezborrow?)\n end",
"def valid_action?(value)\n # TODO: implement octal check\n false\n end",
"def mandate_given_action_external?\n @mandate_given_action && (@mandate_given_action.to_s =~ /^external$/i) ? true : false\n end",
"def mobile_exempt?\n self.class.instance_variable_get(\"@mobile_exempt_actions\").try(:include?, params[:action].to_sym)\n end",
"def menu_action?(action)\n action.to_s.end_with?(SELECT_ACTION_SUFFIX)\n end",
"def allowed?\n # If the agent's busy state will clear this turn, this action\n # could happen. We intentionally don't send a \"disallowed\"\n # notification for the action. It's not cancelled, nor is it\n # dispatched successfully. It's just waiting for a later tick to\n # do one of those two things.\n return false if @agent.state[\"busy\"] > 1\n\n # A dilemma: if we cancel now when no actions are queued, then\n # any action queued this turn (e.g. from an\n # EveryXActionsIntention) won't be executed -- we said this\n # intention wasn't happening. If we *don't* return false in the\n # \"allowed?\" phase then we'll wind up sending out a cancel\n # notice every turn when there are no actions. So we add a\n # \"silent\" info option to the normal-every-turn cancellations,\n # but we *do* allow-then-cancel even in perfectly normal\n # circumstances.\n true\n end",
"def editing_supported?\n !(is_multivalued? || is_resource?)\n end",
"def has_access?( action )\n unless @sir_log.permitted_to_access?( current_user.id )\n render_no_access\n return false\n end\n return true if [ 'index', 'new', 'create', 'show_stats' ].include?( action_name )\n unless current_user.permission_to_access( feature_identifier, action, @sir_item.group_id )\n render_no_permission \n return false \n end\n return true\n end",
"def inner_check(action, resource)\n false\n end",
"def action_allowed?(action_name)\n # TODO: this does some unnecessary work\n compute_allow_and_deny(action_name).then do\n\n deny = @__deny_fields == true || (@__deny_fields && @__deny_fields.size > 0)\n\n clear_allow_and_deny\n\n !deny\n end\n end",
"def match?(action, object)\n true\n end",
"def valid?\n controller_class = begin\n controller_name.constantize\n rescue NameError\n return false\n end\n controller_class.lambda_functions.include?(action_name.to_sym)\n end",
"def request_allowed?(request)\n true\n end",
"def can?(user, action)\n return false unless @actions.key? action\n user.power_in(@room) >= @actions[action]\n end"
] |
[
"0.7865723",
"0.78390485",
"0.7521905",
"0.72955316",
"0.72715336",
"0.72662115",
"0.72453874",
"0.72301155",
"0.7182697",
"0.717772",
"0.7119915",
"0.7035781",
"0.7024137",
"0.7005573",
"0.6927771",
"0.68774325",
"0.6872005",
"0.6849777",
"0.68364644",
"0.68363476",
"0.6703896",
"0.6673138",
"0.666032",
"0.66497225",
"0.6645425",
"0.66191053",
"0.6613515",
"0.6604264",
"0.659531",
"0.65910155",
"0.65708673",
"0.656043",
"0.6528385",
"0.65160453",
"0.6514155",
"0.6505183",
"0.6487567",
"0.6480813",
"0.647613",
"0.6453142",
"0.644264",
"0.6423958",
"0.6423958",
"0.6419161",
"0.64050484",
"0.64022344",
"0.6399697",
"0.63892215",
"0.6383742",
"0.6378938",
"0.63741505",
"0.6360626",
"0.63502175",
"0.634514",
"0.6338602",
"0.63288796",
"0.6294773",
"0.6294464",
"0.6257641",
"0.62487304",
"0.6247003",
"0.62461585",
"0.624469",
"0.62437785",
"0.62331486",
"0.6232717",
"0.6221843",
"0.62216276",
"0.62112916",
"0.6198608",
"0.61976475",
"0.61942023",
"0.61925113",
"0.61892277",
"0.61887985",
"0.61883205",
"0.6179937",
"0.6179502",
"0.6175368",
"0.6169889",
"0.6167745",
"0.6163173",
"0.61623216",
"0.615805",
"0.6143011",
"0.61409616",
"0.6134298",
"0.6096224",
"0.60961336",
"0.6092918",
"0.609231",
"0.6081928",
"0.60819054",
"0.60791",
"0.6076702",
"0.606002",
"0.60568106",
"0.6054183",
"0.60537076",
"0.6045",
"0.60416967"
] |
0.0
|
-1
|
Checks if the given hash only contains one mapping from a nonempty string to a hash
|
def single_spec?(spec, *klasses)
(key, value), second = spec.take(2)
second.nil? && valid_name?(key) &&
(klasses.empty? || klasses.any? { |k| value.is_a?(k) })
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def empty?(hash)\n hash unless hash.empty?\n end",
"def is_unique_with_hash?(str)\n hash = {}\n str.each_char do |ch|\n if hash[ch]\n return false\n else \n hash[ch] = true\n end \n end \n true\nend",
"def hash?(hash)\n return false if hash.nil?\n if hash =~ /^[a-fA-F0-9]{40}$/\n return true\n end\n false\n end",
"def valid_hash?(h)\n h.match(/^[0-9a-z]+\\$[0-9a-z]+\\$[0-9a-z]+\\$[A-Za-z0-9]{16,64}\\$[A-Za-z0-9]{32,1024}$/) != nil\n end",
"def valid_hash?(h)\n h.match(/^[0-9a-z]+\\$[0-9a-z]+\\$[0-9a-z]+\\$[A-Za-z0-9]{16,64}\\$[A-Za-z0-9]{32,1024}$/) != nil\n end",
"def unique_with_hash?(str)\n chars_hash = Hash.new(0)\n chars = str.split(\"\")\n chars.each do |char|\n chars_hash[char] += 1\n end\n chars_hash.values.each do |value|\n if value > 1\n return false\n end\n return true\n end\nend",
"def isUnique(string) \n if (string.length > 128) \n return false \n end\n hash = {}\n i = 0\n while (i < string.length)\n if(hash[string[i]] === true) \n return false\n else \n hash[string[i]] = true\n end\n i+=1\n end\n return true\nend",
"def hash_correct?(hash)\n hash.keys.all? { |key| ALLOWED_KEYS.include?(key) }\n end",
"def methodChecksIfStringUnique(parameter_string) \n\thash_to_return = {}\n\n\tparameter_string.each_char do |char|\n\t\thash_to_return[char].nil? ? hash_to_return[char] = true : (return false)\n\tend\n\n\ttrue\n\t\nend",
"def isHash?(str)\n\t\tstr =~ /^[0-9a-fA-F]+$/\n\tend",
"def check_name(hash, name_to_check)\n hash.each_key do |name|\n if name == name_to_check\n true\n else\n false\n end\n end\nend",
"def validate_hash(info)\r\n\t\t# passes in the parsed info\r\n\t\tstring_to_hash = get_string_to_hash(info)\r\n\t\tcorrect_hash = get_hash(string_to_hash)\r\n\t\t#puts string_to_hash\r\n\t\treturn correct_hash.strip == info['self_hash'].strip\r\n\tend",
"def check_or_create_for!(hash, key)\n hash[key] = \"\" unless hash.include?(key)\n end",
"def includes? hash\n hash.each_pair do |key, value|\n return false unless send(\"#{key}\") == value\n end\n true\n end",
"def include?(hash)\n self.key.each_pair do |key, value|\n unless value === hash[key]\n return false\n end\n end\n true\n end",
"def check(hash)\n # not implemented\n end",
"def opt_unique?(str)\n\texists = {}\n\tfor i in 0..str.length-1\n\t\tif exists[str[i]]\n\t\t\treturn false\n\t\telse\n\t\t\texists[str[i]] = true\n\t\tend\n\tend\n\ttrue\nend",
"def hash_and_matches_redundant_keys?(key, value)\n value.is_a?(Hash) && REDUNDANT_KEYS.any? { |sym| sym == key }\n end",
"def hash_exists?(id)\n @hashes.has_key? id\n end",
"def valid_hash?(h)\n h =~ /^\\$[0-9a-z]{2}\\$[0-9]{2}\\$[A-Za-z0-9\\.\\/]{53}$/\n end",
"def empty?\n @hash.empty?\n end",
"def empty?\n @hash.empty?\n end",
"def empty?\n @hash.empty?\n end",
"def valid_hash?(digest)\n Argon2::HashFormat.valid_hash?(digest)\n end",
"def valid_hash?(h)\n self.class.valid_hash?(h)\n end",
"def is_string_unique?(str)\n # If the string doesn't meet the minimum requirements\n return false if str.length > 128\n\n # Store the keys in our hash\n chars = {}\n str.each_byte do |s|\n # Break out as early as we can\n return false if chars.has_key? s\n chars[s] = true\n end\n\n true\n end",
"def _validate_presence_of_hash(hash)\n\t\thash.each_pair do |key, value|\n\t\t\t_validate_presence_of value\n\t\tend\n\n\tend",
"def unique_chars?(string)\n hash = Hash.new(0)\n string.each_char do |char|\n hash[char] +=1\n end\n # hash.select { |key, value| block } returns an array with key,value pairs\n array = hash.select { |key,value| value > 1}\n if array.length > 0\n return false\n else\n return true\n end\n\nend",
"def unique?(string)\n arr = string.split('')\n my_hash = Hash.new\n \n arr.each do |char|\n if my_hash[char] != nil\n my_hash[char] += 1\n else\n my_hash[char] = 1\n end\n end\n \n my_hash.each do |key, value|\n if my_hash[key] > 1\n return false\n end\n end\n return true\nend",
"def unique_chars?(string)\n hash = {}\n string.each_char do |char|\n if hash[char].nil?\n hash[char] = true\n else\n return false\n end\n end\n true\nend",
"def str_chars_unique? str\n checker = {}\n str.codepoints.each do |c|\n if checker[c] == nil\n checker[c] = true\n else\n return false\n end\n end\n return true\nend",
"def validate_hash(the_input, the_array)\n nil_values(the_input)\n incorrect_keys(the_input, the_array)\n end",
"def is_unique?(string)\n char_hash = {}\n \n string.each_char do |char|\n if char_hash[char]\n return false\n else\n char_hash[char] = true\n end\n end\n \n return true\nend",
"def empty?\n hash.keys.empty?\n end",
"def is_valid_hash(entry)\n\n return false if entry.nil?\n return false unless entry.parse_ok?\n\n last_line = _get_last_line(entry.pid)\n unless last_line.nil?\n computed_hash = ChainLog::Formatter.hash_str(last_line.chomp)\n entry.valid_chain = (computed_hash == entry.hash)\n\n if @verbose\n puts '\"' + last_line + '\"'\n puts computed_hash + \" vs #{entry.hash}\"\n end\n\n end\n\n # compute hash of this line for next call\n\n _set_last_line(entry.pid, entry.line)\n\n entry.valid_chain\n end",
"def has_key?(name)\n hashed.has_key? name\n end",
"def name_exists?(stdname, arr_of_hashes)\n\t!arr_of_hashes.select { |hash| hash[:name] == stdname }.empty?\nend",
"def key_of_type?(hash, key, type)\n return false unless hash.length == 1\n\n hash.key?(key) && hash[key].is_a?(type)\n end",
"def test_dict_to_hash_not_empty\n assert @grapher.dict_to_hash(Set.new(['a', 'bd'])).size > 0\n end",
"def empty?\n @hash.empty?\n end",
"def empty?\n @hash.empty?\n end",
"def populated_hash?(obj)\n obj.is_a?(Hash) && !obj.empty?\n end",
"def empty?\n to_hash[name].respond_to?(:empty?) && to_hash[name].empty?\n end",
"def unique_hash_already_exists?\n return Entry.where(feed_id: self.feed_id, unique_hash: self.unique_hash).exists?\n end",
"def commit_hash?(string)\n string =~ /^\\h{7,40}$/\n end",
"def hash_in_argument_hash\n argument_hash = {} if argument_hash.nil?\n return true\n end",
"def func_none(hash)\n hash.none? {|key, value| value.nil?}\nend",
"def is_unique?(str)\n letters = {}\n\n str.chars.each do |char|\n return false if letters[char]\n letters[char] = true\n end\n\n true\nend",
"def any_blank_fields?(hash, fields)\n fields = [fields] unless fields.kind_of? Array\n fields.any? { |f| hash[f].blank? }\n end",
"def valid_hash?(digest)\n self.class.valid_hash?(digest)\n end",
"def unique?(*keyarray)\n raise \"Key(s) required\" if keyarray.empty?\n keyarray = keyarray.flatten\n keys = map {|hash| hash.key_for(keyarray)}\n return false if keys.any?(&:nil?)\n keys.uniq.count == self.count\n end",
"def check!(hash)\n build!(hash)\n return hash\n end",
"def is_unique(string)\n return false if string.length > 128\n characters = Hash.new\n \n string.each_char do | char | \n return false if characters.has_key? char\n characters[char] = true\n end\n \n return true \nend",
"def include_hash? hash\n return super unless hash.class <= ::Hash\n return (hash.to_a - self.to_a).empty?\n end",
"def Unique(string)\n\n # assumes alphabet of size 128\n return false if string.length > 128\n \n hash={}\n \n for i in 0..string.length-1\n return false if hash[string[i]] \n hash[string[i]]=true\n end\n \n \nreturn true\n\nend",
"def exists_with(hash)\n\t\tcolumn = hash.keys.first\n\t\tcheck_column(column.to_s)\n\t\tvalue = hash[column]\n\t\tresult = @db.execute(\n\t\t\t\"SELECT * FROM #{@table} WHERE #{column.to_s} IS ?\", \n\t\t\tvalue\n\t\t)\n\n\t\tif(result.size == 0)\n\t\t\tfalse\n\t\telse\n\t\t\ttrue\n\t\tend\n\tend",
"def strat_check(hash)\n return hash unless hash.instance_of?(Hash)\n hash.each do |key, val|\n raise NoSuchStrategyError unless (val =~ /[RSP]/i)\n end\nend",
"def has_key(hash, key)\n\thash.has_key? key\nend",
"def test_check_hash_unequal\r\n assert_equal false, @g.check_hash(1, 0)\r\n end",
"def unique(string)\n letter_count = {}\n\n # Iterate through the string, if we have not seen the letter_count\n # place it in the hash, if we have seen it return false\n string.split('').each do |char|\n if letter_count[char]\n return false\n else\n letter_count[char] = true\n end\n end\n\n # If we get to this point there are no duplicates, return true\n true\nend",
"def test_invalid_empty_dict_to_hash\n assert @grapher.dict_to_hash(Set.new([])).size.zero?\n end",
"def is_in_set?(word)\n\t\t# iterate over the hashes and recalc the hash value for the word. If the location in the bitmap is 0, then return false, meaning that the word is DEFINITELY not in the set\n\t\t@hashes.each do |hash|\n\t\t\treturn false if @bitmap[hash.hash_this(word.chomp)] == 0\n\t\tend\n\n\t\ttrue # return true meaning that it is likely to be in the set\n\tend",
"def has_hash_value?(key)\n self.each do |entity|\n entity.each_pair{|hash_key, value| return true if value == key}\n end\n return false\n end",
"def valid?\n return false if !@_hash.nil? && @_hash.to_s.length > 40\n return false if !@_hash.nil? && @_hash.to_s.length < 40\n true\n end",
"def has_key?(p0) end",
"def clean_hash hash\n hash ||= {}\n hash = hash.map do |k,v|\n if v.is_a? Hash\n [k,clean_hash(v)]\n else\n [k,v]\n end\n end\n hash = Hash[hash]\n Hash[hash.select do |k,v|\n if v.is_a? Hash\n v.size > 0\n else\n v.present?\n end\n end]\n end",
"def empty?\n to_hash.empty?\n end",
"def identify_hash(hash)\n hash = hash.to_s.strip\n case\n # operating systems\n when hash.start_with?('$1$') && hash.length == 34\n return 'md5'\n when hash.start_with?('$2$') && hash.length == 59,\n hash.start_with?('$2a$') && hash.length == 60,\n hash.start_with?('$2b$') && hash.length == 60,\n hash.start_with?('$2x$') && hash.length == 60,\n hash.start_with?('$2y$') && hash.length == 60\n return 'bf' #bcrypt\n when hash.start_with?('$5$') && hash.split('$').last.length == 43\n # we dont check full length since it may have 'rounds=' in the [1] area or not with an arbitrary length number\n return 'sha256,crypt'\n when hash.start_with?('$6$') && hash.split('$').last.length == 86\n # we dont check full length since it may have 'rounds=' in the [1] area or not with an arbitrary length number\n return 'sha512,crypt'\n when hash.start_with?('@S@') && hash.length == 148\n return 'qnx,sha512'\n when hash.start_with?('@s@') && hash.length == 84\n return 'qnx,sha256'\n when hash.start_with?('@m@') && hash.length == 52\n return 'qnx,md5'\n when hash.start_with?('_') && hash.length == 20\n return 'des,bsdi,crypt'\n when hash =~ /^[\\.\\/\\dA-Za-z]{13}$/ # hash.length == 13\n return 'des,crypt'\n when hash =~ /^\\$dynamic_82\\$[\\da-f]{128}\\$HEX\\$[\\da-f]{32}$/ # jtr vmware ldap https://github.com/rapid7/metasploit-framework/pull/13865#issuecomment-660718108\n return 'dynamic_82'\n when hash.start_with?(/{SSHA}/i)\n return 'ssha'\n when hash.start_with?(/{SHA512}/i)\n return 'raw-sha512'\n when hash.start_with?(/{SHA}/i)\n return 'raw-sha1'\n when hash.start_with?(/{MD5}/i)\n return 'raw-md5'\n when hash.start_with?(/{SMD5}/i)\n return 'smd5'\n when hash.start_with?(/{SSHA256}/i)\n return 'ssha256'\n when hash.start_with?(/{SSHA512}/i)\n return 'ssha512'\n # windows\n when hash.length == 65 && hash =~ /^[\\da-fA-F]{32}:[\\da-fA-F]{32}$/ && hash.split(':').first.upcase == 'AAD3B435B51404EEAAD3B435B51404EE'\n return 'nt'\n when hash.length == 65 && hash =~ /^[\\da-fA-F]{32}:[\\da-fA-F]{32}$/\n return 'lm'\n # OSX\n when hash.start_with?('$ml$') && hash.split('$').last.length == 256\n return 'pbkdf2-hmac-sha512,osx' # 10.8+\n when hash =~ /^[\\da-fA-F]{48}$/ # hash.length == 48\n return 'xsha,osx' # 10.4-10.6\n # databases\n when hash.start_with?('0x0100') && hash.length == 54\n return 'mssql05'\n when hash.start_with?('0x0100') && hash.length == 94\n return 'mssql'\n when hash.start_with?('0x0200') && hash.length == 142\n return 'mssql12'\n when hash =~ /^[\\da-f]{16}$/ # hash.length == 16\n return 'mysql' # mysql323 (pre 4.1)\n when hash.start_with?('*') && hash.length == 41\n return 'mysql-sha1' # mysql 4.1+\n when hash.start_with?('md5') && hash.length == 35\n return 'postgres'\n when hash =~ /^[\\da-fA-F]{16}$/\n return 'des,oracle' # pre 11g\n when hash =~ /^S:[\\dA-F]{60}$/\n return 'raw-sha1,oracle11'\n when hash =~ /^S:[\\dA-F]{60};H:[\\dA-F]{32};T:[\\dA-F]{160}$/\n return 'raw-sha1,oracle'\n when hash =~ /^H:[\\dA-F]{32};T:[\\dA-F]{160}$/\n return 'pbkdf2,oracle12c'\n # webapps\n when hash.start_with?('$P$') && hash.length == 34,\n hash.start_with?('$H$') && hash.length == 34\n return 'phpass' # wordpress, drupal, phpbb3 (H not P)\n when hash.start_with?('$ml$') && hash.length == 203\n return 'PBKDF2-HMAC-SHA512'\n when hash.start_with?('{PKCS5S2}') && hash.length == 73\n return 'PBKDF2-HMAC-SHA1'\n when hash.start_with?('$B$') && hash.split('$').last.length == 32\n return 'mediawiki'\n # mobile\n when hash =~/^[A-F0-9]{40}:[a-f0-9]{16}$/\n return 'android-sha1'\n when hash =~/^[A-F0-9]{32}:[a-f0-9]{16}$/\n return 'android-md5'\n # other\n when hash =~ /^<\\d+@.+?>#[\\w]{32}$/\n return 'hmac-md5'\n when hash.length == 114 && hash.start_with?('$M$')\n return 'F5-Secure-Vault'\n when hash =~ /^M\\$[[:print:]]+#[\\da-fA-F]{32}(?:(?::[[:print:]]*$)|$)/\n return 'mscash'\n when hash =~ /^\\$DCC2\\$\\d+#[[:print:]]+#[\\da-fA-F]{32}(?:(?::[[:print:]]*$)|$)/\n return 'mscash2'\n end\n ''\nend",
"def check_hash(file, hash)\n if !hash.nil? && File.file?(file)\n computed_h = Digest::SHA256.file(file)\n true if hash.casecmp(computed_h.hexdigest).zero?\n else\n false\n end\n end",
"def verify_sha1_hash(filename, hash)\n require 'digest/sha1'\n compare_hash(filename, Digest::SHA1, hash)\n end",
"def item_included?(str, hash)\n hash.each do |key, value|\n return true if key == str\n end\n false\nend",
"def hash_has_key?(hash, key)\r\n hash.key?(key) # Determines if hash has key with the argument of key.\r\nend",
"def unique_string(string)\n object = {}\n string.each_with_index do |el, i|\n if object[el]\n return false\n else\n object[el] = i\n end\n end\n true\nend",
"def unique_characters(my_string)\n my_hash = {}\n results = true\n my_string.split(\"\").each { |ch|\n ch = ch.downcase\n if my_hash[ch].nil?\n my_hash[ch] = true\n else\n results = false\n break\n end\n }\n results\nend",
"def has_duplicate(str)\n\tset = Set.new\n\tstr.chars do |char|\n\t\treturn true if set.include? char\n\t\tset << char\n\tend\n\tfalse\nend",
"def duplicate_entry?(entry_hash)\n unless entry_hash.include? \"id\" # conditional for record updates\n formatted = format_hash(entry_hash)\n db_hash = get_entry(formatted[\"fname\"], formatted[\"lname\"])\n difference = (formatted.to_a - db_hash.to_a).flatten\n difference.size > 0 ? false : true\n else\n false\n end\nend",
"def has_simple_children?(hash)\n if hash.simple?\n return false\n end\n\n hash.each_value{|sequence|\n if sequence.class != Array\n puts \"error! We expect only arrays.\"\n return true\n end\n\n if sequence.any?{|hash| hash.simple?}\n #puts \"hash has simple children\"\n return true\n else\n #puts \"hash has no simple children\"\n return false\n end\n }\nend",
"def is_one_pair?\n repetitions(2).keys.count == 1\n end",
"def test_hash_empty_string\n knot = KnotHash.new\n assert_equal \"a2582a3a0e66e6e86e3812dcb672a272\", knot.hash('')\n end",
"def key?(node)\n return @hash.key?(node.sha1)\n end",
"def has_uniq_chars?(string) \n if string.length > 256\n raise StringLengthError.new(\"string lengths cannot exceed 256\")\n else\n uniq = Hash.new(0)\n string.chars.each do |char|\n if uniq[char] == 0\n uniq[char] += 1\n else\n return false\n end\n end\n return true, uniq \n end\n end",
"def must_be_hash(hstr)\n hash = hstr.is_a?(String) ? eval(hstr) : hstr\n new_hash = Hash.new\n hash.each_pair { |k, v| new_hash[k.to_sym] = v }\n return new_hash\n end",
"def func_any(hash)\n hash.any? { |k, v| k.is_a?(Integer) }\nend",
"def uniq_chars?(s)\n checked = {}\n s.each_char do |char|\n return false if checked[char]\n checked[char] = true\n end\n true\nend",
"def same_contents?(hash1, hash2, keys_to_ignore=[])\n hash1.keys.each do |key|\n next if keys_to_ignore.include?(key)\n return false unless hash1[key] == hash2[key]\n end\n true\n end",
"def key_for_min_value(name_hash)\n return nil if name_hash == {}\nend",
"def process_hash?(hash)\n return true unless hash['skip_if'] || hash['only_if']\n return true if skip_variables? || variables.empty?\n\n skip_lambdas = normalize_ifs(hash['skip_if'])\n only_lambdas = normalize_ifs(hash['only_if'])\n\n if skip_lambdas\n return false if skip_lambdas.any? { |s| s.call }\n end\n\n if only_lambdas\n return false unless only_lambdas.all? { |s| s.call }\n end\n\n true\n end",
"def find_unique all_hash\n unique = []\n\n all_hash.each_pair do |full_name, cm|\n unique << cm if full_name == cm.full_name\n end\n\n unique\n end",
"def test_nonequal_hash\n chain = \"Person1<Person2(360):Person3<Person4(930)\"\n block = Blockchain.new(0,0,chain, 1.5,\"ch77\")\n block.setHash(\"m1p0\")\n\n assert_equal(0, block.check_curr())\n end",
"def is_hash?(data)\n data && data.is_a?(Hash)\n end",
"def unique_b?(string)\n # O(N)\n string = string.split('')\n characters = {}\n\n # O(N)\n string.each do |character|\n return false if characters[character]\n characters[character] = true\n end\n\n return true\nend",
"def might_be_extinct(hash, string)\n is_It = \"This animal is NOT extinct.\"\n hash.each do |animal, year|\n if string == animal\n is_It = \"This animal is extinct...\"\n end\n end\n is_It\nend",
"def is_unique(string)\n chars = Hash.new(0)\n\n string.each_char do |ch|\n chars[ch] += 1\n \n if chars[ch] > 1\n return false\n end\n end\n\n true\nend",
"def duplicate_character_string(string)\n puts \"Checking if '#{string}' has duplicate characters\"\n string.split('').each_with_object({}) do |character, hash|\n return puts 'Duplicate character keys!' if hash.has_key?(character)\n hash[character] = 1\n end\nend",
"def string_include_key?(string, key)\n return true if key.length == 0\n return false if string.length == 0\n\n if string[0] == key[0]\n string_include_key?(string[1..-1], key[1..-1])\n else\n string_include_key?(string[1..-1], key)\n end\nend",
"def same_hash?(submitted, saved)\n saved.count == submitted.count and\n Hash[saved.map { |key, value| [key, same?(submitted[key], value)] }]\n end",
"def is_unique?(str)\n\nend",
"def nothing_if_empty_or_nil(hash) \n hash.delete_if { |k, v| v.nil? || v.empty? }\n end",
"def uniq?(uniq)\n { 'false': false, 'true': true }[uniq.to_sym]\n end",
"def func_any(hash)\r\n # Check and return true if any key object within the hash is of the type Integer\r\n # If not found, return false.\r\n hash.any? {|k,v| k.is_a?(Integer)}\r\nend",
"def all_unique_chars(str)\n seen = {}\n str.chars.each do |char|\n return false if seen[char]\n seen[char] = true\n end\n true\nend"
] |
[
"0.6872515",
"0.653527",
"0.64753824",
"0.63653773",
"0.63653773",
"0.6327134",
"0.61998135",
"0.61828476",
"0.61455345",
"0.6136147",
"0.6129145",
"0.60743505",
"0.60740703",
"0.6071318",
"0.60477054",
"0.6025387",
"0.6015785",
"0.60072166",
"0.59972966",
"0.59713346",
"0.5968971",
"0.5968971",
"0.5968971",
"0.5950154",
"0.5942168",
"0.5937797",
"0.5916012",
"0.5910683",
"0.59049445",
"0.5897086",
"0.58748513",
"0.5867249",
"0.581129",
"0.58079964",
"0.57978946",
"0.57825184",
"0.57818437",
"0.5769621",
"0.5758029",
"0.57528645",
"0.57528645",
"0.5751362",
"0.5749848",
"0.5748672",
"0.5729895",
"0.57266724",
"0.5714886",
"0.5692912",
"0.56818974",
"0.56781083",
"0.56642884",
"0.5644342",
"0.5617043",
"0.55920047",
"0.55879515",
"0.55835396",
"0.5582423",
"0.55655",
"0.55557317",
"0.5554194",
"0.5552624",
"0.55239743",
"0.55226016",
"0.5516585",
"0.55127966",
"0.5510034",
"0.55048054",
"0.54999053",
"0.549425",
"0.54940414",
"0.5489452",
"0.5474548",
"0.5462996",
"0.5462139",
"0.5458383",
"0.54488176",
"0.5426664",
"0.542383",
"0.54160994",
"0.5405766",
"0.5393748",
"0.5384044",
"0.5379654",
"0.5379077",
"0.53777456",
"0.5370634",
"0.5342249",
"0.5320818",
"0.53058",
"0.52946454",
"0.5286624",
"0.52860844",
"0.5282604",
"0.5280003",
"0.52637744",
"0.5250676",
"0.52462053",
"0.5243925",
"0.52428937",
"0.5240739",
"0.5224663"
] |
0.0
|
-1
|
Is this a RHELcompatible OS with a minimum major version number of `version`
|
def el_min_version?(version)
self.rhel_family? && FB::Version.new(self['platform_version']) >= self._canonical_version(version)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def major_version(version = nil)\n version ||= installed_version?\n return \"0\" if version.nil?\n\n version.sub(/(\\.\\d+)+$/, '')\n end",
"def major(version)\n res = 0\n res = Regexp.last_match(1) if version =~ /^\\s*(\\d+)\\.\\d+\\.\\d+/\n res\n end",
"def major ; version.major ; end",
"def os_minimum_version\n return @os_minimum_version\n end",
"def os_minimum_version\n return @os_minimum_version\n end",
"def major_version\n version.match(/(\\d\\.\\d)/)[0] if name.is_a? String\n end",
"def major_version; end",
"def find_centos_minor_version\n os_minor_version = ''\n kernel_patch_version = find_kernel_patch_version\n\n os_minor_version = '7' if kernel_patch_version >= '1062'\n os_minor_version = '8' if kernel_patch_version >= '1127'\n os_minor_version = '9' if kernel_patch_version >= '1160'\n\n os_minor_version\nend",
"def rhel5x?\n major_version = node['platform_version'].split('.').first.to_i\n platform_family?('rhel') && major_version < 6\n end",
"def rhel5x?\n major_version = node['platform_version'].split('.').first.to_i\n platform_family?('rhel') && major_version < 6\n end",
"def platform_version_for_package\n if platform == 'rhel'\n platform_version[/([\\d]+)\\..+/, 1]\n else\n platform_version\n end\n end",
"def version_supported?\n\tKitchenplan::Log.debug \"#{self.class} : Is platform version lower than #{@lowest_version_supported}?\"\n\treturn false if self.version.to_s < @lowest_version_supported\n\ttrue\n end",
"def version_supported?\n\tKitchenplan::Log.debug \"#{self.class} : Is platform version lower than #{@lowest_version_supported}?\"\n\treturn false if self.version.to_s < @lowest_version_supported\n\ttrue\n end",
"def version_supported?\n\tKitchenplan::Log.debug \"#{self.class} : Is platform version lower than #{@lowest_version_supported}?\"\n\treturn false if self.version.to_s < @lowest_version_supported\n\ttrue\n end",
"def platform_version\n osver[1]\n end",
"def old_version?\n case @node['platform']\n when 'ubuntu'\n Chef::VersionConstraint.new(\"< 11.0\").include?(@node['platform_version'])\n when 'debian'\n Chef::VersionConstraint.new(\"< 7.0\").include?(@node['platform_version'])\n end\n end",
"def os_minimum_version=(value)\n @os_minimum_version = value\n end",
"def os_minimum_version=(value)\n @os_minimum_version = value\n end",
"def major_version\n @delegate.requested_version&.major\n end",
"def rhel6x?\n major_version = node['platform_version'].split('.').first.to_i\n platform_family?('rhel') && major_version >= 6 && major_version < 7\n end",
"def el_max_version?(version)\n self.rhel_family? && FB::Version.new(self['platform_version']) <= self._canonical_version(version)\n end",
"def truncate_platform_version(platform_version, platform)\n case platform\n when \"centos\", \"cumulus\", \"debian\", \"el\", \"fedora\", \"freebsd\", \"omnios\", \"pidora\", \"raspbian\", \"rhel\", \"rocky\", \"sles\", \"suse\", \"smartos\"\n # Only want MAJOR (e.g. Debian 7, OmniOS r151006, SmartOS 20120809T221258Z)\n platform_version.split(\".\").first\n when \"aix\", \"alpine\", \"openbsd\", \"slackware\", \"solaris2\", \"opensuse\", \"opensuseleap\", \"ubuntu\", \"amazon\"\n # Only want MAJOR.MINOR (e.g. Ubuntu 12.04)\n platform_version.split(\".\")[0..1].join(\".\")\n when \"mac_os_x\", \"darwin\", \"macos\"\n # If running macOS >= 11, use only MAJOR version. Otherwise, use MAJOR.MINOR\n pv_bits = platform_version.split(\".\")\n pv_bits[0].to_i >= 11 ? pv_bits[0] : pv_bits[0..1].join(\".\")\n when \"arch\", \"gentoo\", \"kali\"\n # Arch Linux / Gentoo do not have a platform_version ohai attribute, they are rolling release (lsb_release -r)\n \"rolling\"\n when \"windows\"\n # Windows has this really awesome \"feature\", where their version numbers\n # internally do not match the \"marketing\" name.\n #\n # Definitively computing the Windows marketing name actually takes more\n # than the platform version. Take a look at the following file for the\n # details:\n #\n # https://github.com/chef/chef/blob/master/lib/chef/win32/version.rb\n #\n # As we don't need to be exact here the simple mapping below is based on:\n #\n # http://www.jrsoftware.org/ishelp/index.php?topic=winvernotes\n #\n # Microsoft's version listing (more general than the above) is here:\n #\n # https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx\n #\n case platform_version\n when \"5.0.2195\", \"2000\" then \"2000\"\n when \"5.1.2600\", \"xp\" then \"xp\"\n when \"5.2.3790\", \"2003r2\" then \"2003r2\"\n when \"6.0.6001\", \"2008\" then \"2008\"\n when \"6.1.7600\", \"7\" then \"7\"\n when \"6.1.7601\", \"2008r2\" then \"2008r2\"\n when \"6.2.9200\", \"2012\" then \"2012\"\n # The following `when` will never match since Windows 8's platform\n # version is the same as Windows 2012. It's only here for completeness and\n # documentation.\n when \"6.2.9200\", \"8\" then \"8\"\n when /6\\.3\\.\\d+/, \"2012r2\" then \"2012r2\"\n # The following `when` will never match since Windows 8.1's platform\n # version is the same as Windows 2012R2. It's only here for completeness\n # and documentation.\n when /6\\.3\\.\\d+/, \"8.1\" then \"8.1\"\n when \"10\", /^10\\.0/ then \"10\"\n else\n raise UnknownPlatformVersion.new(platform, platform_version)\n end\n else\n raise UnknownPlatform.new(platform)\n end\n end",
"def major\n @major ||= ruby_cc_version.match( /.*-(\\d.\\d).\\d/ )[1]\n end",
"def major_version(full_version)\n full_version.match(/^(\\d+\\.\\d+\\.\\d+)\\.\\d+$/)[1]\n end",
"def Check_OS_Version()\n\tos_version = `ver`\n\treturn os_version\nend",
"def version_number\n self.name =~ /RHEL-([0-9]+)/\n return $1.to_i\n end",
"def major(version)\n if version.include? '_'\n major, _ = version.split('_', 2)\n else\n major = version\n end\n return major\n end",
"def major_version\n @version_helper.major\n end",
"def major_version\n @version_helper.major\n end",
"def major_version\n @version_helper.major\n end",
"def min_version\n @min_version ||= nil\n end",
"def major_version\n '1.8'\n end",
"def pdb_get_os_major_release(facts)\n if facts.is_a?(Hash) && !facts['operatingsystemmajrelease'].nil? && !facts['operatingsystemmajrelease']['value'].nil?\n os_major_release = facts['operatingsystemmajrelease']['value']\n Puppet.info(\"#{log_prefix} puppet os major release for node is: os major release=#{os_major_release}\")\n os_major_release\n else\n \"Unknown\"\n end\n end",
"def minor_version; end",
"def installed_version\n capture(\"#{chef_solo} -v || true\") =~ /Chef: (\\d+\\.\\d+\\.\\d+)/ ? $1 : nil\n end",
"def linux_version\n case ENV['MACHTYPE']\n when \"s390x-suse-linux\"\n :sles_zlnx\n when /^i[356]86/\n if File.exist? \"/etc/fedora-release\"\n :linux_ia32_cell\n else\n :linux_ia32\n end\n else\n if File.exist? \"/etc/rhel-release\"\n :rhel\n elsif File.exist? \"/etc/redhat-release\"\n `awk '/release 5/||/release 4.9/{v=5};/release 4/{v=4}; END {print \"rhel\" v}' /etc/redhad-release`.to_sym\n elsif File.exist? \"/etc/SuSE-release\"\n `awk '$1==\"VERSION\" { v=$3}; END { print \"sles\" v}' /etc/SuSE-release`.to_sym\n elsif File.exist? \"/etc/yellowdog-release\"\n :yhpc\n else\n :rhel\n end\n end\nend",
"def minor_version(version = nil)\n version ||= installed_version?\n return \"0.0\" if version.nil?\n\n version.sub(/\\.\\d+$/, '')\n end",
"def truncate_platform_version(platform_version, platform_shortname=nil)\n\n case platform_shortname\n when 'centos', 'debian', 'fedora', 'freebsd', 'rhel', 'el'\n # Only want MAJOR (e.g. Debian 7)\n platform_version.split('.').first\n when 'aix', 'arch', 'gentoo', 'mac_os_x', 'openbsd', 'slackware', 'solaris2', 'suse', 'ubuntu'\n # Only want MAJOR.MINOR (e.g. Mac OS X 10.9, Ubuntu 12.04)\n platform_version.split('.')[0..1].join('.')\n when 'omnios', 'smartos'\n # Only want MAJOR (e.g OmniOS r151006, SmartOS 20120809T221258Z)\n platform_version.split('.').first\n when 'windows'\n # Windows has this really awesome \"feature\", where their version numbers\n # internally do not match the \"marketing\" name.\n #\n # Definitively computing the Windows marketing name actually takes more\n # than the platform version. Take a look at the following file for the\n # details:\n #\n # https://github.com/opscode/chef/blob/master/lib/chef/win32/version.rb\n #\n # As we don't need to be exact here the simple mapping below is based on:\n #\n # http://www.jrsoftware.org/ishelp/index.php?topic=winvernotes\n #\n case platform_version\n when '5.0.2195', '2000' then '2000'\n when '5.1.2600', 'xp' then 'xp'\n when '5.2.3790', '2003r2' then '2003r2'\n when '6.0.6001', '2008' then '2008'\n when '6.1.7600', '7' then '7'\n when '6.1.7601', '2008r2' then '2008r2'\n when '6.2.9200', '8' then '8'\n # The following `when` will never match since Windows 2012's platform\n # version is the same as Windows 8. It's only here for completeness and\n # documentation.\n when '6.2.9200', '2012' then '2012'\n when '6.3.9200', '8.1' then '8.1'\n # The following `when` will never match since Windows 2012R2's platform\n # version is the same as Windows 8.1. It's only here for completeness\n # and documentation.\n when '6.3.9200', '2012r2' then '2012r2'\n else\n raise UnknownPlatformVersion.new(platform_shortname, platform_version)\n end\n else\n raise UnknownPlatform.new(platform_shortname)\n end\n end",
"def choose_version(version)\n if version =~ /(\\d+)\\.(\\d+)\\.(\\d+)/\n major = $1\n minor = $2\n patch = $3\n if config[:major]\n major = major.to_i + 1\n minor = 0\n patch = 0\n end\n if config[:minor]\n minor = minor.to_i + 1\n patch = 0\n end\n patch = patch.to_i + 1 if config[:patch]\n version = \"#{major}.#{minor}.#{patch}\"\n Chef::Log.debug(\"New version is #{version}\")\n else\n Chef::Log.error(\"Version is in a format I cannot auto-update\")\n exit 1\n end\n version\n end",
"def version_less_than_seventeen?\n verify_gem_version(celluloid_version, '0.17', operator: '<')\n end",
"def platform_version\n truncate_platform_version(Ohai[\"platform_version\"], platform_shortname)\n end",
"def os_version # rubocop:disable Lint/DuplicateMethods\n @os_version ||= @name.match(PLATFORM_REGEX)[2]\n end",
"def osver\n return `uname -r`.chomp\n end",
"def platform_version\n Ohai.platform_version\n end",
"def major_engine_version\n data[:major_engine_version]\n end",
"def version_gte_71?\n version >= v71\n end",
"def test_prerelease?(version)\n !@version.stable? && @version.major == version.major && @version.minor == version.minor && @version.patch == version.patch\n end",
"def minimum_required_minor_engine_version\n data.minimum_required_minor_engine_version\n end",
"def has_version?; end",
"def build_os_version(os)\n # NOTE: UA regexes don't always give us the versions back\n # they do get \"corrected\" for various OSes such as:\n # - Windows (Windows NT 6.0 => 'Vista')\n # - Windows ('Windows NT 6.3' => '8','1')\n # - Windows ('Windows NT 10.0' => '10')\n # - iOS ('Darwin/15.5' => '9','3','2')\n return unless major = os.major\n if major.to_i.to_s == major\n version, sep = duped_string(major), '.'\n else\n version, sep = duped_string(major), ' '\n end\n if os.minor\n version << sep << os.minor\n if os.patch\n version << '.' << os.patch\n if os.patchMinor\n version << '.' << os.patchMinor\n end\n end\n end\n version\n end",
"def required_version\n fetch(:chef_version) || nil\n end",
"def rhel7x?\n platform_family?('rhel') && node['platform_version'].to_f >= 7\n end",
"def rhel7x?\n platform_family?('rhel') && node['platform_version'].to_f >= 7\n end",
"def installed_version\n lines = powershell_out!('Get-WmiObject -Class win32_product')\n .stdout.lines\n idx = lines.index do |l|\n l.match(/^\\W*Name\\W+:\\W+Chef Development Kit/)\n end\n return false if idx.nil?\n ver = lines[idx + 2].match(/:\\W+([0-9]+\\.[0-9]+\\.[0-9]+)\\.[0-9]+/)[1]\n ver == package_metadata[:version] ? 'latest' : ver\n end",
"def extract_os_version(version)\n #version.unpack('CCS').join('.')\n begin\n os_version = NTLM::OSVersion.read(version)\n rescue IOError\n return ''\n end\n return \"#{os_version.major}.#{os_version.minor}.#{os_version.build}\"\n end",
"def have_version?(major, minor = nil, update = nil, build = nil)\n if major.class == Float\n major = major.to_s\n end\n if major.class == String\n major,minor,update = major.split('.').collect { |x| x.to_i }\n end\n if major == @major\n return false if minor != nil && minor != @minor\n return false if update != nil && update != @update\n return false if build != nil && build != @build\n return true\n else\n return false\n end\n end",
"def min_licensing_version\n nil\n end",
"def min_licensing_version\n nil\n end",
"def win_64bit?\n x86_64? && (latest_version? || new_resource.version.split('.').first.to_i >= 42)\nend",
"def yosemite_or_newer?\n Gem::Version.new(`sw_vers -productVersion`) >= Gem::Version.new('10.10')\nend",
"def has_java_version?(ver)\n java_version.start_with? \"1.#{ver}\"\n end",
"def kernel_version\n uname('-v')\n end",
"def version\n str = if detect_product(\"CriOs\")\n crios.version\n else\n chrome.version\n end\n\n Version.new(str)\n end",
"def major_minor(version)\n version.split('.').map(&:to_i)\n end",
"def version_gte_72?\n version >= v72\n end",
"def major_upgrade?(to)\n nil unless installed?\n major_version(installed_version?) != major_version(to)\n end",
"def rhel6?(node = __getnode)\n node[\"platform_family\"] == \"rhel\" && node[\"platform_version\"].to_f >= 6.0 && node[\"platform_version\"].to_f < 7.0\n end",
"def rhel8?(node = __getnode)\n node[\"platform_family\"] == \"rhel\" && node[\"platform_version\"].to_f >= 8.0 && node[\"platform_version\"].to_f < 9.0\n end",
"def major_engine_version\n data.major_engine_version\n end",
"def dev_major() end",
"def pre_0_12?\n VersionRequirement.new('< 0.12.0-alpha').satisfied_by?(version)\n end",
"def minor(version)\n res = 0\n res = Regexp.last_match(1) if version =~ /^\\s*\\d+\\.(\\d+)\\.\\d+/\n res\n end",
"def el_version\n if File.exists?('/etc/fedora-release')\n nil\n elsif File.exists?('/etc/redhat-release')\n rpm = Pkg::Util::Tool.find_tool('rpm', :required => true)\n stdout, _, _ = Pkg::Util::Execution.capture3(\"#{rpm} -q --qf \\\"%{VERSION}\\\" $(#{rpm} -q --whatprovides /etc/redhat-release )\")\n stdout\n end\n end",
"def os_version\n if !@os_version\n if Facter['operatingsystemrelease'] &&\n Facter['operatingsystemrelease'].value &&\n !Facter['operatingsystemrelease'].value.empty?\n @os_version = Facter['operatingsystemrelease'].value\n else\n raise \"Unable to determine proper OS value on this platform\"\n end\n end\n @os_version.dup\n end",
"def have_at_least_version?(major, minor = nil, update = nil, build = nil)\n if major.class == Float\n major = major.to_s\n end\n if major.class == String\n major,minor,update = major.split('.').collect { |x| x.to_i }\n end\n if major == @major #Could true\n if minor != nil #Being asked to test minor level\n if minor == @minor #Could be true\n if update != nil #Being asked to test update level\n if update == @update #Could be true\n if build != nil #Being asked to test the build version\n return build <= @build #have at least the required patch level.\n end\n return true #update was equal\n end\n return update < @update #current version is newer\n end\n return true #major and minor was equal.\n end\n return minor < @minor #true if current version is newer\n end\n return true #major was equal.\n end\n return major < @major #true, if current version is newer\n end",
"def check_version(v)\n return true if (!version || version[0..4].gsub(\".\",\"\").to_i>=v)\n return false\n end",
"def version_check\n version = params[:version]\n return render :status=>400, :json=>{:message=>\"The request must contain the a version number.\"} if version.blank?\n\n #check against current major version of app\n v = version.split(\".\")[0]\n if CURRENT_MAJOR_VERSION.to_i > v.to_i\n render :status=>600, :json=>{:status => \"Needs to upgrade to latest major version\"}\n return\n end\n render :status=>200, :json=>{:status => \"Success\"}\n end",
"def version_less_than_eigthteen?\n verify_gem_version(celluloid_version, '0.18', operator: '<')\n end",
"def platform\n type = os_type(:nice)\n type = case type\n when /Linux/i then linux_type\n else type\n end\n \n # Grab the Solaris version; turns '5.9' into '9', for example. (Solaris has a really\n # bizarre numbering scheme.)\n #\n # FIXME: This should include patchlevel.\n if type =~ /Solaris/i\n if @solaris_version.nil?\n @solaris_version = @platform.exec(\"uname\", \"-r\").strip\n @solaris_version = $2 if @solaris_version =~ /^\\s*(\\d+)\\s*\\.\\s*(\\d+)\\s*$/i\n end\n \n type += @solaris_version\n end\n \n # Grab the OS X version by looking at the Darwin kernel version.\n #\n # FIXME: This should include minor version, too (e.g., 10.4.7).\n if type =~ /OSX/i\n if @osx_version.nil?\n @osx_version = @platform.exec(\"uname\", \"-r\").strip\n if @osx_version =~ /^\\s*(\\d+)\\s*\\.\\s*(\\d+).*$/i\n minor_version = [ $1.to_i - 4, 0 ].max # i.e., Darwin 8.x => OS X 10.4, 7.x => OS X 10.3, etc.\n @osx_version = \"10.%d\" % minor_version\n else\n @osx_version = '-unknown-%s' % @osx_version\n end\n end\n \n type += @osx_version\n end\n \n # Grab the Windows version by System.getProperty\n if type =~ /Windows/i\n os_name = JavaSystem.getProperty('os.name');\n sun_os_patch_level = JavaSystem.getProperty('sun.os.patch.level');\n if @windows_version.nil?\n @windows_version = case os_name \n when /Windows 2003/i: \"win2k3\"\n when /Windows XP/i: \"winxp\"\n else os_name.gsub(/ /, '_')\n end\n unless sun_os_patch_level == \"unknown\"\n patch = ''\n sun_os_patch_level.split(/ /).each do |t|\n patch = \"#{patch}#{t[0..0]}\"\n end\n @windows_version += '-' + patch\n end \n end\n \n type = @windows_version\n end\n \n \"%s-%s\" % [ type.downcase, processor_type.downcase ]\n end",
"def version_gte_81?\n version >= v81\n end",
"def os_x_older?\n os_x? && RUBY_PLATFORM.include?('11')\n end",
"def ios_at_least? version\n version.to_f.round(3) <= ios_version.to_f.round(3)\n end",
"def minimum_required_patch_version\n return @minimum_required_patch_version\n end",
"def fetch_linux_os_version\n `lsb_release -rs`.strip\nend",
"def version_gte_8?\n version >= v80\n end",
"def version_gte_73?\n version >= v73\n end",
"def bump_major_version; end",
"def platform_version_mac_os_x(arg)\n arg.match(/^[0-9]+\\.[0-9]+/).to_s\n end",
"def version_gte_62?\n version >= v62\n end",
"def major; end",
"def major; end",
"def major; end",
"def compatible?(version)\n bin_version = Gem::Version.new(version)\n supports_min = !minimum_cocoapods_version ||\n (bin_version >= Gem::Version.new(minimum_cocoapods_version))\n supports_max = !maximum_cocoapods_version ||\n (bin_version <= Gem::Version.new(maximum_cocoapods_version))\n supports_min && supports_max\n end",
"def versao?\n \"Versão 1.0\"\n end",
"def minimum_supported_operating_system\n return @minimum_supported_operating_system\n end",
"def current_version?\n version == FirmwareUpgrade.current_software_version\n end",
"def rpm_version(name)\n if (self.centos? && !self.centos7?) || self.fedora? || self.redhat8? || self.oracle8? || self.redhat9?\n # returns epoch.version\n v = Chef::Provider::Package::Dnf::PythonHelper.instance.\n package_query(:whatinstalled, name).version\n unless v.nil?\n v.split(':')[1]\n end\n elsif self.centos7? &&\n (FB::Version.new(Chef::VERSION) > FB::Version.new('14'))\n # returns epoch.version.arch\n v = Chef::Provider::Package::Yum::PythonHelper.instance.\n package_query(:whatinstalled, name).version\n unless v.nil?\n v.split(':')[1]\n end\n else\n # return version\n Chef::Provider::Package::Yum::YumCache.instance.\n installed_version(name)\n end\n end",
"def requirement\n \"~> #{major}\"\n end",
"def installed_version_matches?(version)\n installed_version? == version\n end",
"def version_gte_7?\n version >= v70\n end"
] |
[
"0.7731996",
"0.7731392",
"0.7710112",
"0.76567256",
"0.76567256",
"0.73321724",
"0.73151785",
"0.71896255",
"0.71794736",
"0.71794736",
"0.7167988",
"0.7146111",
"0.7146111",
"0.7146111",
"0.71318275",
"0.7128724",
"0.7121457",
"0.7121457",
"0.7103959",
"0.7102385",
"0.70955163",
"0.7092107",
"0.7064371",
"0.7042846",
"0.7037349",
"0.70083815",
"0.6988037",
"0.69765437",
"0.69765437",
"0.69765437",
"0.69540435",
"0.6891018",
"0.68798286",
"0.6797973",
"0.67956764",
"0.6795482",
"0.6782936",
"0.6777956",
"0.6777328",
"0.67616975",
"0.67575276",
"0.6750329",
"0.6711646",
"0.6707535",
"0.67051536",
"0.6697972",
"0.6682528",
"0.6679291",
"0.6676945",
"0.6670214",
"0.66621935",
"0.66412514",
"0.66412514",
"0.6635388",
"0.66329825",
"0.6624229",
"0.6611606",
"0.6611606",
"0.66107213",
"0.6591008",
"0.6578169",
"0.6569518",
"0.6564716",
"0.65615964",
"0.65543735",
"0.6553836",
"0.6549561",
"0.65471333",
"0.65452826",
"0.6541095",
"0.6540629",
"0.6537854",
"0.65334237",
"0.6520388",
"0.6519185",
"0.65114826",
"0.64969677",
"0.64854807",
"0.64775366",
"0.6470499",
"0.64674544",
"0.6464719",
"0.6458957",
"0.6454696",
"0.6445226",
"0.64431936",
"0.64140195",
"0.6413467",
"0.6387749",
"0.6382233",
"0.6382233",
"0.6382233",
"0.6378127",
"0.6371201",
"0.6365632",
"0.63649553",
"0.6364104",
"0.6359787",
"0.6356377",
"0.6354478"
] |
0.8040562
|
0
|
Is this a RHELcompatible OS with a maximum major version number of `version`
|
def el_max_version?(version)
self.rhel_family? && FB::Version.new(self['platform_version']) <= self._canonical_version(version)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def el_min_version?(version)\n self.rhel_family? && FB::Version.new(self['platform_version']) >= self._canonical_version(version)\n end",
"def major(version)\n res = 0\n res = Regexp.last_match(1) if version =~ /^\\s*(\\d+)\\.\\d+\\.\\d+/\n res\n end",
"def major_version(version = nil)\n version ||= installed_version?\n return \"0\" if version.nil?\n\n version.sub(/(\\.\\d+)+$/, '')\n end",
"def major ; version.major ; end",
"def find_centos_minor_version\n os_minor_version = ''\n kernel_patch_version = find_kernel_patch_version\n\n os_minor_version = '7' if kernel_patch_version >= '1062'\n os_minor_version = '8' if kernel_patch_version >= '1127'\n os_minor_version = '9' if kernel_patch_version >= '1160'\n\n os_minor_version\nend",
"def minor_version(version = nil)\n version ||= installed_version?\n return \"0.0\" if version.nil?\n\n version.sub(/\\.\\d+$/, '')\n end",
"def minor(version)\n res = 0\n res = Regexp.last_match(1) if version =~ /^\\s*\\d+\\.(\\d+)\\.\\d+/\n res\n end",
"def os_minimum_version\n return @os_minimum_version\n end",
"def os_minimum_version\n return @os_minimum_version\n end",
"def platform_version_for_package\n if platform == 'rhel'\n platform_version[/([\\d]+)\\..+/, 1]\n else\n platform_version\n end\n end",
"def major_version\n version.match(/(\\d\\.\\d)/)[0] if name.is_a? String\n end",
"def truncate_platform_version(platform_version, platform)\n case platform\n when \"centos\", \"cumulus\", \"debian\", \"el\", \"fedora\", \"freebsd\", \"omnios\", \"pidora\", \"raspbian\", \"rhel\", \"rocky\", \"sles\", \"suse\", \"smartos\"\n # Only want MAJOR (e.g. Debian 7, OmniOS r151006, SmartOS 20120809T221258Z)\n platform_version.split(\".\").first\n when \"aix\", \"alpine\", \"openbsd\", \"slackware\", \"solaris2\", \"opensuse\", \"opensuseleap\", \"ubuntu\", \"amazon\"\n # Only want MAJOR.MINOR (e.g. Ubuntu 12.04)\n platform_version.split(\".\")[0..1].join(\".\")\n when \"mac_os_x\", \"darwin\", \"macos\"\n # If running macOS >= 11, use only MAJOR version. Otherwise, use MAJOR.MINOR\n pv_bits = platform_version.split(\".\")\n pv_bits[0].to_i >= 11 ? pv_bits[0] : pv_bits[0..1].join(\".\")\n when \"arch\", \"gentoo\", \"kali\"\n # Arch Linux / Gentoo do not have a platform_version ohai attribute, they are rolling release (lsb_release -r)\n \"rolling\"\n when \"windows\"\n # Windows has this really awesome \"feature\", where their version numbers\n # internally do not match the \"marketing\" name.\n #\n # Definitively computing the Windows marketing name actually takes more\n # than the platform version. Take a look at the following file for the\n # details:\n #\n # https://github.com/chef/chef/blob/master/lib/chef/win32/version.rb\n #\n # As we don't need to be exact here the simple mapping below is based on:\n #\n # http://www.jrsoftware.org/ishelp/index.php?topic=winvernotes\n #\n # Microsoft's version listing (more general than the above) is here:\n #\n # https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx\n #\n case platform_version\n when \"5.0.2195\", \"2000\" then \"2000\"\n when \"5.1.2600\", \"xp\" then \"xp\"\n when \"5.2.3790\", \"2003r2\" then \"2003r2\"\n when \"6.0.6001\", \"2008\" then \"2008\"\n when \"6.1.7600\", \"7\" then \"7\"\n when \"6.1.7601\", \"2008r2\" then \"2008r2\"\n when \"6.2.9200\", \"2012\" then \"2012\"\n # The following `when` will never match since Windows 8's platform\n # version is the same as Windows 2012. It's only here for completeness and\n # documentation.\n when \"6.2.9200\", \"8\" then \"8\"\n when /6\\.3\\.\\d+/, \"2012r2\" then \"2012r2\"\n # The following `when` will never match since Windows 8.1's platform\n # version is the same as Windows 2012R2. It's only here for completeness\n # and documentation.\n when /6\\.3\\.\\d+/, \"8.1\" then \"8.1\"\n when \"10\", /^10\\.0/ then \"10\"\n else\n raise UnknownPlatformVersion.new(platform, platform_version)\n end\n else\n raise UnknownPlatform.new(platform)\n end\n end",
"def minor_version; end",
"def major_version; end",
"def version_number\n self.name =~ /RHEL-([0-9]+)/\n return $1.to_i\n end",
"def platform_version\n osver[1]\n end",
"def rhel5x?\n major_version = node['platform_version'].split('.').first.to_i\n platform_family?('rhel') && major_version < 6\n end",
"def rhel5x?\n major_version = node['platform_version'].split('.').first.to_i\n platform_family?('rhel') && major_version < 6\n end",
"def os_maximum_version\n return @os_maximum_version\n end",
"def os_maximum_version\n return @os_maximum_version\n end",
"def major\n @major ||= ruby_cc_version.match( /.*-(\\d.\\d).\\d/ )[1]\n end",
"def rhel6x?\n major_version = node['platform_version'].split('.').first.to_i\n platform_family?('rhel') && major_version >= 6 && major_version < 7\n end",
"def major_version\n @delegate.requested_version&.major\n end",
"def minimum_required_minor_engine_version\n data.minimum_required_minor_engine_version\n end",
"def major_version(full_version)\n full_version.match(/^(\\d+\\.\\d+\\.\\d+)\\.\\d+$/)[1]\n end",
"def pdb_get_os_major_release(facts)\n if facts.is_a?(Hash) && !facts['operatingsystemmajrelease'].nil? && !facts['operatingsystemmajrelease']['value'].nil?\n os_major_release = facts['operatingsystemmajrelease']['value']\n Puppet.info(\"#{log_prefix} puppet os major release for node is: os major release=#{os_major_release}\")\n os_major_release\n else\n \"Unknown\"\n end\n end",
"def version_supported?\n\tKitchenplan::Log.debug \"#{self.class} : Is platform version lower than #{@lowest_version_supported}?\"\n\treturn false if self.version.to_s < @lowest_version_supported\n\ttrue\n end",
"def version_supported?\n\tKitchenplan::Log.debug \"#{self.class} : Is platform version lower than #{@lowest_version_supported}?\"\n\treturn false if self.version.to_s < @lowest_version_supported\n\ttrue\n end",
"def version_supported?\n\tKitchenplan::Log.debug \"#{self.class} : Is platform version lower than #{@lowest_version_supported}?\"\n\treturn false if self.version.to_s < @lowest_version_supported\n\ttrue\n end",
"def old_version?\n case @node['platform']\n when 'ubuntu'\n Chef::VersionConstraint.new(\"< 11.0\").include?(@node['platform_version'])\n when 'debian'\n Chef::VersionConstraint.new(\"< 7.0\").include?(@node['platform_version'])\n end\n end",
"def choose_version(version)\n if version =~ /(\\d+)\\.(\\d+)\\.(\\d+)/\n major = $1\n minor = $2\n patch = $3\n if config[:major]\n major = major.to_i + 1\n minor = 0\n patch = 0\n end\n if config[:minor]\n minor = minor.to_i + 1\n patch = 0\n end\n patch = patch.to_i + 1 if config[:patch]\n version = \"#{major}.#{minor}.#{patch}\"\n Chef::Log.debug(\"New version is #{version}\")\n else\n Chef::Log.error(\"Version is in a format I cannot auto-update\")\n exit 1\n end\n version\n end",
"def major_version\n @version_helper.major\n end",
"def major_version\n @version_helper.major\n end",
"def major_version\n @version_helper.major\n end",
"def platform_version\n truncate_platform_version(Ohai[\"platform_version\"], platform_shortname)\n end",
"def truncate_platform_version(platform_version, platform_shortname=nil)\n\n case platform_shortname\n when 'centos', 'debian', 'fedora', 'freebsd', 'rhel', 'el'\n # Only want MAJOR (e.g. Debian 7)\n platform_version.split('.').first\n when 'aix', 'arch', 'gentoo', 'mac_os_x', 'openbsd', 'slackware', 'solaris2', 'suse', 'ubuntu'\n # Only want MAJOR.MINOR (e.g. Mac OS X 10.9, Ubuntu 12.04)\n platform_version.split('.')[0..1].join('.')\n when 'omnios', 'smartos'\n # Only want MAJOR (e.g OmniOS r151006, SmartOS 20120809T221258Z)\n platform_version.split('.').first\n when 'windows'\n # Windows has this really awesome \"feature\", where their version numbers\n # internally do not match the \"marketing\" name.\n #\n # Definitively computing the Windows marketing name actually takes more\n # than the platform version. Take a look at the following file for the\n # details:\n #\n # https://github.com/opscode/chef/blob/master/lib/chef/win32/version.rb\n #\n # As we don't need to be exact here the simple mapping below is based on:\n #\n # http://www.jrsoftware.org/ishelp/index.php?topic=winvernotes\n #\n case platform_version\n when '5.0.2195', '2000' then '2000'\n when '5.1.2600', 'xp' then 'xp'\n when '5.2.3790', '2003r2' then '2003r2'\n when '6.0.6001', '2008' then '2008'\n when '6.1.7600', '7' then '7'\n when '6.1.7601', '2008r2' then '2008r2'\n when '6.2.9200', '8' then '8'\n # The following `when` will never match since Windows 2012's platform\n # version is the same as Windows 8. It's only here for completeness and\n # documentation.\n when '6.2.9200', '2012' then '2012'\n when '6.3.9200', '8.1' then '8.1'\n # The following `when` will never match since Windows 2012R2's platform\n # version is the same as Windows 8.1. It's only here for completeness\n # and documentation.\n when '6.3.9200', '2012r2' then '2012r2'\n else\n raise UnknownPlatformVersion.new(platform_shortname, platform_version)\n end\n else\n raise UnknownPlatform.new(platform_shortname)\n end\n end",
"def linux_version\n case ENV['MACHTYPE']\n when \"s390x-suse-linux\"\n :sles_zlnx\n when /^i[356]86/\n if File.exist? \"/etc/fedora-release\"\n :linux_ia32_cell\n else\n :linux_ia32\n end\n else\n if File.exist? \"/etc/rhel-release\"\n :rhel\n elsif File.exist? \"/etc/redhat-release\"\n `awk '/release 5/||/release 4.9/{v=5};/release 4/{v=4}; END {print \"rhel\" v}' /etc/redhad-release`.to_sym\n elsif File.exist? \"/etc/SuSE-release\"\n `awk '$1==\"VERSION\" { v=$3}; END { print \"sles\" v}' /etc/SuSE-release`.to_sym\n elsif File.exist? \"/etc/yellowdog-release\"\n :yhpc\n else\n :rhel\n end\n end\nend",
"def Check_OS_Version()\n\tos_version = `ver`\n\treturn os_version\nend",
"def major_minor(version)\n version.split('.').map(&:to_i)\n end",
"def major_version\n '1.8'\n end",
"def os_minimum_version=(value)\n @os_minimum_version = value\n end",
"def os_minimum_version=(value)\n @os_minimum_version = value\n end",
"def build_os_version(os)\n # NOTE: UA regexes don't always give us the versions back\n # they do get \"corrected\" for various OSes such as:\n # - Windows (Windows NT 6.0 => 'Vista')\n # - Windows ('Windows NT 6.3' => '8','1')\n # - Windows ('Windows NT 10.0' => '10')\n # - iOS ('Darwin/15.5' => '9','3','2')\n return unless major = os.major\n if major.to_i.to_s == major\n version, sep = duped_string(major), '.'\n else\n version, sep = duped_string(major), ' '\n end\n if os.minor\n version << sep << os.minor\n if os.patch\n version << '.' << os.patch\n if os.patchMinor\n version << '.' << os.patchMinor\n end\n end\n end\n version\n end",
"def major_engine_version\n data[:major_engine_version]\n end",
"def os_version # rubocop:disable Lint/DuplicateMethods\n @os_version ||= @name.match(PLATFORM_REGEX)[2]\n end",
"def major(version)\n if version.include? '_'\n major, _ = version.split('_', 2)\n else\n major = version\n end\n return major\n end",
"def osver\n return `uname -r`.chomp\n end",
"def get_current_version(version)\n # 0 would be if we are looking for latest\n if version.to_s.eql?('0')\n Chef::Log.debug(\n 'No version filtering. Grabbing the highest version from disk',\n )\n # Current_resource.version is string.\n return Gem::Version.new(current_resource.version.max)\n else\n Chef::Log.debug(\"Grabbing the highest version of v#{version} from disk.\")\n # Grab the highest version that meets the major, minor, build given\n list = current_resource.version.map { |v| Gem::Version.new(v) }\n Chef::Log.debug(\"Installed versions found: #{list.join(', ')}\")\n\n # Reducing by version can result in nil array.\n max = reduce_by_version(list, version).max\n return max.nil? ? Gem::Version.new(0) : max\n end\n end",
"def version_less_than_seventeen?\n verify_gem_version(celluloid_version, '0.17', operator: '<')\n end",
"def os_version\n if !@os_version\n if Facter['operatingsystemrelease'] &&\n Facter['operatingsystemrelease'].value &&\n !Facter['operatingsystemrelease'].value.empty?\n @os_version = Facter['operatingsystemrelease'].value\n else\n raise \"Unable to determine proper OS value on this platform\"\n end\n end\n @os_version.dup\n end",
"def win_64bit?\n x86_64? && (latest_version? || new_resource.version.split('.').first.to_i >= 42)\nend",
"def have_version?(major, minor = nil, update = nil, build = nil)\n if major.class == Float\n major = major.to_s\n end\n if major.class == String\n major,minor,update = major.split('.').collect { |x| x.to_i }\n end\n if major == @major\n return false if minor != nil && minor != @minor\n return false if update != nil && update != @update\n return false if build != nil && build != @build\n return true\n else\n return false\n end\n end",
"def extract_os_version(version)\n #version.unpack('CCS').join('.')\n begin\n os_version = NTLM::OSVersion.read(version)\n rescue IOError\n return ''\n end\n return \"#{os_version.major}.#{os_version.minor}.#{os_version.build}\"\n end",
"def test_prerelease?(version)\n !@version.stable? && @version.major == version.major && @version.minor == version.minor && @version.patch == version.patch\n end",
"def dev_major() end",
"def major_engine_version\n data.major_engine_version\n end",
"def yosemite_or_newer?\n Gem::Version.new(`sw_vers -productVersion`) >= Gem::Version.new('10.10')\nend",
"def platform_version\n Ohai.platform_version\n end",
"def check_version(v)\n return true if (!version || version[0..4].gsub(\".\",\"\").to_i>=v)\n return false\n end",
"def version_gte_71?\n version >= v71\n end",
"def minor_version\n @version_helper.minor\n end",
"def minor_version\n @version_helper.minor\n end",
"def minor_version\n @version_helper.minor\n end",
"def min_version\n @min_version ||= nil\n end",
"def has_version?; end",
"def version_gte_62?\n version >= v62\n end",
"def version_major_minor\n version.split('.')[0..1].join('.')\n end",
"def os_maximum_version=(value)\n @os_maximum_version = value\n end",
"def os_maximum_version=(value)\n @os_maximum_version = value\n end",
"def major_upgrade?(to)\n nil unless installed?\n major_version(installed_version?) != major_version(to)\n end",
"def have_at_least_version?(major, minor = nil, update = nil, build = nil)\n if major.class == Float\n major = major.to_s\n end\n if major.class == String\n major,minor,update = major.split('.').collect { |x| x.to_i }\n end\n if major == @major #Could true\n if minor != nil #Being asked to test minor level\n if minor == @minor #Could be true\n if update != nil #Being asked to test update level\n if update == @update #Could be true\n if build != nil #Being asked to test the build version\n return build <= @build #have at least the required patch level.\n end\n return true #update was equal\n end\n return update < @update #current version is newer\n end\n return true #major and minor was equal.\n end\n return minor < @minor #true if current version is newer\n end\n return true #major was equal.\n end\n return major < @major #true, if current version is newer\n end",
"def fetch_linux_os_version\n `lsb_release -rs`.strip\nend",
"def platform\n type = os_type(:nice)\n type = case type\n when /Linux/i then linux_type\n else type\n end\n \n # Grab the Solaris version; turns '5.9' into '9', for example. (Solaris has a really\n # bizarre numbering scheme.)\n #\n # FIXME: This should include patchlevel.\n if type =~ /Solaris/i\n if @solaris_version.nil?\n @solaris_version = @platform.exec(\"uname\", \"-r\").strip\n @solaris_version = $2 if @solaris_version =~ /^\\s*(\\d+)\\s*\\.\\s*(\\d+)\\s*$/i\n end\n \n type += @solaris_version\n end\n \n # Grab the OS X version by looking at the Darwin kernel version.\n #\n # FIXME: This should include minor version, too (e.g., 10.4.7).\n if type =~ /OSX/i\n if @osx_version.nil?\n @osx_version = @platform.exec(\"uname\", \"-r\").strip\n if @osx_version =~ /^\\s*(\\d+)\\s*\\.\\s*(\\d+).*$/i\n minor_version = [ $1.to_i - 4, 0 ].max # i.e., Darwin 8.x => OS X 10.4, 7.x => OS X 10.3, etc.\n @osx_version = \"10.%d\" % minor_version\n else\n @osx_version = '-unknown-%s' % @osx_version\n end\n end\n \n type += @osx_version\n end\n \n # Grab the Windows version by System.getProperty\n if type =~ /Windows/i\n os_name = JavaSystem.getProperty('os.name');\n sun_os_patch_level = JavaSystem.getProperty('sun.os.patch.level');\n if @windows_version.nil?\n @windows_version = case os_name \n when /Windows 2003/i: \"win2k3\"\n when /Windows XP/i: \"winxp\"\n else os_name.gsub(/ /, '_')\n end\n unless sun_os_patch_level == \"unknown\"\n patch = ''\n sun_os_patch_level.split(/ /).each do |t|\n patch = \"#{patch}#{t[0..0]}\"\n end\n @windows_version += '-' + patch\n end \n end\n \n type = @windows_version\n end\n \n \"%s-%s\" % [ type.downcase, processor_type.downcase ]\n end",
"def kernel_version\n uname('-v')\n end",
"def rhel6?(node = __getnode)\n node[\"platform_family\"] == \"rhel\" && node[\"platform_version\"].to_f >= 6.0 && node[\"platform_version\"].to_f < 7.0\n end",
"def rhel7x?\n platform_family?('rhel') && node['platform_version'].to_f >= 7\n end",
"def rhel7x?\n platform_family?('rhel') && node['platform_version'].to_f >= 7\n end",
"def version_less_than_eigthteen?\n verify_gem_version(celluloid_version, '0.18', operator: '<')\n end",
"def el_version\n if File.exists?('/etc/fedora-release')\n nil\n elsif File.exists?('/etc/redhat-release')\n rpm = Pkg::Util::Tool.find_tool('rpm', :required => true)\n stdout, _, _ = Pkg::Util::Execution.capture3(\"#{rpm} -q --qf \\\"%{VERSION}\\\" $(#{rpm} -q --whatprovides /etc/redhat-release )\")\n stdout\n end\n end",
"def compatible?(version)\n bin_version = Gem::Version.new(version)\n supports_min = !minimum_cocoapods_version ||\n (bin_version >= Gem::Version.new(minimum_cocoapods_version))\n supports_max = !maximum_cocoapods_version ||\n (bin_version <= Gem::Version.new(maximum_cocoapods_version))\n supports_min && supports_max\n end",
"def version_gte_72?\n version >= v72\n end",
"def platform_version_mac_os_x(arg)\n arg.match(/^[0-9]+\\.[0-9]+/).to_s\n end",
"def installed_version\n capture(\"#{chef_solo} -v || true\") =~ /Chef: (\\d+\\.\\d+\\.\\d+)/ ? $1 : nil\n end",
"def bump_major_version; end",
"def rhel8?(node = __getnode)\n node[\"platform_family\"] == \"rhel\" && node[\"platform_version\"].to_f >= 8.0 && node[\"platform_version\"].to_f < 9.0\n end",
"def version\n str = if detect_product(\"CriOs\")\n crios.version\n else\n chrome.version\n end\n\n Version.new(str)\n end",
"def platform_version\n version = capabilities['platformVersion']\n version.nil? ? nil : version.to_s\n end",
"def major; end",
"def major; end",
"def major; end",
"def installed_version\n lines = powershell_out!('Get-WmiObject -Class win32_product')\n .stdout.lines\n idx = lines.index do |l|\n l.match(/^\\W*Name\\W+:\\W+Chef Development Kit/)\n end\n return false if idx.nil?\n ver = lines[idx + 2].match(/:\\W+([0-9]+\\.[0-9]+\\.[0-9]+)\\.[0-9]+/)[1]\n ver == package_metadata[:version] ? 'latest' : ver\n end",
"def major_minor\n # TODO: It would be cool to try <major>.<minor + 1> if possible.\n ver = version_data['serverVersion']\n [ver['major'], ver['minor']]\n .map(&:to_i)\n .map(&:to_s)\n .join('.')\n end",
"def ios_at_least? version\n version.to_f.round(3) <= ios_version.to_f.round(3)\n end",
"def version\n @version ||= version_hex.to_s(16).chars.entries.join('.')\n end",
"def version_check\n version = params[:version]\n return render :status=>400, :json=>{:message=>\"The request must contain the a version number.\"} if version.blank?\n\n #check against current major version of app\n v = version.split(\".\")[0]\n if CURRENT_MAJOR_VERSION.to_i > v.to_i\n render :status=>600, :json=>{:status => \"Needs to upgrade to latest major version\"}\n return\n end\n render :status=>200, :json=>{:status => \"Success\"}\n end",
"def platform_version_windows(arg)\n # Make a best guess and assume a server OS\n # See: http://msdn.microsoft.com/en-us/library/windows/\n # desktop/ms724832(v=vs.85).aspx\n {\n '6.3' => '2012r2', '6.2' => '2012', '6.1' => '2008r2',\n '6.0' => '2008', '5.2' => '2003r2', '5.1' => 'xp', '5.0' => '2000'\n }[arg.match(/^[0-9]+\\.[0-9]+/).to_s]\n end",
"def max_version\n @max_version ||= nil\n end",
"def has_java_version?(ver)\n java_version.start_with? \"1.#{ver}\"\n end",
"def semantic_version(major: T.unsafe(nil), minor: T.unsafe(nil), patch: T.unsafe(nil)); end",
"def current_version?\n version == FirmwareUpgrade.current_software_version\n end"
] |
[
"0.7908768",
"0.778943",
"0.7641181",
"0.75656223",
"0.74951726",
"0.73930484",
"0.73029363",
"0.72966486",
"0.72966486",
"0.7276666",
"0.72604084",
"0.7234367",
"0.7230939",
"0.7185924",
"0.7123798",
"0.7100777",
"0.70891786",
"0.70891786",
"0.7075512",
"0.7075512",
"0.7075223",
"0.70202845",
"0.69922036",
"0.6985944",
"0.6966881",
"0.69578063",
"0.6921613",
"0.6921613",
"0.6921613",
"0.69062907",
"0.69034606",
"0.6897621",
"0.6897621",
"0.6897621",
"0.6878074",
"0.6877577",
"0.6869135",
"0.68157923",
"0.6811119",
"0.6774831",
"0.6752502",
"0.6752502",
"0.6741386",
"0.673652",
"0.6729888",
"0.6702932",
"0.6684038",
"0.6676214",
"0.6675799",
"0.6667492",
"0.6662234",
"0.666175",
"0.6638188",
"0.6617506",
"0.66133493",
"0.65995157",
"0.6598104",
"0.6593121",
"0.65701973",
"0.6547811",
"0.65465057",
"0.65465057",
"0.65465057",
"0.654462",
"0.65322495",
"0.6529197",
"0.6522766",
"0.65196955",
"0.65196955",
"0.6515917",
"0.6504026",
"0.65029454",
"0.6502089",
"0.64879",
"0.6486101",
"0.6481622",
"0.6481622",
"0.64750683",
"0.6455485",
"0.6452793",
"0.6442141",
"0.643765",
"0.64347035",
"0.64073694",
"0.6394676",
"0.6382662",
"0.63606083",
"0.6349783",
"0.6349783",
"0.6349783",
"0.63440263",
"0.63419574",
"0.63418794",
"0.63409007",
"0.63392776",
"0.6338625",
"0.63215256",
"0.63211757",
"0.6317787",
"0.63053733"
] |
0.78176755
|
1
|
Takes one or more AWS account IDs as strings and return true if this node is in any of those accounts.
|
def in_aws_account?(*accts)
return false if self.quiescent?
return false unless self['ec2']
accts.flatten!
accts.include?(self['ec2']['account_id'])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def users_include?(*user_ids)\n user_ids.map { |user_id| @users.include?(user_id) }.all?\n end",
"def contains(uid)\n #This doesn't work in ruby 1.8.5\n #return self[\"USERS/ID[.=#{uid}]\"] != nil\n\n id_array = retrieve_elements('USERS/ID')\n return id_array != nil && id_array.include?(uid.to_s)\n end",
"def contains(uid)\n #This doesn't work in ruby 1.8.5\n #return self[\"USERS/ID[.=#{uid}]\"] != nil\n\n id_array = retrieve_elements('USERS/ID')\n return id_array != nil && id_array.include?(uid.to_s)\n end",
"def in_any_rolegroup? *rolegroups\n !(rolegroup_list & rolegroups.to_symbols).empty?\n end",
"def is_a_merchant?(given_ids)\n return given_ids.include?(self.id)\n end",
"def in?(*list)\n for item in list\n self === item and return true\n end\n false\n end",
"def is_any?(*queried_roles)\n (queried_roles & roles).present?\n end",
"def contains_node?(node)\n self.any? { |arr| arr.include?(node.id)}\n end",
"def exists?(ids)\r\n if ids.is_a?(Array) && ids.first.is_a?(String)\r\n count(:conditions => ids) > 0\r\n else\r\n obj = find(ids) rescue false\r\n !obj.nil? and obj.is_a?(self) \r\n end\r\n end",
"def servers_for_role?(roles) #:nodoc:\n roles=Array(roles)\n roles.any? { |r| @roles.keys.include? (r) }\n end",
"def user_role_in?(*roles)\n if (roles - ROLES.keys).length > 0\n raise \"role not defined in application_controller#user_role_in?. It's likely you've mistyped a role symbol.\"\n end\n return false if current_user.nil?\n r = roles.map {|i| ROLES[i]}\n matching_roles = current_user.roles.pluck(:id) & r\n return true if matching_roles.length > 0\n return false\n end",
"def has? *rolegroups\n list == rolegroups.to_symbols_uniq\n end",
"def multiple_account_types?\n account_types.size > 1\n end",
"def allows_access?(account)\n return false if account.nil?\n if(account.is_a? Worker) then \n return true if account.has_role?(Role::ADMIN)\n worker_group_ids = account.worker_groups.collect {|g| g.id}\n return worker_group_ids.include?(self.worker_group_id)\n else\n client_group_ids = account.client_groups.collect {|g| g.id}\n return client_group_ids.include?(self.client_group_id)\n end\n end",
"def allowed?\n @roles.any? { |r| r.to_s.downcase == Account.find(@account_id).role.downcase }\n end",
"def include?(roles)\n return false if roles.nil?\n\n # Ensure we've an array of roles, one way or another\n roles = roles.to_s if roles.class == Symbol\n roles = roles.split(',') if roles.class == String\n\n roles.each do |role|\n return true if @role_array.include?(role.to_s.intern)\n end\n\n return false\n end",
"def has_role?(*role_names)\n self.roles.where(:name => role_names).present?\n end",
"def in?(*values)\n if !values.nil?\n values = values[0] if values.length == 1 and values[0].is_a? Array\n ->(o) { values.map { |l| wrap(l, ->(a, b) { a == b }).call(o) }.any? }\n else\n ANY\n end\n end",
"def range_include?(ranges, addr)\n\t\t\tranges.each do |range|\n\t\t\t\treturn true if range.include? addr\n\t\t\tend\n\t\t\tfalse\n\t\tend",
"def include?(conn)\n return @uuids.include? conn.uuid\n end",
"def roles_contain_one_of?(allowed_roles)\n roles.any? do |role|\n allowed_roles.include? role\n end\n end",
"def has_role_in? (roles_in = [])\n # Rails.logger.debug(\"* Models::UserRoles.has_role_in? self.roles:#{self.roles}, role_in:#{roles_in.inspect.to_s}\")\n ret_val = false\n roles_in.each do |a_role|\n ret_val = true if (to_array_if_not(self.roles)).index(a_role.to_s) != nil\n end\n ret_val\n end",
"def member?(user)\n user_ids.include?(user.id)\n end",
"def _is_in(token, list)\n return false unless list\n list.include?(token[1])\n end",
"def isIn(user)\n \n isIn = false\n @userList.getcontents.each { |users| \n \n if(user == users)\n isIn = true\n break\n end\n \n }\n return isIn\n end",
"def current_user_has_any_role?(node)\n current_user.present? && current_user.has_any_role?(node)\n end",
"def search_node_in_roles( roles )\n roles.each do |r|\n Chef::Log.info \"Searching for '#{self[:fqdn]}' in the '#{r}' role.\"\n if self.role?(r)\n # return true for the first match\n Chef::Log.info \"Whitelisting: Found node '#{self[:fqdn]}' via role '#{r}'.\"\n return true\n end\n end\n\n return false\n\n end",
"def has_role? *roles\n (roles_list & roles.flatten).not.empty? \n end",
"def account_insync?(current, should)\n return false unless current\n\n should_empty = should.nil? || should.empty?\n return false if current.empty? != should_empty\n\n get_account_id(current) == get_account_id(should)\n end",
"def valid_user?(user_id)\n user_ids.include?(user_id)\nend",
"def is_account_holder?\n roles.any? { |r| r.title == 'account_holder' }\n end",
"def member_of?(context)\n context.users.include? self\n end",
"def check_access_control_account_all\n @account = Account.find(params[:account_id])\n\n response_access_denied unless current_user.has_role?(:admin) || current_user.id == @account.user_id\n rescue\n response_access_denied\n end",
"def matches? invoice\n contact_ids.include? invoice.contact_id\n end",
"def account_name_exists?\n (company.accounts.pluck(:name) - [current_account.try(:name)]).include?(name)\n end",
"def checked?(checked_zones)\n checked_zones.include?(id)\n end",
"def valid?\n ids.include?(@id)\n end",
"def in(*list)\n if list.length == 1\n return list[0].include?(self)\n else\n return list.include?(self)\n end\n end",
"def include_ids?(item_ids)\n all_item_ids == item_ids\n end",
"def member_of_group?(*names)\n @group_names && @group_names.intersect?(names.to_set) \n end",
"def any_role?(guild_id, *allowed_roles)\n character_ids = Character.where(user_id: id, guild_id: guild_id).pluck(:id)\n GuildRole.exists?(guild_id: guild_id, character_id: character_ids, name: allowed_roles)\n end",
"def is_role?(*roles)\n roles.include? role\n end",
"def has_categories?(company, *category_ids)\n return false if category_ids.empty?\n customer_category_ids = get_customer_categories(customer_id: company.id)\n customer_category_ids = as_array(customer_category_ids)\n (customer_category_ids & category_ids) == category_ids\n end",
"def has_entitlements?(id, entitlement_keys, scope = SilverSpoon.default_scope)\n SilverSpoon.redis.multi do |transaction|\n entitlement_keys.each do |entitlement_key|\n transaction.hexists(silver_spoon_key(id, SilverSpoon.namespace, scope), entitlement_key)\n end\n end\n end",
"def credentials?\n credentials.values.all?\n end",
"def pin_exists?(pin)\r\n all.map(&:pin).include?(pin)\r\n end",
"def in_rolegroups? *rolegroups\n (rolegroups.to_symbols - rolegroup_list).empty?\n end",
"def local_jid?(*jids)\n !jids.flatten.index do |jid|\n !vhost?(JID.new(jid).domain)\n end\n end",
"def ids_in\n \"p.id IN :ids\" if options[:id].present?\n end",
"def includes_all? *args\n args.all? { |arg| include? arg }\n end",
"def contains_admin(uid)\n #This doesn't work in ruby 1.8.5\n #return self[\"ADMINS/ID[.=#{uid}]\"] != nil\n\n id_array = retrieve_elements('ADMINS/ID')\n return id_array != nil && id_array.include?(uid.to_s)\n end",
"def object_exists_in_list(objects, text)\n objects.each do |item|\n if item.text.upcase.include? text.upcase\n return true\n end\n end\n false\n end",
"def authorize(ids)\n authorized = ids.any? { |id| @data.user_id == id }\n raise UnauthorizedError unless authorized\n end",
"def ancestor_on_list?(paths)\n paths.any? { |path|\n ancestors.any? { |ancestor| ancestor.match?(path) }\n }\n end",
"def has_role? (roles_array)\n roles_array.each do |role|\n if roles.include? role.to_s\n return true\n end\n end\n return false\n end",
"def exists?(*args)\n args.flatten!(1)\n keys_per_node = args.group_by { |key| node_for(key) }\n keys_per_node.each do |node, keys|\n return true if node.exists?(*keys)\n end\n false\n end",
"def select_accounts_from_names(names)\n names.uniq!\n\n found_accounts = config.accounts.select do |account|\n names.include?(account[:name])\n end\n\n missing_accounts(names, found_accounts) unless names.length == found_accounts.length\n\n found_accounts\n end",
"def include?(address)\n return false unless address\n\n members.any? do |zone_member|\n case zone_member.zoneable_type\n when \"Spree::Country\"\n zone_member.zoneable_id == address.country_id\n when \"Spree::State\"\n zone_member.zoneable_id == address.state_id\n when \"Spree::Zipcode\"\n zone_member.zoneable.name == address.zipcode_base\n else\n false\n end\n end\nend",
"def is_customer_in_exclusion_list?(first_name, last_name)\n name = [first_name, last_name].join(' ')\n !name.strip.blank? and config.exclude_customers.include?(name)\n end",
"def exists? tag_or_tags_or_id_or_ids, owners_or_ids=nil\n tag_ids = (tag_or_tags_or_id_or_ids.is_a?(Array) ? tag_or_tags_or_id_or_ids : [ tag_or_tags_or_id_or_ids ] ).collect { |tag_or_id|\n tag_or_id.is_a?(Fixnum) ? tag_or_id : tag_or_id.id\n }\n return false if tag_ids.empty? # Empty in, empty out\n tag_ids = tag_ids.first if tag_ids.count == 1\n query = { tag_id: tag_ids,\n entity_id: @taggable_entity.id,\n entity_type: @taggable_entity.class }\n\n if owners_or_ids\n owner_ids = (owners_or_ids.is_a?(Array) ? owners_or_ids : [ owners_or_ids ] ).collect { |owner_or_id|\n owner_or_id.is_a?(Fixnum) ? owner_or_id : owner_or_id.id\n }\n query[:user_id] = ((owner_ids.count == 1) ? owner_ids.first : owner_ids) unless owner_ids.empty?\n end\n Tagging.where(query).any?\n end",
"def has_roles?(*roles)\n (roles_list - roles.flatten).empty? \n end",
"def account_belongs_to?(user, acct_no)\n acct_user = DB[:Account].where(AcctNo: acct_no).first[:UserID]\n acct_user == user\n end",
"def has_at_least_one_of_roles(atts)\n if !atts[:roles]\n return true\n end\n\n for role in atts[:roles]\n if has_role( { :role => role, :user => atts[:user] } )\n return true\n end\n end\n\n return false\n end",
"def include_uuid?(uuid)\n return @uuids.include? uuid\n end",
"def check_accounts\n\t\t( @participant.facebook_account != nil && @participant.facebook_account != \"\" ) ||\n\t\t( @participant.twitter_account != nil && @participant.twitter_account != \"\" ) ||\n\t\t( @participant.github_account != nil && @participant.github_account != \"\" ) ||\n\t\t( @participant.google_plus_account != nil && @participant.google_plus_account != \"\" )\n\tend",
"def roles?(roles)\n roles.include?(role&.name)\n end",
"def active_bank_accounts?\n # (client_bank_accounts_count > 0) && (!client_bank_accounts.where(ending_at: nil).blank?)\n (client_bank_accounts_count > 0) && (!active_bank_accounts.empty?)\n end",
"def addressed_only?(commit_authors)\n identifiers = commit_authors.map do |commit_author|\n [commit_author.login, commit_author.email]\n end.flatten.compact\n\n Set.new(identifiers) == mentioned_commit_authors\n end",
"def pm_is_in_ancestry?(vc, screen_names)\n screen_names.any? do |screen_name|\n vc.class.to_s.include?(screen_name) ||\n vc.class.ancestors.any? do |ancestor|\n screen_name.include?(ancestor.to_s)\n end\n end\n end",
"def employee?(user_asking)\n user_asking.in? employees\n end",
"def accessible_from?(cidr_s)\n return false if ingress_permissions.empty?\n\n cidr = NetAddr::CIDR.create(cidr_s)\n allowed_cidrs = ingress_permissions.map(&:ip_ranges)\n .flatten.map(&:cidr_ip)\n matching_rules = allowed_cidrs.map do |source_cidr|\n cidr == source_cidr || cidr.is_contained?(source_cidr)\n end\n matching_rules.include? true\n end",
"def has_an_approved_account_set?\n all_monetary_processor_accounts.was_verified.any?\n end",
"def has_one_of_roles?(roles)\n !roles.select {|r| has_role?(r)}.empty?\n end",
"def current_user_is_only_email?(cc_emails)\n cc_emails_arr = cc_emails.split(\",\").uniq\n return (cc_emails_arr.size == 1 and cc_emails_arr.include? user.email)\n end",
"def check_ip_in_whitelist(ip, whitelist)\n whitelist.map do |whitelist_cidr|\n ip_in_range(ip, whitelist_cidr)\n end.any?\n end",
"def has_account_merged_with?(provider)\n self.o_auth_credentials.where(provider: provider).any?\n end",
"def has_roles? roles, match_any=false\n roles = [*roles]\n\n return true if @roles.include? :all\n return !(roles & @roles).empty? if match_any\n\n (roles & @roles).length == roles.length\n end",
"def in_group?(group_or_id)\n group_ids.include?(Ecircle::User.group_id(group_or_id))\n end",
"def match?(cidr)\n @entries.each do |entry|\n if ( entry.matches?(cidr) )\n return(true)\n end\n end\n return(false)\n end",
"def whitelist_users?\n self.whitelist_users.any?\n end",
"def user_owner?(id)\n # find the role id for owner\n owner_id = DB[:roles].select.where(:name=>'Owner').all[0][:id]\n\n # I am not sure if a user can have more than one roll so I am going to assume it can\n users_roles = DB[:roles_users].select.where(:user_id=>id).all\n users_roles.each do |users_role|\n if users_role[:role_id] == owner_id\n return true\n else\n next\n end\n end\n return false\nend",
"def include? entity, user_or_id, with_pullins=true\n # Trivial accept if the entity is physically in among the list items\n return true if @list.stores? entity\n user_id = user_or_id.is_a?(Integer) ? user_or_id : user_or_id.id\n ts = TaggingServices.new entity\n # It's included if the owner or this user has tagged it with the name tag\n return true if ts.exists? @list.name_tag_id, (user_id == @list.owner_id ? user_id : [user_id, @list.owner_id])\n # If not directly tagged, it's included if it's tagged with any of the list's tags, BY ANYONE (?)\n return false unless with_pullins && @list.pullin\n ts.exists? pulled_tag_ids\n end",
"def include_any?(arr, arr2)\n #good for large sets w/ few matches\n # Set.new(self).intersection(arr).empty?\n arr2.any? {|e| arr.include?(e) }\n end",
"def include?(name)\n inclusively { users.has_key?(name) }\n end",
"def in?(object)\n object.include?(self)\n end",
"def in?(object)\n object.include?(self)\n end",
"def validate_accounts(id_list)\n raise ArgumentError unless id_list.is_a?(Array)\n\n api.post('validateAccounts', id_list, 'application/json')\n end",
"def active?(con, ercs)\n ercs.any? { |erc| erc.w?(con) }\n end",
"def search_players(search_names)\n @player_names.include?(each_player)\n end",
"def in_set?(set, element)\n set.each do |t|\n if t == element\n return true\n end\n end\n return false\n end",
"def employs?(user)\n employees.include?(user) or (affiliate == user) or user.admin?\n end",
"def in? first, *rest\n (first.is_a?(Array) ? first : [first].concat(rest)).include? self\n end",
"def roles_overlap?(obj)\n obj_roles = EffectiveRoles.roles_for(obj)\n (roles.blank? && obj_roles.blank?) || (roles & obj_roles).any?\n end",
"def include?(address)\n return false unless address\n \n # NOTE: This is complicated by the fact that include? for HMP is broken in Rails 2.1 (so we use awkward index method)\n members.any? do |zone_member|\n case zone_member.zoneable_type\n when \"Zone\"\n zone_member.zoneable.include?(address)\n when \"Country\"\n zone_member.zoneable == address.country\n when \"State\"\n zone_member.zoneable == address.state\n\n when \"ZipCodeRange\"\n address.zipcode and address.zipcode.between?(\n zone_member.zoneable.start_zip,\n zone_member.zoneable.end_zip)\n \n else\n false\n end\n end\n end",
"def check_cloud_identity_accounts_exist 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_check_cloud_identity_accounts_exist_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::Channel::V1::CheckCloudIdentityAccountsExistResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def include_atoms?(atoms_arr)\n atoms_arr.each do |a|\n return false if !include_atom?(a)\n end\n true\n end",
"def include? remote_ip_address\n ip_addresses.any? do |ip_address|\n ip_address.include? remote_ip_address\n end\n end",
"def codesign_identites_match?(identity1, identity2)\n return true if identity1.downcase.include?(identity2.downcase)\n return true if identity2.downcase.include?(identity1.downcase)\n false\n end",
"def all_roles_assigned?(roles)\n \n all_roles_assigned = false\n self.board_design_entry_users.reload\n \n roles.each do | role|\n all_roles_assigned = self.board_design_entry_users.detect { |user| \n user.role_id == role.id \n }\n break if !all_roles_assigned\n end\n\n all_roles_assigned != nil\n \n end",
"def member?(trip)\n trip.users.include?(self)\n end"
] |
[
"0.6463729",
"0.5934939",
"0.5934939",
"0.58159834",
"0.5791001",
"0.57766926",
"0.57446176",
"0.5658904",
"0.5648091",
"0.5631529",
"0.5608362",
"0.56019205",
"0.5571382",
"0.5539207",
"0.55386674",
"0.5517688",
"0.54203606",
"0.5391145",
"0.5376663",
"0.5371528",
"0.53691953",
"0.5368385",
"0.5351683",
"0.5332768",
"0.5330477",
"0.5329028",
"0.53126943",
"0.53030527",
"0.53021985",
"0.5295645",
"0.5290653",
"0.52763397",
"0.52721685",
"0.52639985",
"0.52620375",
"0.5252154",
"0.5241524",
"0.5214363",
"0.5213725",
"0.52097696",
"0.52070147",
"0.52055043",
"0.520237",
"0.520103",
"0.51939327",
"0.519022",
"0.518868",
"0.5179814",
"0.5164593",
"0.5148338",
"0.5111883",
"0.51104176",
"0.51042485",
"0.5100435",
"0.5099868",
"0.50984025",
"0.50968367",
"0.5095954",
"0.50948596",
"0.509032",
"0.5087229",
"0.50710607",
"0.5068644",
"0.5066128",
"0.50600326",
"0.5051864",
"0.5042715",
"0.5040107",
"0.5034217",
"0.5033423",
"0.5032249",
"0.5032228",
"0.5018852",
"0.5015708",
"0.50118494",
"0.5007553",
"0.4998868",
"0.49973258",
"0.49934292",
"0.49829885",
"0.49789",
"0.4977904",
"0.49763435",
"0.49722084",
"0.496246",
"0.496246",
"0.4959147",
"0.49590942",
"0.49379638",
"0.49378768",
"0.49230158",
"0.49164614",
"0.49137262",
"0.4910388",
"0.4904347",
"0.4900303",
"0.48939574",
"0.4883083",
"0.48815894",
"0.4877218"
] |
0.7621516
|
0
|
Take a string representing a mount point, and return the device it resides on.
|
def device_of_mount(m)
fs = self.filesystem_data
unless Pathname.new(m).mountpoint?
Chef::Log.warn(
"fb_helpers: #{m} is not a mount point - I can't determine its " +
'device.',
)
return nil
end
unless fs && fs['by_pair']
Chef::Log.warn(
'fb_helpers: no filesystem data so no node.device_of_mount',
)
return nil
end
fs['by_pair'].to_hash.each do |pair, info|
# we skip fake filesystems 'rootfs', etc.
next unless pair.start_with?('/')
# is this our FS?
next unless pair.end_with?(",#{m}")
# make sure this isn't some fake entry
next unless info['kb_size']
return info['device']
end
Chef::Log.warn(
"fb_helpers: #{m} shows as valid mountpoint, but Ohai can't find it.",
)
nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def device_of_mount(m)\n unless Pathname.new(m).mountpoint?\n Chef::Log.warn(\n \"#{m} is not a mount point - I can't determine its device.\",\n )\n return nil\n end\n node['filesystem2']['by_pair'].to_hash.each do |pair, info|\n # we skip fake filesystems 'rootfs', etc.\n next unless pair.start_with?('/')\n # is this our FS?\n next unless pair.end_with?(\",#{m}\")\n # make sure this isn't some fake entry\n next unless info['kb_size']\n return info['device']\n end\n Chef::Log.warn(\n \"#{m} shows as valid mountpoint, but Ohai can't find it.\",\n )\n return nil\n end",
"def get_device_mount_point( incoming_path )\n mount_lines = `mount`\n raise EBSRemoteExecException.new(nil,$?,mount_lines) if $? != 0\n path = File.ftype(incoming_path) != 'directory'? File.dirname(incoming_path) : incoming_path\n device=nil\n longest = \"\"\n mount_lines.each_line {|line|\n match = line =~ /(.+)\\son\\s(.+?)\\s.*/\n candidate = $2.strip\n candidate_device = $1.strip\n # Keep the longest prefix matching\n if match && path =~ /^#{candidate}/ && candidate.length > longest.length\n longest = candidate\n device = candidate_device\n end\n }\n unless device\n STDERR.puts \"Couldn't find the device for mount point #{path}\"\n Kernel.exit(-1)\n end\n device\n end",
"def guest_device(name, mount_point_obj)\n \"/dev/#{guest_vg_name(name, mount_point_obj)}/#{guest_lv_name(mount_point_obj)}\"\n end",
"def mount_point\n Pathname.new(self['MountPoint'])\n end",
"def mountpoint\n 'dev/.osctl-mount-helper'\n end",
"def setup_device_for_mount\n # use ramdisk for creating a test device for mount.\n # This can cleaner if we have chef resource/provider for ramdisk.\n case ohai[:platform_family]\n when \"aix\"\n # On AIX, we can't create a ramdisk inside a WPAR, so we use\n # a \"namefs\" mount against / to test\n # https://www-304.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.performance/namefs_file_sys.htm\n device = \"/\"\n fstype = \"namefs\"\n when \"debian\", \"rhel\", \"amazon\"\n device = \"/dev/ram1\"\n unless File.exist?(device)\n shell_out(\"mknod -m 660 #{device} b 1 0\")\n shell_out(\"chown root:disk #{device}\")\n end\n shell_out(\"ls -1 /dev/ram*\").stdout.each_line do |d|\n if shell_out(\"mount | grep #{d}\").exitstatus == \"1\"\n # this device is not mounted, so use it.\n device = d\n break\n end\n end\n fstype = \"tmpfs\"\n shell_out!(\"mkfs -q #{device} 512\")\n when \"solaris2\"\n device = \"swap\"\n fstype = \"tmpfs\"\n else\n end\n [device, fstype]\n end",
"def get_mount_path(filepath)\n cmd_exec(\"df \\\"#{filepath}\\\" | tail -1\").split(' ')[0]\n rescue\n raise \"Unable to get mount path of #{filepath}\"\n end",
"def format_mount(partition, mount)\n\n # Partitions that we already have mounts set for.\n return nil if partition == '/dev/mapper/rootvg-slash'\n return nil if partition == '/dev/mapper/rootvg-var'\n return nil if partition == '/dev/mapper/rootvg-tmp'\n\n mount\nend",
"def mount_command(path)\n \"udisksctl mount --block-device #{path}\"\nend",
"def mount_at(mountpoint)\n @mountpoint = mountpoint\n end",
"def convert_from_mapper(name)\n if name.match(/\\/dev\\/mapper/)\n v=name.split(\"/\")\n c=v[3].split(\"-\")\n vg=c[0]\n lv=c[1]\n \"/dev/#{vg}/#{lv}\"\n else\n name\n end\n end",
"def mount_point\n @mount_point ||= options[:iso_mount_point]\n return @mount_point\n end",
"def device(value, &block)\n value = value.to_s\n device = devices.find { |d| d.name == value || d.shortname == value }\n\n run_device_block_if_needed(device, &block)\n\n device\n end",
"def device_with_name(name)\n c = settings.subaru_config[:devices][name]\n return Object.const_get(\"Subaru::Definitions::#{c[:definition]}\").new(c) if c\n rescue => e\n puts e.message\n return nil\n end",
"def mountpoint\n self\n end",
"def mountpoint\n self\n end",
"def mount(name, root_dev)\n puts \"Mounting KVM device: #{root_dev}\"\n mount_loc = File.join(KVM_MOUNT_POINT, name)\n unless(system(\"mount | grep #{mount_loc}\"))\n FileUtils.mkdir_p(mount_loc)\n if(system(\"mount #{root_dev} #{mount_loc}\"))\n mount_loc\n else\n raise \"Failed to mount #{root_dev} to #{mount_loc}\"\n end\n else\n puts \"Device already mounted (#{mount_loc})\"\n mount_loc\n end\nend",
"def device\n xpath '.', 'device'\n end",
"def test_mountstring\n mount = nil\n name = \"yaytest\"\n path = tmpdir\n assert_nothing_raised {\n mount = Puppet::Network::Handler.fileserver::Mount.new(name, path)\n }\n\n assert_equal(\"mount[#{name}]\", mount.to_s)\n end",
"def is_mounted?(device)\n system(\"grep -q '#{device}' /proc/mounts\")\nend",
"def mount_device(device, mount_point, owner, group, fs_type)\n puts `echo #{device} #{mount_point} #{fs_type} noatime 0 0|tee -a /etc/fstab`\n puts \"Making mount directory #{mount_point} for #{device}\"\n puts `mkdir -p #{mount_point}`\n puts \"Mounting #{device} at #{mount_point}\"\n puts `mount #{mount_point}`\n puts \"Setting ownership on #{mount_point} to #{owner}\"\n puts `chown #{owner}:#{owner} #{mount_point}`\n end",
"def GetMountString(used_fs, defaultv)\n fsmap = GetFsMap(used_fs)\n ret = Ops.get_string(fsmap, :mount_string, defaultv)\n Builtins.y2milestone(\"GetMountString used_fs:%1 ret:%2\", used_fs, ret)\n ret\n end",
"def get_fs_type(device)\n fs_check = Mixlib::ShellOut.new(\"blkid -c /dev/null #{device}\")\n fs_check.run_command\n match = fs_check.stdout.match(/TYPE=\\\"(.*)\\\"/)\n match = '' if match.nil?\n\n match[1]\nend",
"def name\n File.join(\"/dev/\",@device.gsub(/!/, \"/\"))\n end",
"def root_device\n begin\n @root_device = open('http://instance-data/latest/meta-data/block-device-mapping/root').read\n rescue\n message.fatal 'Could not get the root device!'\n end\n end",
"def ip_by_mount(name)\n dev = available_dev unless mounted?(name)\n loc = mount(name, dev)\n addr = %x{cat #{File.join(loc, 'etc', 'network', 'interfaces')} | grep address}.split(' ').last.to_s.strip\n unmount_kvm_volume(name, dev) if dev\n addr\nend",
"def get_fs_type(device)\n fs_check = Mixlib::ShellOut.new(\"blkid -c /dev/null #{device}\")\n fs_check.run_command\n match = fs_check.stdout.match(/\\sTYPE=\\\"(.*?)\\\"/)\n match = '' if match.nil?\n\n Chef::Log.info(\"File system type for device #{device}: #{match[1]}\")\n match[1]\nend",
"def device(device)\n @devices[device] \n end",
"def device(device)\n @devices[device] \n end",
"def getDeviceByBacking(backingFile, hardware = nil)\n hardware ||= getHardware\n\n hardware[\"device\"].to_a.each do |dev|\n next if dev.xsiType != \"VirtualDisk\"\n next if dev[\"backing\"][\"fileName\"] != backingFile\n return dev\n end\n nil\n end",
"def get_1st_partition(device)\n # Resolves the real device name (ex. /dev/sdg)\n Chef::Log.info(\"Getting 1st partition for device: #{device}\")\n fs_check = Mixlib::ShellOut.new(\"lsblk -ln -o Name #{device}|awk 'NR==2'\")\n fs_check.run_command\n partition = \"/dev/\" + fs_check.stdout.strip\n Chef::Log.info(\"1st partition for device: #{device} is: #{partition}\")\n partition\nend",
"def mountpoints\n mtab = IO.readlines '/proc/mounts'\n mountpoints = mtab.map{ |line| line.split(/\\s+/)[1]}\n mountpoints.map!{ |mount| unescape(mount) }\n # Ignore common system mountpoints.\n mountpoints.reject!{ |mount| mount =~ /^\\/$/ }\n mountpoints.reject!{ |mount| mount =~ /^\\/(proc|sys|usr|boot|tmp|dev|var|bin|etc|lib).*/ }\n # Mount /run/media/* but ignore other /run/ mountpoints.\n mountpoints.reject!{ |mount| mount =~ /^\\/run.*/ unless mount =~ /^\\/run\\/(media.*)/ }\n\n # Add home dir.\n mountpoints << home\n end",
"def select_device_name(volume_attachments, first_device_name_letter)\n (first_device_name_letter..'z').each do |char|\n # Some kernels remap device names (from sd* to vd* or xvd*).\n device_names = [\"/dev/sd#{char}\", \"/dev/vd#{char}\", \"/dev/xvd#{char}\"]\n # Bosh Agent will lookup for the proper device name if we set it initially to sd*.\n return \"/dev/sd#{char}\" if volume_attachments.select { |v| device_names.include?(v['device']) }.empty?\n @logger.warn(\"`/dev/sd#{char}' is already taken\")\n end\n\n nil\n end",
"def get_active_mount_point( index )\n Comatose.mount_points.each do |path_info|\n if path_info[:index] == index\n return path_info\n end\n end\n {:root=>\"\", :index=>index}\n end",
"def detect_device(asm_file)\n first_line = File.open(asm_file, 'r') { |f| f.readline }\n md = first_line.match %r{(p|chip=)([0-9A-Za-z]+)}\n if !md\n raise \"Could not determine device from first line of #{asm_file}.\"\n end\n md[2]\nend",
"def path\n if location =~ /^\\/dev/\n \"dev:#{location}\"\n elsif location =~ /iso$/\n \"iso:#{location}\"\n elsif location.is_a?(Integer)\n \"disc:#{location}\"\n elsif location =~ /^disc/\n location\n else\n raise RuntimeError\n end\n end",
"def path\n if location =~ /^\\/dev/\n \"dev:#{location}\"\n elsif location =~ /iso$/\n \"iso:#{location}\"\n elsif location.is_a?(Integer)\n \"disc:#{location}\"\n elsif location =~ /^disc/\n location\n else\n raise RuntimeError\n end\n end",
"def get_current_devices(output)\n lines = output.split(\"\\n\")\n partitions = lines.drop(2).map do |line|\n line.chomp.split.last\n end\n partitions.reject! do |partition|\n partition =~ /^dm-\\d/\n end\n devices = partitions.select do |partition|\n partition =~ /[a-z]$/\n end\n devices.sort!.map! {|device| \"/dev/#{device}\"}\n if devices.empty?\n devices = partitions.select do |partition|\n partition =~ /[0-9]$/\n end.sort.map {|device| \"/dev/#{device}\"}\n end\n devices\n end",
"def device\n device_name\n end",
"def parent_whole_disk\n Device.new('/dev/' + self['ParentWholeDisk'])\n end",
"def mount_usb_drive\n execute_system_cmd('mount /home/pi/compartida/musica/discousb')\n end",
"def device\n dev_entry = self.dev_node\n return nil if dev_entry.nil?\n return Device.new(dev_entry)\n end",
"def get_uuid(device)\n Chef::Log.info(\"Getting uuid for device: #{device}\")\n fs_check = Mixlib::ShellOut.new(\"blkid -c /dev/null #{device}\")\n fs_check.run_command\n match = fs_check.stdout.match(/\\sUUID=\\\"(.*?)\\\"/)\n match = '' if match.nil?\n Chef::Log.info(\"uuid for device: #{device} is #{match[1]}\")\n match[1]\nend",
"def mount_uuid(device)\n device[\"uuid\"] || \"#{device['pciBusNumber']}#{device['pciDeviceNumber']}\"\n end",
"def read_device_info (device, kind)\n kind = kind.to_sym\n kinds = [:ip, :udid, :serial]\n unless kinds.include?(kind)\n raise \"#{kind} must be one of '#{kinds}'\"\n end\n cmd = \"cat ~/.xamarin/devices/#{device}/#{kind} | tr -d '\\n'\"\n `#{cmd}`\nend",
"def find(a)\n devices.find { |d| d.alias.match(/^#{a}$/i) }\n end",
"def device\n return nil unless length >= 4\n return nil unless self[3].comment.last.include?(' Build/')\n\n self[3].comment.last.split(' Build/').first\n end",
"def mountBy(settings)\n settings = deep_copy(settings)\n tm = Storage.GetTargetMap\n Builtins.y2milestone(\"Storage::GetTargetMap returns %1\", tm)\n settings = Builtins.maplist(settings) do |d|\n device = Ops.get_string(d, \"device\", \"\")\n Ops.set(\n d,\n \"partitions\",\n Builtins.maplist(Ops.get_list(d, \"partitions\", [])) do |p|\n mountby = \"\"\n mountByIsList = false\n if Ops.get_string(p, \"mount\", \"\") == \"swap\" ||\n Ops.get_symbol(p, \"filesystem\", :none) == :swap\n Ops.set(p, \"mount\", \"swap\")\n Ops.set(p, \"filesystem\", :swap)\n end\n if Builtins.haskey(p, \"mountby\")\n if Ops.get_symbol(p, \"mountby\", :none) == :label\n mountby = \"label\"\n elsif Ops.get_symbol(p, \"mountby\", :none) == :uuid\n mountby = \"uuid\"\n elsif Ops.get_symbol(p, \"mountby\", :none) == :path\n mountby = \"udev_path\"\n elsif Ops.get_symbol(p, \"mountby\", :none) == :id\n mountByIsList = true\n mountby = \"udev_id\"\n elsif Ops.get_symbol(p, \"mountby\", :none) != :device\n Builtins.y2milestone(\n \"unknown mountby parameter '%1' will be ignored\",\n Ops.get_symbol(p, \"mountby\", :none)\n )\n end\n end\n # reuse partition by \"mountby\"\n if mountby != \"\" && Ops.get_boolean(p, \"create\", true) == false &&\n !Builtins.haskey(p, \"partition_nr\")\n label = Ops.get_string(p, mountby, \"\")\n Builtins.y2milestone(\n \"mountby found for %1=%2 in part=%3\",\n mountby,\n label,\n p\n )\n target = Ops.get(tm, device, {})\n if device == \"\"\n Builtins.y2milestone(\"searching for the device by %1\", mountby)\n Builtins.foreach(tm) do |deviceName, tmp_target|\n Builtins.foreach(Ops.get_list(tmp_target, \"partitions\", [])) do |targetPart|\n if mountByIsList ?\n Builtins.contains(\n Ops.get_list(targetPart, mountby, []),\n label\n ) :\n Ops.get_string(targetPart, mountby, \"\") == label\n target = deep_copy(tmp_target)\n device = deviceName\n Builtins.y2milestone(\"device=%1 found\", device)\n raise Break\n end\n end\n end\n end\n Builtins.foreach(Ops.get_list(target, \"partitions\", [])) do |targetPart|\n if mountByIsList ?\n Builtins.contains(\n Ops.get_list(targetPart, mountby, []),\n label\n ) :\n Ops.get_string(targetPart, mountby, \"\") == label\n Builtins.y2milestone(\"%1 found in targetmap\", mountby)\n Ops.set(d, \"device\", device) #FIXME: for some reason this does not work\n Ops.set(\n p,\n \"partition_nr\",\n Ops.get_integer(targetPart, \"nr\", 0)\n )\n Ops.set(p, \"usepart\", Ops.get_integer(targetPart, \"nr\", 0))\n end\n end\n end\n deep_copy(p)\n end\n )\n deep_copy(d)\n end\n Builtins.y2milestone(\"after mountBy settings=%1\", settings)\n deep_copy(settings)\n end",
"def get_pt_type(device)\n fs_check = Mixlib::ShellOut.new(\"blkid -c /dev/null #{device}\")\n fs_check.run_command\n match = fs_check.stdout.match(/\\sPTTYPE=\\\"(.*?)\\\"/)\n match = '' if match.nil?\n\n Chef::Log.info(\"Partition type for device #{device}: #{match[1]}\")\n match[1]\nend",
"def mount_list(www_root)\n arr = []\n %x{mount -t iso9660}.scan(/\\S+ on (\\S+)/) do |a|\n mountpoint = a[0]\n arr << mountpoint if mountpoint.match %r{#{www_root}}\n end\n arr\nend",
"def fstype\n return self['fstype'] if has_key?('fstype')\n Chef::Log.info([\n self['fstype'], current[:fstype],\n File.exists?(device) && `file -s '#{device}'`.chomp,\n self,\n ].inspect)\n return current[:fstype] if current[:fstype]\n return unless File.exists?(device)\n dev_type_str = `file -s '#{device}'`.chomp\n case\n when dev_type_str =~ /SGI XFS/ then self['fstype'] = 'xfs'\n when dev_type_str =~ /Linux.*(ext[2-4])/ then self['fstype'] = $1\n else\n raise \"Can't determine filesystem type of #{device} -- set it explicitly in node[:volumes]\"\n end\n self['fstype']\n end",
"def mount_path; end",
"def mountpoint?\n begin\n stat1 = lstat\n stat2 = parent.lstat\n stat1.dev != stat2.dev or stat1.ino == stat2.ino\n rescue Errno::ENOENT\n false\n end\n end",
"def get_assign_command_for_device(device)\n if device.match(@assignable_disk_regex)\n \"assign letter=#{device[0,1]}\"\n elsif device.match(@assignable_path_regex)\n \"assign mount=\\\"#{device}\\\"\"\n end\n end",
"def mountpoint?\n begin\n stat1 = expand_tilde.lstat\n stat2 = expand_tilde.parent.lstat\n stat1.dev == stat2.dev && stat1.ino == stat2.ino ||\n stat1.dev != stat2.dev\n rescue Errno::ENOENT\n false\n end\n end",
"def dev_num(dev, regex = 'modem(\\d+)')\n dev.match(regex)[1].to_i\nend",
"def IsMounted(mountpoint)\n if Builtins.substring(\n mountpoint,\n Ops.subtract(Builtins.size(mountpoint), 1),\n 1\n ) == \"/\"\n mountpoint = Builtins.substring(\n mountpoint,\n 0,\n Ops.subtract(Builtins.size(mountpoint), 1)\n )\n end\n\n ret = true\n Builtins.foreach(@activated) do |e|\n if Ops.get_string(e, :type, \"\") == \"mount\" &&\n (Ops.get_string(e, :mntpt, \"\") == mountpoint ||\n Ops.get_string(e, :mntpt, \"\") == Ops.add(mountpoint, \"/\"))\n ret = true\n end\n end\n ret\n end",
"def MountPartition(mount_point, device, mount_type)\n if mount_type == \"\"\n # e.g. -> \"reiserfs\"\n mount_type = FileSystems.GetMountString(Storage.DetectFs(device), \"\")\n end\n\n # #223878, do not call modprobe with empty mount_type\n if mount_type == \"\"\n Builtins.y2warning(\"Unknown filesystem, skipping modprobe...\") \n # #211916, sysfs, proc are not modular\n elsif !Builtins.contains(@non_modular_fs, mount_type)\n # #167976, was broken with \"-t \", modprobe before adding it\n Builtins.y2milestone(\"Calling 'modprobe %1'\", mount_type)\n SCR.Execute(path(\".target.modprobe\"), mount_type, \"\")\n else\n Builtins.y2milestone(\n \"FS type %1 is not modular, skipping modprobe...\",\n mount_type\n )\n end\n\n error_message = nil\n if !(\n error_message_ref = arg_ref(error_message);\n _RunFSCKonJFS_result = RunFSCKonJFS(\n mount_type,\n device,\n error_message_ref\n );\n error_message = error_message_ref.value;\n _RunFSCKonJFS_result\n )\n return error_message\n end\n\n mount_type = Ops.add(\"-t \", mount_type) if mount_type != \"\"\n\n ret = Convert.to_boolean(\n SCR.Execute(\n path(\".target.mount\"),\n [\n device,\n Ops.add(Installation.destdir, mount_point),\n Installation.mountlog\n ],\n mount_type\n )\n )\n if ret\n return nil\n else\n return Convert.to_string(\n SCR.Read(path(\".target.string\"), Installation.mountlog)\n )\n end\n end",
"def root_device_name\n data[:root_device_name]\n end",
"def mountpoint\n \"#{spec[:temp_dir]}\"\n end",
"def nbd_device\n sys_parts = lsblk('')\n nbds = []\n\n sys_parts.each do |p|\n m = p['name'].match(/nbd(\\d+)/)\n next unless m\n\n nbds << m[1].to_i\n end\n\n nbds_max.times do |i| # if nbds_max returns 0 block is skipped\n return \"/dev/nbd#{i}\" unless nbds.include?(i)\n end\n\n OpenNebula.log_error(\"#{__method__}: Cannot find free nbd device\")\n\n ''\n end",
"def device\n @client.get('VBD', :device, @uuid)\n end",
"def get_mount(page, mount)\n mount_begin = page.index{|s| s.include?(\"<!-- Mount -->\")}\n mount_end = page.index{|s| s.include?(\"<!-- //Mount -->\")}\n\n mount_section = page[mount_begin..mount_end]\n\n\n mount_section.each do |line|\n if line.include?(mount)\n return 1\n end\n end\n\n return 0\n end",
"def find_unique_device(name)\n devs = SimCtl.devices.select {|d| d.name == name}\n\n case devs.length\n when 0\n return nil\n when 1\n return devs[0]\n else\n raise \"more than one device with name\"\n return nil\n end\n \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 mount_path=(_arg0); end",
"def read_device_info (device, kind)\n kind = kind.to_sym\n kinds = [:ip, :udid, :serial]\n unless kinds.include?(kind)\n raise \"illegal argument '#{kind}' - must be one of '#{kinds}'\"\n end\n\n path = File.expand_path(\"~/.xamarin/devices/#{device}/#{kind}\")\n\n unless File.exist?(path)\n @log.fatal{\"cannot read device information for '#{device}'\"}\n @log.fatal{\"file '#{path}' does not exist\"}\n exit 1\n end\n\n begin\n IO.readlines(path).first.strip\n rescue Exception => e\n @log.fatal{\"cannot read device information for '#{device}'\"}\n @log.fatal{e}\n exit 1\n end\nend",
"def mounted?(name)\n mount_loc = File.join(KVM_MOUNT_POINT, name)\n system(\"mount | grep #{mount_loc}\")\nend",
"def mount_path\n path = settings.mount_path\n path += '/' unless path.end_with?('/')\n path\n end",
"def device\n attachments[0]['device'] if has_attachments?\n end",
"def get_current_devices(proc_partitions_output)\n lines = proc_partitions_output.split(\"\\n\")\n partitions = lines.drop(2).map do |line|\n line.chomp.split.last\n end.reject do |partition|\n partition =~ /^dm-\\d/\n end\n devices = partitions.select do |partition|\n partition =~ /[a-z]$/\n end.sort.map {|device| \"/dev/#{device}\"}\n if devices.empty?\n devices = partitions.select do |partition|\n partition =~ /[0-9]$/\n end.sort.map {|device| \"/dev/#{device}\"}\n end\n devices\n end",
"def FindPartitionInFstab(fstab, mountpoint)\n if Builtins.substring(\n mountpoint,\n Ops.subtract(Builtins.size(mountpoint), 1),\n 1\n ) == \"/\"\n mountpoint = Builtins.substring(\n mountpoint,\n 0,\n Ops.subtract(Builtins.size(mountpoint), 1)\n )\n end\n\n tmp = Builtins.filter(fstab.value) do |entry|\n Ops.get_string(entry, \"file\", \"\") == mountpoint ||\n Ops.get_string(entry, \"file\", \"\") == Ops.add(mountpoint, \"/\")\n end\n\n return nil if Builtins.size(tmp) == 0\n\n Ops.get_string(tmp, [0, \"spec\"], \"\")\n end",
"def convert_to_mapper(name)\n c=name.split(\"/\")\n vg=c[2]\n lv=c[3]\n \"/dev/mapper/#{vg}-#{lv}\"\n end",
"def get_mounts\n mount_hash = {}\n mounts = File.open(\"/etc/mtab\", \"r\").read.split(\"\\n\").map{|l| l.split(/\\s+/)}\n mounts.each{|m| mount_hash[m[1]] = m[0] unless %w[devpts udev sysfs tmpfs none proc].include?(m[0])}\n mount_hash\nend",
"def parse_device(device)\n result = parse(device, parent::ParserDictionaryConstants::GUEST_DEVICE)\n\n result[:uid_ems] = mount_uuid(device)\n result[:device_name] = device[\"productName\"] ? device[\"productName\"] : device[\"name\"]\n result[:device_type] = \"storage\"\n result[:firmwares] = parse_device_firmware(device)\n result[:location] = device['slotNumber'] ? \"Bay #{device['slotNumber']}\" : nil\n\n result\n end",
"def get_parent child_path\n parent_maj_min = nil\n if DEBUG_MODE or Platform.ubuntu? or Platform.fedora?\n command = \"udevadm\"\n params = \" info --query=property --name=#{child_path}\"\n end\n udevadm = CommandsExecutor.new command, params\n udevadm.execute false, false # None blocking and not debug mode\n raise \"Command execution error: #{udevadm.stderr.read}\" if not udevadm.success?\n udevadm.result.each_line do |line|\n line.squish!\n key = 'ID_PART_ENTRY_DISK'\n _key, value = line.split '='\n parent_maj_min = value and break if _key.eql? key\n end\n\n if DEBUG_MODE or Platform.ubuntu? or Platform.fedora?\n command = \"lsblk\"\n params = \" -b -P -o VENDOR,MODEL,TYPE,SIZE,KNAME,UUID,LABEL,MOUNTPOINT,FSTYPE,RM,MAJ:MIN\"\n end\n lsblk = CommandsExecutor.new command, params\n lsblk.execute\n raise \"Command execution error: #{lsblk.stderr.read}\" if not lsblk.success?\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 return data_hash['kname'] if value == parent_maj_min\n end\n end\n raise \"Unable to find parent device for #{child_path}\"\n end",
"def mount(bundle_id=nil)\n app_arg = bundle_id ? \"--documents '#{bundle_id}'\" : \"\"\n mount_point = Dir.mktmpdir(\"mount-#{self.id}\")\n %x{ifuse #{app_arg} -u #{self.id} #{mount_point}}\n fail(\"can't mount ios device #{self.id} at #{mount_point}\") unless $?.success?\n mount_point\n end",
"def initialize dev_node\n di = Plist::parse_xml(diskutil 'info', '-plist', dev_node)\n raise \"#{dev_node} is not a valid volume\" if di.nil?\n @dev_node = di['DeviceNode']\n end",
"def device_str\n\tdev_str = {\n\t\t \"iPhone\" => \"iPhone\",\n\t\t \"iPad (Retina)\" => \"iPad_Retina\",\n\t\t \"iPhone (Retina 4-inch)\"\t=> \"iPhone_Retina_4_inch\",\n\t\t \"iPhone (Retina 3.5-inch)\" => \"iPhone_Retina_3.5_inch\"\n\t}\n\n\tsv = server_version[\"simulator\"]\n\tsv=~/\\((.*)\\//\n\tdev_str[$1]\n\nend",
"def command_get_device(command)\n\t\tif @device then message(\"device: #{@device.name}\")\n\t\telse error(\"no device loaded\")\n\t\tend\n\tend",
"def get_gpu_driver_volume(json_result, slot)\n nvidia_volumes = json_result['Volumes'][slot].split(\":\")\n driver = nvidia_volumes[slot].gsub('nvidia_driver_', '')\n return '/var/lib/nvidia-docker/volumes/nvidia_driver/' + driver\nend",
"def device\n unless (@device.nil?) then return @device end\n\n addr = self.device_address\n dev_path = nil\n begin\n dev_path = @adapter.FindDevice(addr)[0]\n rescue DBus::Error => e\n dev_path = @adapter.CreateDevice(addr)[0]\n end\n if (dev_path.nil?) then raise \"Error: Could not get or create a device for the address #{addr}\" end\n #puts addr\n #puts dev_path\n @device ||= @@rootservice.object dev_path\n @device.introspect\n @device['org.bluez.Device'].DiscoverServices ''\n @device\n end",
"def device_id\n accessory_info.device_id\n end",
"def dev_node\n disk_info = self.info\n return nil if disk_info.nil?\n return disk_info['system-entities'][0]['dev-entry']\n end",
"def lookup_device(ip)\n\t\t@map[ip]\n\tend",
"def set_variation_mount_point(mnt)\n @mount_point = mnt\n end",
"def unmount_device( dev )\n sudo <<-SH\n if mount | grep -q '^#{dev} '; then\n umount #{dev}\n sed -r -i '\\\\|^#{dev}\\\\s|d' /etc/fstab\n fi\n SH\n end",
"def parse_druid(druid)\n matches = druid.match(/[a-zA-Z]{2}\\d{3}[a-zA-Z]{2}\\d{4}/)\n matches.nil? ? raise('invalid druid') : matches[0]\n end",
"def mountpoint?\n begin\n stat1 = self.lstat\n stat2 = self.parent.lstat\n stat1.dev == stat2.dev && stat1.ino == stat2.ino ||\n stat1.dev != stat2.dev\n rescue Errno::ENOENT\n false\n end\n end",
"def device_name\n return @device_name\n end",
"def device_name\n return @device_name\n end",
"def device_name\n return @device_name\n end",
"def filesystem_labels\n\n labels = {}\n\n mount = capture_command_output('mount')\n mount.each do |mount_line|\n\n mount_line.strip!\n device = mount_line.match(/^(.*?) on/)[1]\n\n if PlatformInfo.linux?\n\n # /dev/hda3 on / type ext4 (rw,errors=remount-ro)\n mount_point = mount_line.match(/^#{Regexp.quote(device)} on (.*?) type/)[1]\n fs_type = mount_line.match(/type (.*?) \\(/)[1]\n\n elsif PlatformInfo.osx?\n\n # /dev/disk0s2 on / (hfs, local, journaled)\n mount_point = mount_line.match(/^#{Regexp.quote(device)} on (.*?) \\(/)[1]\n fs_type = mount_line.match(/ \\((.*?), /)[1]\n \n else\n unsupported_platform\n end\n\n labels[device] = {\n :mount_point => mount_point,\n :file_system => fs_type\n }\n\n end\n\n labels\n\n end",
"def find_by_name(device_name)\n find_by_block { |device| device if device.name == device_name }\n end",
"def mount options = {}\n opts = {\n :force_readonly => false\n }.merge!(options)\n args = []\n args << 'readOnly' if opts[:force_readonly]\n args << opts[:mountpoint] if opts.has_key?(:mountpoint)\n args << self.dev_node\n diskutil 'mount', *args\n end",
"def FsckAndMount(mount_point, device, mount_type)\n FSCKPartition(device)\n\n ret = MountPartition(mount_point, device, mount_type)\n\n if ret == nil\n AddMountedPartition(\n { :type => \"mount\", :device => device, :mntpt => mount_point }\n )\n end\n\n Builtins.y2milestone(\n \"mounting (%1, %2, %3) yield %4\",\n Ops.add(Installation.destdir, mount_point),\n device,\n mount_type,\n ret\n )\n\n ret\n end",
"def getFsPath(path)\n if path.kind_of? Array\n if path.length == 0\n localPath = @cwd.dup\n else\n localPath = normalizePath(path[0].dup)\n end\n else\n localPath = normalizePath(path.dup)\n end\n\n dl = localPath.slice!(0..1).upcase\n raise MiqException::MiqVmMountError, \"Unknown drive letter - #{dl}\" unless (fs = @driveToFS[dl])\n return fs, localPath\n end",
"def lsblk_path(p)\n return unless !p['path'] && p['name']\n\n if File.exist?(\"/dev/#{p['name']}\")\n p['path'] = \"/dev/#{p['name']}\"\n elsif File.exist?(\"/dev/mapper/#{p['name']}\")\n p['path'] = \"/dev/mapper/#{p['name']}\"\n end\n end",
"def device_and_model\n if os_name == :watchos\n # Sample string: Apple Watch Series 2 - 38mm\n name.split ' - '\n else\n # Sample string: \"iPhone 5s\" or \"iPhone 6 Plus\" or \"iPad Air 2\"\n if name.start_with? 'Apple TV'\n # The last part is the model, and the rest is the device\n parts = name.rpartition(' ').reject { |str| str.strip.empty? }\n [parts[0...-1].join(' '), parts.drop(parts.count - 1).join(' ')].map(&:strip)\n else\n # The first part is device, and the rest is the model\n name.split ' ', 2\n end\n end\n end",
"def device\n return if application.nil?\n return unless application.comment.last.include?(' Build/')\n\n application.comment.last.split(' Build/').first\n end"
] |
[
"0.7978163",
"0.7947849",
"0.67994153",
"0.6692301",
"0.6387517",
"0.62892807",
"0.62242097",
"0.59843117",
"0.59592485",
"0.592807",
"0.5920276",
"0.5916922",
"0.5877466",
"0.58217335",
"0.5814342",
"0.5814342",
"0.58069736",
"0.57812154",
"0.5777981",
"0.57406163",
"0.5740248",
"0.5718238",
"0.5716758",
"0.57072884",
"0.5702977",
"0.5678032",
"0.5641265",
"0.5621074",
"0.5621074",
"0.55771595",
"0.55575764",
"0.55327713",
"0.55116767",
"0.5506077",
"0.55000985",
"0.5489537",
"0.5489537",
"0.5487606",
"0.548471",
"0.5475719",
"0.54236394",
"0.539768",
"0.5386728",
"0.5378578",
"0.53515625",
"0.5347536",
"0.53218293",
"0.53199375",
"0.52791375",
"0.52507406",
"0.52476406",
"0.52276444",
"0.52253246",
"0.5219847",
"0.52059245",
"0.518697",
"0.5182957",
"0.51819885",
"0.5181089",
"0.5174961",
"0.5169924",
"0.5166246",
"0.5163587",
"0.5160503",
"0.51564485",
"0.51557755",
"0.5150555",
"0.5129525",
"0.5112706",
"0.510252",
"0.50970465",
"0.5092345",
"0.508651",
"0.5076776",
"0.506437",
"0.5053042",
"0.5050238",
"0.5046499",
"0.5041641",
"0.50306505",
"0.5028865",
"0.50247115",
"0.5019182",
"0.50188494",
"0.5010547",
"0.4995048",
"0.4974865",
"0.49734265",
"0.49626413",
"0.49544975",
"0.49544975",
"0.49544975",
"0.49190503",
"0.49179092",
"0.49139223",
"0.48887157",
"0.48702946",
"0.48650625",
"0.4845736",
"0.48393574"
] |
0.77884984
|
2
|
Takes a string corresponding to a filesystem. Returns the size in GB of that filesystem.
|
def fs_value(p, val)
key = case val
when 'size'
'kb_size'
when 'used'
'kb_used'
when 'available'
'kb_available'
when 'percent'
'percent_used'
else
fail "fb_helpers: Unknown FS val #{val} for node.fs_value"
end
fs = self.filesystem_data
# Some things like /dev/root and rootfs have same mount point...
if fs && fs['by_mountpoint'] && fs['by_mountpoint'][p] &&
fs['by_mountpoint'][p][key]
return fs['by_mountpoint'][p][key].to_f
end
Chef::Log.warn(
"fb_helpers: Tried to get filesystem information for '#{p}', but it " +
'is not a recognized filesystem, or does not have the requested info.',
)
nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def calculate_string_size_in_kb string\n total_bytes = 0\n string.each_byte {|b| total_bytes += 1}\n result = total_bytes.to_f / 1024.to_f\n end",
"def size\n size = popen(%W(du -s), full_path).first.strip.to_i\n (size.to_f / 1024).round(2)\n end",
"def convertsize(str)\n\t\t\t\tif(str.kind_of?(Numeric))\n\t\t\t\t\treturn(str)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tstr.strip!()\n\t\t\t\tregex = /^([0-9]+(?:\\.[0-9]+)?)\\s*([gmk])b?$/i\n\t\t\t\tmatch = regex.match(str)\n\t\t\t\tif(match == nil)\n\t\t\t\t\traise(ArgumentError, \"Unable to parse size of \\\"#{str}\\\"\")\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tsize = match[1].to_f()\n\t\t\t\t\n\t\t\t\tcase(match[2].downcase())\n\t\t\t\twhen('g')\n\t\t\t\t\tsize = size * 1024 * 1024 * 1024\n\t\t\t\twhen('m')\n\t\t\t\t\tsize = size * 1024 * 1024\n\t\t\t\twhen('k')\n\t\t\t\t\tsize = size * 1024\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn(size)\n\t\t\tend",
"def fetch_disk_size\n total_size = 0\n total_size = `lsblk -b --output SIZE -d -n | paste -s -d + - | bc`\n number_to_human_size total_size\n end",
"def size(full_path)\n\t\t`du -s #{Rush.quote(full_path)}`.match(/(\\d+)/)[1].to_i\n\tend",
"def size(full_path)\n\t\t`du -sb #{full_path}`.match(/(\\d+)/)[1].to_i\n\tend",
"def path_size (path)\n if Dir.exist? path\n o, e, s = Open3.capture3('du', '-s', '-b', path)\n o.split('/')[0].to_i\n end\n end",
"def file_size_string(fs)\n # n cuts off all decimal places after the second\n n = lambda{|f| f.to_s[/.*\\..{0,2}/] } \n if fs < 1024\n \"#{n.call(fs)} Bytes\"\n elsif fs <= 1024**2\n \"#{n.call(fs/1024.0)} KBytes\"\n elsif fs <= 1024**3\n \"#{n.call(fs/1024.0**2)} MBytes\"\n elsif fs <= 1024**4\n \"#{n.call(fs/1024.0**3)} GBytes\"\n end\n end",
"def current_size(path)\n `du -shm #{path}`.match(/^[0-9]+/).to_s.to_i\n end",
"def sfdisk_get_size(dev_name)\n out = %x{sfdisk #{dev_name} -s}\n Chef::Log.info(\"updating geo using sfdisk: #{out}\")\n\n # sfdisk sees the world as 1k blocks\n @current.blocks(out.to_i)\nend",
"def file_total_size_gb\n ((total_ram_mb.to_f * 2).to_f / 1024).ceil\n end",
"def sizestring(core)\n size = core.size\n if size.nil? or size == 0\n if core.numDocs == 0\n '(empty)'\n else\n '(< 1MB)'\n end\n elsif size > 1024\n gbsize(size)\n else\n mbsize(size)\n end\n end",
"def size(path)\n info = Private.info_with(path, GLib::G_FILE_ATTRIBUTE_STANDARD_SIZE)\n GLib.g_file_info_get_size(info)\n end",
"def get_size(path)\n read_size(@uri + path)\n end",
"def volume_size\n # If not user-specified, I'm using a fudge factor of 1.5 on the volume size -- arbitrarily chosen\n @volume_size || (`du -x #{volume_to_bundle}`.split(/\\n/)[-1].split[0].to_f * 1.5 / 1024).ceil\n end",
"def size(name)\n File.size(path(name))\n end",
"def size_mb \n return size / 1048576 # (1024 * 1024) \n end",
"def interpret_size(size)\n case size\n when /k$/i then size.to_i * 1024\n when /m$/i then size.to_i * 1024 * 1024\n when /g$/i then size.to_i * 1024 * 1024 * 1024\n else size.to_i\n end\n end",
"def byte_size\n inject(0){ |sum, path| sum + FileTest.size(path) }\n end",
"def size_from_bytes(qty, unit)\n qty = qty.to_i\n case unit.downcase\n when \"b\", \"bytes\"\n qty.to_s\n when \"kb\", \"kilobytes\"\n (qty / 1000).to_s\n when \"kib\", \"kibibytes\"\n (qty / 1024).to_s\n when \"mb\", \"megabytes\"\n (qty / 1000000).to_s\n when \"m\", \"mib\", \"mebibytes\"\n (qty / 1048576).to_s\n when \"gb\", \"gigabytes\"\n (qty / 1000000000).to_s\n when \"g\", \"gib\", \"gibibytes\"\n (qty / 1073741824).to_s\n else\n raise ArgumentError, \"Unknown unit #{unit}\"\n end\n end",
"def size\n size = File.size(@path).to_i\n case\n when size.to_i == 1; \"1 byte\"\n when size < 1024; \"%d bytes\" % size\n when size < (1024*1024); \"%.2f kilobytes\" % (size / 1024.0)\n else \"%.2f megabytes\" % (size / (1024 * 1024.0))\n end.sub(/([0-9])\\.?0+ /, '\\1 ' )\n end",
"def calculate_disk_space(data)\n sum_sizes = 0\n\n data.each do |disk_name, disk|\n\n unless disk_name =~ %r{^sr}\n if disk.has_key?('size_bytes')\n sum_sizes = sum_sizes + disk['size_bytes']\n end\n end\n end\n\n sum_sizes = sum_sizes / 1024 / 1024 / 1024\n\n sum_sizes\n end",
"def volume_size(vol_path)\n # default values\n vol_vsize = {:size => 10, :unit => 'G'}\n vsize_regex = %r{virtual size:\\s+(?<size>\\d+(\\.\\d+))?(?<unit>.)\\s+\\((?<bytesize>\\d+)\\sbytes\\)}\n diskinfo = %x[qemu-img info #{vol_path}]\n diskinfo.each_line do |line|\n result = line.match(vsize_regex)\n if result\n # always take the size in bytes to avoid conversion\n vol_vsize = {:size => result[:bytesize], :unit => \"B\"}\n break\n end\n end\n return vol_vsize\n end",
"def disk_current_size\n\t\treturn 1024\n\tend",
"def size_used\n info[\"size-used\"]\n end",
"def disk_usage_mb \n return disk_usage \n end",
"def get_file_size_in_mb\n mb = ::ApplicationController.helpers.number_to_human_size(self.file_size, precision: 2) \n return mb\n end",
"def getdiskusage\n content = \"\"\n begin\n content = `df -k`\n rescue\n warn \"Failed to run df command\"\n return nil\n end\n used_space = 0\n avail_space = 0\n content.split(\"\\n\").each do |line|\n if line =~ /\\s+\\d+\\s+(\\d+)\\s+(\\d+)\\s+\\d+%\\s+\\/($|home$)/\n used_space += $1.to_i\n avail_space += $2.to_i\n end\n end\n return {:avail_space => avail_space, :used_space => used_space}\n end",
"def interpret_size(size)\n case size\n when /k$/i then size.to_i * 1024\n when /m$/i then size.to_i * 1024 * 1024\n when /g$/i then size.to_i * 1024 * 1024 * 1024\n else size.to_i\n end\n end",
"def get_size(path)\n file = scope.get(path)\n InvalidPath.raise! {!file}\n return 0 if file.is_dir\n file.info[:size]\n end",
"def d_size\n @diskObj.info[:capacity]\n end",
"def byteweight(path_or_string)\n path_or_string=\"\" if path_or_string.nil?\n \n if File.exists?(path_or_string)\n File.size(path_or_string)\n else\n bweight=0\n path_or_string.each_byte{|b|bweight+=1}\n bweight\n end\n end",
"def get_size(folder,hash)\n \n size_command = 'du -sh '+folder+' | cut -f 1'\n\n job_size = `#{size_command}`\n job_size = job_size.chomp\n\n hash['job_size']=job_size\n\n\nend",
"def block_size\n @disk.block_size\n end",
"def human_size size_bytes\n size = size_bytes\n type = \"B\"\n\n %w{KB MB GB}.each do |t|\n if size > 1024\n size = size/1024\n type = t\n else\n break\n end\n end\n\n \"#{size}#{type}\"\nend",
"def getFileSize()\n getRealFileSize(file) / MEGABYTE\n end",
"def size\n ['o', 'k', 'G'].inject(super.to_f) do |s, unit|\n # recusively divide by 1024 until...\n if s.is_a?(Float) && s >= 1024\n s = s / 1024\n # we format it here with the unit\n elsif !s.is_a?(String)\n s = \"#{s.to_s.gsub(/(\\.\\d{3})\\d+$/, \"\\\\1\")} #{unit}\"\n end\n s\n end\n end",
"def directory_size(path)\n\ta = get_dir_size(path)\n\tdisplay(a)\n\t@calls = 0\n\treturn a\nend",
"def sizeOnDisk(someFile)\n #get directory\n #size of file in directories\n #add\n return Dir.glob(File.join(someFile, '**', '*')).map{|f| File.size(f)}.inject(:+)\nend",
"def content_size(url)\n Rails.cache.fetch(\"/content_size/#{url}\", expires_in: 10.minutes) do\n begin\n meta = meta_file(url)\n size_text = meta.xpath(\"//m:metalink//m:file//m:size[1]//text()\", 'm' => 'urn:ietf:params:xml:ns:metalink')\n size = Integer(size_text.to_s)\n size\n rescue OpenURI::HTTPError, RuntimeError\n # This is actualy gibibytes, not gigabytes\n return 5.gigabytes\n end\n end\n end",
"def du\n `du -s -b #{path}`.to_i\n end",
"def get_character_size account, filename\n end",
"def size_in_bytes\n ( file_length * 16 ) / 8\n end",
"def calculate_size(a_size)\n\tres = 0\n\tif(a_size == \"small\")\n\t\tres = 1\n\telsif(a_size == \"medium\")\n\t\tres = 2\t\n\telsif(a_size == \"large\")\n\t\tres = 3\t\n\tend\n\tres\n end",
"def format_size(bytes)\n sprintf \"%0.1fG\", bytes.to_f / 10**9\nend",
"def file_size(file_name, ignore_errors = false)\n dst_path = \"#{self.path}#{file_name}\"\n \n cmd = self.class.curr_host == host ? \n \"du -sb #{dst_path.shellescape}\" : \n \"ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \\\"du -sb #{dst_path.shellescape}\\\"\"\n r = ignore_errors ? `#{cmd} 2>/dev/null` : `#{cmd} 2>&1`\n raise r if $?.exitstatus != 0\n r.to_i\n end",
"def file_size(file_name, ignore_errors = false)\n dst_path = \"#{self.path}#{file_name}\"\n \n cmd = self.class.curr_host == host ? \n \"du -sb #{dst_path.shellescape}\" : \n \"ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \\\"du -sb #{dst_path.shellescape}\\\"\"\n r = ignore_errors ? `#{cmd} 2>/dev/null` : `#{cmd} 2>&1`\n raise r if $?.exitstatus != 0\n r.to_i\n end",
"def disk_space_usage(folder)\n space = `df -P '#{folder}' | grep -o \"[0-9]*%\" | cut -c 1-2`\n space\n end",
"def list_size_swap_partitions # nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"82\") print $5;else {if ($5==\"82\") print $4}}' | sed s/+//g`.chomp\nend",
"def get_size(card_name)\n if @sizes\n begin\n size_key = /[<{\\[](.+)[>}\\]]/.match(card_name)[1].to_sym\n if @sizes.has_key? size_key\n size = @sizes[size_key] \n else\n if size_key.to_s.to_i != 0\n size = size_key.to_s.to_i\n else\n size = @sizes[:default]\n end\n end\n rescue Exception => e\n size = @sizes[:default]\n end\n else\n size = (/[<{\\[](\\d+)[>}\\]]/.match(card_name) || DEFAULT_SIZE )[1].to_i\n end\n size\n end",
"def list_size_nix_partitions # nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"83\") print $5;else {if ($5==\"83\") print $4}}' | sed s/+//g`.chomp.split\nend",
"def part_size_in_bytes\n data.part_size_in_bytes\n end",
"def size(msg)\n debug \"#{Dir.pwd}/#{msg}: #{File.exists?(\"#{Dir.pwd}/#{msg}\")}\"\n if File.exists?(\"#{Dir.pwd}/#{msg}\")\n bytes = File.size(msg)\n \"#{msg} #{bytes}\"\n else\n \"553 File doesn't exist\" \n end\n\n end",
"def size\n raise MissingFileMapping.new if mapping.blank?\n raise NodesMissing.new if mapping.nodes.blank?\n\n retrieve_meta!\n\n return self.meta['file_size'].to_i\n end",
"def size_in_bytes\n files.inject(0) do |sum, f|\n path = File.join self.path, f\n sum + File.size(path)\n end\n end",
"def size_in_bytes(qty, unit, mib=false)\n qty = qty.to_i\n unit = unit.downcase\n if !mib\n case unit\n when \"kb\", \"kilobytes\"\n unit = \"kib\"\n when \"mb\", \"megabytes\"\n unit = \"mib\"\n when \"gb\", \"gigabytes\"\n unit = \"gib\"\n end\n end\n case unit\n when \"b\", \"bytes\"\n qty.to_s\n when \"kb\", \"kilobytes\"\n (qty * 1000).to_s\n when \"kib\", \"kibibytes\"\n (qty * 1024).to_s\n when \"mb\", \"megabytes\"\n (qty * 1000000).to_s\n when \"m\", \"mib\", \"mebibytes\"\n (qty * 1048576).to_s\n when \"gb\", \"gigabytes\"\n (qty * 1000000000).to_s\n when \"g\", \"gib\", \"gibibytes\"\n (qty * 1073741824).to_s\n else\n raise ArgumentError, \"Unknown unit #{unit}\"\n end\n end",
"def as_byte_size(bytes)\n bytes = bytes.to_f\n i = BYTE_RANGE.length - 1\n while bytes > 512 && i > 0\n i -= 1\n bytes /= 1024\n end\n ((bytes > 9 || bytes.modulo(1) < 0.1 ? '%d' : '%.1f') % bytes) + ' ' + BYTE_RANGE[i]\n end",
"def size(str)\n str.unpack(\"U*\").size\n end",
"def human_filesize(value)\n {\n 'B' => 1024,\n 'KB' => 1024 * 1024,\n 'MB' => 1024 * 1024 * 1024,\n 'GB' => 1024 * 1024 * 1024 * 1024,\n 'TB' => 1024 * 1024 * 1024 * 1024 * 1024\n }.each_pair { |e, s| return \"#{(value.to_f / (s / 1024)).round(1)} #{e}\" if value.to_i < s }\n end",
"def size_in_bytes(qty, unit, mib = false)\n qty = qty.to_i\n unit = unit.downcase\n unless mib\n case unit\n when 'kb', 'kilobytes'\n unit = 'kib'\n when 'mb', 'megabytes'\n unit = 'mib'\n when 'gb', 'gigabytes'\n unit = 'gib'\n end\n end\n case unit\n when 'b', 'bytes'\n qty\n when 'kb', 'kilobytes'\n (qty * 1000)\n when 'kib', 'kibibytes'\n (qty * 1024)\n when 'mb', 'megabytes'\n (qty * 1_000_000)\n when 'm', 'mib', 'mebibytes'\n (qty * 1_048_576)\n when 'gb', 'gigabytes'\n (qty * 1_000_000_000)\n when 'g', 'gib', 'gibibytes'\n (qty * 1_073_741_824)\n else\n fail ArgumentError, \"Unknown unit #{unit}\"\n end\n end",
"def size_in_bytes(qty, unit, mib=false)\n qty = qty.to_i\n unit = unit.downcase\n if !mib\n case unit\n when \"kb\", \"kilobytes\"\n unit = \"kib\"\n when \"mb\", \"megabytes\"\n unit = \"mib\"\n when \"gb\", \"gigabytes\"\n unit = \"gib\"\n end\n end\n case unit\n when \"b\", \"bytes\"\n qty\n when \"kb\", \"kilobytes\"\n (qty * 1000)\n when \"kib\", \"kibibytes\"\n (qty * 1024)\n when \"mb\", \"megabytes\"\n (qty * 1000000)\n when \"m\", \"mib\", \"mebibytes\"\n (qty * 1048576)\n when \"gb\", \"gigabytes\"\n (qty * 1000000000)\n when \"g\", \"gib\", \"gibibytes\"\n (qty * 1073741824)\n else\n raise ArgumentError, \"Unknown unit #{unit}\"\n end\n end",
"def determine_disk\n df_cmd = \"df 2>/dev/null|awk '$1 ~ /\\\\// {I=I+$3} END {print I}'\"\n disk = @shell.query('DISK_DF', df_cmd)\n\n # Result is expected to be in KiB. Convert to GB.\n @info[:disk] = disk.to_f / 1000 ** 2\n end",
"def human_size\n count = 0\n n = size\n while n >= 1024 and count < 4\n n /= 1024.0\n count += 1\n end\n format(\"%.1f\",n) + %w(B kB MB GB TB)[count]\n end",
"def human_readable_file_size(num, type='file')\n string = ''\n factor = 1024\n suffixes = ['KB', 'MB', 'GB', 'TB']\n if type == 'base10'\n factor = 1000\n suffixes = ['', 'K', 'M', 'B']\n end\n\n if num < factor\n string = \"#{num}#{suffixes[0]}\"\n elsif num < factor**2\n string = \"#{((num) / factor).round(1)}#{suffixes[1]}\"\n elsif num < factor**3\n string = \"#{((num) / (factor*factor)).round(1)}#{suffixes[2]}\"\n else\n string = \"#{((num) / (factor*factor*factor)).round(1)}#{suffixes[3]}\"\n end\n\n return string\nend",
"def get_file_size\n file = Storage.get_file(ENV['AWS_S3_DIR_PAGES'], self.issue_id, self.filename )\n return file.content_length\n end",
"def file_size\n number_to_human_size(super)\n end",
"def local_size\n return @local_size if defined?(@local_size)\n @local_size = File.size(\"#{resource[:name]}\")\n end",
"def size\n @gapi[\"size\"]\n end",
"def size\n info[\"size\"]\n end",
"def size\n\t\tstat[:size]\n\tend",
"def size\n\t\tstat[:size]\n\tend",
"def size\n File.new(self.server_path).size\n end",
"def fast_size\n c_size = 0\n ids = self.child_ids\n q = \"SELECT octet_length(data), octet_length(body) AS octet_length2 FROM ws_files WHERE id in (#{ ids.join(\", \")})\"\n request = $postgres.exec(q)\n request.each do |req|\n c_size += req.map{|k,v| v.to_i }.inject(:+)\n end\n c_size\n end",
"def bytesize\n @fd.stat.size\n end",
"def list_nix_partitions_with_size # nelsongs \n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{if ($2==\"*\" && $6==\"83\") print $1\":\"$5;else {if ($5==\"83\") print $1\":\"$4}}' | sed s/+//g`.chomp.split\nend",
"def number_of_free_gigabytes\n if plan_id == 'pro'\n 100\n elsif plan_id == 'basic'\n 10\n else\n 1\n end\n end",
"def total_filesize_count(folder_name)\n\n # You will fill in something here. Remember that the method only\n # gets the folder name, not the folder handle. So the method needs\n # to first create the corresponding handle object.\n\nend",
"def get_size(path)\n raise NotImplemented\n end",
"def s3_storage_used\n bytes = contents.sum(:size)\n backup_sources.gmail.each do |gmail|\n bytes += gmail.backup_emails.sum(:size)\n end\n # TODO: move size calculations to each source\n backup_sources.blog.each do |blog|\n blog.feed.entries.each do |entry|\n\tif entry.feed_content\n\t bytes += entry.feed_content.size\n\tend\n end\n end\n bytes\n end",
"def GetFreeSpace(device, used_fs, verbose)\n resize_info = {}\n content_info = {}\n\n r = (\n resize_info_ref = arg_ref(resize_info);\n content_info_ref = arg_ref(content_info);\n _GetFreeInfo_result = GetFreeInfo(\n device,\n true,\n resize_info_ref,\n true,\n content_info_ref,\n used_fs == :ntfs\n );\n resize_info = resize_info_ref.value;\n content_info = content_info_ref.value;\n _GetFreeInfo_result\n )\n\n used = 1024*Ops.get_integer(resize_info, :used_k, 0)\n resize_free = 1024*Ops.get_integer(resize_info, :resize_free_k, 0)\n df_free = 1024*Ops.get_integer(resize_info, :df_free_k, 0)\n resize_ok = Ops.get_boolean(resize_info, :resize_ok, false)\n\n win_disk = Ops.get_boolean(content_info, :windows, false)\n efi = Ops.get_boolean(content_info, :efi, false)\n\n if used_fs == :ntfs && (!r || !resize_ok) && verbose\n cmd = Builtins.sformat(\"/usr/sbin/ntfsresize -f -i '%1'\", device)\n Builtins.y2milestone(\"GetFreeSpace Executing cmd:%1\", cmd)\n bcall = Convert.to_map(\n SCR.Execute(\n path(\".target.bash_output\"),\n cmd,\n { \"LC_MESSAGES\" => \"POSIX\" }\n )\n )\n Builtins.y2milestone(\"GetFreeSpace Executing ret:%1\", bcall)\n tmp = _(\"Resize Not Possible:\") + \"\\n\\n\"\n tmp = Ops.add(\n Ops.add(tmp, Ops.get_string(bcall, \"stdout\", \"\")),\n Ops.get_string(bcall, \"stderr\", \"\")\n )\n Popup.Error(tmp)\n return {}\n end\n\n linux_size = 0\n min_linux_size = 0\n add_free = Ops.subtract(df_free, resize_free)\n\n Builtins.y2milestone(\n \"GetFreeSpace resize_free %1 add_free %2\",\n resize_free,\n add_free\n )\n\n if Ops.less_than(resize_free, 300 * 1024 * 1024) || !r\n linux_size = 0\n min_linux_size = 0\n elsif Ops.less_than(resize_free, 600 * 1024 * 1024)\n linux_size = resize_free\n if Ops.less_than(add_free, 75 * 1024 * 1024)\n linux_size = Ops.add(\n Ops.subtract(linux_size, 75 * 1024 * 1024),\n add_free\n )\n end\n min_linux_size = linux_size\n elsif Ops.less_than(resize_free, 1024 * 1024 * 1024)\n linux_size = resize_free\n if Ops.less_than(add_free, 200 * 1024 * 1024)\n linux_size = Ops.add(\n Ops.subtract(linux_size, 200 * 1024 * 1024),\n add_free\n )\n end\n min_linux_size = 300 * 1024 * 1024\n elsif Ops.less_than(resize_free, 2 * 1024 * 1024 * 1024)\n linux_size = resize_free\n if Ops.less_than(add_free, 300 * 1024 * 1024)\n linux_size = Ops.add(\n Ops.subtract(linux_size, 300 * 1024 * 1024),\n add_free\n )\n end\n min_linux_size = 500 * 1024 * 1024\n elsif Ops.less_than(resize_free, 3 * 1024 * 1024 * 1024)\n linux_size = resize_free\n if Ops.less_than(add_free, 800 * 1024 * 1024)\n linux_size = Ops.add(\n Ops.subtract(linux_size, 800 * 1024 * 1024),\n add_free\n )\n end\n min_linux_size = 500 * 1024 * 1024\n else\n linux_size = resize_free\n if Ops.less_than(add_free, Ops.divide(resize_free, 3))\n linux_size = Ops.add(\n Ops.subtract(linux_size, Ops.divide(resize_free, 3)),\n add_free\n )\n end\n min_linux_size = 500 * 1024 * 1024\n end\n\n new_size = Ops.subtract(\n Ops.add(Ops.add(used, add_free), resize_free),\n linux_size\n )\n\n ret = {\n \"free\" => (resize_free>0) ? resize_free : 0,\n \"df_free\" => df_free,\n \"used\" => used,\n \"win_disk\" => win_disk,\n \"efi\" => efi,\n \"linux_size\" => linux_size,\n \"max_win_size\" => Ops.subtract(\n Ops.add(Ops.add(used, resize_free), add_free),\n min_linux_size\n ),\n \"ntfs\" => used_fs == :ntfs,\n \"new_size\" => new_size\n }\n Ops.set(ret, \"ok\", r)\n Builtins.y2milestone(\"GetFreeSpace %1 ret %2\", device, ret)\n ret\n end",
"def _size(domain, key)\n dmid = get_dmid(domain)\n\n sql = <<-EOS\n SELECT length FROM file\n WHERE dmid = #{dmid} AND dkey = '#{@my.quote(key)}'\n LIMIT 1\n EOS\n\n res = query(sql).fetch_row\n return res[0].to_i if res && res[0]\n raise MogileFS::Backend::UnknownKeyError\n end",
"def get_safe_size(s)\n safe_size = get_unsafe_size(s)\n while (safe_size.to_s(16).rjust(8, '0')).scan(/../).include?(\"00\")\n safe_size -= 1\n end\n\n safe_size\n end",
"def filesystem_usage\n\n usage = {}\n\n df = capture_command_output('df', '-k')[1..-1] # Don't include the column headers.\n df.each do |df_line|\n\n df_line.strip!\n device = df_line.match(/^(.*?)\\s{2,}/)[1]\n tokens = df_line.gsub(/^#{Regexp.quote(device)}\\s+/, '').split(/\\s+/, 5)\n \n # Convert all KB values to bytes.\n size = tokens[0].to_i * 1024\n used = tokens[1].to_i * 1024\n available = tokens[2].to_i * 1024\n used_percentage = tokens[3].to_i\n\n usage[device] = {\n :size => size,\n :used => used,\n :used_percentage => used_percentage,\n :available => available\n }\n\n end\n\n usage\n\n end",
"def total_disk_size\n if @partition_layout.find { |p| !p.size_mb.is_a?(Integer) }\n raise RuntimeError, \"Some partition sizes unspecified, cannot infer \"\\\n \"total size of all partitions\"\n end\n\n @partition_layout.inject(0) { |memo, elem| memo + elem.size_mb } \\\n + FIRST_PARTITION_OFFSET \\\n + 1\n end",
"def size_in_bytes\n to_i description['SizeInBytes']\n end",
"def bytes(value)\n if value.is_a?(String)\n value =~ /([\\d\\.]+)\\s*(\\w*)/i\n size = $1.to_f\n unit = $2.strip.upcase if $2\n power = case unit\n when \"B\", \"\" then 0\n when \"K\", \"KB\" then 1\n when \"M\", \"MB\" then 2\n when \"G\", \"GB\" then 3\n when \"T\", \"TB\" then 4\n else raise UnitError\n end\n factor = 1024**power\n (size*factor).round\n elsif value.is_a?(Float)\n value.round\n elsif value.is_a?(Integer)\n value\n else\n raise ArgumentError\n end\n end",
"def display_size\n s = self.body.size\n\n if s > 1024 * 1024\n return sprintf(\"%.1f\", s.to_f / 1024 / 1024) + 'M'\n else\n return (s / 1024).to_s + 'K'\n end\n end",
"def size\n File.size( fullpath )\n end",
"def output_size(stat)\n HdfsUtils::Units.new.format_filesize(stat['length'],\n @settings[:filesizeunits])\n end",
"def human_size\n number_to_human_size size\n end",
"def file_size(remote_filename)\n rpath = File.join(self.remote_storage_dir, remote_filename)\n rfile = File.basename(rpath)\n rdir = File.dirname(rpath)\n\n Timeout::timeout(@@ftp_timeout) { entries = ftp.ls(rdir) }\n correct = entries.detect{ |entry| entry =~ /#{rfile}/ }\n\n Integer(correct.split[4])\n\n rescue Net::FTPPermError => nftpe\n nil\n end",
"def readable_file_size(size, precision)\n case\n #when size == 1 : \"1 B\"\n when size < KILO_SIZE then \"%d B\" % size\n when size < MEGA_SIZE then \"%.#{precision}f K\" % (size / KILO_SIZE)\n when size < GIGA_SIZE then \"%.#{precision}f M\" % (size / MEGA_SIZE)\n else \"%.#{precision}f G\" % (size / GIGA_SIZE)\n end\nend",
"def readable_file_size(size, precision)\n case\n #when size == 1 : \"1 B\"\n when size < KILO_SIZE then \"%d B\" % size\n when size < MEGA_SIZE then \"%.#{precision}f K\" % (size / KILO_SIZE)\n when size < GIGA_SIZE then \"%.#{precision}f M\" % (size / MEGA_SIZE)\n else \"%.#{precision}f G\" % (size / GIGA_SIZE)\n end\nend",
"def size\n @size ||= @request[FSIZE].to_i\n end",
"def file_size; @io_size[@rio] end",
"def unit2raw(str)\n val, unit = str.split()\n\n if unit.casecmp(\"kb\")\n ret = val.to_i * 1024\n elsif unit.casecmp(\"mb\")\n ret = val.to_i * 1024 * 1024\n elsif unit.casecmp(\"gb\")\n ret = val.to_i * 1024 * 1024 * 1024\n end\n \n return ret.to_s\nend",
"def percent_bytes(fs_info)\n (100.0 - (100.0 * fs_info.bytes_free / fs_info.bytes_total)).round(2)\n end",
"def percent_bytes(fs_info)\n (100.0 - (100.0 * fs_info.bytes_free / fs_info.bytes_total)).round(2)\n end",
"def gigabytes(value, unit = \"B\")\n round(megabytes(value, unit) / 1024)\n end",
"def total(fs = ?/.freeze)\n\t\t\t\ts = stat_raw(fs)\n\t\t\t\treturn nil if s.empty?\n\t\t\t\ts.default = 0\n\t\t\t\ts[:block_size] * s[:blocks]\n\t\t\tend",
"def filesize; end"
] |
[
"0.722561",
"0.7021257",
"0.69915",
"0.69172364",
"0.6838267",
"0.68184334",
"0.67541575",
"0.6747483",
"0.6691074",
"0.6665308",
"0.65760976",
"0.6521253",
"0.6512398",
"0.64639455",
"0.6439165",
"0.63662434",
"0.63384694",
"0.6327546",
"0.63271976",
"0.6322732",
"0.6319997",
"0.6295391",
"0.6293623",
"0.62919176",
"0.62900037",
"0.62883544",
"0.62686545",
"0.6253168",
"0.6251105",
"0.62178206",
"0.6209609",
"0.6160238",
"0.6157268",
"0.6122267",
"0.6119619",
"0.60920155",
"0.60685754",
"0.6061284",
"0.60494936",
"0.60404897",
"0.60100394",
"0.60086757",
"0.60025156",
"0.5977444",
"0.5972308",
"0.5958867",
"0.5958867",
"0.59362274",
"0.5934767",
"0.59179765",
"0.58977336",
"0.58890283",
"0.5871198",
"0.58520156",
"0.5829636",
"0.582649",
"0.582609",
"0.5820754",
"0.5804494",
"0.5798315",
"0.57969826",
"0.5796449",
"0.5790664",
"0.57850933",
"0.57699215",
"0.5756372",
"0.5741392",
"0.5740443",
"0.57400376",
"0.5738734",
"0.5738734",
"0.5738697",
"0.57337475",
"0.5729782",
"0.57269835",
"0.57096815",
"0.56987244",
"0.56978226",
"0.56916726",
"0.5690534",
"0.56784225",
"0.5677706",
"0.5676411",
"0.5672054",
"0.5667027",
"0.5663736",
"0.5657126",
"0.5654547",
"0.5652314",
"0.5645294",
"0.56439245",
"0.56392115",
"0.56392115",
"0.56372535",
"0.56349844",
"0.5630943",
"0.56253403",
"0.56243354",
"0.56242967",
"0.5609727",
"0.5608671"
] |
0.0
|
-1
|
This method allows you to conditionally shard chef resources
|
def shard_block(threshold, &block)
yield block if block_given? && in_shard?(threshold)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def shard; end",
"def run_w_shard(mongo, config_source, config_reader_builder,\n config_writer_builder, opt = {})\n @stop_mutex.synchronize { @stop = false }\n\n config_poll_interval = opt[:config_poll_interval] || 1\n err_retry_interval = opt[:err_retry_interval] || 10\n logger = opt[:logger] || Logger.new(STDOUT)\n opt[:is_sharded] = true\n shard_set = {}\n\n connection_opt = {\n :pool_size => opt[:pool_size],\n :pool_timeout => opt[:pool_timeout]\n }\n\n shard_coll = mongo[\"config\"][\"shards\"]\n\n loop do\n new_shard_set = {}\n\n begin\n shard_coll.find.each do |shard_doc|\n shard_id = shard_doc[\"_id\"]\n host = shard_doc[\"host\"]\n\n if shard_set.has_key? shard_id then\n shard = shard_set[shard_id]\n shard_set.delete(shard_id)\n else\n host_part1, host_part2 = host.split(\"/\")\n\n if host_part2.nil? then\n # not a replica set\n address = host_part1\n else\n address = host_part2\n end\n\n location, port = address.split(\":\")\n shard_conn = Mongo::Connection.new(location, port, connection_opt)\n shard_conn = upgrade_to_replset(shard_conn, connection_opt)\n\n if shard_conn.is_a? Mongo::ReplSetConnection then\n oplog_coll = get_oplog_collection(shard_conn, :repl_set)\n else\n oplog_coll = get_oplog_collection(shard_conn, :master_slave)\n end\n\n name = opt[:name] || \"\"\n extra_opt = {\n :name => name + \"[#{shard_id}]\"\n }\n\n shard = DaemonThread.new(Daemon.new(), host, logger)\n shard.start(mongo, oplog_coll, config_source,\n ObjectBuilder.new(config_reader_builder, shard_id),\n ObjectBuilder.new(config_writer_builder, shard_id),\n opt.merge(extra_opt))\n end\n\n new_shard_set[shard_id] = shard\n end\n rescue => e\n logger.error get_full_exception_msg(e)\n sleep err_retry_interval\n end\n\n shard_set.each do |id, daemon_thread|\n logger.info \"Shard #{id} removed: stopping sync.\"\n daemon_thread.stop\n end\n\n shard_set = new_shard_set\n\n @stop_mutex.synchronize do\n if @stop then\n shard_set.each do |id, daemon_thread|\n logger.info \"Stopping daemon: Stop sync on shard #{id}.\"\n daemon_thread.stop\n end\n\n return\n end\n end\n\n sleep config_poll_interval\n end\n end",
"def rsync_resources\n ::ObjectSpace.each_object(::Chef::Resource).select do |resource|\n resource.resource_name == :rsync_serve\n end\nend",
"def shard\n @pool.shard\n end",
"def with_each_healthy_shard\n shards.each do |shard_name, v|\n begin\n yield(v)\n rescue => e\n if Octopus.robust_environment?\n Octopus.logger.error \"Error on shard #{shard_name}: #{e.message}\"\n else\n raise\n end\n end\n end\n\n ar_pools = ActiveRecord::Base.connection_handler.connection_pool_list\n\n ar_pools.each do |pool|\n next if pool == shards[:master] # Already handled this\n\n begin\n yield(pool)\n rescue => e\n if Octopus.robust_environment?\n Octopus.logger.error \"Error on pool (spec: #{pool.spec}): #{e.message}\"\n else\n raise\n end\n end\n end\n end",
"def process_shard_specs\n @shard_specs.each do |shard_spec|\n RFlow.logger.debug \"Found #{shard_spec[:type]} shard '#{shard_spec[:name]}', creating\"\n\n shard_class = case shard_spec[:type]\n when :process\n RFlow::Configuration::ProcessShard\n when :thread\n RFlow::Configuration::ThreadShard\n else\n raise RFlow::Configuration::Shard::ShardInvalid, \"Invalid shard: #{shard_spec.inspect}\"\n end\n\n shard = shard_class.create! :name => shard_spec[:name], :count => shard_spec[:count]\n\n shard_spec[:components].each do |component_spec|\n RFlow.logger.debug \"Shard '#{shard_spec[:name]}' found component '#{component_spec[:name]}', creating\"\n RFlow::Configuration::Component.create!(:shard => shard,\n :name => component_spec[:name],\n :specification => component_spec[:specification],\n :options => component_spec[:options])\n end\n end\n end",
"def sharded?\n $mongo_client ||= initialize_scanned_client!\n $sharded ||= ($mongo_client.cluster.sharded? || single_mongos?)\nend",
"def sharded?\n $mongo_client ||= initialize_scanned_client!\n $sharded ||= ($mongo_client.cluster.sharded? || single_mongos?)\nend",
"def distribute( resource ) # of type resource\n @harvested[resource] += 1\n end",
"def rsync_resources\n run_context.resource_collection.select do |resource|\n resource.is_a?(Chef::Resource::RsyncServe)\n end\n end",
"def shard\n self\n end",
"def shard(shard_name, shard_options={})\n raise ArgumentError, \"Cannot use DEFAULT as a shard name\" if shard_name == 'DEFAULT'\n shard_type = if shard_options[:thread] || shard_options[:type] == :thread\n :thread\n else\n :process\n end\n\n shard_count = shard_options[shard_type] || shard_options[:count] || 1\n\n @current_shard = {:name => shard_name, :type => shard_type, :count => shard_count, :components => [], :config_line => get_config_line(caller)}\n @shard_specs << @current_shard\n yield self\n @current_shard = @shard_specs.first\n end",
"def prereqs\n response = getRequest(\"/hosts/#{new_resource.host}\")\n haveHost = response.code.to_i.between?(200,299)\n unless haveHost\n Chef::Log::info \"Can't execute on this resource until host #{new_resource.host} is available\"\n return false\n end\n\n haveService = getRequest(\"/clusters/#{new_resource.cluster}/services/#{new_resource.service}\").code.to_i.between?(200,299)\n unless haveService\n Chef::Log::info \"Can't execute on this resource until service #{new_resource.service} is available\"\n return false\n end \n \n return true\nend",
"def with_default_and_all(continue_on_error = false)\n ([default_shard] + cluster.shards).map do |shard|\n begin\n with_shard(shard) {\n yield\n }\n rescue Exception => err\n unless continue_on_error\n raise err\n end\n err\n end\n end\n end",
"def ceph_chef_pool_set(pool)\n if !node['ceph']['pools'][pool]['federated_names'].empty? && node['ceph']['pools'][pool]['federated_enable']\n node_loop = node['ceph']['pools'][pool]['federated_names']\n node_loop.each do |name|\n # if node['ceph']['pools'][pool]['settings']['type'] == 'replicated'\n next unless name['type'] == 'replicated'\n val = if node['ceph']['pools'][pool]['settings']['size']\n node['ceph']['pools'][pool]['settings']['size']\n else\n node['ceph']['osd']['size']['max']\n end\n\n ceph_chef_pool name do\n action :set\n key 'size'\n value val\n only_if \"ceph osd pool #{name} size | grep #{val}\"\n end\n end\n else\n node_loop = node['ceph']['pools'][pool]['pools']\n node_loop.each do |pool_val|\n # if node['ceph']['pools'][pool]['settings']['type'] == 'replicated'\n next unless pool_val['type'] == 'replicated'\n val = if node['ceph']['pools'][pool]['settings']['size']\n node['ceph']['pools'][pool]['settings']['size']\n else\n node['ceph']['osd']['size']['max']\n end\n\n ceph_chef_pool pool_val['name'] do\n action :set\n key 'size'\n value val\n only_if \"ceph osd pool #{pool_val['name']} size | grep #{val}\"\n end\n end\n end\nend",
"def balanced_shard\n # TODO Disabling balanced shard until we rework counts to go faster\n #@_ar_sharded_balance_count ||= 0\n #@_ar_sharded_semaphore ||= Mutex.new\n #returning_shard = nil\n #\n ## Do a thread sync on the balancing agent so we don't rebalance while\n ## we are retrieving a shard class\n #@_ar_sharded_semaphore.synchronize do\n #\n # # Rebalance every 10000 lookups\n # if @_ar_sharded_balance_count.to_i > 10000\n # @_ar_sharded_laggers = []\n #\n # # Find the leaders count\n # # TODO this is a bottle neck on large sets.\n # max_count = 0\n # @_ar_cached_shard_classes.each do |shard_class|\n # curr_count = shard_class.count\n # max_count = curr_count if curr_count > max_count\n # end\n #\n # # Designate the laggers\n # # You are a lagger if you are 10% behind the leader\n # @_ar_cached_shard_classes.each do |shard_class|\n # curr_count = shard_class.count\n # @_ar_sharded_laggers << shard_class if (max_count * 0.9) > curr_count\n # end\n #\n # #After rebalancing reset the counter\n # @_ar_sharded_balance_count = 0\n # end\n #\n # # If we have laggers favor them half the time to have them catch up\n # if @_ar_sharded_laggers.present? && rand >= 0.5\n # returning_shard = @_ar_sharded_laggers.sample\n # else\n # returning_shard = random_shard\n # end\n #\n # @_ar_sharded_balance_count += 1\n #end\n #\n #returning_shard\n @_ar_cached_shard_classes.sample\n end",
"def assign_suspended_tenant_to_shard(args = {}) \n put(\"/shards.json/#{args[:shardId]}/tenant/#{args[:tenantId]}\", args)\nend",
"def shard( name )\n definitions_by_name[ name.to_sym ]\n end",
"def shard_world; end",
"def select_shard(&block)\n Octopus.using(:master, &block)\n end",
"def add_tenant_to_specified_shard(args = {}) \n post(\"/tenants.json/shard/#{args[:shardId]}\", args)\nend",
"def shard_eval(&block)\n all_shards.each do |shard|\n shard.class_eval(&block)\n end\n end",
"def switch!\n solr_endpoint.switch!\n fcrepo_endpoint.switch!\n redis_endpoint.switch!\n data_cite_endpoint.switch!\n switch_host!(cname)\n setup_tenant_cache(cache_api?) if self.class.column_names.include?('settings')\n end",
"def require_set_write_concern\n before do\n if ClusterConfig.instance.topology == :sharded && ClusterConfig.instance.short_server_version >= '4.0'\n skip \"mongos 4.0+ overrides write concern\"\n end\n end\n end",
"def create_resource_set(job,site_name)\n job_name = job['name']\n job_nodes = job['assigned_nodes']\n\n # job_id will be the same for all the clusters of one site\n\n job_id = job['uid']\n clusters = []\n\n ## It needs to find out where to put the id of the job\n ## It could be in the site, if there is just one job per site\n ## It could be int he cluster, if there is multiple jobs per site\n\n resource_site = MyExperiment.resources.select_resource(:name => site_name)\n ## if the site already exits in the resource set this will return a resourceSet\n ## Otherwise I will return an array\n gateway = \"\"\n if not resource_site then ## puff it exists\n logger.info \"The site does not exits adding it\"\n site_set = ResourceSet::new(:site)\n site_set.properties[:id] = job['uid'] if @resources[site_name.to_sym].length < 2 ## there is just one job per site\n site_set.properties[:name] = site_name\n gateway = \"frontend.#{site_name}.grid5000.fr\"\n site_set.properties[:gateway] = gateway ## Fix-me gateway definition will depend on the context\n #site_set.properties[:ssh_user] = Console.variables[:user]\n MyExperiment.resources.push(site_set)\n elsif resource_site.is_a?(ResourceSet) then\n gateway = \"frontend.#{site_name}.grid5000.fr\"\n site_set = resource_site\n end\n\n regexp = /(\\w*)-\\w*/\n job_nodes.each { |node|\n cl = regexp.match(node)\n clusters.push(cl[1])\n }\n\n clusters.uniq!\n\n clusters_struct = []\n clusters.each{ |cluster|\n cluster_set = ResourceSet::new(:cluster)\n cluster_set.properties[:id] = job['uid'] if @resources[site_name.to_sym].length > 1 ## there are several jobs per site\n cluster_set.properties[:name] = cluster\n cluster_set.properties[:gateway] = \"localhost\" # gateway it is scalable enough\n cluster_set.properties[:ssh_user] = Console.variables[:user] ## Fix-me for Deploying\n cluster_set.properties[:gw_ssh_user] = Console.variables[:gw_user].nil? ? Console.variables[:user] : Console.variables[:gw_user]\n cluster_set.properties[:hw] = get_info_cluster(cluster)\n job_nodes.each { |node|\n node_hash = {}\n if node =~ /#{cluster}\\w*/ then\n ## the finest granularity is the node, a node belongs to a particular job\n ## in a cluster we could have different jobs\n resource = Resource::new(:node, nil, node)\n resource.properties[:gateway] = @gateway\n cluster_set.push(resource)\n # node_hash[:name] = node\n # node_hash[:job] = job['uid'] ## I have to check why I'm not taking into account the job_id\n # cluster_hash[:nodes].push(node_hash)\n end\n }\n\n clusters_struct.push(cluster_set) ## this is an array of resources sets\n }\n\n\n clusters_struct.each{ |cluster_set|\n ## here the method select_resource return a reference of the self object\n resource_cluster = MyExperiment.resources.select_resource(:name => cluster_set.name)\n if not resource_cluster then ## it doesn't exist we add cluster_set to the site_set\n site_set.properties[:hw] = cluster_set.properties[:hw] if @resources[site_name.to_sym].length < 2\n ## When we just have a cluster per site , we assigned the hardware cluster to the site\n site_set.push(cluster_set)\n elsif resource_cluster.is_a?(ResourceSet) then\n cluster_set.each { |node|\n resource_cluster.push(node)\n }\n end\n\n }\n\n ### saving resource_set in yaml\n logger.info \"Saving resources in yaml\"\n File.open(RESOURCE_SET_FILE,'w+') do |f|\n f.puts(MyExperiment.resources.to_yaml)\n end\n\n create_metadata_file\n end",
"def recipes\n ['runit', proc {\n begin\n if node['virtualization'] && %w{docker lxc}.include?(node['virtualization']['system'])\n resources('service[runsvdir-start]').action(:nothing)\n end\n rescue Chef::Exceptions::ResourceNotFound\n end\n }]\n end",
"def add_resource_pools_to_manifest(manifest)\n if any_service_nodes?\n config.each do |cluster|\n server_count = cluster[\"count\"]\n server_flavor = cluster[\"flavor\"]\n resource_pool = {\n \"name\" => cluster_name(cluster),\n \"network\" => \"default\",\n \"size\" => server_count,\n \"stemcell\" => {\n \"name\" => system_config.stemcell_name,\n \"version\" => system_config.stemcell_version\n },\n # TODO how to create \"cloud_properties\" per-provider?\n \"cloud_properties\" => {\n \"instance_type\" => server_flavor\n },\n \"persistent_disk\" => system_config.common_persistent_disk\n }\n manifest[\"resource_pools\"] << resource_pool\n end\n end\n end",
"def shard_for(key)\n connection_name = connection_router.fetch_connection_name(key)\n shard_repository.fetch(connection_name)\n end",
"def each_resource(&block)\n Chef::Resource.constants.each do |res_class_name|\n res_class = Chef::Resource.const_get(res_class_name)\n next unless res_class.is_a?(Class) && res_class < Chef::Resource\n res_name = @recipe.convert_to_snake_case(res_class_name.to_s)\n block.call(res_name, res_class)\n end\n end",
"def with_all(continue_on_error = false)\n cluster.shards.map do |shard|\n begin\n with_shard(shard) {\n yield\n }\n rescue Exception => err\n unless continue_on_error\n raise err\n end\n err\n end\n end\n end",
"def run\n # Ensure this is never run with a dirty in-memory shard cache\n ::Switchman::Shard.clear_cache\n migrate_strands\n migrate_everything\n end",
"def _rewire_sub_resources!\n rewire_map = {\n 'remote_file' => 'cerner_tomcat_remote_file',\n 'template' => 'cerner_tomcat_template',\n 'cookbook_file' => 'cerner_tomcat_cookbook_file',\n 'web_app' => 'cerner_tomcat_web_app'\n }\n # Generate stub methods for all the rewiring.\n rewire_map.each do |new_name, old_name|\n # This is defined as a singleton method on self so it looks like\n # the DSL but is scoped to just this context.\n define_singleton_method(new_name) do |name=nil, *args, &block|\n # Store the caller to correct the source_line.\n created_at = caller[0]\n public_send(old_name, name, *args) do\n # Set the declared type to be the native name.\n self.declared_type = self.class.resource_name\n # Fix the source location. for chef 12.4 we could do this with the\n # declared_at parameter on the initial send.\n self.source_line = created_at\n # Run the original block.\n instance_exec(&block) if block\n end\n end\n end\n end",
"def set_sharding\n Rails.application.config.allow_sharding = params[:state]\n render :get_sharding\n end",
"def list_all_shards(args = {}) \n get(\"/shards.json/\", args)\nend",
"def _rewire_resources\n if defined?(Chef::DSL::Resources)\n # Chef >= 12.4.\n Chef::DSL::Resources.instance_methods\n else\n # Chef < 12.4 >= 12.0.\n Chef::Resource.descendants.map do |klass|\n klass.node_map.instance_variable_get(:@map).keys + if klass.dsl_name.include?('::')\n # Probably not valid.\n # :nocov:\n []\n # :nocov:\n else\n # Needed for things that don't call provides().\n [klass.dsl_name]\n end\n end.flatten\n end.map {|name| name.to_s }.select {|name| name.start_with?('application_') }.uniq\n end",
"def apply(resource)\n [:one, :two, :ensure, :target].each do |st|\n Puppet.info \"Setting #{resource[:name]}: #{st} => #{resource.should(st)}\"\n resource.provider.send(st.to_s + \"=\", resource.should(st))\n end\n end",
"def shard_for(key)\n connection_name = cluster_routing.route(key.to_s)\n shard_repository.fetch(connection_name)\n end",
"def init_cluster_resources(app_name, cache_node_type, param_group_seed: nil, **properties)\n subnet_group_name = \"#{app_name}ElasticacheSubnetGroup\"\n resource subnet_group_name,\n Type: 'AWS::ElastiCache::SubnetGroup',\n Properties: {\n Description: 'SubnetGroup for elasticache',\n SubnetIds: ref_resource_subnets\n }\n\n security_group_name =\n security_group_vpc \"#{app_name}RedisSecurityGroup\",\n \"Redis Security Group for #{app_name}\",\n ref_vpc_id,\n security_group_ingress: [\n {\n IpProtocol: 'tcp',\n FromPort: '6379',\n ToPort: '6389',\n SourceSecurityGroupId: ref_application_security_group\n }\n ],\n tags: {\n Name: join('-', aws_stack_name, 'res', 'sg'),\n Application: aws_stack_name\n }\n\n parameter_group_required_props = {\n 'reserved-memory': Core::InstanceType.elasticache_instance_type.max_memory(cache_node_type) / 2\n }\n\n parameter_group_props = (\n if !properties.nil? && properties.key?(:parameter_group_properties)\n properties[:parameter_group_properties]\n else\n {}\n end).merge(parameter_group_required_props)\n\n # TODO: remove this workaround when related template gets fixed\n parameter_group_name = if param_group_seed\n \"#{app_name}RedisParameterGroup#{param_group_seed}\"\n else\n \"#{app_name}RedisParameterGroup#{magic_number(parameter_group_props)}\"\n end\n\n resource parameter_group_name,\n Type: 'AWS::ElastiCache::ParameterGroup',\n Properties: {\n Description: \"#{app_name} redis parameter group\",\n CacheParameterGroupFamily: 'redis3.2',\n Properties: parameter_group_props\n }\n\n {\n subnet_group: subnet_group_name,\n security_group: security_group_name,\n parameter_group: parameter_group_name\n }\n end",
"def elasticsearch_init(app_name,\n ssh_key:,\n es_config: {},\n os: 'Amazon Linux 2015.09',\n cookbook: 'https://github.com/en-japan-air/opsworks-elasticsearch-cookbook.git')\n\n parameter \"ES#{app_name}ChefCookbook\",\n Default: cookbook,\n Description: 'GitURL',\n Type: 'String'\n\n parameter \"ES#{app_name}InstanceDefaultOs\",\n Default: os,\n Description: ['The stack\\'s default operating system, which is installed',\n 'on every instance unless you specify a different',\n 'operating system when you create the instance.'].join(' '),\n Type: 'String'\n\n parameter \"ES#{app_name}SshKeyName\",\n Default: ssh_key,\n Description: 'SSH key name for EC2 instances.',\n Type: 'String'\n\n resource 'InstanceRole',\n Type: 'AWS::IAM::InstanceProfile',\n Properties: {\n Path: '/',\n Roles: [\n ref('OpsWorksEC2Role')\n ]\n }\n\n resource 'ServiceRole',\n Type: 'AWS::IAM::Role',\n Properties: {\n AssumeRolePolicyDocument: {\n Statement: [\n {\n Effect: 'Allow',\n Principal: {\n Service: [\n 'opsworks.amazonaws.com'\n ]\n },\n Action: [\n 'sts:AssumeRole'\n ]\n }\n ]\n },\n Path: '/',\n Policies: [\n {\n PolicyName: \"#{app_name}-opsworks-service\",\n PolicyDocument: {\n Statement: [\n {\n Effect: 'Allow',\n Action: %w( ec2:* iam:PassRole cloudwatch:GetMetricStatistics elasticloadbalancing:* ),\n Resource: '*'\n }\n ]\n }\n }\n ]\n }\n\n resource 'OpsWorksEC2Role',\n Type: 'AWS::IAM::Role',\n Properties: {\n AssumeRolePolicyDocument: {\n Statement: [\n {\n Effect: 'Allow',\n Principal: {\n Service: [\n 'ec2.amazonaws.com'\n ]\n },\n Action: [\n 'sts:AssumeRole'\n ]\n }\n ]\n },\n Path: '/',\n Policies: [\n {\n PolicyName: \"#{app_name}-opsworks-ec2-role\",\n PolicyDocument: {\n Statement: [\n {\n Effect: 'Allow',\n Action: %w(\n ec2:DescribeInstances\n ec2:DescribeRegions\n ec2:DescribeSecurityGroups\n ec2:DescribeTags\n cloudwatch:PutMetricData),\n Resource: '*'\n }\n ]\n }\n }\n ]\n }\n\n instances_security_group = security_group_vpc(\"ES#{app_name}\", 'so that ES cluster can find other nodes', vpc.id)\n\n ops_stack_name = \"#{app_name}-ES\"\n resource 'ESStack',\n Type: 'AWS::OpsWorks::Stack',\n Properties: {\n Name: ops_stack_name,\n VpcId: vpc.id,\n DefaultSubnetId: ref_resource_subnets.first,\n ConfigurationManager: {\n Name: 'Chef',\n Version: '12'\n },\n UseCustomCookbooks: 'true',\n CustomCookbooksSource: {\n Type: 'git',\n Url: ref(\"ES#{app_name}ChefCookbook\")\n },\n DefaultOs: ref(\"ES#{app_name}InstanceDefaultOs\"),\n DefaultRootDeviceType: 'ebs',\n DefaultSshKeyName: ref(\"ES#{app_name}SshKeyName\"),\n CustomJson: {\n java: {\n jdk_version: '8',\n oracle: {\n accept_oracle_download_terms: 'true'\n },\n accept_license_agreement: 'true',\n install_flavor: 'oracle'\n },\n elasticsearch: {\n plugins: [\n 'analysis-kuromoji',\n 'cloud-aws',\n { name: 'elasticsearch-head', url: 'mobz/elasticsearch-head' }\n ],\n config: {\n 'cluster.name': \"#{app_name}-elasticsearch\",\n 'path.data': '/mnt/elasticsearch-data',\n 'path.logs': '/mnt/elasticsearch-data/logs/',\n 'network.bind_host': '0.0.0.0',\n 'network.publish_host': '_non_loopback_',\n 'index.routing.allocation.disable_allocation': 'false',\n 'cloud.aws.region': region,\n discovery: {\n type: 'ec2',\n ec2: {\n groups: [ref(instances_security_group)],\n tag: {\n 'opsworks:stack': ops_stack_name\n }\n }\n },\n 'cluster.routing.allocation.awareness.attributes': 'rack_id'\n }.merge(es_config)\n }\n },\n ServiceRoleArn: {\n 'Fn::GetAtt': %w(ServiceRole Arn)\n },\n DefaultInstanceProfileArn: {\n 'Fn::GetAtt': %w(InstanceRole Arn)\n }\n }\n\n resource 'ESLayer',\n Type: 'AWS::OpsWorks::Layer',\n Properties: {\n StackId: ref('ESStack'),\n Name: 'Search',\n Type: 'custom',\n Shortname: 'search',\n CustomRecipes: {\n Setup: %w(apt ark java layer-custom::es-opsworks)\n },\n EnableAutoHealing: 'true',\n AutoAssignElasticIps: 'false',\n AutoAssignPublicIps: 'false',\n VolumeConfigurations: [\n {\n MountPoint: '/mnt/elasticsearch-data',\n NumberOfDisks: 1,\n VolumeType: 'gp2',\n Size: 100\n }\n ],\n CustomSecurityGroupIds: [\n {\n 'Fn::GetAtt': %W(#{instances_security_group} GroupId)\n },\n ref_private_security_group\n ]\n }\n\n resource 'ESMainInstance',\n Type: 'AWS::OpsWorks::Instance',\n Properties: {\n # EbsOptimized: true, # Not available for m3.medium\n InstanceType: 'm3.medium',\n LayerIds: [ref('ESLayer')],\n StackId: ref('ESStack')\n }\n end",
"def create_instances\n min_count = max_count = @bs.number_of_nodes\n puts \"\\nCreating #{max_count} on-demand instance(s)\"\n options = {\n 'ClientToken' => generate_token,\n 'KeyName' => Chef::Config[:knife][:aws_ssh_key_id],\n 'InstanceType' => @bs.flavor,\n 'SubnetId' => @bs[:novpc] ? nil : @bs.subnet_id,\n 'Placement.AvailabilityZone' => @bs.mixins.az.data,\n 'SecurityGroupId' => @bs.mixins.sg.data\n }\n options['EbsOptimized'] = !! @bs[:ebs_optimized]\n\n ## REVIEW\n if ami.root_device_type == \"ebs\"\n ami_map = ami.block_device_mapping.first\n block_device_mapping = {\n 'DeviceName' => ami_map['deviceName'],\n 'Ebs.VolumeSize' => ami_map['volumeSize'].to_s,\n 'Ebs.DeleteOnTermination' => ami_map['deleteOnTermination']\n }\n options['BlockDeviceMapping'] = [block_device_mapping]\n end\n\n ## Optionally only include mapped devices\n ## This way we get all of the ephemeral drives, some unmapped however\n if @bs.mixins.volume.data[:ephemeral_available]\n ephmap = @bs.mixins.volume.data.ephemeral_available.each_with_index.map do |d,i|\n {\n 'VirtualName' => \"ephemeral#{i}\",\n 'DeviceName' => d\n }\n end\n options['BlockDeviceMapping'].concat( ephmap )\n end\n\n if (max_count == 1) and @bs[:private_ip_address]\n options['PrivateIpAddress'] = @bs.private_ip_address\n puts \"Assigning IP ADDRESS : #{options['PrivateIpAddress']}\"\n end\n\n if Chef::Config[:knife][:aws_user_data]\n begin\n options['UserData']= File.read(Chef::Config[:knife][:aws_user_data])\n rescue\n ui.warn(\"Cannot read #{Chef::Config[:knife][:aws_user_data]}:\"\\\n \" #{$!.inspect}. Ignoring option.\")\n end\n end\n\n # -----------------------------------------------------------------\n tries = 5\n print_table(options, 'Launch Config')\n begin\n puts \"\\nSending request...\"\n response = connection.run_instances(@bs.image, min_count,\n max_count, options)\n ui.msg(response.inspect)\n rescue Exception => e\n ui.warn(\"#{e.message}\\nException creating instances\")\n if (tries -= 1) <= 0\n ui.warn(\"\\n\\nMax tries reached. Exiting.\\n\\n\")\n exit 1\n else\n ui.msg(\"Trying again.\\n\")\n retry\n end\n end\n # now we have our servers\n instances = response.body['instancesSet']\n # select only instances that have instanceId key and collect those ids\n # into an array\n @bs[:instance_ids] =\n instances.select {|i| i.has_key?('instanceId')}.collect do |i|\n i['instanceId']\n end\n\n puts \"\\nNumber of instances started: #{@bs.instance_ids.size}\\n\"\n sleep 10\n puts \"Getting servers..\"\n # collect an array of servers retrieved based on the instance ids we\n # obtained above\n @bs[:servers] = @bs.instance_ids.collect do |id|\n begin\n server = connection.servers.get(id)\n rescue Exception => e\n sleep 7\n retry\n end\n raise Ec2Error.new(\"server #{id} was nil\") if server.nil?\n server\n end\n end",
"def create\n # this routine creates the cluster - if this runs, exists? has exited false\n # first we check all the nodes to ensure mysql is listening, and if the\n # wsrep_cluster_status is primary. If one is, we'll join it.\n \n # array cluster_servers is the list of hosts to check\n first_node = true\n gcomm_address = \"gcomm://\"\n @resource[:cluster_servers].each { | node | \n if @resource[:hostname] != node # not this host, so do the check\n puts \"checking host #{node} for Primary\"\n #TODO - refactor this to simplify, it's ugly like this\n begin\n cluster_check_result = mysql([defaults_file, \"-h\", node, '-NBe', \"show status like 'wsrep_cluster_status'\"].compact)\n puts \"Result of check on #{node} was #{cluster_check_result}\"\n rescue => e\n debug(e.message)\n cluster_check_result = \"someerror\"\n end\n if cluster_check_result.match(/Primary/)\n first_node = false\n gcomm_address = \"gcomm://#{node}\"\n puts \"Node #{node} matched Primary, first_node is #{first_node}, address is now #{gcomm_address}\"\n # TODO what happens when mysql isn't listening on node?\n # that node is a primary, we can connect to it\n # we should end the loop here, but it probably doesn't hurt if we don't\n #break\n else\n puts \"host #{node} is not a primary\"\n end\n end\n }\n # after that loop, we'll have a boolean first_node that tells if this is the first node.\n if first_node == true\n puts \"This is the first node of the cluster, so we will create the cluster now, address: #{gcomm_address}\"\n # this is the first node, and it's not yet a cluster\n else\n puts \"first node is #{first_node}, address: #{gcomm_address}\"\n end\n\n # stop the service\n mysqladmin([defaults_file, \"shutdown\"].compact)\n service([@resource[:servicename], \"stop\"].compact)\n # start it special with the address as set above\n # TODO if this is the first node, do another check after some random sleep time, just in case...\n mysql_startup = fork do\n exec \"/usr/bin/mysqld_safe --wsrep_cluster_address=#{gcomm_address}\"\n end\n Process.detach(mysql_startup)\n end",
"def using_shard(shard, &_block)\n older_shard = current_shard\n older_slave_group = current_slave_group\n older_load_balance_options = current_load_balance_options\n\n begin\n unless current_model && !current_model.allowed_shard?(shard)\n self.current_shard = shard\n end\n yield\n ensure\n self.current_shard = older_shard\n self.current_slave_group = older_slave_group\n self.current_load_balance_options = older_load_balance_options\n end\n end",
"def init\n file = Google::StringUtils.underscore(@resource_name || @name)\n\n @recipes = setup_hash(@recipes)\n @recipes['create'] = \"tests~#{file}\" unless @recipes['create']\n @recipes['delete'] = \"tests~delete_#{file}\" unless @recipes['delete']\n\n @resources = setup_hash(@resource_count)\n @resources['create'] = DEFAULT_RESOURCE_COUNT unless @resources['create']\n @resources['delete'] = DEFAULT_RESOURCE_COUNT unless @resources['delete']\n\n @affected = setup_hash(@affected_count)\n unless @affected['create']\n @affected['create'] =\n DEFAULT_RESOURCE_COUNT - 1\n end\n\n return if @affected['delete']\n @affected['delete'] = DEFAULT_RESOURCE_COUNT - 1\n end",
"def replicas; end",
"def is_cassandra_node settings\n has_role settings, \"cassandra_node\"\n security_group 'cassandra_node' do\n authorize :group_name => 'cassandra_node'\n authorize :network => '70.91.172.41/29', :from_port => \"9160\", :to_port => \"9160\"\n authorize :network => '72.32.68.18/32', :from_port => \"9160\", :to_port => \"9160\"\n authorize :network => '72.32.70.9/32', :from_port => \"9160\", :to_port => \"9160\"\n end\nend",
"def chef_refresh_tenants\n foundation_bag = chef_api_connect.data_bags.fetch('foundation')\n current_tenants = fetch_databag_tenants\n tenant_array = fetch_fconfig_tenants\n\n # Acqure .feature data bag to whitelist/track features we care about\n feature_bag = Hash.new\n chef_api_connect.search.query('foundation', 'id:.features', start: 0).rows.each do |item|\n feature_bag = item['raw_data']\n end\n\n tenant_array.each do |t_config|\n tenant = t_config[0]\n fconfigdb = t_config[1]\n envname = t_config[2]\n tenant_bag = Hash.new\n mysql_connect = mysql_api_connect(envname)\n client = mysql_connect[0] # mysql connection\n\n # Acquire contextmode value for tenant attribute\n chef_api_connect.search.query('environment', \"name:#{envname}\").rows.each do |envitem|\n @contextmode = envitem['default_attributes']['database']['contextmode']\n end\n\n results = client.query(\"select * from #{fconfigdb}.tenant_config where tenant_name='#{tenant}'\")\n results.each do |row_schema|\n # Set initial tenant attributes from corresponding .tenant_config\n row_schema.each do |col_name, col_val|\n case col_name\n when \"tenant_name\" \n tenant_bag['id'] = col_val\n tenant_bag['url'] = col_val\n tenant_bag['url_alias'] = col_val\n tenant_bag['tenant_name'] = col_val\n tenant_bag['tenant_header'] = col_val\n tenant_bag['tenant_status'] = 'active'\n tenant_bag['is_provisioned'] = 'false'\n when 'datasource_id' then\n tenant_bag['datasource.id'] = col_val # for queries\n when 'id' then\n tenant_bag['tenant_config.id'] = col_val # for queries\n end\n end\n end\n\n # Fetch and set additional tenant attributes outside of .tenant_config\n tenant_bag['env'] = envname\n tenant_bag['context'] = @contextmode\n\n # Queries are combined into multi-statements to reduce query load\n @sql_tenant_config = client.query(\"\n select * from #{fconfigdb}.tenant_config where tenant_name='#{tenant_bag['id']}';\n select * from #{fconfigdb}.datasource where id='#{tenant_bag['datasource.id']}';\n select ref_feature_code_id from #{fconfigdb}.tenant_feature where tenant_config_id='#{tenant_bag['tenant_config.id']}'\n \")\n while client.next_result\n @sql_tenant_datasource = client.store_result\n while client.next_result\n @sql_tenant_features = client.store_result\n end\n end\n\n # Construct .tenant_config attributes\n @sql_tenant_config.each do |tenant_config_row|\n tenant_config_row.each do |tenant_key, tenant_val|\n tenantconfigkey = \"tenant_config.#{tenant_key}\"\n tenant_bag[tenantconfigkey] = tenant_val\n end\n end\n\n # Fetch and construct .datasource attributes\n @sql_tenant_datasource.each do |ds_row|\n ds_row.each do |ds_key, ds_val|\n datasourcekey = \"datasource.#{ds_key}\"\n tenant_bag[datasourcekey] = ds_val\n end\n end\n\n # Fetch and construct .feature attributes\n @sql_tenant_features.each do |feature_row|\n feature_row.each do|_feature_key, feature_val|\n # Compare against useful features listed in .features data bag.\n feature_bag.each do |key,value|\n case feature_val\n when value\n tenant_bag[key] = value\n end\n end\n end\n end\n \n # Determine whether the tenant should be updated or created\n update_bag = Hash.new\n if current_tenants.include?(tenant)\n puts \"(chef_tenant_update): Updating data bag for #{tenant}.\"\n # Values to retain from existing tenant before updating\n chef_api_connect.search.query('foundation', \"id:#{tenant_bag['id']}\", start: 0).rows.each do |item|\n tenant_bag['is_provisioned'] = item['raw_data']['is_provisioned']\n tenant_bag['url_alias'] = item['raw_data']['url_alias']\n tenant_bag['tenant_status'] = item['raw_data']['tenant_status']\n end\n update_bag = foundation_bag.items.update(tenant)\n update_bag.data = tenant_bag\n else\n puts \"(chef_tenant_update): Creating data bag for #{tenant}.\"\n update_bag = foundation_bag.items.create(tenant_bag)\n end\n update_bag.save!\n end\nend",
"def primary_shard\n case shard_value\n when Shard, DefaultShard\n shard_value\n # associated_shards\n when ::ActiveRecord::Base\n shard_value.shard\n when Array\n shard_value.first\n when ::ActiveRecord::Relation\n Shard.default\n when nil\n Shard.current(klass.connection_classes)\n else\n raise ArgumentError, \"invalid shard value #{shard_value}\"\n end\n end",
"def cook(&block)\n the_recipes = [\n self.class.standard_recipes,\n self.base_recipe,\n self.recipes,\n (block_given? ? block : nil)\n ].flatten.compact.uniq\n the_recipes.each do |r|\n if r.is_a?(Proc)\n self.cap_config.load(:proc => r)\n else # assume recipe filename\n self.cap_config.load(:file => r)\n end\n end\n @cooked = true\n self.cap_config\n end",
"def set_resource_limits(app, search_cluster, memory, disk, address_space, reporter_noise_level = nil)\n if @block_feed_in_distributor\n set_proton_limits(search_cluster, 1.0, 1.0, 1.0)\n set_cluster_controller_limits(app, search_cluster, memory, disk, address_space)\n else\n set_proton_limits(search_cluster, memory, disk, address_space)\n set_cluster_controller_limits(app, search_cluster, 1.0, 1.0, 1.0)\n end\n if reporter_noise_level != nil\n search_cluster.config(get_filestor_config(reporter_noise_level))\n end\n end",
"def traffic_shaping\n Puppet.debug \"Entering traffic_shaping\"\n @networksystem=host.configManager.networkSystem\n portg=find_portgroup\n if ( resource[:traffic_shaping_policy] == :enabled )\n avgbandwidth = resource[:averagebandwidth].to_i * 1000\n peakbandwidth = resource[:peakbandwidth].to_i * 1000\n burstsize = resource[:burstsize].to_i * 1024\n enabled = 1\n\n hostnetworktrafficshapingpolicy = RbVmomi::VIM.HostNetworkTrafficShapingPolicy(:averageBandwidth => avgbandwidth, :burstSize => burstsize, :enabled => enabled, :peakBandwidth => peakbandwidth)\n\n elsif ( resource[:traffic_shaping_policy] == :disabled)\n enabled = 0\n hostnetworktrafficshapingpolicy = RbVmomi::VIM.HostNetworkTrafficShapingPolicy(:enabled => enabled)\n end\n\n hostnetworkpolicy = RbVmomi::VIM.HostNetworkPolicy(:shapingPolicy => hostnetworktrafficshapingpolicy)\n\n actualspec = portg.spec\n if (actualspec.policy != nil )\n actualspec.policy.shapingPolicy = hostnetworktrafficshapingpolicy\n else\n actualspec.policy = hostnetworkpolicy\n end\n @networksystem.UpdatePortGroup(:pgName => resource[:portgrp], :portgrp => actualspec)\n return true\n end",
"def with_shard(shard)\n shard = cluster.to_shard(shard)\n\n old_shard = current_shard\n old_fixed = fixed_shard\n self.current_shard = shard\n self.fixed_shard = shard\n yield\n ensure\n self.fixed_shard = old_fixed\n self.current_shard = old_shard\n end",
"def run\n super\n\n bucket_name = _get_entity_name\n opt_use_file = _get_option(\"use_file\")\n opt_filename = _get_option(\"brute_file\")\n opt_additional_buckets = _get_option(\"additional_buckets\")\n opt_use_creds = _get_option(\"use_creds\")\n opt_threads = _get_option(\"threads\")\n\n if opt_use_file\n _log \"Using file: #{opt_filename}\"\n potential_buckets = File.read(\"#{$intrigue_basedir}/data/#{opt_filename}\").split(\"\\n\")\n else\n _log \"Using provided brute list\"\n potential_buckets = [bucket_name]\n end\n\n # add in any additional buckets to the list of potentials\n all_potential_buckets = potential_buckets.concat(opt_additional_buckets.split(\",\"))\n\n # Create our queue of work from the checks in brute_list\n work_q = Queue.new\n all_potential_buckets.each do |pb|\n work_q << pb.strip\n end\n\n # Create a pool of worker threads to work on the queue\n workers = (0...opt_threads).map do\n Thread.new do\n begin\n while bucket_name = work_q.pop(true)\n\n #skip anything that isn't a real name\n next unless bucket_name && bucket_name.length > 0\n\n # Authenticated method\n if opt_use_creds\n\n access_key_id = _get_global_config \"aws_access_key_id\"\n secret_access_key = _get_global_config \"aws_secret_access_key\"\n\n unless access_key_id && secret_access_key\n _log_error \"FATAL! To scan with authentication, you must specify a aws_access_key_id aws_secret_access_key in the config!\"\n return\n end\n\n # Check for it, and get the contents\n Aws.config[:credentials] = Aws::Credentials.new(access_key_id, secret_access_key)\n exists = check_existence_authenticated(bucket_name)\n\n # create our entity and store the username with it\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => true,\n \"username\" => access_key_id\n }) if exists\n\n #########################\n # Unauthenticated check #\n #########################\n else\n\n s3_uri = \"https://#{bucket_name}.s3.amazonaws.com\"\n exists = check_existence_unauthenticated(s3_uri)\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => false\n }) if exists\n\n next if exists ## Only proceed if we got an error above (bucket exists!) !!!\n\n s3_uri = \"https://s3.amazonaws.com/#{bucket_name}\"\n exists = check_existence_unauthenticated(s3_uri)\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => false,\n }) if exists\n\n end # end if opt_use_creds\n\n\n end # end while\n rescue ThreadError\n end\n end\n end; \"ok\"\n workers.map(&:join); \"ok\"\n\n end",
"def settings_for_node\n cluster_name = self.parent.name.to_sym\n cluster_role = self.name.to_sym\n node_settings = {\n :user_data => { :attributes => { :run_list => [] } },\n :cluster_name => cluster_name,\n :cluster_role => cluster_role,\n }.deep_merge(Settings)\n node_settings.delete :pools\n raise \"Please define the '#{cluster_name}' cluster and the '#{cluster_role}' role in your ~/.chef/cluster_chef.yaml\" if (Settings[:pools][cluster_name].blank? || Settings[:pools][cluster_name][cluster_role].blank?)\n node_settings = node_settings.deep_merge(\n Settings[:pools][cluster_name][:common] ||{ }).deep_merge(\n Settings[:pools][cluster_name][cluster_role] ||{ })\n configure_aws_region node_settings\n node_settings\nend",
"def on_default_shard(proxy_target = nil, &block)\n raise ArgumentError, \"No sharded connection configured!\" unless sharded_connection\n\n if sharded_connection.support_default_shard?\n shard_for(:default, proxy_target, &block)\n else\n raise ArgumentError, \"This model's sharding method does not support default shard\"\n end\n end",
"def is_cassandra_node settings\n has_role settings, \"cassandra_node\"\n security_group 'cassandra_node' do\n authorize :group_name => 'cassandra_node'\n end\nend",
"def sharded?; true; end",
"def distributePrimaryRegions(priRegions)\n c = HBaseConfiguration.new()\n admin = HBaseAdmin.new(c)\n servers = Array.new()\n dServers = Array.new()\n dServers = admin.getClusterStatus.getDeadServerNames()\n serv = admin.getClusterStatus.getServers()\n serv.each do |s|\n if (!dServers.include?(s))\n servers << s.getServerName()\n end\n end\n count=0\n totRS = servers.size()\n priRegions.each do |r|\n puts r+\" will move to \"+servers[count%totRS]\n move r,servers[count%totRS]\n count+=1\n end\n puts priRegions.size().to_s() + \"primary regions moved\"\nend",
"def make_super_clusters(options)\n require 'core-access/cluster_database'\n extend ClusterDB\n require 'core-access/cluster_models'\n require 'tempfile'\n\n default_options = {\n :cutoff => 70,\n :cdhit_dir => \"/usr/local/cdhit\"\n }\n options.reverse_merge!(default_options)\n\n options = MethodArgumentParser::Parser.check_options options do\n option :db_location, :required => true, :type => :string\n end\n\n connection = make_db_connection(options[:db_location]).connection\n\n tmpfile_object = write_cluster_representatives_to_file\n\n # make cdhit clusters\n `#{options[:cdhit_dir]}/cd-hit -i #{tmpfile_object.path} -o /tmp/cdhit_super_clusters-#{options[:cutoff]} -c #{options[:cutoff]/100.to_f} -n 5 -d 200`\n\n # read in cluster info from cdhit output\n super_clusters = read_super_clstr_file(\"/tmp/cdhit_super_clusters-#{options[:cutoff]}.clstr\")\n add_super_clusters_to_db(super_clusters, options[:cutoff])\n\n puts \"updating cluster number_of_members and number_of_strains\"\n # update cluster info\n update_cluster_number_of_members(Cluster.where(\"clusters.is_parent_cluster = ?\", true).all)\n update_cluster_number_of_strains(Cluster.where(\"clusters.is_parent_cluster = ?\", true).all)\n\n tmpfile_object.close\n end",
"def is_generic_node settings\n # Instance described in settings files\n instance_type settings[:instance_type]\n image_id AwsServiceData.ami_for(settings)\n availability_zones settings[:availability_zones]\n disable_api_termination settings[:disable_api_termination] if settings[:instance_backing] == 'ebs'\n elastic_ip settings[:elastic_ip] if settings[:elastic_ip]\n set_instance_backing settings\n keypair settings[:cluster_name].to_s, File.join(ENV['HOME'], '.chef', 'keypairs')\n has_role settings, \"base_role\"\n settings[:user_data][:attributes][:cluster_name] = settings[:cluster_name]\n settings[:user_data][:attributes][:cluster_role] = settings[:cluster_role]\n security_group_unless_exists settings[:cluster_name].to_s do\n authorize :group_name => settings[:cluster_name].to_s\n end\n security_group do\n authorize :from_port => 22, :to_port => 22\n authorize :from_port => 80, :to_port => 80\n end\n security_group_unless_exists \"default\"\n user 'ubuntu'\n is_spot_priced settings\n sends_aws_keys settings\nend",
"def action_create\n if current_resource.exists? && correct_config?\n Chef::Log.debug(\"#{new_resource} exists - skipping\")\n else\n converge_by(\"Create #{new_resource}\") do\n executor.groovy! <<-EOH.gsub(/ ^{12}/, '')\n import hudson.model.*\n import hudson.slaves.*\n import jenkins.model.*\n import jenkins.slaves.*\n\n props = []\n availability = #{convert_to_groovy(new_resource.availability)}\n usage_mode = #{convert_to_groovy(new_resource.usage_mode)}\n env_map = #{convert_to_groovy(new_resource.environment)}\n labels = #{convert_to_groovy(new_resource.labels.sort.join(\"\\s\"))}\n\n // Compute the usage mode\n if (usage_mode == 'normal') {\n mode = Node.Mode.NORMAL\n } else {\n mode = Node.Mode.EXCLUSIVE\n }\n\n // Compute the retention strategy\n if (availability == 'demand') {\n retention_strategy =\n new RetentionStrategy.Demand(\n #{new_resource.in_demand_delay},\n #{new_resource.idle_delay}\n )\n } else if (availability == 'always') {\n retention_strategy = new RetentionStrategy.Always()\n } else {\n retention_strategy = RetentionStrategy.NOOP\n }\n\n // Create an entry in the prop list for all env vars\n if (env_map != null) {\n env_vars = new hudson.EnvVars(env_map)\n entries = env_vars.collect {\n k,v -> new EnvironmentVariablesNodeProperty.Entry(k,v)\n }\n props << new EnvironmentVariablesNodeProperty(entries)\n }\n\n // Launcher\n #{launcher_groovy}\n\n // Build the slave object\n slave = new DumbSlave(\n #{convert_to_groovy(new_resource.name)},\n #{convert_to_groovy(new_resource.description)},\n #{convert_to_groovy(new_resource.remote_fs)},\n #{convert_to_groovy(new_resource.executors.to_s)},\n mode,\n labels,\n launcher,\n retention_strategy,\n props\n )\n\n // Create or update the slave in the Jenkins instance\n nodes = new ArrayList(Jenkins.instance.getNodes())\n ix = nodes.indexOf(slave)\n (ix >= 0) ? nodes.set(ix, slave) : nodes.add(slave)\n Jenkins.instance.setNodes(nodes)\n EOH\n end\n end\n end",
"def reconcile\n \n #First sync instances \n Instance.sync_with_ec2\n \n #then make sure this farm is operating withing limits... start and stop based on limits\n #now lets go through our configs and sync what is running with what is configured to run\n\n num_stop = 0\n num_start = 0\n\n logger.info \"Reconciling farm #{ami_id}...\"\n EventLog.info \"Reconciling farm #{ami_id}...\"\n \n ia = instances.select{ |i| i.running?} \n if ia.size < min\n num_start = min.to_i - ia.size\n # need to start some of them\n logger.info \"Attempting to start #{num_start} #{ami_id} instances... may take a few moments.\"\n EventLog.info \"Attempting to start #{num_start} #{ami_id} instances... may take a few moments.\"\n start_and_create_instances(num_start)\n\n elsif ia.size > max\n # need to stop some of the instances, if they are either 'IDLE' or 'LAUNCHED' state or \"ERROR\"\n num_stop = ia.size - max.to_i\n count = 0\n ia.each do |ri|\n break if count >= num_stop\n if ri.available? || ri.error?\n #shut it down!\n logger.info \"Shutting down instance #{ami_id} -- #{ri.instance_id}...\"\n EventLog.info \"Shutting down instance #{ami_id} -- #{ri.instance_id}...\"\n ri.terminate\n count += 1\n end \n end\n end\n \n # shutdown what we can from idle\n \n num_stop += scale_down\n \n #########################\n #\n # now that we scaled down, lets recycle those compute nodes that have not checked in for a while (15 mins)\n # we're looking for those that are available or busy and are compute nodes\n #\n \n ia = instances.select{ |i| i.running?} \n \n ia.each do |ri|\n if (ri.available? || ri.state.eql?('busy')) && ri.farm.farm_type.eql?('compute') && ri.silent_since?(NODE_TIMEOUT)\n #shut down silent nodes\n logger.info \"Shutting down instance #{ri.farm.ami_id} -- #{ri.instance_id} because it was unresponsive.\"\n EventLog.info \"Shutting down instance #{ri.farm.ami_id} -- #{ri.instance_id} because it was unresponsive.\"\n ri.terminate\n \n #recycle if not heard from in a while\n # if ri.cycle_count < NODE_CYCLE_MAX\n # logger.info \"Recycling instance #{ri.farm.ami_id} -- #{ri.instance_id}...\"\n # EventLog.info \"Recycling instance #{ri.farm.ami_id} -- #{ri.instance_id}...\"\n # ri.recycle\n # else\n # logger.info \"Shutting down instance #{ri.farm.ami_id} -- #{ri.instance_id} because it was unresponsive and exceeded max recycle tries.\"\n # EventLog.info \"Shutting down instance #{ri.farm.ami_id} -- #{ri.instance_id} because it was unresponsive and exceeded max recycle tries.\"\n # ri.terminate \n # end\n end \n end\n \n \n return {:farm_name => name, :message => 'Finished reconciling', :num_shutdown => num_stop, :num_started => num_start}\n \n end",
"def retain_replicas_on_node(old_node_ip)\n \n Chef::Log.info( \"***Old node IP : #{old_node_ip}\")\n new_ip = node['ipaddress']\n Chef::Log.info( \"***New node IP : #{new_ip}\")\n \n #get host ip other than the replaced node as old(replaced) ip has already gone from cluster\n computes = node.workorder.payLoad.has_key?(\"RequiresComputes\") ? node.workorder.payLoad.RequiresComputes : node.workorder.payLoad.computes\n other_computes = computes.select { |compute| compute['ciAttributes']['private_ip'] != old_node_ip}\n host = other_computes[0][\"ciAttributes\"][\"private_ip\"]\n port = (node[\"solr_version\"].start_with? \"4.\")?\"8080\":node['port_no']\n \n solrCollectionUrl = \"http://#{host}:#{port}/solr/admin/collections?\"\n \n #Get cluster state to fetch all collection & its details\n params = {:action => \"CLUSTERSTATUS\"}\n cluster_state_resp = solr_collection_api(host, port, params)\n Chef::Log.info(\"cluster_state_resp = #{cluster_state_resp.to_json}\")\n cluster_status_collections = cluster_state_resp[\"cluster\"][\"collections\"]\n \n #Get list of all existing collection names\n collection_names = []\n if !cluster_status_collections.nil? && !cluster_status_collections.empty?\n collection_names = cluster_status_collections.keys\n end\n \n #For each collection->shard->replica, delete replica and add it back if it was hosted on replaced node\n collection_names.each do |collection_name|\n \n #Process next collection if no shards found\n next if cluster_status_collections[collection_name][\"shards\"].nil? || cluster_status_collections[collection_name][\"shards\"].empty?\n \n shard_names = cluster_status_collections[collection_name][\"shards\"].keys\n shards = cluster_status_collections[collection_name][\"shards\"]\n \n #Process each shard to delete and add replica if it was hosted on replaced(old_ip) then delete first and add it back again\n shard_names.each do |shard_name|\n Chef::Log.info( \"*** Processing shard '#{shard_name}' for collection '#{collection_name}'\")\n \n #Process next shard if no replica found\n next if shards[shard_name][\"replicas\"].nil? || shards[shard_name][\"replicas\"].empty?\n \n replica_names = shards[shard_name][\"replicas\"].keys\n replicas = shards[shard_name][\"replicas\"]\n Chef::Log.info( \"*** Replica names for shard #{shard_name} : #{replica_names}\")\n Chef::Log.info( \"*** Replicas for for shard #{shard_name} : #{replicas.to_json}\")\n new_ip_exist = 0\n old_ip_exist = 0\n \n #Process each replica to and if it was hosted on replaced(old_ip) then delete first and add it back again\n replica_names.each do |replica_name|\n Chef::Log.info( \"*** Replica is : #{replica_name}\")\n if (replicas.has_key?replica_name) && (replicas[replica_name][\"base_url\"].include? old_node_ip)\n old_ip_exist += 1\n Chef::Log.info(\"Deleting old Replica : #{old_node_ip}, for collection = #{collection_name} & shard = #{shard_name} & replica=#{replica_name}\")\n delete_replica_url = \"#{solrCollectionUrl}action=DELETEREPLICA&collection=#{collection_name}&shard=#{shard_name}&replica=#{replica_name}\"\n Chef::Log.info(\"DELETEREPLICA : #{delete_replica_url}\")\n delete_replica_resp_obj = run_solr_action_api(delete_replica_url)\n Chef::Log.info(\"Deleted old Replica : #{old_node_ip}, for collection = #{collection_name} & shard = #{shard_name} & replica=#{replica_name}\")\n \n #Refresh the collection/shard state to reflect the DELETEREPLICA change\n replicas = get_replicas_by_shard(host, port, collection_name, shard_name)\n Chef::Log.info(\"replicas for collection #{collection_name} & shard #{shard_name} after deleted replica=#{replica_name}\")\n \n else\n Chef::Log.info(\"Skipping Delete Replica for the replica #{replica_name} as no replica found on node #{old_node_ip}\")\n end\n \n # before adding the replica check if the new node ip is part of any collection in the cluster state, if so then don't do it\n # new-IP exists and old-IP too exists - Deletes the replica and sets old_ip_exist = 1, sets new_ip_exist = 1 => No add replica\n # new-IP exists and old-IP does not - doesn't delete replica, old_ip_exist = 0, sets new_ip_exist = 1 => No add replica\n # new-IP does not exist and old IP does - Deletes the replica and sets old_ip_exist = 1, new_ip_exist = 0 => Satisfies the condition for add replica\n Chef::Log.info(\"replicas before checking new_ip = #{replicas.to_json}\")\n Chef::Log.info(\"replicas[replica] before checking new_ip #{new_ip} = #{replicas[replica_name].to_json}\")\n #Check if for shard, any replica is using the new_ip\n if replica_exists_on_ip?(replicas, new_ip)\n Chef::Log.info(\"New IP #{new_ip} is found in the Replica for collection = #{collection_name} & shard = #{shard_name}\")\n new_ip_exist += 1\n else\n Chef::Log.info(\"New IP #{new_ip} is not found in replicas of collection = #{collection_name} & shard = #{shard_name}\")\n end\n end # next replica\n \n #Add replica on new ip if it was deleted from old ip. i.e. if old IP existed and new IP is not shown\n if (old_ip_exist > 0 && new_ip_exist == 0)\n add_replica_url = \"#{solrCollectionUrl}action=ADDREPLICA&collection=#{collection_name}&shard=#{shard_name}&node=#{new_ip}:#{port}_solr\"\n Chef::Log.info(\"ADDREPLICA: #{add_replica_url}\")\n add_replica_resp_obj = run_solr_action_api(add_replica_url)\n Chef::Log.info(\"Added new Replica : #{new_ip}, for collection = #{collection_name} & shard = #{shard_name}\")\n else\n Chef::Log.info(\"Skipping Add Replica for collection = #{collection_name} & shard = #{shard_name}, since value of old_ip_exist=#{old_ip_exist} and value of new_ip_exist=#{new_ip_exist}\")\n end\n end # next shard\n end # next collection\n end",
"def multiple_clusters_available?\n false\n end",
"def run\n super\n\n bucket_name = _get_entity_name\n opt_use_file = _get_option(\"use_file\")\n opt_filename = _get_option(\"brute_file\")\n opt_additional_buckets = _get_option(\"additional_buckets\")\n opt_use_creds = _get_option(\"use_creds\")\n opt_threads = _get_option(\"threads\")\n opt_permute = _get_option(\"create_permutations\")\n\n if opt_use_file\n _log \"Using file: #{opt_filename}\"\n potential_buckets = File.read(\"#{$intrigue_basedir}/data/#{opt_filename}\").split(\"\\n\")\n else\n _log \"Using provided brute list\"\n potential_buckets = [bucket_name]\n end\n\n # add in any additional buckets to the list of potentials\n all_potential_buckets = potential_buckets.concat(opt_additional_buckets.split(\",\"))\n\n # Create our queue of work from the checks in brute_list\n work_q = Queue.new\n all_potential_buckets.each do |pb|\n work_q << pb.strip\n\n # Add permutations\n if opt_permute\n begin\n # AWS is case sensitive.\n # https://forums.aws.amazon.com/thread.jspa?threadID=19928\n first_letter_cap = \"#{pb.strip}\".slice(0,1).upcase + \"#{pb.strip}\".slice(1..-1)\n work_q << \"#{first_letter_cap}\" unless \"#{first_letter_cap}\" == \"#{pb.strip}\"\n work_q << \"#{pb.strip.upcase}\" unless \"#{pb.strip.upcase}\" == \"#{pb.strip}\"\n work_q << \"#{pb.strip.downcase}\" unless \"#{pb.strip.downcase}\" == \"#{pb.strip}\"\n\n # General development permutations\n work_q << \"#{pb.strip}-backup\"\n work_q << \"#{pb.strip}-beta\"\n work_q << \"#{pb.strip}-dev\"\n work_q << \"#{pb.strip}-development\"\n work_q << \"#{pb.strip}-eng\"\n work_q << \"#{pb.strip}-engineering\"\n work_q << \"#{pb.strip}-old\"\n work_q << \"#{pb.strip}-prod\"\n work_q << \"#{pb.strip}-qa\"\n work_q << \"#{pb.strip}-stage\"\n work_q << \"#{pb.strip}-staging\"\n work_q << \"#{pb.strip}-test\"\n work_q << \"#{pb.strip}-web\"\n work_q << \"backup-#{pb.strip}\"\n work_q << \"beta-#{pb.strip}\"\n work_q << \"dev-#{pb.strip}\"\n work_q << \"development-#{pb.strip}\"\n work_q << \"eng-#{pb.strip}\"\n work_q << \"engineering-#{pb.strip}\"\n work_q << \"old-#{pb.strip}\"\n work_q << \"prod-#{pb.strip}\"\n work_q << \"qa-#{pb.strip}\"\n work_q << \"stage-#{pb.strip}\"\n work_q << \"staging-#{pb.strip}\"\n work_q << \"test-#{pb.strip}\"\n work_q << \"web-#{pb.strip}\"\n rescue TypeError => e\n puts \"Unable to permute: #{pb}, failing\"\n end\n end\n\n end\n\n # Create a pool of worker threads to work on the queue\n workers = (0...opt_threads).map do\n Thread.new do\n begin\n while bucket_name = work_q.pop(true)\n\n #skip anything that isn't a real name\n next unless bucket_name && bucket_name.length > 0\n\n # Authenticated method\n if opt_use_creds\n\n access_key_id = _get_task_config \"aws_access_key_id\"\n secret_access_key = _get_task_config \"aws_secret_access_key\"\n\n unless access_key_id && secret_access_key\n _log_error \"FATAL! To scan with authentication, you must specify a aws_access_key_id aws_secret_access_key in the config!\"\n return\n end\n\n # Check for it, and get the contents\n Aws.config[:credentials] = Aws::Credentials.new(access_key_id, secret_access_key)\n exists = check_existence_authenticated(bucket_name)\n\n # create our entity and store the username with it\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => true,\n \"username\" => access_key_id\n }) if exists\n\n #########################\n # Unauthenticated check #\n #########################\n else\n\n s3_uri = \"https://#{bucket_name}.s3.amazonaws.com\"\n exists = check_existence_unauthenticated(s3_uri)\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => false\n }) if exists\n\n next if exists ## Only proceed if we got an error above (bucket exists!) !!!\n\n s3_uri = \"https://s3.amazonaws.com/#{bucket_name}\"\n exists = check_existence_unauthenticated(s3_uri)\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => false,\n }) if exists\n\n end # end if opt_use_creds\n\n\n end # end while\n rescue ThreadError\n end\n end\n end; \"ok\"\n workers.map(&:join); \"ok\"\n\n end",
"def on_each_shard(&block)\n @_ar_cached_shard_classes.each do |shard_class|\n block.call(shard_class)\n end\n end",
"def shards\n perform_request(api_url('shards')).map do |shard_data|\n DynamicModel.new shard_data\n end\n end",
"def distribute(request)\n promote_replica_to_primary if primary_not_available?\n return \"Uh Oh, no primary\" if primary.nil?\n\n if write?(request)\n send(primary, request)\n else\n send(random_server, request)\n end\n end",
"def with_default_shard(&block)\n if is_sharded? && current_shard_id.nil? && table_name != ActiveRecord::SchemaMigration.table_name\n on_first_shard(&block)\n else\n yield\n end\n end",
"def perform(*args)\n resource = StashEngine::Resource.where(id: args[0]).first\n return if resource.nil? || resource&.zenodo_copies&.data&.first&.state != 'enqueued' || self.class.should_defer?(resource: resource)\n\n data_copy = resource&.zenodo_copies&.data&.first\n zr = Stash::ZenodoReplicate::Copier.new(copy_id: data_copy.id)\n zr.add_to_zenodo\n end",
"def test\n connection = Fog::Compute.new(:provider => \"google\")\n health = connection.http_health_checks.create(:name => \"test-checks\")\n instance1 = connection.servers.get(\"fog-l7-instance-1\")\n instance2 = connection.servers.get(\"fog-l7-instance-2\")\n instance3 = connection.servers.get(\"fog-l7-instance-3\")\n\n resource_view1 = connection.resource_views.create(\n :name => \"fog-l7-resource-view-1\",\n :numMembers => 1,\n :members => [instance1.self_link],\n :zone => \"us-central1-a\"\n )\n resource_view1.add_resources(instance1.self_link)\n resource_view2 = connection.resource_views.create(\n :name => \"fog-l7-resource-view-2\",\n :numMembers => 1,\n :members => [instance2.self_link],\n :zone => \"us-central1-a\"\n )\n resource_view2.add_resources(instance2.self_link)\n resource_view3 = connection.resource_views.create(\n :name => \"fog-l7-resource-view-3\",\n :members => [instance3.self_link],\n :zone => \"us-central1-b\"\n )\n resource_view3.add_resources(instance3.self_link)\n backend_service1 = connection.backend_services.create(\n :name => \"fog-l7-backend-service-1\",\n :health_checks => [health.self_link],\n :backends => [{ \"balancingMode\" => \"RATE\", \"maxRate\" => 100, \"group\" => resource_view1.self_link }]\n )\n backend_service2 = connection.backend_services.create(\n :name => \"fog-l7-backend-service-2\",\n :health_checks => [health.self_link],\n :backends => [{ \"balancingMode\" => \"RATE\", \"maxRate\" => 100, \"group\" => resource_view2.self_link }]\n )\n backend_service3 = connection.backend_services.create(\n :name => \"fog-l7-backend-service-3\",\n :health_checks => [health.self_link],\n :backends => [{ \"balancingMode\" => \"RATE\", \"maxRate\" => 100, \"group\" => resource_view3.self_link }]\n )\n url_map = connection.url_maps.create(\n :name => \"fog-l7-url-map\",\n :pathMatchers => [{\n \"name\" => \"pathmatcher\",\n \"defaultService\" => backend_service1.self_link,\n \"pathRules\" => [\n {\n \"paths\" => [\"/one/*\"],\n \"service\" => backend_service1.self_link\n },\n {\n \"paths\" => [\"/two/*\"],\n \"service\" => backend_service2.self_link\n },\n {\n \"paths\" => [\"/three/*\"],\n \"service\" => backend_service3.self_link\n }\n ]\n }],\n :hostRules => [{ \"hosts\" => [\"*\"], \"pathMatcher\" => \"pathmatcher\" }],\n :default_service => backend_service1.self_link\n )\n proxy = connection.target_http_proxies.create(\n :name => \"fog-l7-proxy\",\n :url_map => url_map.self_link\n )\n\n connection.global_forwarding_rules.create(:name => \"fog-l7-fwd-rule\", :target => proxy.self_link)\nend",
"def add_remove_resource # mark not use\n if @chef_resource.resource_type == \"Repository\" # repo not check chef_resource_id because install from repo will have one or more program\n value = @chef_resource.chef_properties.where(:value_type => \"program_name\").pluck(:value).first\n remove_resource = RemoveResource.new(program_id: @program.id, chef_resource_id: @chef_resource.id, resource_type: @chef_resource.resource_type, value: value, value_type: \"program\")\n remove_resource.save\n else\n if !@program.remove_resources.find_by(chef_resource_id: @chef_resource.id).present? # check Is chef_resource_id alredy in remove_resources\n value = nil\n value_type = nil\n case @chef_resource.resource_type\n when \"Deb\"\n value = @chef_resource.chef_properties.where(:value_type => \"program_name\").pluck(:value).first\n value_type = \"program\"\n when \"Source\"\n value = @chef_resource.chef_properties.where(:value_type => \"source_file\").pluck(:value).first\n value_type = \"program\"\n when \"Download\"\n value = @chef_resource.chef_properties.where(:value_type => \"source_file\").pluck(:value).first\n value_type = \"file\"\n when \"Extract\"\n value = @chef_resource.chef_properties.where(:value_type => \"extract_to\").pluck(:value).first\n value_type = \"folder\"\n when \"Config_file\"\n delete_chef_attributes\n value = @chef_resource.chef_properties.where(:value_type => \"config_file\").pluck(:value).first\n #delete_config_file_in_templates(value)\n value_type = \"file\"\n when \"Copy_file\"\n value = @chef_resource.chef_properties.where(:value_type => \"destination_file\").pluck(:value).first\n value_type = @chef_resource.chef_properties.where(:value_type => \"copy_type\").pluck(:value).first\n when \"Create_file\"\n delete_chef_attributes\n value = @chef_resource.chef_properties.where(:value_type => \"created_file\").pluck(:value).first\n #delete_file_in_templates(value)\n value_type = \"file\"\n when \"Move_file\"\n move_type = @chef_resource.chef_properties.where(:value_type => \"move_type\").pluck(:value).first\n value = @chef_resource.chef_properties.where(:value_type => \"destination_file\").pluck(:value).first\n value_type = move_type\n when \"Bash_script\" # เพื่อลบไฟล์ใน instance (/tmp/xxx กับ /var/lib/tomcat7/webapps/ROOT/bash_script/xxx) และลบไฟล์ใน template ของ cookbook program\n value = @chef_resource.id.to_s\n value_type = \"file\"\n delete_chef_attributes\n when \"Execute_command\"\n value = @chef_resource.chef_properties.where(:value_type => \"execute_command\").pluck(:value).first\n value_type = \"command\"\n end\n remove_resource = RemoveResource.new(program_id: @program.id, chef_resource_id: @chef_resource.id, resource_type: @chef_resource.resource_type, value: value, value_type: value_type)\n remove_resource.save\n end\n end\n end",
"def deploy_cookbook(cookbook)\n cookbook[:targets].each do |target|\n if system(\"scp #{@ssh_opts} #{cookbook[:cookbook_filename]} #{target}:/tmp #{@q_all}\")\n `ssh #{@ssh_opts} #{target} sudo rm -rf /var/chef/cookbooks/* #{@q_all}`\n `ssh #{@ssh_opts} #{target} sudo tar -xzvf /tmp/#{cookbook[:cookbook_filename]} -C /var/chef/cookbooks #{@q_all}`\n `ssh #{@ssh_opts} #{target} sudo rm -rf /tmp/#{cookbook[:cookbook_filename]} #{@q_all}`\n else\n DreamOps.ui.error \"Failed to copy cookbook to host '#{target}'\"\n end\n\n if !system(\n \"ssh #{@ssh_opts} #{target} \"+\n \"\\\"echo '#{cookbook[:local_sha]}' | sudo tee /var/chef/#{cookbook[:sha_filename]}\\\" #{@q_all}\"\n )\n DreamOps.ui.error \"Failed to update remote cookbook sha\"\n end\n end\n end",
"def setup(resources)\n @bucket_size = Hash.new\n end",
"def create_service(resource, actions)\n service_name = get_service_name()\n\n case resource.service_type\n when \"upstart\"\n service service_name do\n provider Chef::Provider::Service::Upstart\n supports :status => true, :restart => true, :reload => true\n action actions\n end\n when \"init.d\"\n service service_name do\n supports :status => true, :restart => true, :reload => true\n action actions\n end\n else\n raise \"dashing: Unknown service_type '#{resource.service_type}'\"\n end\nend",
"def configure_chef_only_once\r\n bootstrap_options = value_from_json_file(handler_settings_file,'runtimeSettings','0','handlerSettings', 'publicSettings', 'bootstrap_options')\r\n bootstrap_options = eval(bootstrap_options) ? eval(bootstrap_options) : {}\r\n\r\n if File.directory?(\"#{bootstrap_directory}\")\r\n puts \"#{Time.now} Bootstrap directory [#{bootstrap_directory}] already exists, skipping creation...\"\r\n else\r\n puts \"#{Time.now} Bootstrap directory [#{bootstrap_directory}] does not exist, creating...\"\r\n FileUtils.mkdir_p(\"#{bootstrap_directory}\")\r\n end\r\n\r\n puts \"#{Time.now} Creating chef configuration files\"\r\n\r\n copy_settings_file\r\n\r\n load_settings\r\n\r\n begin\r\n require 'chef/azure/core/bootstrap_context'\r\n\r\n config = configure_settings(bootstrap_options)\r\n\r\n Chef::Config[:validation_key_content] = @validation_key\r\n Chef::Config[:client_key_content] = @client_key\r\n Chef::Config[:chef_server_ssl_cert_content] = @chef_server_ssl_cert\r\n template_file = File.expand_path(File.dirname(File.dirname(__FILE__)))\r\n runlist = @run_list.empty? ? [] : escape_runlist(@run_list)\r\n load_cloud_attributes_in_hints if ! @ohai_hints.empty?\r\n\r\n if windows?\r\n context = Chef::Knife::Core::WindowsBootstrapContext.new(config, runlist, Chef::Config, config[:secret])\r\n template_file += \"\\\\bootstrap\\\\windows-chef-client-msi.erb\"\r\n bootstrap_bat_file ||= \"#{ENV['TMP']}/bootstrap.bat\"\r\n template = IO.read(template_file).chomp\r\n bash_template = Erubis::Eruby.new(template).evaluate(context)\r\n File.open(bootstrap_bat_file, 'w') {|f| f.write(bash_template)}\r\n bootstrap_command = \"cmd.exe /C #{bootstrap_bat_file}\"\r\n else\r\n context = Chef::Knife::Core::BootstrapContext.new(config, runlist, Chef::Config, config[:secret])\r\n template_file += '/bootstrap/chef-full.erb'\r\n template = IO.read(template_file).chomp\r\n bootstrap_command = Erubis::Eruby.new(template).evaluate(context)\r\n end\r\n\r\n result = shell_out(bootstrap_command)\r\n result.error!\r\n puts \"#{Time.now} Created chef configuration files\"\r\n\r\n # remove the temp bootstrap file\r\n FileUtils.rm(bootstrap_bat_file) if windows?\r\n rescue Mixlib::ShellOut::ShellCommandFailed => e\r\n Chef::Log.warn \"chef-client configuration files creation failed (#{e})\"\r\n @chef_client_error = \"chef-client configuration files creation failed (#{e})\"\r\n return\r\n rescue => e\r\n Chef::Log.error e\r\n @chef_client_error = \"chef-client configuration files creation failed (#{e})\"\r\n return\r\n end\r\n\r\n if @extended_logs == 'true'\r\n @chef_client_success_file = windows? ? \"c:\\\\chef_client_success\" : \"/tmp/chef_client_success\"\r\n end\r\n\r\n # Runs chef-client with custom recipe to set the run_list and environment\r\n begin\r\n current_dir = File.expand_path(File.dirname(File.dirname(__FILE__)))\r\n first_client_run_recipe_path = windows? ? \"#{current_dir}\\\\first_client_run_recipe.rb\" : \"#{current_dir}/first_client_run_recipe.rb\"\r\n if !config[:first_boot_attributes][\"policy_name\"].nil? and !config[:first_boot_attributes][\"policy_group\"].nil?\r\n command = \"chef-client -j #{bootstrap_directory}/first-boot.json -c #{bootstrap_directory}/client.rb -L #{@azure_plugin_log_location}/chef-client.log --once\"\r\n else\r\n command = \"chef-client #{first_client_run_recipe_path} -j #{bootstrap_directory}/first-boot.json -c #{bootstrap_directory}/client.rb -L #{@azure_plugin_log_location}/chef-client.log --once\"\r\n end\r\n command += \" -E #{config[:environment]}\" if config[:environment]\r\n result = shell_out(command)\r\n result.error!\r\n rescue Mixlib::ShellOut::ShellCommandFailed => e\r\n Chef::Log.error \"First chef-client run failed. (#{e})\"\r\n @chef_client_error = \"First chef-client run failed (#{e})\"\r\n return\r\n rescue => e\r\n Chef::Log.error e\r\n @chef_client_error = \"First chef-client run failed (#{e})\"\r\n end\r\n\r\n params = \"-c #{bootstrap_directory}/client.rb -L #{@azure_plugin_log_location}/chef-client.log --once \"\r\n\r\n # Runs chef-client in background using scheduled task if windows else using process\r\n if windows?\r\n puts \"#{Time.now} Creating scheduled task with runlist #{runlist}..\"\r\n schtask = \"SCHTASKS.EXE /Create /TN \\\"Chef Client First Run\\\" /RU \\\"NT Authority\\\\System\\\" /RP /RL \\\"HIGHEST\\\" /SC ONCE /TR \\\"cmd /c 'C:\\\\opscode\\\\chef\\\\bin\\\\chef-client #{params}'\\\" /ST \\\"#{Time.now.strftime('%H:%M')}\\\" /F\"\r\n\r\n begin\r\n result = @extended_logs == 'true' ? shell_out(\"#{schtask} && touch #{@chef_client_success_file}\") : shell_out(schtask)\r\n result.error!\r\n @chef_client_run_start_time = Time.now\r\n\r\n # call to run scheduled task immediately after creation\r\n result = shell_out(\"SCHTASKS.EXE /Run /TN \\\"Chef Client First Run\\\"\")\r\n result.error!\r\n rescue Mixlib::ShellOut::ShellCommandFailed => e\r\n Chef::Log.error \"Creation or running of scheduled task for first chef-client run failed (#{e})\"\r\n @chef_client_error = \"Creation or running of scheduled task for first chef-client run failed (#{e})\"\r\n rescue => e\r\n Chef::Log.error e\r\n @chef_client_error = \"Creation or running of scheduled task for first chef-client run failed (#{e})\"\r\n end\r\n puts \"#{Time.now} Created and ran scheduled task for first chef-client run with runlist #{runlist}\"\r\n else\r\n command = @extended_logs == 'true' ? \"chef-client #{params} && touch #{@chef_client_success_file}\" : \"chef-client #{params}\"\r\n @child_pid = Process.spawn command\r\n @chef_client_run_start_time = Time.now\r\n Process.detach @child_pid\r\n puts \"#{Time.now} Successfully launched chef-client process with PID [#{@child_pid}]\"\r\n end\r\n end",
"def create_pool\n cmd_text = \"ceph osd pool create #{new_resource.name} #{new_resource.pg_num} #{new_resource.pgp_num} #{new_resource.type}\"\n cmd_text << \" #{new_resource.profile}\" if new_resource.profile\n cmd_text << \" #{new_resource.crush_ruleset_name}\" if new_resource.crush_ruleset_name\n cmd_text << \" #{new_resource.options}\" if new_resource.options\n\n puts \"\\nRunning... #{cmd_text}\"\n\n cmd = Mixlib::ShellOut.new(cmd_text)\n cmd.run_command\n cmd.error!\n Chef::Log.debug \"Pool created: #{cmd.stderr}\"\nend",
"def add_shard( *args )\n shard_def = ( args.first.is_a?(ShardDefinition) ? args.first : ShardDefinition.new( *args ) )\n\n duplicate_exists = shard_name_exists?( shard_def.name )\n\n raise NameNotUniqueError,\n \"Shard named '#{shard_def.name.to_s}' exists for schema '#{shard_def.schema.to_s}'\" if duplicate_exists\n\n definitions << shard_def\n definitions_by_schema( shard_def.schema ) << shard_def\n definitions_by_name[ shard_def.name.to_sym ] = shard_def\n\n shard_def\n end",
"def run\n Shef::Extensions.extend_context_object(self)\n ssh_config = []\n\n ssh_config << \"\\n\\n### BEGIN KNIFE BLOCK ###\"\n ssh_config << \"## This was generated by `knife setup ssh`:\"\n\n STDOUT.sync = true\n\n nodes.all do |n|\n next if /vagrant/.match(n.name)\n name = n.name\n name << '.lisausa.net' unless /\\.lisausa.net\\Z/.match(n.name)\n\n begin\n hostname = n.ipaddress\n rescue => ex\n ui.warn(\"Error (#{ex.inspect}) while getting #ipaddress for #{n.name}\")\n next\n end\n\n ssh_config << [\n \"Host #{name}\",\n \" HostName #{hostname}\",\n \" HostKeyAlias #{[name,hostname,n.macaddress].join('-')}\"\n ]\n end\n\n if (c = Chef::Config.knife).keys.grep(/identity_file|ssh_user/).any?\n ssh_config.push [\n \"Host *.lisausa.net\",\n \" IdentitiesOnly yes\",\n \" PasswordAuthentication no\",\n \" ForwardAgent yes\"\n ]\n ssh_config.push \" IdentityFile #{c[:identity_file]}\" if c[:identity_file]\n ssh_config.push \" User #{c[:ssh_user]}\" if c[:ssh_user]\n end\n\n ssh_config << \"### END KNIFE BLOCK ###\"\n ssh_config = ssh_config.flatten.join(\"\\n\")\n\n file_path = File.join(ENV['HOME'], '.ssh', 'config')\n if config[:write] or ui.ask_question(\"Write config to #{file_path} (Y/N)?\", default: 'N').downcase == 'y'\n FileUtils.copy_file(file_path, \"#{file_path}~\")\n File.open(file_path, File::RDWR|File::CREAT) do |f|\n f.flock(File::LOCK_EX)\n\n contents = f.read.gsub(/\\n*### BEGIN KNIFE BLOCK ###.+?(### END KNIFE BLOCK ###|\\Z)/m, ssh_config)\n unless contents.include?('### BEGIN KNIFE BLOCK ###')\n contents << ssh_config\n end\n f.rewind\n f.truncate(0)\n f.write contents\n end\n ui.msg \"Wrote to #{file_path}. Previous contents were backed up to #{file_path}~\"\n else\n ui.msg \"Copy and paste the following into your #{file_path} file:\"\n ui.msg ssh_config\n end\n end",
"def branched_upgrade_move_writes\n raise \"Shard #{self} in wrong state to perform this action! expected :child, found #{@state}\" unless @state == :child\n @master.disable_read_only!\n @state = :needs_cleanup\n sync_configuration\n end",
"def check_clustering(manifest, bosh_properties)\n # :: hash (release -> hash (job -> hash (property -> default)))\n\n params = {}\n manifest.configuration.templates.each do |property, template|\n params[property] = Common.parameters_in_template(template)\n end\n rparams = nil\n collected_params = nil\n\n for_each_role_job(manifest, bosh_properties, lambda { |role, block|\n rparams = params.dup\n role.configuration.fetch('templates', {}).each do |property, template|\n rparams[property] = Common.parameters_in_template(template)\n end\n\n collected_params = Hash.new { |h, parameter| h[parameter] = [] }\n # collected_params :: hash (parameter -> array (pair (job,release)))\n # And default unknown elements as empty list.\n\n block.call(lambda do |job|\n bosh_properties[job.release][job.name].each_key do |property|\n rparams.fetch(\"properties.#{property}\", []).each do |param|\n next unless param == \"KUBE_NATS_CLUSTER_IPS\"\n collected_params[param] << \"Job #{job.name.red} in release #{job.release.red}\"\n end\n end\n end)\n\n if collected_params.empty?\n next unless script?(role, SCRIPT_HA)\n STDOUT.puts \"Superfluous use of #{SCRIPT_HA.red} by role #{role['name'].red}\"\n @has_errors += 1\n else\n next if script?(role, SCRIPT_HA)\n # secrets-generation uses KUBERNETES_CLUSTER_DOMAIN for cert generation but is not an HA role itself\n next if role['name'] == 'secret-generation'\n STDOUT.puts \"Missing #{SCRIPT_HA.red} in role #{role['name'].red}, requested by\"\n collected_params.each do |param, jobs|\n STDOUT.puts \"- #{param.red}\"\n jobs.each do |job_desc|\n STDOUT.puts \" - #{job_desc}\"\n end\n end\n @has_errors += 1\n end\n })\nend",
"def sync_configuration\n status = case\n when in_config? then 'Allocated'\n when @state == :deprecated then 'Cancelled'\n when @state == :recycle then 'Decommissioned'\n else 'Provisioning'\n end\n collins_set asset: collins_asset(true),\n status: status,\n shard_state: @state.to_s.upcase,\n shard_parent: @parent ? @parent.name : ''\n if @state == :recycle\n [@master, @master.slaves].flatten.each do |db|\n db.collins_pool = ''\n db.collins_secondary_role = ''\n db.collins_status = 'Unallocated'\n end\n elsif @state != :initializing\n # Note that we don't call Pool#slaves here to get all 3 types in one shot,\n # because that potentially includes child shards, and we don't want to overwrite\n # their pool setting...\n [@master, active_slaves, standby_slaves, backup_slaves].flatten.each do |db|\n current_status = (db.collins_status || '').downcase\n db.collins_status = 'Allocated:RUNNING' unless current_status == 'maintenance'\n db.collins_pool = @name\n end\n @master.collins_secondary_role = 'MASTER'\n\n standby_slaves.each {|db| db.collins_secondary_role = 'STANDBY_SLAVE'}\n backup_slaves.each {|db| db.collins_secondary_role = 'BACKUP_SLAVE'}\n end\n \n # handle lockless master migration situations\n if @state == :child && master.master && !@parent\n to_be_ejected_master = master.master\n to_be_ejected_master.collins_secondary_role = :standby_slave # not accurate, but no better option for now\n end\n \n true\n end",
"def resource(*args,&block)\n command(*args) do |cmd|\n # add resource actions\n # TODO: Figure out override/mod/new default action...\n cmd.action(:name=>:sample,:default=>true) { (load_data||[]).sample }\n cmd.action(:name=>:list) { (load_data||[]).map{|l| l.to_s}.join(\"\\n\")}\n cmd.action(:name=>[:add,'+'],:required=>:d) {|msg,d| save_data( (load_data||[]) | [d] )}\n cmd.action(:name=>[:delete,:del,:-],:required=>:d) {|msg,d| debug(\"RESOURCE: - #{load_data.inspect} d: #{d.inspect}\"); save_data( (load_data||[]) - [d] )}\n\n # now run as normal\n block.call(cmd) if block\n end\n end",
"def mongos_each_direct_client\n return unless ClusterConfig.instance.topology == :sharded\n\n client = ClientRegistry.instance.global_client('basic')\n client.cluster.next_primary\n client.cluster.servers.each do |server|\n direct_client = ClientRegistry.instance.new_local_client(\n [ server.address.to_s ],\n SpecConfig.instance.test_options.merge(\n connect: :sharded\n ).merge(SpecConfig.instance.auth_options)\n )\n yield direct_client\n direct_client.close\n end\n end",
"def test_multi_resource_lock_child_locked\n response = @request.delete('coll')\n\n response = @request.mkcol('coll')\n assert_equal '201', response.status\n\n response = @request.mkcol('coll/subcoll')\n assert_equal '201', response.status\n\n response = @request.put('coll/file', @stream)\n assert_equal '201', response.status\n\n lock = lock 'coll/subcoll'\n\n response = @request.lock 'coll'\n assert_equal '207', response.status\n resps = response.responses\n assert_equal '424', resps[@uri.path + 'coll'].status\n assert_equal '423', resps[@uri.path + 'coll/subcoll'].status\n\n response = @request.delete('coll', :depth => RubyDav::INFINITY,\n :if => { 'coll/subcoll' => lock.token })\n end",
"def discover_chef_nodes!\n chef_nodes.each do |chef_node|\n if chef_node[\"cluster_name\"] && chef_node[\"facet_name\"] && chef_node[\"facet_index\"]\n cluster_name = chef_node[\"cluster_name\"]\n facet_name = chef_node[\"facet_name\"]\n facet_index = chef_node[\"facet_index\"]\n elsif chef_node.name\n ( cluster_name, facet_name, facet_index ) = chef_node.name.split(/-/)\n else\n next\n end\n svr = Ironfan::Server.get(cluster_name, facet_name, facet_index)\n svr.chef_node = chef_node\n @aws_instance_hash[ chef_node.ec2.instance_id ] = svr if chef_node && chef_node[:ec2] && chef_node.ec2.instance_id\n end\n end",
"def add_shards( shard_definitions )\n added_shards = []\n\n shard_definitions.each do |definition|\n begin\n added_shards << add_shard( definition )\n rescue NameNotUniqueError\n # bury\n end\n end\n\n added_shards\n end",
"def should_host_resque_cpu?\n if is_zz?\n return app_config[:we_host_resque_cpu]\n end\n\n return @should_host_resque_cpu if @should_host_resque_cpu != nil\n if resque_cpu_host_names.include?(this_host_name)\n @should_host_resque_cpu = true\n else\n @should_host_resque_cpu = false\n end\n end",
"def action_create\n job_name = \"#{@new_resource.job_name}\"\n remote_host = \"#{@new_resource.remote_host}\"\n job_config = \"#{node[:jenkins][:server][:home]}/#{@new_resource.job_name}-config.xml\"\n \n run_commands = Array.new\n to_store_scripts = Array.new\n \n @new_resource.commands.each do |command|\n if (command[:type] == 'script')\n\t to_store_scripts << \"#{command[:content]}\"\n\t command[:fullPath] = \"#{node[:jenkins][:node][:home]}/jenkins-scripts/#{command[:content]}\"\n\telse\n\t command[:fullPath] = \"#{command[:content]}\"\n\tend\n \n if (command[:type] == 'script' && command[:action] == 'run') || command[:type] == 'command'\n run_commands << command\n end\n end\n\n template job_config do\n source \"#{new_resource.config_template}\"\n variables :job_name => job_name, :remote_host => remote_host, :commands => run_commands\n\towner node[:jenkins][:server][:user]\n group node[:jenkins][:server][:group]\n end\n \n \n # Create sh files and upload them to remote host\n to_store_scripts.each do |script|\n \n # create scripts on jenkins server\n cookbook_file \"#{node[:jenkins][:server][:home]}/jenkins-scripts/#{script}\" do\n source \"#{script}\"\n owner node[:jenkins][:server][:user]\n group node[:jenkins][:server][:group]\n action :create\n\t mode \"0755\"\n end\n \n #upload scripts to host only if host is reachable\n\tbash \"upload script #{script} on server #{remote_host}\" do\n user node[:jenkins][:server][:user]\n cwd \"#{node[:jenkins][:server][:home]}/jenkins-scripts/\"\n\t code <<-EOH\nscp #{script} #{node[:jenkins][:node][:user]}@#{remote_host}:#{node[:jenkins][:node][:home]}/jenkins-scripts\nssh #{node[:jenkins][:node][:user]}@#{remote_host} chmod 755 #{node[:jenkins][:node][:home]}/jenkins-scripts/*\nEOH\n only_if \"ping -q -c1 #{remote_host}\"\n end\n end\n\n jenkins_job \"#{@new_resource.job_name}\" do\n action :update\n config job_config\n end \n \n file job_config do\n action :delete\n\tbackup false\n end\r\nend",
"def shard_count\n shard_count_based_on_word_1\n end",
"def check_clustering(manifest, bosh_properties)\n # :: hash (release -> hash (job -> hash (property -> default)))\n\n params = {}\n manifest['configuration']['templates'].each do |property, template|\n params[property] = Common.parameters_in_template(template)\n end\n\n # Iterate over roles\n # - Iterate over jobs\n # - Determine templates used by job\n # - Determine parameters used by template\n # - Collect /_CLUSTER_IPS$/\n\n manifest['roles'].each do |role|\n rparams = params.dup\n if role['configuration'] && role['configuration']['templates']\n role['configuration']['templates'].each do |property, template|\n rparams[property] = Common.parameters_in_template(template)\n end\n end\n\n collected_params = Hash.new { |h, parameter| h[parameter] = [] }\n # collected_params :: hash (parameter -> array (pair (job,release)))\n # And default unknown elements as empty list.\n\n (role['jobs'] || []).each do |job|\n job_name = job['name']\n release_name = job['release_name']\n unless bosh_properties.has_key? release_name\n STDOUT.puts \"Role #{role['name']} has job #{job_name} from unknown release #{release_name}\"\n end\n unless bosh_properties[release_name].has_key? job_name\n STDOUT.puts \"Role #{role['name']} has job #{job_name} not in release #{release_name}\"\n @has_errors += 1\n next\n end\n bosh_properties[release_name][job_name].each_key do |property|\n (rparams[\"properties.\" + property] || []).each do |param|\n next unless /^(KUBERNETES_CLUSTER_DOMAIN|KUBE_.*_CLUSTER_IPS)$/ =~ param\n collected_params[param] << [job_name, release_name]\n end\n end\n end\n\n if collected_params.empty?\n next unless has_script(role, @configure_ha)\n STDOUT.puts \"Superfluous use of #{@configure_ha.red} by role #{role['name'].red}\"\n @has_errors += 1\n else\n next if has_script(role, @configure_ha)\n # secrets-generation uses KUBERNETES_CLUSTER_DOMAIN for cert generation but is not an HA role itself\n next if role['name'] == 'secret-generation'\n STDOUT.puts \"Missing #{@configure_ha.red} in role #{role['name'].red}, requested by\"\n collected_params.each do |param, jobs|\n STDOUT.puts \"- #{param.red}\"\n jobs.each do |job|\n STDOUT.puts \" - Job #{job[0].red} in release #{job[1].red}\"\n end\n end\n @has_errors += 1\n end\n end\nend",
"def cookbook_runlist\n verify_cookbook_creation\n\n Souschef::Print.header 'Berkshelf configuration'\n Souschef::Berkshelf.new(@opts).berks_create\n Souschef::Print.header 'Configure gemfile'\n Souschef::Gemfile.new(@opts).write\n Souschef::Print.header 'Create essential template files'\n Souschef::Template.run(@opts)\n # Mock Scaffold to generate default recipe and tests\n\n Souschef::Print.header 'Create default recipe and tests'\n Souschef::Scaffold.new(path: @opts[:path],\n recipe: 'default',\n profile: @opts[:profile],\n force: true,\n verbose: @opts[:verbose]).start\n\n Souschef::Print.header 'Testkitchen configuration'\n Souschef::Testkitchen.new(@opts).setup\n\n Souschef::Print.header \"Don't forget to run bundle install!\"\n end",
"def render_wrapper\n if new_resource.template\n Chef::Log.debug('Template attribute provided, all other attributes ignored.')\n\n resource = template \"#{node['authorization']['tcp_wrappers']['prefix']}#{tcp_wrappers_filename}\" do\n source new_resource.template\n owner 'root'\n group node['root_group']\n mode '0440'\n variables new_resource.variables\n action :nothing\n end\n else\n hosts_allow = new_resource.user || (\"%#{new_resource.group}\".squeeze('%') if new_resource.group)\n\n resource = template \"#{node['authorization']['tcp_wrappers']['prefix']}/wrappers.d/#{tcp_wrappers_filename}\" do\n source 'hosts_allow.erb'\n cookbook 'tcp_wrappers'\n owner 'root'\n group node['root_group']\n mode '0440'\n variables hosts_allow: hosts_allow,\n daemon_list: new_resource.daemon_list,\n client_list: new_resource.client_list,\n shell_command: new_resource.shell_command\n action :nothing\n end\n end\n\n resource.run_action(:create)\n\n # Return whether the resource was updated so we can notify in the action\n resource.updated_by_last_action?\nend",
"def run\n super\n\n opt_use_file = _get_option(\"use_file\")\n opt_filename = _get_option(\"brute_file\")\n\n if opt_use_file\n _log \"Using file: #{opt_filename}\"\n potential_buckets = File.read(\"#{$intrigue_basedir}/data/#{opt_filename}\").split(\"\\n\")\n else\n _log \"Using provided brute list\"\n potential_buckets = _get_entity_name.split(\",\")\n end\n\n potential_buckets.each do |pb|\n\n pb.chomp!\n\n # Check prefix\n potential_bucket_uri = \"https://#{pb}.s3.amazonaws.com?max-keys=1\"\n doc = Nokogiri::HTML(http_get_body(\"#{potential_bucket_uri}\"))\n next if ( doc.xpath(\"//code\").text =~ /NoSuchBucket/ ||\n doc.xpath(\"//code\").text =~ /InvalidBucketName/ ||\n doc.xpath(\"//code\").text =~ /AllAccessDisabled/ ||\n doc.xpath(\"//code\").text =~ /AccessDenied/ ||\n doc.xpath(\"//code\").text =~ /PermanentRedirect/)\n _create_entity(\"AwsS3Bucket\", {\"name\" => \"#{potential_bucket_uri}\", \"uri\" => \"#{potential_bucket_uri}\" })\n end\n\n potential_buckets.each do |pb|\n # Check postfix\n potential_bucket_uri = \"https://s3.amazonaws.com/#{pb}?max-keys=1\"\n doc = Nokogiri::HTML(http_get_body(\"#{potential_bucket_uri}\"))\n next if ( doc.xpath(\"//code\").text =~ /NoSuchBucket/ ||\n doc.xpath(\"//code\").text =~ /InvalidBucketName/ ||\n doc.xpath(\"//code\").text =~ /AllAccessDisabled/ ||\n doc.xpath(\"//code\").text =~ /AccessDenied/ ||\n doc.xpath(\"//code\").text =~ /PermanentRedirect/)\n _create_entity(\"AwsS3Bucket\", {\"name\" => \"#{potential_bucket_uri}\", \"uri\" => \"#{potential_bucket_uri}\" })\n end\n\n end",
"def optimize_master_settings(resources, with_activemq, with_orchestrator)\n output_minimum_system_requirements_error_and_exit unless meets_minimum_system_requirements?(resources)\n\n minimum_cpu_jrubies = 1\n maximum_cpu_jrubies = resources['cpu'] - 1\n minimum_mb_puppetserver = 1024\n mb_per_puppetserver_jruby = memory_per_jruby(resources['ram'])\n mb_puppetserver_code_cache = (resources['ram'] < 2048) ? 48 : 512\n mb_orchestrator = fit_to_memory(resources['ram'], 512, 768, 1024)\n mb_activemq = fit_to_memory(resources['ram'], 512, 1024, 2048)\n minimum_mb_os = reserved_memory_os\n # minimum_mb_g1gc = 2048\n\n mb_orchestrator = with_orchestrator ? mb_orchestrator : 0\n mb_activemq = with_activemq ? mb_activemq : 0\n mb_puppetserver_code_cache = 0 unless jruby_9k_enabled?\n\n settings = {}\n totals = {}\n\n available_mb_for_puppetserver = resources['ram'] - minimum_mb_os - mb_orchestrator - mb_activemq - mb_puppetserver_code_cache\n if available_mb_for_puppetserver < minimum_mb_puppetserver\n Puppet.debug(\"Error: available_mb_for_puppetserver: #{available_mb_for_puppetserver} < minimum_mb_puppetserver: #{minimum_mb_puppetserver}\")\n output_minimum_system_requirements_error_and_exit\n end\n\n jrubies_by_mb = (available_mb_for_puppetserver / mb_per_puppetserver_jruby).to_i\n jruby_max_active_instances = clamp_percent_of_resource(jrubies_by_mb, 100, minimum_cpu_jrubies, maximum_cpu_jrubies)\n settings['puppet_enterprise::master::jruby_max_active_instances'] = jruby_max_active_instances\n\n settings['puppet_enterprise::master::puppetserver::reserved_code_cache'] = \"#{mb_puppetserver_code_cache}m\" if mb_puppetserver_code_cache > 0\n\n mb_jrubies = (jruby_max_active_instances * mb_per_puppetserver_jruby)\n mb_puppetserver = [mb_jrubies, minimum_mb_puppetserver].max\n java_args_for_puppetserver = { 'Xms' => \"#{mb_puppetserver}m\", 'Xmx' => \"#{mb_puppetserver}m\" }\n # java_args_for_puppetserver['XX:+UseG1GC'] = '' if (jruby_9k_enabled? == false) && (mb_puppetserver >= minimum_mb_g1gc)\n settings['puppet_enterprise::profile::master::java_args'] = java_args_for_puppetserver\n\n if with_orchestrator\n java_args_for_orchestrator = { 'Xms' => \"#{mb_orchestrator}m\", 'Xmx' => \"#{mb_orchestrator}m\" }\n # java_args_for_orchestrator['XX:+UseG1GC'] = '' if (jruby_9k_enabled? == false) && (mb_orchestrator >= minimum_mb_g1gc)\n settings['puppet_enterprise::profile::orchestrator::java_args'] = java_args_for_orchestrator\n end\n\n if with_activemq\n settings['puppet_enterprise::profile::amq::broker::heap_mb'] = mb_activemq\n end\n\n cpu_used = jruby_max_active_instances\n ram_used = mb_puppetserver + mb_activemq + mb_orchestrator + mb_puppetserver_code_cache\n totals['CPU'] = { 'total' => resources['cpu'], 'used' => cpu_used }\n totals['RAM'] = { 'total' => resources['ram'], 'used' => ram_used }\n totals['MB_PER_JRUBY'] = mb_per_puppetserver_jruby\n\n [settings, totals]\n end",
"def any_shard\n definitions[ rand( definitions.size ) ].name\n end",
"def bootstrap(basedir)\n config = get_config(basedir)\n # Initialize Rhoconnect and Resque\n Rhoconnect.base_directory = basedir\n Rhoconnect.app_directory = get_setting(config,environment,:app_directory)\n Rhoconnect.data_directory = get_setting(config,environment,:data_directory)\n Rhoconnect.vendor_directory = get_setting(config,environment,:vendor_directory)\n Rhoconnect.bulk_sync_poll_interval = get_setting(config,environment,:bulk_sync_poll_interval,3600)\n Rhoconnect.redis = get_setting(config,environment,:redis,false)\n Rhoconnect.connection_pool_size ||= get_setting(config,environment,:connection_pool_size,5)\n Rhoconnect.connection_pool_timeout = get_setting(config,environment,:connection_pool_timeout,30)\n Rhoconnect.redis_timeout = get_setting(config,environment,:redis_timeout,30)\n Rhoconnect.api_token = ENV['API_TOKEN'] || get_setting(config,environment,:api_token,false)\n Rhoconnect.log_disabled = get_setting(config,environment,:log_disabled,false)\n Rhoconnect.raise_on_expired_lock = get_setting(config,environment,:raise_on_expired_lock,false)\n Rhoconnect.lock_duration = get_setting(config,environment,:lock_duration)\n Rhoconnect.cookie_expire = get_setting(config,environment,:cookie_expire) || 31536000\n Rhoconnect.store_key_ttl = get_setting(config, environment, :store_key_ttl) || 86400\n Rhoconnect.predefined_sources = {}\n yield self if block_given?\n Store.create(Rhoconnect.redis)\n Resque.redis = Rhoconnect.redis.is_a?(Array) ? Rhoconnect.redis[0] : Rhoconnect.redis\n Rhoconnect.base_directory ||= File.join(File.dirname(__FILE__),'..')\n Rhoconnect.app_directory ||= Rhoconnect.base_directory\n Rhoconnect.data_directory ||= File.join(Rhoconnect.base_directory,'data')\n Rhoconnect.vendor_directory ||= File.join(Rhoconnect.base_directory,'vendor')\n Rhoconnect.stats ||= false\n Rhoconnect.disable_rc_console ||= false\n Rhoconnect.disable_resque_console ||= false\n Rhoconnect.use_node = Rhoconnect.use_node.nil? ? true : Rhoconnect.use_node\n Rhoconnect.restart_node_on_error ||= true if Rhoconnect.use_node\n Rhoconnect.node_channel_timeout = get_setting(config, environment, :node_channel_timeout, 30)\n if File.directory?(File.join(Rhoconnect.app_directory,'sources'))\n check_and_add(File.join(Rhoconnect.app_directory,'sources'))\n # post deprecation warning !!!\nwarning_for_deprecated_sources_dir = <<_MIGRATE_TO_NEW_RHOCONNECT\n\n***** WARNING *****\nRhoConnect has detected that you're using deprecated SourceAdapter classes.\n\n SourceAdapter class support will be removed in RhoConnect 4.1.\n Please, migrate your SourceAdapter classes into RhoConnect Models.\n\n For more details, see RhoConnect Migration guidelines at\n docs.rhomobile.com\n\n_MIGRATE_TO_NEW_RHOCONNECT\n puts warning_for_deprecated_sources_dir\n end\n\n check_and_add(File.join(Rhoconnect.app_directory,'models','ruby'))\n start_app(config)\n create_admin_user\n end",
"def test_put_too_many_locktokens_given\n new_coll 'httplock'\n new_file 'httplock/a', StringIO.new(\"hello\")\n new_file 'httplock/b', StringIO.new(\"world\")\n\n b_locktoken = lock('httplock/b', :depth => 0).token\n a_locktoken = lock('httplock/a', :depth => 0).token\n\n response = @request.put('httplock/a', StringIO.new('hello'), :if => [a_locktoken, b_locktoken])\n assert_equal '412', response.status\n \n response = @request.put('httplock/a', StringIO.new('hello'), { :if => [a_locktoken, b_locktoken], :strict_if => false } )\n assert_equal '204', response.status \n\n # cleanup\n unlock('httplock/a', a_locktoken)\n unlock('httplock/b', b_locktoken)\n delete_coll('httplock')\n end",
"def load_current_resource\n @current_resource = Chef::Resource::Php5FpmPool.new(@new_resource.name)\n #default entries, will override if file exists and can find a matching configuration key\n #Overwrite\n @current_resource.overwrite(@new_resource.overwrite)\n #Base Pool Configuration\n @current_resource.pool_name(@new_resource.pool_name)\n @current_resource.pool_user(@new_resource.pool_user)\n @current_resource.pool_group(@new_resource.pool_group)\n @current_resource.listen_address(@new_resource.listen_address)\n @current_resource.listen_port(@new_resource.listen_port)\n @current_resource.listen_allowed_clients(@new_resource.listen_allowed_clients) # <<<<<<<<<< Need to complete\n @current_resource.listen_owner(@new_resource.listen_owner)\n @current_resource.listen_group(@new_resource.listen_group)\n @current_resource.listen_mode(@new_resource.listen_mode)\n @current_resource.use_sockets(@new_resource.use_sockets)\n @current_resource.listen_socket(@new_resource.listen_socket)\n @current_resource.listen_backlog(@new_resource.listen_backlog)\n #PM Configuration\n @current_resource.pm(@new_resource.pm)\n @current_resource.pm_max_children(@new_resource.pm_max_children)\n @current_resource.pm_start_servers(@new_resource.pm_start_servers)\n @current_resource.pm_min_spare_servers(@new_resource.pm_min_spare_servers)\n @current_resource.pm_max_spare_servers(@new_resource.pm_max_spare_servers)\n @current_resource.pm_process_idle_timeout(@new_resource.pm_process_idle_timeout)\n @current_resource.pm_max_requests(@new_resource.pm_max_requests)\n @current_resource.pm_status_path(@new_resource.pm_status_path)\n #Ping Status\n @current_resource.ping_path(@new_resource.ping_path)\n @current_resource.ping_response(@new_resource.ping_response)\n #Logging\n @current_resource.access_format(@new_resource.access_format)\n @current_resource.request_slowlog_timeout(@new_resource.request_slowlog_timeout)\n @current_resource.request_terminate_timeout(@new_resource.request_terminate_timeout)\n @current_resource.access_log(@new_resource.access_log)\n @current_resource.slow_log(@new_resource.slow_log)\n #Misc\n @current_resource.chdir(@new_resource.chdir)\n @current_resource.chroot(@new_resource.chroot)\n @current_resource.catch_workers_output(@new_resource.catch_workers_output)\n @current_resource.security_limit_extensions(@new_resource.security_limit_extensions)\n @current_resource.rlimit_files(@new_resource.rlimit_files)\n @current_resource.rlimit_core(@new_resource.rlimit_core)\n #PHP INI\n @current_resource.php_ini_values(@new_resource.php_ini_values)\n @current_resource.php_ini_flags(@new_resource.php_ini_flags)\n @current_resource.php_ini_admin_values(@new_resource.php_ini_admin_values)\n @current_resource.php_ini_admin_flags(@new_resource.php_ini_admin_flags)\n #ENV Variables\n @current_resource.env_variables(@new_resource.env_variables)\n #Auto Resource Provisioning\n @current_resource.auto_calculate(@new_resource.auto_calculate)\n @current_resource.percent_share(@new_resource.percent_share)\n @current_resource.round_down(@new_resource.round_down)\n\n #if the file exists, load current state\n if file_exists?(@current_resource.pool_name)\n\n #Tmp hash holding for our PHP and ENV Variables\n tmp_flags = {}\n tmp_values = {}\n tmp_admin_flags = {}\n tmp_admin_values = {}\n tmp_env_variables = {}\n\n #open the file for read\n ::File.open(\"#{ node[\"php_fpm\"][\"pools_path\"] }/#{ @current_resource.pool_name }.conf\", \"r\") do |fobj|\n\n #loop through each line\n fobj.each_line do |fline|\n\n #Split the line for configuration value\n lstring = fline.split('=').at(1)\n #Get the conf variable if there is one\n #Need to extract the variable name first\n conf_file_variable = fline.scan(/\\[.*?\\]/).first\n !conf_file_variable.nil? ? conf_file_variable = conf_file_variable.sub('[', '').sub(']', '') : nil\n\n #Start base configuration\n configuration_exists(fline,\"user =\") ? @current_resource.pool_user(lstring.chomp.strip) : nil\n if configuration_exists(fline,\"group =\") && !configuration_exists(fline,\"listen.group =\")\n @current_resource.pool_group(lstring.chomp.strip)\n end\n\n #Pull address and port // If we are using sockets bypass\n if configuration_exists(fline,\"listen =\") && !@current_resource.use_sockets\n if fline =~ /.*\\..*\\..*\\..*:.*/ #do a check on a valid ip address/port combination, if no match, just set new to current\n #split away the address and port\n sp_address = lstring.split(':').at(0)\n sp_port = lstring.split(':').at(1)\n #remove newline chars and whitespacing\n @current_resource.listen_address(sp_address.chomp.strip)\n @current_resource.listen_port(sp_port.chomp.strip.to_i)\n end #don't apply the current resource | this is for a socket to ip transition | will work for modify as well\n elsif configuration_exists(fline,\"listen =\") && @current_resource.use_sockets ## Only for sockets\n @current_resource.listen_socket(lstring.chomp.strip)\n end\n\n #Finish out base configuration options\n configuration_exists(fline,\"listen.allowed_clients =\") ? @current_resource.listen_allowed_clients(lstring.chomp.strip) : nil\n configuration_exists(fline,\"listen.owner =\") ? @current_resource.listen_owner(lstring.chomp.strip) : nil\n configuration_exists(fline,\"listen.group =\") ? @current_resource.listen_group(lstring.chomp.strip) : nil\n configuration_exists(fline,\"listen.mode =\") ? @current_resource.listen_mode(lstring.chomp.strip) : nil\n configuration_exists(fline,\"listen.backlog =\") ? @current_resource.listen_backlog(lstring.chomp.strip) : nil\n\n #Start PM configuration\n configuration_exists(fline,\"pm =\") ? @current_resource.pm(lstring.chomp.strip) : nil\n configuration_exists(fline,\"pm.max_children =\") ? @current_resource.pm_max_children(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"pm.start_servers =\") ? @current_resource.pm_start_servers(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"pm.min_spare_servers =\") ? @current_resource.pm_min_spare_servers(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"pm.max_spare_servers =\") ? @current_resource.pm_max_spare_servers(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"pm.process_idle_timeout =\") ? @current_resource.pm_process_idle_timeout(lstring.chomp.strip) : nil\n configuration_exists(fline,\"pm.max_requests =\") ? @current_resource.pm_max_requests(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"pm.status_path =\") ? @current_resource.pm_status_path(lstring.chomp.strip) : nil\n\n #Start ping status\n configuration_exists(fline,\"ping.path =\") ? @current_resource.ping_path(lstring.chomp.strip) : nil\n configuration_exists(fline,\"ping.response =\") ? @current_resource.ping_response(lstring.chomp.strip) : nil\n\n #Start logging\n configuration_exists(fline,\"access.format =\") ? @current_resource.access_format(lstring.chomp.strip) : nil\n configuration_exists(fline,\"request_slowlog_timeout =\") ? @current_resource.request_slowlog_timeout(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"request_terminate_timeout =\") ? @current_resource.request_terminate_timeout(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"access.log =\") ? @current_resource.access_log(lstring.chomp.strip) : nil\n configuration_exists(fline,\"slowlog =\") ? @current_resource.slow_log(lstring.chomp.strip) : nil\n\n #Start misc\n configuration_exists(fline,\"chdir =\") ? @current_resource.chdir(lstring.chomp.strip) : nil\n configuration_exists(fline,\"chroot =\") ? @current_resource.chroot(lstring.chomp.strip) : nil\n configuration_exists(fline,\"catch_workers_output =\") ? @current_resource.catch_workers_output(lstring.chomp.strip) : nil\n configuration_exists(fline,\"security.limit_extensions =\") ? @current_resource.security_limit_extensions(lstring.chomp.strip) : nil\n configuration_exists(fline,\"rlimit_files =\") ? @current_resource.rlimit_files(lstring.chomp.strip.to_i) : nil\n configuration_exists(fline,\"rlimit_core =\") ? @current_resource.rlimit_core(lstring.chomp.strip.to_i) : nil\n\n #Start PHP INI\n configuration_exists(fline,\"php_value[#{conf_file_variable}] =\") && !@current_resource.php_ini_values.nil? ? tmp_values[\"#{conf_file_variable}\"] = lstring.chomp.strip : nil\n configuration_exists(fline,\"php_flag[#{conf_file_variable}] =\") && !@current_resource.php_ini_flags.nil? ? tmp_flags[\"#{conf_file_variable}\"] = lstring.chomp.strip : nil\n configuration_exists(fline,\"php_admin_value[#{conf_file_variable}] =\") && !@current_resource.php_ini_admin_values.nil? ? tmp_admin_values[\"#{conf_file_variable}\"] = lstring.chomp.strip : nil\n configuration_exists(fline,\"php_admin_flag[#{conf_file_variable}] =\") && !@current_resource.php_ini_admin_flags.nil? ? tmp_admin_flags[\"#{conf_file_variable}\"] = lstring.chomp.strip : nil\n\n #Start ENV Variables\n configuration_exists(fline,\"env[#{conf_file_variable}] =\") && !@current_resource.env_variables.nil? ? tmp_env_variables[\"#{conf_file_variable}\"] = lstring.chomp.strip : nil\n\n end\n\n #Reset current resource hashes on PHP and ENV Variables\n @current_resource.php_ini_values(tmp_values)\n @current_resource.php_ini_flags(tmp_flags)\n @current_resource.php_ini_admin_values(tmp_admin_values)\n @current_resource.php_ini_admin_flags(tmp_admin_flags)\n\n end\n\n #flag that they current file exists\n @current_resource.exists = true\n end\n\n #If we are to auto_calculate, then call the method\n if @current_resource.auto_calculate\n\n #Call auto_calculate\n auto_calculate(@new_resource.pm, (@new_resource.percent_share / 100.00), @new_resource.round_down)\n\n end\n\nend",
"def tidy_resources\n Varnisher.log.info 'Tidying resources...'\n\n @urls = @urls.make_absolute(@uri).with_hostname(@uri.host)\n\n Varnisher.log.info \"#{@urls.length} purgeable resources found.\\n\"\n end",
"def check_recipes\n if new_resource.web_server == 'apache'\n web_server_recipe = \"apache2::default\"\n else\n web_server_recipe = \"#{new_resource.web_server}::default\"\n end\n\n unless run_context.loaded_recipes.include?(web_server_recipe)\n Chef::Application.fatal!(\"Did not include the #{web_server_recipe} recipe\")\n end\n end"
] |
[
"0.65044063",
"0.5700196",
"0.56292653",
"0.56289804",
"0.54907453",
"0.5487057",
"0.54701674",
"0.54701674",
"0.54226494",
"0.5355603",
"0.53491527",
"0.53360707",
"0.5304525",
"0.5271161",
"0.5245763",
"0.52338797",
"0.5229104",
"0.5222399",
"0.5178472",
"0.5132586",
"0.51127267",
"0.5107288",
"0.51025754",
"0.50928724",
"0.5047306",
"0.49930555",
"0.4989789",
"0.4988609",
"0.4969212",
"0.495482",
"0.49523622",
"0.49386802",
"0.49341682",
"0.49323475",
"0.4915354",
"0.490049",
"0.4897762",
"0.48796064",
"0.4877791",
"0.48751462",
"0.48666283",
"0.4864824",
"0.4850343",
"0.48437983",
"0.4826637",
"0.482205",
"0.48056978",
"0.4799542",
"0.47947893",
"0.47888514",
"0.4787278",
"0.47775096",
"0.477545",
"0.47630236",
"0.47600627",
"0.47543752",
"0.47493947",
"0.47460228",
"0.47414577",
"0.47395894",
"0.47366256",
"0.4729148",
"0.47219282",
"0.4717301",
"0.47111213",
"0.4710072",
"0.47064492",
"0.4700226",
"0.46847114",
"0.4684097",
"0.4677928",
"0.4675696",
"0.4667221",
"0.46502182",
"0.46475857",
"0.4643935",
"0.4642966",
"0.46413386",
"0.46389452",
"0.4638191",
"0.4630904",
"0.46288177",
"0.46284598",
"0.46247014",
"0.4624157",
"0.46240258",
"0.4623019",
"0.4622811",
"0.46185222",
"0.4615483",
"0.46126455",
"0.46065775",
"0.46005994",
"0.45992586",
"0.45986432",
"0.4596622",
"0.45948678",
"0.45852783",
"0.45817834",
"0.45789114"
] |
0.563348
|
2
|
Shard range is 099
|
def rollout_shard(start_date)
rollout_map = [
1,
10,
25,
50,
99,
]
rd = Date.parse(start_date)
# Now we use today as an index into the rollout map, except we have to
# discount weekends
today = Date.today
numdays = (today - rd).to_i
num_weekend_days = 0
(0..numdays).each do |i|
t = rd + i
if t.saturday? || t.sunday?
num_weekend_days += 1
end
end
# Subtract that from how far into the index we go
numdays -= num_weekend_days
# Return -1 because in_shard?() does a >= comparison to shard number
if numdays < 0
return -1
end
Chef::Log.debug(
"fb_helpers: rollout_shard: days into rollout: #{numdays}",
)
if numdays >= rollout_map.size
FB::Helpers.warn_to_remove(3)
shard = 99
else
shard = rollout_map[numdays]
end
Chef::Log.debug(
"fb_helpers: rollout_shard: rollout_shard: #{shard}",
)
return shard
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def rdfs_range\n end",
"def shard; end",
"def m_range\r\n end",
"def range; end",
"def range; end",
"def range; end",
"def shard_index(n)\n orig_n = n\n n = n.to_i if n.is_a?(GenericNumeric)\n if n.is_a?(Numeric) || n.to_s =~ /^[+-]\\d+$/\n n = n.to_i if n.is_a?(String)\n n += shard_count if n<0\n stop \"Frozen file does not contain shard number #{orig_n}\" if n<0 || n>shard_count\n else\n name = n.to_s.sub(/^\\\\/,'') # Remove leading '\\\\', if any\n raise \"!Missing shard index or name\" if n.to_s == ''\n n = _shard_index(name)\n stop \"!Frozen file does not contain a shard named #{name.inspect}\" unless n\n end\n n\n end",
"def range\n @range ||= 0.upto(@limit)\n end",
"def range\n DEFAULT_RANGE\n end",
"def range\n DEFAULT_RANGE\n end",
"def range\n DEFAULT_RANGE\n end",
"def sql_range_check(sharding_key, min_id, max_id)\n \"SELECT count(*) AS invalid_records FROM #{@name} WHERE #{sharding_key} > #{max_id} OR #{sharding_key} < #{min_id}\"\n end",
"def range\n @range ||= set_range\n end",
"def range(start, stop)\n fetch(redis.zrange(key, start, stop))\n end",
"def zrange(key, start, stop, options = {})\n send_cluster_command([:zrange, key, start, stop, options])\n end",
"def query_range(left, right)\n \n end",
"def query_range(left, right)\n \n end",
"def auto_range(direction); end",
"def zrange(key, start, stop, options = {})\n send_cluster_command([:zrange, key, start, stop, options],\n master_only: false)\n end",
"def range\n min, max = span\n min..max\n end",
"def range_start; range.first; end",
"def range(from, to)\n from_query(raw_range(from, to))\n end",
"def shard_world; end",
"def schema_range_type(db_type)\n :range\n end",
"def range(range)\n assert_range range\n schema do |s|\n s.type range.begin.is_a?(Integer) ? 'integer' : 'number'\n s.minimum range.begin\n s.maximum range.end, exclusive: range.exclude_end? unless range.end.nil?\n end\n end",
"def range=(range)\n @range = range\n end",
"def retirement_range\n #large simulation\n (1..30)\n end",
"def range_bucket(value, size=10)\n if value.present?\n x = (value / size * size) + 1\n y = x + (size - 1)\n return \"#{x} - #{y}\"\n end\n end",
"def to_index_range(spec)\r\n alter_ego = (self >= 0) ? self : (spec.max + self + 1)\r\n\r\n if spec === alter_ego\r\n alter_ego..alter_ego\r\n else\r\n fail IndexError, \"Subscript out of range: #{self.inspect}\"\r\n end\r\n end",
"def range\n from_truncated..to_truncated\n end",
"def range(range)\n opts[:min] = range.begin\n opts[:max] = range.end\n end",
"def shards\n @data['shards']\n end",
"def range(input); end",
"def breakable_range; end",
"def column_of(range); end",
"def range(start, stop)\n fetch(key.call(\"LRANGE\", start, stop))\n end",
"def range=(range)\n @range = range\n end",
"def effective_column(range); end",
"def list_range(key, start, ending)\n timeout_retry(3, 3){\n write \"LRANGE #{key} #{start} #{ending}\\r\\n\"\n multi_bulk_reply\n }\n end",
"def range\n @cached_range ||= get_range\n end",
"def range\n object.range + DEFAULT_MAX_DISTANCE\n end",
"def range\n attributes.fetch(:range)\n end",
"def range\n attributes.fetch(:range)\n end",
"def range\n attributes.fetch(:range)\n end",
"def range\n attributes.fetch(:range)\n end",
"def emit_range\n emit_finish_mutations\n emit_start_mutations\n end",
"def query_hash_range(key, start, count, step_size, ts_index, ts_size = 2)\n hash = make_redis_hash(start, count, step_size, ts_index, ts_size)\n\n ckey = convert_keys(key)\n node = @root[ckey]\n\n keys = hash.to_a.sort_by { |it| it[0] }\n mres = @redis.pipelined do\n keys.each do |key, values|\n node[key].hmget(*values)\n end\n end\n\n mres.flatten.collect(&:to_i)\n end",
"def create_mongo_index(apparent_page)\n page = apparent_page - 1\n if page == 0\n from = 0\n to = apparent_page == self.max_page ? self.selected_restaurant_ids.length-1 : 8\n else\n from = page * 9\n to = apparent_page == self.max_page ? self.selected_restaurant_ids.length-1 : apparent_page * 9 -1\n end\n\n return from, to\n end",
"def region_range(i, opts={})\r\n refresh opts\r\n (@memlist[i][0]..(@memlist[i][1]+@memlist[i][0]))\r\n end",
"def _range from, to\n\t\trange = `IDBKeyRange.bound(#{from}, #{to})`\n\t\tEnumerator.new do |out, done|\n\t\t\ttry do\n\t\t\t\ttransaction = `#@db.transaction(['kv'], 'readonly')`\n\t\t\t\tstore = `#{transaction}.objectStore('kv')`\n\t\t\t\tindex = `#{store}.index('key')`\n\t\t\t\t%x{#{index}.openCursor(#{range}).onsuccess = function(e) {\n\t\t\t\t\tvar cursor = e.target.result\n\t\t\t\t\tif(cursor) {\n\t\t\t\t\t\t// #{log `cursor.value.key`, `cursor.value.val`}\n\t\t\t\t\t\t// debugger\n\t\t\t\t\t\t#{out << [`cursor.value.key`, `cursor.value.val`]}\n\t\t\t\t\t\tcursor.continue()\n\t\t\t\t\t} else {\n\t\t\t\t\t\t#{done[]}\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\tend\n\t\tend.lazy\n\tend",
"def shard_count\n @obj['shard_count']\n end",
"def shard_count\n shard_count_based_on_word_1\n end",
"def test_get_node_range_no_features\n nodes = @container.get_nodes('1',12,27,0)\n assert_equal(4, nodes.length)\n assert_equal([11,15,0], [nodes[0].start, nodes[0].stop, nodes[0].count])\n assert_equal([16,20,0], [nodes[1].start, nodes[1].stop, nodes[1].count])\n assert_equal([21,25,1], [nodes[2].start, nodes[2].stop, nodes[2].count])\n assert_equal([26,28,0], [nodes[3].start, nodes[3].stop, nodes[3].count])\n end",
"def random_index\n return 0 if shards.size == 1\n\n rand(shards.size)\n end",
"def test_raw_range_1\r\n r = GerbilCharts::Models::RawRange.new\r\n\r\n \t[10,20,10,0,0,1001,19920,882991.22].each do |v|\r\n\t\tr.update v\r\n\tend\r\n\r\n\tr.min_max do |mn,mx|\r\n \tassert mn==0\r\n\t\tassert mx==882991.22\r\n\tend\r\n end",
"def get_range ( addr )\n\tindex = addr - @base\n\tif index >= @size\n\t return \"Q\", 0\n\tend\n\tif @map[index] == \"L\"\n\t return \"L\", addr + 4\n\tend\n\tt = @map[index]\n\tloop {\n\t index = index + 1\n\t break if index >= @size\n\t break if @map[index] != t\n\t}\n\treturn t, @base + index\n end",
"def initialize(number)\n @range = (1..number)\n end",
"def initialize(number)\n @range = (1..number)\n end",
"def initialize(number)\n @range = (1..number)\n end",
"def initialize(number)\n @range = (1..number)\n end",
"def export_range(range = Iterable::Export::TODAY)\n params = { range: range }\n Iterable.request(conf, base_path, request_params(params)).get\n end",
"def range_value\n string_value\n end",
"def test_port_range\n proxy = OpenShift::FrontendProxyServer.new\n \n range = proxy.port_range(500)\n\n assert_equal range.begin, @ports_begin\n assert_equal range.end, (@ports_begin + @ports_per_user)\n end",
"def get_all_by_range(sorted_set_key, min, max)\n redis.zrangebyscore(sorted_set_key, min, max)\n end",
"def breakable_range=(_arg0); end",
"def range\n @from..@to\n end",
"def get_range\n\t\tif params.has_key?(\"start\") and params.has_key?(\"end\")\n\t\t\tif params[\"end\"] == \"Z\"\n\t\t\t\t# had to do some hackish stuff to include Z\n\t\t\t\tfirst = AToZEntry.select(:topic, :id).where(topic: params[:start]..params[:end])\n\t\t\t\tprefix = 'Z'\n\t\t\t\tsecond = AToZEntry.select(:topic, :id).where(\"topic LIKE :prefix\", prefix: \"#{prefix}%\")\n\t\t\t\trespond({ status: 0, topics: first+second })\n\t\t\telse\n\t\t\t\trespond({ status: 0, topics: AToZEntry.select(:topic, :id).where(topic: params[:start]..params[:end]) })\n\t\t\tend\t\t\t\n\t\telse\n\t\t\trespond({ status: 1, error: \"Must supply :start and :end parameter.\" })\n\t\tend\t\n\tend",
"def from(start_key)\n unless partition_specified?\n raise IllegalQuery,\n \"Can't construct exclusive range on partition key #{range_key_name}\"\n end\n scoped(lower_bound: bound(true, true, start_key))\n end",
"def spread mappings, range, default_value = 0\n occupied = Hash[mappings]\n range.map { |index| [index, occupied[index] || default_value] }\nend",
"def zrangestore(dest_key, src_key, start, stop, byscore: T.unsafe(nil), by_score: T.unsafe(nil), bylex: T.unsafe(nil), by_lex: T.unsafe(nil), rev: T.unsafe(nil), limit: T.unsafe(nil)); end",
"def source_range=(_arg0); end",
"def range\n\t\t\t#(@end > @start) ? (@start .. @end) : (@end .. @start)\n\t\t\t(start .. self.end)\n\t\tend",
"def shard\n self\n end",
"def test_inclusive_bounded_range_name_1_to_4_max_4\n header 'Range', 'name my-app-1..my-app-4; max=4'\n\n get '/'\n json_response = JSON.parse(last_response.body)\n\n assert last_response.ok?\n assert_equal Array, json_response.class\n assert_equal 4, json_response.count\n assert_equal 1, json_response.first['id']\n assert_equal 101, json_response.last['id']\n end",
"def query_range(options)\n run_command('query_range', options)\n end",
"def find_range(size_slab, input)\n min = size_slab.split('-')[0].to_i\n max = size_slab.split('-')[1].to_i\n (min..max).include? input.to_i\n end",
"def usedrange\n raise NoMethodError, 'Sheet is empty' if empty?\n Range.new( self, 'A1:' + indices_to_address( maxrow, maxcol ) )\n end",
"def rand_in_range(from, to); end",
"def range!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 7)\n\n type = RANGE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 13:9: '..'\n match(\"..\")\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__, 7)\n\n end",
"def create_range_data( rng, minrng=0, type=0, direction=2 )\n return Handlers::Range.createRange( rng, minrng, type, direction )\n end",
"def shard\n @pool.shard\n end",
"def zrange(key, start, stop, byscore: T.unsafe(nil), by_score: T.unsafe(nil), bylex: T.unsafe(nil), by_lex: T.unsafe(nil), rev: T.unsafe(nil), limit: T.unsafe(nil), withscores: T.unsafe(nil), with_scores: T.unsafe(nil)); end",
"def _reduce_518(val, _values, result)\n result = @builder.range_inclusive(val[0], val[1], val[2])\n \n result\nend",
"def range(column)\n min(column)..max(column)\n end",
"def shards\n @obj['shards']\n end",
"def _reduce_516(val, _values, result)\n result = @builder.range_inclusive(val[0], val[1], val[2])\n \n result\nend",
"def initialize(range)\n\t\t@secret_number = generate_secret_number(range.to_a)\n\tend",
"def map_local_range()\n @begin_index = time2index(local_range.begin)\n @end_index = time2index(local_range.end, -1) # FIXME this gives an unreachable index causing Exceptions down the line...\n @index_range = begin_index..end_index\n debugger if end_index < begin_index\n index_range\n end",
"def _reduce_528(val, _values, result)\n result = @builder.range_inclusive(val[0], val[1], val[2])\n\n result\nend",
"def _reduce_535(val, _values, result)\n result = @builder.range_inclusive(nil, val[0], val[1])\n\n result\nend",
"def binom_dist_range()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Binom_Dist_Range::BinomDistRangeRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def _reduce_510(val, _values, result)\n result = @builder.range_inclusive(nil, val[0], val[1])\n \n result\nend",
"def range_map\n @range_map ||= ranges.inject({}) do |res, (key, value)|\n range = value.split('-').map(&:to_i)\n res.merge! key => Range.new(range.first, range.last)\n end\n end",
"def nt_range(range)\n dna_hash = self.dna_hash\n new_hash = {}\n dna_hash.each do |k,v|\n new_hash[k] = v[range]\n end\n ViralSeq::SeqHash.new(new_hash)\n end",
"def compute_local_range()\n begin_index = time2index(local_range.begin)\n end_index = time2index(local_range.end, -1) # FIXME this gives an unreachable index causing Exceptions down the line...\n begin_index..end_index\n end",
"def count(range)\n conn.zcount key, *range_pair(range)\n end",
"def range(arr)\n\nend",
"def bench_range\n @bench_range ||= 2.upto(4).map { |n| 10 ** n }\n end",
"def one_index_range(range)\n Range.new(one_index_number(range.begin), one_index_number(range.end))\n end",
"def rank_range(range,board=@board,&block)\n range.to_a.each {|r| whole_rank(r,board,&block) }\n end"
] |
[
"0.6611703",
"0.66045314",
"0.6315301",
"0.6259179",
"0.6259179",
"0.6259179",
"0.62228215",
"0.6189474",
"0.60474354",
"0.60474354",
"0.60474354",
"0.6000904",
"0.5977611",
"0.5940206",
"0.59218925",
"0.5908179",
"0.5908179",
"0.5900818",
"0.5892729",
"0.5892535",
"0.5890437",
"0.58418506",
"0.577619",
"0.5762701",
"0.57570726",
"0.5738276",
"0.573687",
"0.5723499",
"0.5693197",
"0.5692097",
"0.5689629",
"0.56804895",
"0.5680208",
"0.5661286",
"0.5660182",
"0.56413347",
"0.56247294",
"0.5615963",
"0.56018025",
"0.55957514",
"0.55903447",
"0.55725044",
"0.55725044",
"0.55725044",
"0.55725044",
"0.55336297",
"0.5533236",
"0.552693",
"0.5524538",
"0.5517822",
"0.55056846",
"0.5504888",
"0.54919934",
"0.548953",
"0.54771787",
"0.54697436",
"0.5463228",
"0.5463228",
"0.5463228",
"0.5463228",
"0.5459311",
"0.54501724",
"0.54472977",
"0.54472035",
"0.54401195",
"0.54337466",
"0.54326683",
"0.54298955",
"0.5409243",
"0.5398152",
"0.53923887",
"0.5391564",
"0.53880733",
"0.53813714",
"0.5381121",
"0.5379085",
"0.5376876",
"0.5375101",
"0.53744614",
"0.5372108",
"0.5367745",
"0.53613865",
"0.5358569",
"0.5353429",
"0.5346653",
"0.5344766",
"0.5336204",
"0.5330461",
"0.531681",
"0.53152966",
"0.5311285",
"0.53094196",
"0.53051555",
"0.53010434",
"0.5297045",
"0.5292041",
"0.52901757",
"0.52874225",
"0.52797997",
"0.52782834"
] |
0.5906514
|
17
|
is this device a SSD? If it's not rotational, then it's SSD expects a short device name, e.g. 'sda', not '/dev/sda', not '/dev/sda3'
|
def device_ssd?(device)
unless node['block_device'][device]
fail "fb_helpers: Device '#{device}' passed to node.device_ssd? " +
"doesn't appear to be a block device!"
end
node['block_device'][device]['rotational'] == '0'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def select_device_name(volume_attachments, first_device_name_letter)\n (first_device_name_letter..'z').each do |char|\n # Some kernels remap device names (from sd* to vd* or xvd*).\n device_names = [\"/dev/sd#{char}\", \"/dev/vd#{char}\", \"/dev/xvd#{char}\"]\n # Bosh Agent will lookup for the proper device name if we set it initially to sd*.\n return \"/dev/sd#{char}\" if volume_attachments.select { |v| device_names.include?(v['device']) }.empty?\n @logger.warn(\"`/dev/sd#{char}' is already taken\")\n end\n\n nil\n end",
"def device_of_mount(m)\n unless Pathname.new(m).mountpoint?\n Chef::Log.warn(\n \"#{m} is not a mount point - I can't determine its device.\",\n )\n return nil\n end\n node['filesystem2']['by_pair'].to_hash.each do |pair, info|\n # we skip fake filesystems 'rootfs', etc.\n next unless pair.start_with?('/')\n # is this our FS?\n next unless pair.end_with?(\",#{m}\")\n # make sure this isn't some fake entry\n next unless info['kb_size']\n return info['device']\n end\n Chef::Log.warn(\n \"#{m} shows as valid mountpoint, but Ohai can't find it.\",\n )\n return nil\n end",
"def first_sata_disk\n disks_enum = physical_disk_views\n logger.info(\"disks enum from physical_disk_views is %s\" % [disks_enum])\n sata_disks = []\n disks_enum.each do |x|\n slot = x[:slot]\n connector = x[:connector]\n sata_disks << \"%s-%s\" % [slot, connector] if x[:model] =~ /SATADOM/i\n end\n return if sata_disks.empty?\n\n logger.info(\"SATA Disk: #{sata_disks}\")\n suffix = sata_disks.min.split(\"-\")\n disk_name = (\"A\"..\"Z\").to_a[suffix[0].to_i]\n \"Disk.SATAEmbedded.%s-%s\" % [disk_name, \"1\"]\n end",
"def sd\n field_fetch('SD')\n end",
"def partition_check_device(devicename)\n if External.cmd(@server, \"/usr/bin/sudo /sbin/fdisk -l #{devicename}\").include? \"Disk #{devicename} doesn't contain a valid partition table\"\n false\n else\n true\n end\n end",
"def device_of_mount(m)\n fs = self.filesystem_data\n unless Pathname.new(m).mountpoint?\n Chef::Log.warn(\n \"fb_helpers: #{m} is not a mount point - I can't determine its \" +\n 'device.',\n )\n return nil\n end\n unless fs && fs['by_pair']\n Chef::Log.warn(\n 'fb_helpers: no filesystem data so no node.device_of_mount',\n )\n return nil\n end\n fs['by_pair'].to_hash.each do |pair, info|\n # we skip fake filesystems 'rootfs', etc.\n next unless pair.start_with?('/')\n # is this our FS?\n next unless pair.end_with?(\",#{m}\")\n # make sure this isn't some fake entry\n next unless info['kb_size']\n\n return info['device']\n end\n Chef::Log.warn(\n \"fb_helpers: #{m} shows as valid mountpoint, but Ohai can't find it.\",\n )\n nil\n end",
"def is_mounted?(device)\n system(\"grep -q '#{device}' /proc/mounts\")\nend",
"def disk_or_cdrom?(device)\n is_disk =\n !device\n .class\n .ancestors\n .index(RbVmomi::VIM::VirtualDisk).nil?\n is_cdrom =\n !device\n .class\n .ancestors\n .index(RbVmomi::VIM::VirtualCdrom).nil?\n is_disk || is_cdrom\n end",
"def disk_or_iso?(device)\n is_disk =\n !device\n .class\n .ancestors\n .index(RbVmomi::VIM::VirtualDisk).nil?\n is_iso =\n device\n .backing\n .is_a? RbVmomi::VIM::VirtualCdromIsoBackingInfo\n is_disk || is_iso\n end",
"def device?\n type == :device\n end",
"def guest_device(name, mount_point_obj)\n \"/dev/#{guest_vg_name(name, mount_point_obj)}/#{guest_lv_name(mount_point_obj)}\"\n end",
"def name\n File.join(\"/dev/\",@device.gsub(/!/, \"/\"))\n end",
"def mountpoint\n 'dev/.osctl-mount-helper'\n end",
"def disk?(device)\n !device.class.ancestors.index(RbVmomi::VIM::VirtualDisk).nil?\n end",
"def mountpoint?\n begin\n stat1 = lstat\n stat2 = parent.lstat\n stat1.dev != stat2.dev or stat1.ino == stat2.ino\n rescue Errno::ENOENT\n false\n end\n end",
"def mountpoint?\n begin\n stat1 = expand_tilde.lstat\n stat2 = expand_tilde.parent.lstat\n stat1.dev == stat2.dev && stat1.ino == stat2.ino ||\n stat1.dev != stat2.dev\n rescue Errno::ENOENT\n false\n end\n end",
"def setup_device_for_mount\n # use ramdisk for creating a test device for mount.\n # This can cleaner if we have chef resource/provider for ramdisk.\n case ohai[:platform_family]\n when \"aix\"\n # On AIX, we can't create a ramdisk inside a WPAR, so we use\n # a \"namefs\" mount against / to test\n # https://www-304.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.performance/namefs_file_sys.htm\n device = \"/\"\n fstype = \"namefs\"\n when \"debian\", \"rhel\", \"amazon\"\n device = \"/dev/ram1\"\n unless File.exist?(device)\n shell_out(\"mknod -m 660 #{device} b 1 0\")\n shell_out(\"chown root:disk #{device}\")\n end\n shell_out(\"ls -1 /dev/ram*\").stdout.each_line do |d|\n if shell_out(\"mount | grep #{d}\").exitstatus == \"1\"\n # this device is not mounted, so use it.\n device = d\n break\n end\n end\n fstype = \"tmpfs\"\n shell_out!(\"mkfs -q #{device} 512\")\n when \"solaris2\"\n device = \"swap\"\n fstype = \"tmpfs\"\n else\n end\n [device, fstype]\n end",
"def IsRealDisk(entry)\n entry = deep_copy(entry)\n Ops.get_symbol(entry, \"type\", :CT_UNKNOWN) == :CT_DISK &&\n !(Ops.get_symbol(entry, \"type\", :CT_UNKNOWN) == :CT_DISK &&\n Ops.get_boolean(entry, \"readonly\", false) &&\n Ops.get_string(entry, \"driver\", \"\") == \"vbd\")\n end",
"def using_disk?\n return @status[ 'Disk' ][ 'Active' ]\n end",
"def iscsi?\n disk_type == DiskType.iscsi\n end",
"def debug_if_root_device(bdms)\n return if bdms.nil? || bdms.empty?\n image_id = config[:image_id]\n image = ec2.resource.image(image_id)\n begin\n root_device_name = image.root_device_name\n rescue ::Aws::EC2::Errors::InvalidAMIIDNotFound\n # Not raising here because AWS will give a more meaningful message\n # when we try to create the instance\n return\n end\n bdms.find { |bdm|\n if bdm[:device_name] == root_device_name\n logger.info(\"Overriding root device [#{root_device_name}] from image [#{image_id}]\")\n end\n }\n end",
"def get_fs_type(device)\n fs_check = Mixlib::ShellOut.new(\"blkid -c /dev/null #{device}\")\n fs_check.run_command\n match = fs_check.stdout.match(/TYPE=\\\"(.*)\\\"/)\n match = '' if match.nil?\n\n match[1]\nend",
"def mountpoint?\n begin\n stat1 = self.lstat\n stat2 = self.parent.lstat\n stat1.dev == stat2.dev && stat1.ino == stat2.ino ||\n stat1.dev != stat2.dev\n rescue Errno::ENOENT\n false\n end\n end",
"def nbd_device\n sys_parts = lsblk('')\n nbds = []\n\n sys_parts.each do |p|\n m = p['name'].match(/nbd(\\d+)/)\n next unless m\n\n nbds << m[1].to_i\n end\n\n nbds_max.times do |i| # if nbds_max returns 0 block is skipped\n return \"/dev/nbd#{i}\" unless nbds.include?(i)\n end\n\n OpenNebula.log_error(\"#{__method__}: Cannot find free nbd device\")\n\n ''\n end",
"def fstype\n return self['fstype'] if has_key?('fstype')\n Chef::Log.info([\n self['fstype'], current[:fstype],\n File.exists?(device) && `file -s '#{device}'`.chomp,\n self,\n ].inspect)\n return current[:fstype] if current[:fstype]\n return unless File.exists?(device)\n dev_type_str = `file -s '#{device}'`.chomp\n case\n when dev_type_str =~ /SGI XFS/ then self['fstype'] = 'xfs'\n when dev_type_str =~ /Linux.*(ext[2-4])/ then self['fstype'] = $1\n else\n raise \"Can't determine filesystem type of #{device} -- set it explicitly in node[:volumes]\"\n end\n self['fstype']\n end",
"def disc_blank?(drive)\n fd = File.open(drive, File::NONBLOCK | File::RDONLY)\n \n # Check the drive itself.\n rv = fd.ioctl($CDROM_DRIVE_STATUS, 0);\n if (rv!=$CDS_DISC_OK)\n fd.close\n return false\n end\n\n # Now check the disc type.\n rv = fd.ioctl($CDROM_DISC_STATUS, 0);\n fd.close\n case rv \n when $CDS_NO_INFO\n return true;\n end\n \n return false\nend",
"def get_fs_type(device)\n fs_check = Mixlib::ShellOut.new(\"blkid -c /dev/null #{device}\")\n fs_check.run_command\n match = fs_check.stdout.match(/\\sTYPE=\\\"(.*?)\\\"/)\n match = '' if match.nil?\n\n Chef::Log.info(\"File system type for device #{device}: #{match[1]}\")\n match[1]\nend",
"def check_root_device(partition, fstab, found_partition)\n fstab = deep_copy(fstab)\n tmp = Builtins.filter(fstab) do |entry|\n Ops.get_string(entry, \"file\", \"\") == \"/\"\n end\n\n if Builtins.size(tmp) != 1\n Builtins.y2error(\"not exactly one root partition found in fstab\")\n found_partition.value = \"none\"\n return false\n end\n\n root = Ops.get(tmp, 0, {})\n\n if !Storage.DeviceRealDisk(Ops.get_string(root, \"spec\", \"\"))\n # There's nothing I can check. Anyway, it's not mounted per device\n # name so it can't be wrong, in theory.\n return true\n end\n\n true\n end",
"def is_root_device?(volume_id)\n vols = @ec2_api.describe_volumes(:volume_id => volume_id)\n if vols['volumeSet']['item'][0]['attachmentSet'] == nil || vols['volumeSet']['item'][0]['attachmentSet']['item'].size == 0\n #not linked to any instance, cannot be a root-device\n return false\n end\n instance_id = vols['volumeSet']['item'][0]['attachmentSet']['item'][0]['instanceId']\n res = @ec2_api.describe_instance_attribute(:instance_id => instance_id, :attributes => {:rootDeviceName => true})\n if res[\"rootDeviceName\"] == nil\n return false\n end\n rdn = res['rootDeviceName']['value']\n res = @ec2_api.describe_instances(:instance_id => instance_id)\n if res['reservationSet']['item'][0]['instancesSet']['item'][0]['blockDeviceMapping']['item'].size == 0\n # volume unattached in the meantime\n return false\n end\n attached = res['reservationSet']['item'][0]['instancesSet']['item'][0]['blockDeviceMapping']['item']\n attached.each() {|ebs|\n volume = ebs['ebs']['volumeId']\n device_name = ebs['deviceName']\n if volume == volume_id && rdn == device_name\n return true\n end\n }\n return false\n end",
"def unmount_device( dev )\n sudo <<-SH\n if mount | grep -q '^#{dev} '; then\n umount #{dev}\n sed -r -i '\\\\|^#{dev}\\\\s|d' /etc/fstab\n fi\n SH\n end",
"def get_verbose_disc_type(drive)\n if !disc_ready?(drive)\n return \"NOT READY\"\n end\n\n if disc_blank?(drive)\n return \"BLANK (unknown type)\"\n end\n\n fd = File.open(drive, File::NONBLOCK | File::RDONLY) \n rv = fd.ioctl($CDROM_DISC_STATUS, 0);\n fd.close\n\n # Possible race with above, so repeat a few cases.\n case rv \n when $CDS_NO_INFO\n return \"BLANK (unknown type)\"\n when $CDS_NO_DISC\n return \"NOT READY\"\n when $CDS_AUDIO\n return \"AUDIO (Red Book CD-DA)\"\n when $CDS_DATA_1\n return \"DATA (Yellow Book, Mode 1, Format 1)\"\n when $CDS_DATA_2\n return \"DATA (Yellow Book, Mode 1, Format 2)\"\n when $CDS_XA_2_1\n return \"DATA (Green Book, Mode 2, Format 1)\"\n when $CDS_XA_2_2\n return \"DATA (Green Book, Mode 2, Format 2)\"\n when $CDS_MIXED\n return \"MIXED (Vomit Book)\"\n else\n return \"FUCKED!\"\n end\n\nend",
"def get_device_mount_point( incoming_path )\n mount_lines = `mount`\n raise EBSRemoteExecException.new(nil,$?,mount_lines) if $? != 0\n path = File.ftype(incoming_path) != 'directory'? File.dirname(incoming_path) : incoming_path\n device=nil\n longest = \"\"\n mount_lines.each_line {|line|\n match = line =~ /(.+)\\son\\s(.+?)\\s.*/\n candidate = $2.strip\n candidate_device = $1.strip\n # Keep the longest prefix matching\n if match && path =~ /^#{candidate}/ && candidate.length > longest.length\n longest = candidate\n device = candidate_device\n end\n }\n unless device\n STDERR.puts \"Couldn't find the device for mount point #{path}\"\n Kernel.exit(-1)\n end\n device\n end",
"def sd_params\n params.require(:sd).permit(:name, :cpu, :disk, :process)\n end",
"def mounted?(name)\n mount_loc = File.join(KVM_MOUNT_POINT, name)\n system(\"mount | grep #{mount_loc}\")\nend",
"def suse?\n @flavor =~ /suse/\n end",
"def get_1st_partition(device)\n # Resolves the real device name (ex. /dev/sdg)\n Chef::Log.info(\"Getting 1st partition for device: #{device}\")\n fs_check = Mixlib::ShellOut.new(\"lsblk -ln -o Name #{device}|awk 'NR==2'\")\n fs_check.run_command\n partition = \"/dev/\" + fs_check.stdout.strip\n Chef::Log.info(\"1st partition for device: #{device} is: #{partition}\")\n partition\nend",
"def first_device_name_letter(server)\n letter = FIRST_DEVICE_NAME_LETTER.dup\n return letter if server.flavor.nil?\n return letter unless server.flavor.key?('id')\n flavor = @openstack.with_openstack { @openstack.compute.flavors.find { |f| f.id == server.flavor['id'] } }\n return letter if flavor.nil?\n\n letter.succ! if flavor_has_ephemeral_disk?(flavor)\n letter.succ! if flavor_has_swap_disk?(flavor)\n letter.succ! if @config_drive == 'disk'\n letter\n end",
"def physical_device?\n if udid.nil?\n stack = Kernel.caller(0, 6)[0..-1].join(\"\\n\")\n raise RuntimeError,\n %Q[udid is nil\n\n#{stack}\n\n name: #{name}\nversion: #{version}\n]\n end\n !udid[DEVICE_UDID_REGEX, 0].nil?\n end",
"def device\n device_name\n end",
"def flavor_has_swap_disk?(flavor)\n flavor.swap.nil? || flavor.swap.to_i <= 0 ? false : true\n end",
"def parts_on?(device)\n partitions = lsblk(device)\n return true if partitions[0]['type'] == 'part'\n\n false\n end",
"def device_with_name(name)\n c = settings.subaru_config[:devices][name]\n return Object.const_get(\"Subaru::Definitions::#{c[:definition]}\").new(c) if c\n rescue => e\n puts e.message\n return nil\n end",
"def device(value, &block)\n value = value.to_s\n device = devices.find { |d| d.name == value || d.shortname == value }\n\n run_device_block_if_needed(device, &block)\n\n device\n end",
"def chardev?() end",
"def verify_mounted(partition)\n\treturn `grep partition /proc/mounts | wc -l`.chomp\nend",
"def suse?(node = __getnode)\n node[\"platform_family\"] == \"suse\"\n end",
"def dev?\n without_extension.end_with?(DEV_IDENTIFIER)\n end",
"def is_sname?(); @type == GRT_SNAME; end",
"def device_name\n return @device_name\n end",
"def device_name\n return @device_name\n end",
"def device_name\n return @device_name\n end",
"def tmpfs_mount_status(desired)\n # Start with checking if it was mounted the way we would mount it\n # this is ALMOST the same as the 'is it identical' check for non-tmpfs\n # filesystems except that with tmpfs we don't treat 'auto' as equivalent and\n # that we skip inode64 option on current mount status - because it's activated\n # by default on Linux kernel >= 5.9\n fs_data = node.filesystem_data\n key = \"#{desired['device']},#{desired['mount_point']}\"\n if fs_data['by_pair'][key]\n mounted = fs_data['by_pair'][key].to_hash\n if mounted['fs_type'] == 'tmpfs'\n Chef::Log.debug(\n \"fb_fstab: tmpfs #{desired['device']} on \" +\n \"#{desired['mount_point']} is currently mounted...\",\n )\n\n skipped_opts = []\n if _are_tmpfs_using_inode64?\n\n # inode64 is active by default on tmpfs for Linux kernel > 5.9\n skipped_opts.push('inode64')\n end\n\n if compare_opts(desired['opts'], mounted['mount_options'], skipped_opts)\n Chef::Log.debug('fb_fstab: ... with identical options.')\n return :same\n else\n Chef::Log.debug(\n \"fb_fstab: ... with different options #{desired['opts']} vs \" +\n mounted['mount_options'].join(','),\n )\n Chef::Log.info(\n \"fb_fstab: #{desired['mount_point']} is mounted with options \" +\n \"#{canonicalize_opts(mounted['mount_options'])} instead of \" +\n canonicalize_opts(desired['opts']).to_s,\n )\n return :remount\n end\n end\n end\n # OK, if that's not the case, we don't have the same device, which\n # is OK. Find out if we have something mounted at the same spot, and\n # get its device name so we can find it's entry in node['filesystem']\n if fs_data['by_mountpoint'][desired['mount_point']]\n # If we are here the mountpoints are the same...\n mounted = fs_data['by_mountpoint'][desired['mount_point']].to_hash\n # OK, if it's tmpfs as well, we're diong good\n if mounted['fs_type'] == 'tmpfs'\n Chef::Log.warn(\n \"fb_fstab: Treating #{mounted['devices']} on \" +\n \"#{desired['mount_point']} the same as #{desired['device']} on \" +\n \"#{desired['mount_point']} because they are both tmpfs.\",\n )\n Chef::Log.debug(\n \"fb_fstab: tmpfs #{desired['device']} on \" +\n \"#{desired['mount_point']} is currently mounted...\",\n )\n Chef::Log.debug(\"fb_fstab: #{desired} vs #{mounted}\")\n if compare_opts(desired['opts'], mounted['mount_options'])\n Chef::Log.debug('fb_fstab: ... with identical options.')\n return :same\n else\n Chef::Log.debug(\n \"fb_fstab: ... with different options #{desired['opts']} vs \" +\n mounted['mount_options'].join(','),\n )\n Chef::Log.info(\n \"fb_fstab: #{desired['mount_point']} is mounted with options \" +\n \"#{canonicalize_opts(mounted['mount_options'])} instead of \" +\n canonicalize_opts(desired['opts']).to_s,\n )\n return :remount\n end\n end\n Chef::Log.warn(\n \"fb_fstab: tmpfs is desired on #{desired['mount_point']}, but \" +\n \"non-tmpfs #{mounted['devices']} (#{mounted['fs_type']}) currently \" +\n 'mounted there.',\n )\n return :conflict\n end\n :missing\n end",
"def drive_sucks?(drive)\n fd = File.open(drive, File::NONBLOCK | File::RDONLY)\n rv = fd.ioctl($CDROM_DRIVE_STATUS, 0);\n fd.close\n if (rv==CDS_NO_INFO)\n return true\n end\n return false\nend",
"def phys_adapter_name\n new_resource.vlan.nil? ? new_resource.device : \"#{new_resource.device}-NIC\"\n end",
"def exists?\n begin\n partition= resource[:name]\n device=partition[0,(partition.length-1)]\n if File.exist?(partition)\n true\n else\n false\n end\n end\n end",
"def has_disk?(disk_id)\n @cloud_core.has_disk?(disk_id)\n end",
"def bsd?\n kind_of? BSD::Platform rescue false\n end",
"def suse_platform?(node = __getnode)\n node[\"platform\"] == \"suse\"\n end",
"def mount(name, root_dev)\n puts \"Mounting KVM device: #{root_dev}\"\n mount_loc = File.join(KVM_MOUNT_POINT, name)\n unless(system(\"mount | grep #{mount_loc}\"))\n FileUtils.mkdir_p(mount_loc)\n if(system(\"mount #{root_dev} #{mount_loc}\"))\n mount_loc\n else\n raise \"Failed to mount #{root_dev} to #{mount_loc}\"\n end\n else\n puts \"Device already mounted (#{mount_loc})\"\n mount_loc\n end\nend",
"def IsMounted(mountpoint)\n if Builtins.substring(\n mountpoint,\n Ops.subtract(Builtins.size(mountpoint), 1),\n 1\n ) == \"/\"\n mountpoint = Builtins.substring(\n mountpoint,\n 0,\n Ops.subtract(Builtins.size(mountpoint), 1)\n )\n end\n\n ret = true\n Builtins.foreach(@activated) do |e|\n if Ops.get_string(e, :type, \"\") == \"mount\" &&\n (Ops.get_string(e, :mntpt, \"\") == mountpoint ||\n Ops.get_string(e, :mntpt, \"\") == Ops.add(mountpoint, \"/\"))\n ret = true\n end\n end\n ret\n end",
"def parent_whole_disk\n Device.new('/dev/' + self['ParentWholeDisk'])\n end",
"def mount?\n return $game_player.system_tag == TMount\n end",
"def systemd?\n `ps -o comm= 1`.chomp == 'systemd'\n end",
"def systemd?\n `ps -o comm= 1`.chomp == 'systemd'\n end",
"def bsd_based?(node = __getnode)\n # we could use os, platform_family or platform here equally\n %w{netbsd freebsd openbsd dragonflybsd}.include?(node[\"platform\"])\n end",
"def device_display_name\n return @device_display_name\n end",
"def device_display_name\n return @device_display_name\n end",
"def display_device_name\n return @display_device_name\n end",
"def mount_device(device, mount_point, owner, group, fs_type)\n puts `echo #{device} #{mount_point} #{fs_type} noatime 0 0|tee -a /etc/fstab`\n puts \"Making mount directory #{mount_point} for #{device}\"\n puts `mkdir -p #{mount_point}`\n puts \"Mounting #{device} at #{mount_point}\"\n puts `mount #{mount_point}`\n puts \"Setting ownership on #{mount_point} to #{owner}\"\n puts `chown #{owner}:#{owner} #{mount_point}`\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 mount_dev(dev, path)\n OpenNebula.log_info \"Mounting #{dev} at #{path}\"\n\n mkdir_safe(path)\n\n rc, _out, err = Command.execute(\"#{COMMANDS[:mount]} #{dev} #{path}\",\n true)\n\n if rc != 0\n OpenNebula.log_error(\"mount_dev: #{err}\")\n return false\n end\n\n true\n end",
"def set_sd\n @sd = Sd.find(params[:id])\n end",
"def set_ssd\n @ssd = Ssd.find(params[:id])\n end",
"def suse_linux_type\n if @suse_linux_type.nil?\n out = nil\n text = FilePath.new(\"/etc/SuSE-release\").suck_file\n unless text.nil?\n if text =~ /suse/i\n out = \"sl\"\n out += \"es\" if text =~ /enterprise\\s*server/i\n out += \"%s\" % $1 if text =~ /^[^\\d]+(\\d+)/i\n end\n end\n \n @suse_linux_type = out\n end\n \n @suse_linux_type\n end",
"def disc_ready?(drive)\n fd = File.open(drive, File::NONBLOCK | File::RDONLY)\n \n # Check the drive itself.\n rv = fd.ioctl($CDROM_DRIVE_STATUS, 0);\n fd.close\n if (rv==$CDS_DISC_OK)\n return true\n end\n \n return false\nend",
"def mount_command(path)\n \"udisksctl mount --block-device #{path}\"\nend",
"def mounted?\n '' != self['MountPoint']\n end",
"def device_name=(value)\n @device_name = value\n end",
"def device_name=(value)\n @device_name = value\n end",
"def device_name=(value)\n @device_name = value\n end",
"def is_dev?\n @dev\n end",
"def scsi_controller_item\n find_item('SCSI Controller')\n end",
"def controller_supports_non_raid?(non_raid_fqdd)\n non_raid_disk_controller = disk_controllers.find { |c| c[:fqdd].include?(non_raid_fqdd) }\n !(non_raid_disk_controller.nil? || non_raid_disk_controller[:product_name] =~ /Dell HBA330/i)\n end",
"def dev_host\n case Socket.gethostname\n when /romeo-foxtrot/i ; true\n else ; false\n end\nend",
"def disk_type\n return @disk_type\n end",
"def determine_name\n name = nil\n\n case @type\n when :computer\n name = `sudo dmidecode -s system-serial-number`.chomp\n when :hard_drive\n `sudo smartctl -i #{@options['device']}`.each_line do |line|\n line =~ /^Serial\\sNumber:\\s+([A-Za-z0-9_-]+)$/\n name = $1\n end\n end\n\n # Check if the id is valid (all word characters plus dash)\n if ( name =~ /^[A-Za-z0-9_-]+$/ )\n name\n else\n nil\n end\n end",
"def disk?\n ! url?\n end",
"def mount_usb_drive\n execute_system_cmd('mount /home/pi/compartida/musica/discousb')\n end",
"def sshd_service_exists?\n # FIXME: We should probably check exit status rather than AIX-specific error codes.\n output=ssh_command(\"#{config[:sudo]} #{config[:clogin]} #{config[:wpar_name]} #{config[:lssrc]} -s sshd\", :stderr)\n if output.include?('0513-085') # 0513-085 The sshd Subsystem is not on file.\n return false\n end\n true\n end",
"def validate_disk_size\n return unless @dev\n\n # we can't use execute!() since we want to capture the output of the cmd\n output, _, stat = Open3.capture3(\"sudo blockdev --getsize64 #{@dev}\")\n raise RuntimeError, 'Unable determine dev size' unless stat.success?\n\n dev_mib = output.strip.to_i / (1024 * 1024) # space on device (MiB)\n begin\n tot_mib = total_disk_size()\n rescue RuntimeError => e\n warn(\"Performing lax disk size check (#{e})\")\n tot_mib = minimum_disk_size()\n end\n\n if tot_mib >= dev_mib\n warn(\"Insufficient space! need MiB: #{tot_mib}, device MiB: #{dev_mib}\")\n raise RuntimeError, \"Total size #{tot_mib} > block device size #{dev_mib}\"\n end\n\n nil\n end",
"def has_rackspace_kernel?\n kernel[:release].split('-').last.eql?(\"rscloud\")\nend",
"def device_id\n accessory_info.device_id\n end",
"def determine_disk\n df_cmd = \"df 2>/dev/null|awk '$1 ~ /\\\\// {I=I+$3} END {print I}'\"\n disk = @shell.query('DISK_DF', df_cmd)\n\n # Result is expected to be in KiB. Convert to GB.\n @info[:disk] = disk.to_f / 1000 ** 2\n end",
"def is_debian?\n return !!@name.match(/^debian-.*$/)\n end",
"def present?\n ['/dev/ipmi0', '/dev/ipmi/0', '/dev/ipmidev/0'].find { |dev| File.exist? dev }\n end",
"def is_sles?\n return !!@name.match(/^sles-.*$/)\n end",
"def autodiscover_devices\n logger.debug 'Discovering information about storage subsystem (HDD and MD devices)'\n @storage_information = HddAutodiscover.new(STORAGE_CONFIG[:volume_name])\n collected = @storage_information.collect()\n\n assert [:storage, :free_space, collected[:lvm][:free]]\n collected[:hdd].each do |hdd|\n assert [:hdd, hdd.device, :sn, hdd.sn]\n assert [:hdd, hdd.device, :temperature, hdd.temperature]\n assert [:hdd, hdd.device, :health, hdd.health]\n end\n end",
"def is_cisco_wrlinux?\n return !!@name.match(/^cisco-wrlinux-.*$/)\n end",
"def root_device_name\n data[:root_device_name]\n end",
"def format_mount(partition, mount)\n\n # Partitions that we already have mounts set for.\n return nil if partition == '/dev/mapper/rootvg-slash'\n return nil if partition == '/dev/mapper/rootvg-var'\n return nil if partition == '/dev/mapper/rootvg-tmp'\n\n mount\nend"
] |
[
"0.64648587",
"0.6390836",
"0.6318847",
"0.6230825",
"0.6149251",
"0.6143996",
"0.61226445",
"0.6002282",
"0.5961526",
"0.5947527",
"0.58912826",
"0.58758265",
"0.58645123",
"0.5856323",
"0.5852366",
"0.5843651",
"0.57776934",
"0.57702684",
"0.57570446",
"0.57345617",
"0.56921333",
"0.56573075",
"0.56539285",
"0.5641886",
"0.56059635",
"0.5579594",
"0.5572",
"0.55640256",
"0.55625695",
"0.55557346",
"0.5490225",
"0.54803455",
"0.5475942",
"0.5475888",
"0.5468914",
"0.54527444",
"0.5418656",
"0.54126894",
"0.54110014",
"0.5404912",
"0.53796035",
"0.5378796",
"0.53747135",
"0.53736293",
"0.5366878",
"0.5356344",
"0.53433704",
"0.53291017",
"0.52936316",
"0.52936316",
"0.52936316",
"0.5284848",
"0.5283742",
"0.5282793",
"0.5281001",
"0.5274047",
"0.5262302",
"0.5258765",
"0.52444434",
"0.5244405",
"0.52429694",
"0.52390605",
"0.52296215",
"0.52296215",
"0.52118754",
"0.5199703",
"0.5199703",
"0.51939213",
"0.5190123",
"0.5169522",
"0.51629287",
"0.5158829",
"0.51559246",
"0.5143756",
"0.5143332",
"0.5127524",
"0.5124691",
"0.51238143",
"0.51238143",
"0.51238143",
"0.51214635",
"0.5120252",
"0.5110598",
"0.5100737",
"0.5095353",
"0.5085618",
"0.50796497",
"0.5075161",
"0.5067156",
"0.5057474",
"0.5054735",
"0.50486386",
"0.50454766",
"0.5045292",
"0.5037123",
"0.5033838",
"0.5032557",
"0.5032506",
"0.5028505",
"0.5003928"
] |
0.67621386
|
0
|
On Linux and Mac, as of Chef 13, FS and FS2 were identical and in Chef 14, FS2 is dropped. For FreeBSD and other platforms, they become identical in late 15 and FS2 is dropped in late 16 So we always try 2 and fail back to 1 (if 2 isn't around, then 1 is the new format) This will return modern filesystem data, where it exists if it exists. Otherwise it will fail
|
def filesystem_data
self['filesystem2'] || self['filesystem']
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def filesystem_type(host)\n case host['platform']\n when %r{aix}\n 'jfs2'\n when %r{el-|centos|fedora|sles|debian|ubuntu}\n 'ext3'\n else\n # TODO: Add Solaris and OSX support, as per PUP-5201 and PUP-4823\n fail_test(\"Unable to determine a standard filesystem table type for #{host['platform']}\")\n end\n end",
"def filesystem_file(host)\n case host['platform']\n when %r{aix}\n '/etc/filesystems'\n when %r{el-|centos|fedora|sles|debian|ubuntu}\n '/etc/fstab'\n else\n # TODO: Add Solaris and OSX support, as per PUP-5201 and PUP-4823\n fail_test(\"Unable to determine filesystem table file location for #{host['platform']}\")\n end\n end",
"def get_fs_type(device)\n fs_check = Mixlib::ShellOut.new(\"blkid -c /dev/null #{device}\")\n fs_check.run_command\n match = fs_check.stdout.match(/\\sTYPE=\\\"(.*?)\\\"/)\n match = '' if match.nil?\n\n Chef::Log.info(\"File system type for device #{device}: #{match[1]}\")\n match[1]\nend",
"def fstype\n return self['fstype'] if has_key?('fstype')\n Chef::Log.info([\n self['fstype'], current[:fstype],\n File.exists?(device) && `file -s '#{device}'`.chomp,\n self,\n ].inspect)\n return current[:fstype] if current[:fstype]\n return unless File.exists?(device)\n dev_type_str = `file -s '#{device}'`.chomp\n case\n when dev_type_str =~ /SGI XFS/ then self['fstype'] = 'xfs'\n when dev_type_str =~ /Linux.*(ext[2-4])/ then self['fstype'] = $1\n else\n raise \"Can't determine filesystem type of #{device} -- set it explicitly in node[:volumes]\"\n end\n self['fstype']\n end",
"def tmpfs_mount_status(desired)\n # Start with checking if it was mounted the way we would mount it\n # this is ALMOST the same as the 'is it identical' check for non-tmpfs\n # filesystems except that with tmpfs we don't treat 'auto' as equivalent and\n # that we skip inode64 option on current mount status - because it's activated\n # by default on Linux kernel >= 5.9\n fs_data = node.filesystem_data\n key = \"#{desired['device']},#{desired['mount_point']}\"\n if fs_data['by_pair'][key]\n mounted = fs_data['by_pair'][key].to_hash\n if mounted['fs_type'] == 'tmpfs'\n Chef::Log.debug(\n \"fb_fstab: tmpfs #{desired['device']} on \" +\n \"#{desired['mount_point']} is currently mounted...\",\n )\n\n skipped_opts = []\n if _are_tmpfs_using_inode64?\n\n # inode64 is active by default on tmpfs for Linux kernel > 5.9\n skipped_opts.push('inode64')\n end\n\n if compare_opts(desired['opts'], mounted['mount_options'], skipped_opts)\n Chef::Log.debug('fb_fstab: ... with identical options.')\n return :same\n else\n Chef::Log.debug(\n \"fb_fstab: ... with different options #{desired['opts']} vs \" +\n mounted['mount_options'].join(','),\n )\n Chef::Log.info(\n \"fb_fstab: #{desired['mount_point']} is mounted with options \" +\n \"#{canonicalize_opts(mounted['mount_options'])} instead of \" +\n canonicalize_opts(desired['opts']).to_s,\n )\n return :remount\n end\n end\n end\n # OK, if that's not the case, we don't have the same device, which\n # is OK. Find out if we have something mounted at the same spot, and\n # get its device name so we can find it's entry in node['filesystem']\n if fs_data['by_mountpoint'][desired['mount_point']]\n # If we are here the mountpoints are the same...\n mounted = fs_data['by_mountpoint'][desired['mount_point']].to_hash\n # OK, if it's tmpfs as well, we're diong good\n if mounted['fs_type'] == 'tmpfs'\n Chef::Log.warn(\n \"fb_fstab: Treating #{mounted['devices']} on \" +\n \"#{desired['mount_point']} the same as #{desired['device']} on \" +\n \"#{desired['mount_point']} because they are both tmpfs.\",\n )\n Chef::Log.debug(\n \"fb_fstab: tmpfs #{desired['device']} on \" +\n \"#{desired['mount_point']} is currently mounted...\",\n )\n Chef::Log.debug(\"fb_fstab: #{desired} vs #{mounted}\")\n if compare_opts(desired['opts'], mounted['mount_options'])\n Chef::Log.debug('fb_fstab: ... with identical options.')\n return :same\n else\n Chef::Log.debug(\n \"fb_fstab: ... with different options #{desired['opts']} vs \" +\n mounted['mount_options'].join(','),\n )\n Chef::Log.info(\n \"fb_fstab: #{desired['mount_point']} is mounted with options \" +\n \"#{canonicalize_opts(mounted['mount_options'])} instead of \" +\n canonicalize_opts(desired['opts']).to_s,\n )\n return :remount\n end\n end\n Chef::Log.warn(\n \"fb_fstab: tmpfs is desired on #{desired['mount_point']}, but \" +\n \"non-tmpfs #{mounted['devices']} (#{mounted['fs_type']}) currently \" +\n 'mounted there.',\n )\n return :conflict\n end\n :missing\n end",
"def get_filesystem\n @@current_fake ? @@current_fake[:filesystem] : ''\n end",
"def DetectFs(device)\n ret = :unknown\n Builtins.y2milestone(\"DetectFs:%1\", device)\n vinfo = ::Storage::VolumeInfo.new()\n r = @sint.getVolume(device, vinfo)\n if r != 0\n Builtins.y2error(\"DetectFs device:%1 not found (ret:%2)\", device, r)\n else\n curr = {}\n curr = volumeMap(vinfo, curr)\n ret = Ops.get_symbol(curr, \"detected_fs\", :unknown)\n end\n Builtins.y2milestone(\"DetectFs ret %1\", ret)\n ret\n end",
"def filesystem\n platform_service(:filesystem)\n end",
"def mount_status(desired)\n # We treat tmpfs specially. While we don't want people to mount tmpfs with\n # a device of 'none' or 'tmpfs', we also don't want to make them remount\n # (and lose all their data) just to convert to fb_fstab. So we'll make\n # them use a new name in the config, but we will treat the pre-mounted\n # mounts as valid/the same. Besides, since the device is meaningless, we\n # can just ignore it for the purposes of this test anyway.\n if desired['type'] == 'tmpfs'\n return tmpfs_mount_status(desired)\n end\n\n key = \"#{desired['device']},#{desired['mount_point']}\"\n fs_data = node.filesystem_data\n mounted = nil\n if fs_data['by_pair'][key]\n mounted = fs_data['by_pair'][key].to_hash\n else\n key = \"#{desired['device']}/,#{desired['mount_point']}\"\n if fs_data['by_pair'][key]\n mounted = fs_data['by_pair'][key].to_hash\n end\n end\n\n if mounted\n Chef::Log.debug(\n \"fb_fstab: There is an entry in node['filesystem'] for #{key}\",\n )\n # If it's a virtual device, we require the fs type to be identical.\n # otherwise, we require them to be similar. This is because 'auto'\n # is meaningless without a physical device, so we don't want to allow\n # it to be the same.\n if compare_fstype(desired['type'], mounted['fs_type']) ||\n (desired['device'].start_with?('/') &&\n [desired['type'], mounted['fs_type']].include?('auto'))\n Chef::Log.debug(\n \"fb_fstab: FS #{desired['device']} on #{desired['mount_point']}\" +\n ' is currently mounted...',\n )\n if compare_opts(desired['opts'], mounted['mount_options'])\n Chef::Log.debug('fb_fstab: ... with identical options.')\n return :same\n else\n Chef::Log.debug(\n \"fb_fstab: ... with different options #{desired['opts']} vs \" +\n mounted['mount_options'].join(','),\n )\n Chef::Log.info(\n \"fb_fstab: #{desired['mount_point']} is mounted with options \" +\n \"#{canonicalize_opts(mounted['mount_options'])} instead of \" +\n canonicalize_opts(desired['opts']).to_s,\n )\n return :remount\n end\n else\n Chef::Log.warn(\n \"fb_fstab: Device #{desired['device']} is mounted at \" +\n \"#{mounted['mount']} as desired, but with fstype \" +\n \"#{mounted['fs_type']} instead of #{desired['type']}\",\n )\n return :conflict\n end\n end\n\n # In this case we don't have the device we expect at the mountpoint we\n # expect. Assuming it's not NFS/Gluster which can be mounted in more than\n # once place, we look up this device and see if it moved or just isn't\n # mounted\n unless ['nfs', 'nfs4', 'glusterfs'].include?(desired['type'])\n device = fs_data['by_device'][desired['device']]\n # Here we are checking if the device we want\n # has already a mount defined\n # We want to return :moved if it does except\n # in the case when it's a btrfs\n # disk and our desired and current options\n # are trying to mount different subvolumes\n if device && device['mounts'] && !device['mounts'].empty? &&\n !(\n FB::Fstab.btrfs_subvol?(\n device['fs_type'],\n device['mount_options'].join(','),\n ) &&\n FB::Fstab.btrfs_subvol?(\n desired['type'],\n desired['opts'],\n ) &&\n !FB::Fstab.same_subvol?(\n device['mounts'][0],\n device['mount_options'].join(','),\n desired['opts'],\n )\n )\n\n Chef::Log.warn(\n \"fb_fstab: #{desired['device']} is at #{device['mounts']}, but\" +\n \" we want it at #{desired['mount_point']}\",\n )\n return :moved\n end\n end\n\n # Ok, this device isn't mounted, but before we return we need to check\n # if anything else is mounted where we want to be.\n if fs_data['by_mountpoint'][desired['mount_point']]\n devices = fs_data['by_mountpoint'][\n desired['mount_point']]['devices']\n Chef::Log.warn(\n \"fb_fstab: Device #{desired['device']} desired at \" +\n \"#{desired['mount_point']} but something #{devices} already \" +\n 'mounted there.',\n )\n return :conflict\n end\n :missing\n end",
"def get_fs_type(device)\n fs_check = Mixlib::ShellOut.new(\"blkid -c /dev/null #{device}\")\n fs_check.run_command\n match = fs_check.stdout.match(/TYPE=\\\"(.*)\\\"/)\n match = '' if match.nil?\n\n match[1]\nend",
"def fs_value(p, val)\n key = case val\n when 'size'\n 'kb_size'\n when 'used'\n 'kb_used'\n when 'available'\n 'kb_available'\n when 'percent'\n 'percent_used'\n else\n fail \"fb_helpers: Unknown FS val #{val} for node.fs_value\"\n end\n fs = self.filesystem_data\n # Some things like /dev/root and rootfs have same mount point...\n if fs && fs['by_mountpoint'] && fs['by_mountpoint'][p] &&\n fs['by_mountpoint'][p][key]\n return fs['by_mountpoint'][p][key].to_f\n end\n\n Chef::Log.warn(\n \"fb_helpers: Tried to get filesystem information for '#{p}', but it \" +\n 'is not a recognized filesystem, or does not have the requested info.',\n )\n nil\n end",
"def ExtFs(fs)\n fs == :ext2 || fs == :ext3 || fs == :ext4\n end",
"def check_unwanted_filesystems\n # extra things to skip\n devs_to_skip = node['fb_fstab']['umount_ignores']['devices'].dup\n dev_prefixes_to_skip =\n node['fb_fstab']['umount_ignores']['device_prefixes'].dup\n mounts_to_skip =\n node['fb_fstab']['umount_ignores']['mount_points'].dup\n mount_prefixes_to_skip =\n node['fb_fstab']['umount_ignores']['mount_point_prefixes'].dup\n mount_regexes_to_skip =\n node['fb_fstab']['umount_ignores']['mount_point_regexes'].dup\n fstypes_to_skip = node['fb_fstab']['umount_ignores']['types'].dup\n\n base_mounts = get_unmasked_base_mounts(:hash)\n\n # we're going to iterate over specified mounts a lot, lets dump it\n desired_mounts = node['fb_fstab']['mounts'].to_hash\n\n fs_data = node.filesystem_data\n fs_data['by_pair'].to_hash.each_value do |mounted_data|\n # ohai uses many things to populate this structure, one of which\n # is 'blkid' which gives info on devices that are not currently\n # mounted. This skips those, plus swap, of course.\n unless mounted_data['mount']\n Chef::Log.debug(\n \"fb_fstab: Skipping umount check for #{mounted_data['device']} \" +\n \"- it isn't mounted.\",\n )\n next\n end\n # Work around chef 12 ohai bug\n if mounted_data.key?('inodes_used') && !mounted_data.key?('kb_used')\n Chef::Log.debug(\n 'fb_fstab: Skipping mal-formed Chef 12 \"df -i\" entry ' +\n mounted_data.to_s,\n )\n next\n end\n # skip anything seemingly magical\n if devs_to_skip.include?(mounted_data['device'])\n Chef::Log.debug(\n \"fb_fstab: Skipping umount check for #{mounted_data['device']} \" +\n \"(#{mounted_data['mount']}): exempted device\",\n )\n next\n elsif mounts_to_skip.include?(mounted_data['mount'])\n Chef::Log.debug(\n \"fb_fstab: Skipping umount check for #{mounted_data['device']} \" +\n \"(#{mounted_data['mount']}): exempted mountpoint\",\n )\n next\n elsif fstypes_to_skip.include?(mounted_data['fs_type'])\n Chef::Log.debug(\n \"fb_fstab: Skipping umount check for #{mounted_data['device']} \" +\n \"(#{mounted_data['mount']}): exempted fstype\",\n )\n next\n elsif dev_prefixes_to_skip.any? do |i|\n mounted_data['device']&.start_with?(i)\n end\n Chef::Log.debug(\n \"fb_fstab: Skipping umount check for #{mounted_data['device']} \" +\n \"(#{mounted_data['mount']}) - exempted device prefix\",\n )\n next\n elsif mount_prefixes_to_skip.any? do |i|\n mounted_data['mount']&.start_with?(i)\n end\n Chef::Log.debug(\n \"fb_fstab: Skipping umount check for #{mounted_data['device']} \" +\n \"(#{mounted_data['mount']}) - exempted mount_point prefix\",\n )\n next\n elsif mount_regexes_to_skip.any? do |i|\n mounted_data['mount'] =~ /#{i}/\n end\n Chef::Log.debug(\n \"fb_fstab: Skipping umount check for #{mounted_data['device']} \" +\n \"(#{mounted_data['mount']}) - exempted mount_point regex\",\n )\n next\n end\n\n # Is this device in our list of desired mounts?\n next if should_keep(mounted_data, desired_mounts, base_mounts)\n\n if node['fb_fstab']['enable_unmount']\n converge_by \"unmount #{mounted_data['mount']}\" do\n umount(mounted_data['mount'], mounted_data['lock_file'], node['fb_fstab']['umount_delete_empty_mountdir'])\n end\n else\n Chef::Log.warn(\n \"fb_fstab: Would umount #{mounted_data['device']} from \" +\n \"#{mounted_data['mount']}, but \" +\n 'node[\"fb_fstab\"][\"enable_unmount\"] is false',\n )\n Chef::Log.debug(\"fb_fstab: #{mounted_data}\")\n end\n end\n end",
"def getFsPath(path)\n if path.kind_of? Array\n if path.length == 0\n localPath = @cwd.dup\n else\n localPath = normalizePath(path[0].dup)\n end\n else\n localPath = normalizePath(path.dup)\n end\n\n dl = localPath.slice!(0..1).upcase\n raise MiqException::MiqVmMountError, \"Unknown drive letter - #{dl}\" unless (fs = @driveToFS[dl])\n return fs, localPath\n end",
"def fs_remote?(mount)\n fs_type(mount) == 'nfs'\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 floadfs(name)\n if floadf name\n s = fslistf name\n s.each do |i|\n floadf i\n end\n return true\n else\n return false\n end\nend",
"def is_mounted?(device)\n system(\"grep -q '#{device}' /proc/mounts\")\nend",
"def zfs_exist?(name)\n cmd = Mixlib::ShellOut.new('zfs', 'get', 'mountpoint', name)\n cmd.environment['PATH'] = \"/usr/sbin:#{ENV['PATH']}\" if platform_family?('solaris2')\n cmd.run_command\n cmd.exitstatus == 0\nend",
"def root_fs\n\t\t\t\tfind_root[2].to_s\n\t\t\tend",
"def filesystem_labels\n\n labels = {}\n\n mount = capture_command_output('mount')\n mount.each do |mount_line|\n\n mount_line.strip!\n device = mount_line.match(/^(.*?) on/)[1]\n\n if PlatformInfo.linux?\n\n # /dev/hda3 on / type ext4 (rw,errors=remount-ro)\n mount_point = mount_line.match(/^#{Regexp.quote(device)} on (.*?) type/)[1]\n fs_type = mount_line.match(/type (.*?) \\(/)[1]\n\n elsif PlatformInfo.osx?\n\n # /dev/disk0s2 on / (hfs, local, journaled)\n mount_point = mount_line.match(/^#{Regexp.quote(device)} on (.*?) \\(/)[1]\n fs_type = mount_line.match(/ \\((.*?), /)[1]\n \n else\n unsupported_platform\n end\n\n labels[device] = {\n :mount_point => mount_point,\n :file_system => fs_type\n }\n\n end\n\n labels\n\n end",
"def find_fstab(partitions, path)\n fstab = ''\n partitions.each do |p|\n OpenNebula.log(\"Looking for fstab on #{p['path']}\")\n\n rc = mount_dev(p['path'], path)\n next unless rc\n\n bin = COMMANDS[:catfstab]\n bin = COMMANDS[:cat] unless path.include?('containers/one-')\n\n cmd = \"#{bin} #{path}/etc/fstab\"\n\n _rc, fstab, _e = Command.execute(cmd, false)\n\n if fstab.empty?\n return false unless umount_dev(p['path'])\n\n next\n end\n\n OpenNebula.log(\"Found fstab on #{p['path']}\")\n break\n end\n\n return fstab unless fstab.empty?\n\n OpenNebula.log_error('No fstab file found')\n\n false\n end",
"def device_of_mount(m)\n fs = self.filesystem_data\n unless Pathname.new(m).mountpoint?\n Chef::Log.warn(\n \"fb_helpers: #{m} is not a mount point - I can't determine its \" +\n 'device.',\n )\n return nil\n end\n unless fs && fs['by_pair']\n Chef::Log.warn(\n 'fb_helpers: no filesystem data so no node.device_of_mount',\n )\n return nil\n end\n fs['by_pair'].to_hash.each do |pair, info|\n # we skip fake filesystems 'rootfs', etc.\n next unless pair.start_with?('/')\n # is this our FS?\n next unless pair.end_with?(\",#{m}\")\n # make sure this isn't some fake entry\n next unless info['kb_size']\n\n return info['device']\n end\n Chef::Log.warn(\n \"fb_helpers: #{m} shows as valid mountpoint, but Ohai can't find it.\",\n )\n nil\n end",
"def _are_tmpfs_using_inode64?\n return node.linux? && (FB::Version.new(node['kernel']['release']) > FB::Version.new('5.9'))\n end",
"def device_of_mount(m)\n unless Pathname.new(m).mountpoint?\n Chef::Log.warn(\n \"#{m} is not a mount point - I can't determine its device.\",\n )\n return nil\n end\n node['filesystem2']['by_pair'].to_hash.each do |pair, info|\n # we skip fake filesystems 'rootfs', etc.\n next unless pair.start_with?('/')\n # is this our FS?\n next unless pair.end_with?(\",#{m}\")\n # make sure this isn't some fake entry\n next unless info['kb_size']\n return info['device']\n end\n Chef::Log.warn(\n \"#{m} shows as valid mountpoint, but Ohai can't find it.\",\n )\n return nil\n end",
"def test_data_find\n file = 'foo.dat'\n assert_equal(File.join(Dir.pwd,'home/.local/share', file), XDG.data.find(file))\n file = 'bar.dat'\n assert_equal(File.join(Dir.pwd,'usr/share', file), XDG.data.find(file))\n end",
"def mountpoint?\n begin\n stat1 = expand_tilde.lstat\n stat2 = expand_tilde.parent.lstat\n stat1.dev == stat2.dev && stat1.ino == stat2.ino ||\n stat1.dev != stat2.dev\n rescue Errno::ENOENT\n false\n end\n end",
"def type\n if File.directory?(path)\n return :filesystem\n elsif File.file?(path)\n return :zip\n else\n return :nofile\n end\n end",
"def mountpoint?\n begin\n stat1 = lstat\n stat2 = parent.lstat\n stat1.dev != stat2.dev or stat1.ino == stat2.ino\n rescue Errno::ENOENT\n false\n end\n end",
"def get_1st_partition(device)\n # Resolves the real device name (ex. /dev/sdg)\n Chef::Log.info(\"Getting 1st partition for device: #{device}\")\n fs_check = Mixlib::ShellOut.new(\"lsblk -ln -o Name #{device}|awk 'NR==2'\")\n fs_check.run_command\n partition = \"/dev/\" + fs_check.stdout.strip\n Chef::Log.info(\"1st partition for device: #{device} is: #{partition}\")\n partition\nend",
"def verify_mounted(partition)\n\treturn `grep partition /proc/mounts | wc -l`.chomp\nend",
"def format_filesystem(system_arch, device)\n fs_type = system_arch == \"x86_64\" ? \"XFS\" : \"ext4\"\n puts \"Formatting #{fs_type} filesystem on #{device} ...\"\n\n command = case system_arch\n when \"x86_64\" then \"/sbin/mkfs.xfs -f #{device}\"\n else \"/sbin/mkfs.ext4 -F #{device}\"\n end\n IO.popen(command) do |f|\n while ! f.eof\n puts f.gets\n end\n end\n end",
"def growfs\n case\n when checkfs == false && ismounted == false\n createfs\n when ismounted\n xfs_growfs(@resource[:fs_path])\n info(\"#{@resource[:fs_path]} has been grown\")\n end\n end",
"def get_linux_version_info(iso_file_name)\n iso_info = File.basename(iso_file_name)\n if iso_file_name.match(/purity/)\n iso_info = iso_info.split(/_/)\n else\n iso_info = iso_info.split(/-/)\n end\n linux_distro = iso_info[0]\n linux_distro = linux_distro.downcase\n if linux_distro.match(/^sle$/)\n linux_distro = \"sles\"\n end\n if linux_distro.match(/oraclelinux/)\n linux_distro = \"oel\"\n end\n if linux_distro.match(/centos|ubuntu|sles|sl|oel|rhel/)\n if linux_distro.match(/sles/)\n if iso_info[2].match(/Server/)\n iso_version = iso_info[1]+\".0\"\n else\n iso_version = iso_info[1]+\".\"+iso_info[2]\n iso_version = iso_version.gsub(/SP/,\"\")\n end\n else\n if linux_distro.match(/sl$/)\n iso_version = iso_info[1].split(//).join(\".\")\n if iso_version.length == 1\n iso_version = iso_version+\".0\"\n end\n else\n if linux_distro.match(/oel|rhel/)\n if iso_file_name =~ /-rc-/\n iso_version = iso_info[1..3].join(\".\")\n iso_version = iso_version.gsub(/server/,\"\")\n else\n iso_version = iso_info[1..2].join(\".\")\n iso_version = iso_version.gsub(/[a-z,A-Z]/,\"\")\n end\n iso_version = iso_version.gsub(/^\\./,\"\")\n else\n iso_version = iso_info[1]\n end\n end\n end\n case iso_file_name\n when /i[3-6]86/\n iso_arch = \"i386\"\n when /x86_64/\n iso_arch = \"x86_64\"\n else\n if linux_distro.match(/centos|sl$/)\n iso_arch = iso_info[2]\n else\n if linux_distro.match(/sles|oel/)\n iso_arch = iso_info[4]\n else\n iso_arch = iso_info[3]\n iso_arch = iso_arch.split(/\\./)[0]\n if iso_arch.match(/amd64/)\n iso_arch = \"x86_64\"\n else\n iso_arch = \"i386\"\n end\n end\n end\n end\n else\n if linux_distro.match(/fedora/)\n iso_version = iso_info[1]\n iso_arch = iso_info[2]\n else\n if linux_distro.match(/purity/)\n iso_version = iso_info[1]\n iso_arch = \"x86_64\"\n else\n if linux_distro.match(/vmware/)\n iso_version = iso_info[3].split(/\\./)[0..-2].join(\".\")\n iso_update = iso_info[3].split(/\\./)[-1]\n iso_release = iso_info[4].split(/\\./)[-3]\n iso_version = iso_version+\".\"+iso_update+\".\"+iso_release\n iso_arch = \"x86_64\"\n else\n iso_version = iso_info[2]\n iso_arch = iso_info[3]\n end\n end\n end\n end\n return linux_distro,iso_version,iso_arch\nend",
"def file_system(op, path)\n path = @mudlib_path + path\n if op == :ls\n return Dir.entries(path)\n elsif op == :cat\n if File.file?(path)\n\treturn File.read(path)\n else\n\treturn \"File not found\"\n end\n end\n end",
"def fs_for_select(selected)\n fs_values = [\n \"ext3\",\n \"ext4\",\n \"xfs\",\n \"btrfs\"\n ]\n options_for_select(\n fs_values.zip(fs_values),\n selected.to_s\n )\n end",
"def find_for_fs_path(fs_path)\n fs_path = File.expand_path(fs_path)\n TreeWalker.walk_tree(self) do |node|\n return node if node.fs_path == fs_path\n end\n end",
"def whichfile(cmd)\n\n Chef::Log.debug(\"Executing which #{cmd}\")\n\n shell = Mixlib::ShellOut.new(\"which \" + cmd, :env => { 'PATH' => '/usr/bin:/usr/local/bin:/bin' })\n shell.run_command\n\n unless shell.exitstatus == 0\n return false\n else\n return true\n end\nend",
"def tmpfs\n\t\t\t\tret = {}\n\t\t\t\tmounts.each { |x|\n\t\t\t\t\tret.merge!({x.split[1] => x}) if x.start_with?('tmpfs '.freeze)\n\t\t\t\t}\n\t\t\t\tret\n\t\t\tend",
"def nfs?\n false\n end",
"def storage_use_nfs\n super\n end",
"def prefix\n (platform_family?('windows') ? 'C:/Chef/' : '/etc/chef/')\nend",
"def statfs(ctx,path)\n return wrap_context(ctx,__method__,path) if ctx\n block_size = 1024\n\n stats = @root.statistics(path)\n case stats\n when Array\n used_space, used_files, total_space, total_files = stats\n used_files ||= 0\n used_space ||= 0\n total_files ||= used_files\n total_space ||= used_space\n result = RFuse::StatVfs.new(\n \"bsize\" => block_size,\n \"frsize\" => block_size,\n \"blocks\" => total_space / block_size,\n \"bfree\" => (total_space - used_space)/block_size,\n \"bavail\" => (total_space - used_space)/block_size,\n \"files\" => total_files,\n \"ffree\" => (total_files - used_files)\n )\n return result\n else\n #expected to quack like rfuse:statvfs\n return stats\n end\n end",
"def check_fusion_vm_doesnt_exist(options)\n if options['host-os-name'].to_s.match(/Linux/)\n fusion_vm_dir = options['fusiondir']+\"/\"+options['name']\n else\n fusion_vm_dir = options['fusiondir']+\"/\"+options['name']+\".vmwarevm\"\n end\n fusion_vmx_file = fusion_vm_dir+\"/\"+options['name']+\".vmx\"\n fusion_disk_file = fusion_vm_dir+\"/\"+options['name']+\".vmdk\"\n if File.exist?(fusion_vmx_file)\n handle_output(options,\"Information:\\t#{options['vmapp']} VM #{options['name']} already exists\")\n quit(options)\n end\n return fusion_vm_dir,fusion_vmx_file,fusion_disk_file\nend",
"def using_fake_filesystem\n return false unless MetricFu.configuration.mri?\n require 'fakefs/safe'\n true\nrescue NameError, LoadError\n warn \"Fake filesystem not available\"\n false\nend",
"def setup_disk(path)\n dev = ::File.readlink(path)\n full_path = ::File.absolute_path(dev, ::File.dirname(path))\n\n fs_type = get_fs_type(full_path)\n if fs_type.nil?\n Mixlib::ShellOut.new(\"mkfs.ext4 #{full_path}\").run_command\n fs_type = 'ext4'\n end\n\n fs_type\nend",
"def setup_disk(path)\n dev = ::File.readlink(path)\n full_path = ::File.absolute_path(dev, ::File.dirname(path))\n\n fs_type = get_fs_type(full_path)\n if fs_type.nil?\n Mixlib::ShellOut.new(\"mkfs.ext4 #{full_path}\").run_command\n fs_type = 'ext4'\n end\n\n fs_type\nend",
"def lsblk_path(p)\n return unless !p['path'] && p['name']\n\n if File.exist?(\"/dev/#{p['name']}\")\n p['path'] = \"/dev/#{p['name']}\"\n elsif File.exist?(\"/dev/mapper/#{p['name']}\")\n p['path'] = \"/dev/mapper/#{p['name']}\"\n end\n end",
"def bindfs_fuse_loaded(machine)\n machine.guest.capability(:bindfs_fuse_installed)\n end",
"def fs(path)\n OodAppkit.files.url(path: path).to_s\n end",
"def find(feature)\n reinitialize if (@has_relative_paths && dir_changed?) || stale?\n feature = feature.to_s.freeze\n\n return feature if Bootsnap.absolute_path?(feature)\n\n if feature.start_with?(\"./\", \"../\")\n return expand_path(feature)\n end\n\n @mutex.synchronize do\n x = search_index(feature)\n return x if x\n\n # Ruby has some built-in features that require lies about.\n # For example, 'enumerator' is built in. If you require it, ruby\n # returns false as if it were already loaded; however, there is no\n # file to find on disk. We've pre-built a list of these, and we\n # return false if any of them is loaded.\n return false if BUILTIN_FEATURES.key?(feature)\n\n # The feature wasn't found on our preliminary search through the index.\n # We resolve this differently depending on what the extension was.\n case File.extname(feature)\n # If the extension was one of the ones we explicitly cache (.rb and the\n # native dynamic extension, e.g. .bundle or .so), we know it was a\n # failure and there's nothing more we can do to find the file.\n # no extension, .rb, (.bundle or .so)\n when \"\", *CACHED_EXTENSIONS\n nil\n # Ruby allows specifying native extensions as '.so' even when DLEXT\n # is '.bundle'. This is where we handle that case.\n when DOT_SO\n x = search_index(feature[0..-4] + DLEXT)\n return x if x\n\n if DLEXT2\n x = search_index(feature[0..-4] + DLEXT2)\n return x if x\n end\n else\n # other, unknown extension. For example, `.rake`. Since we haven't\n # cached these, we legitimately need to run the load path search.\n return FALLBACK_SCAN\n end\n end\n\n # In development mode, we don't want to confidently return failures for\n # cases where the file doesn't appear to be on the load path. We should\n # be able to detect newly-created files without rebooting the\n # application.\n return FALLBACK_SCAN if @development_mode\n end",
"def mountpoint?\n begin\n stat1 = self.lstat\n stat2 = self.parent.lstat\n stat1.dev == stat2.dev && stat1.ino == stat2.ino ||\n stat1.dev != stat2.dev\n rescue Errno::ENOENT\n false\n end\n end",
"def looks_like_orionvm_v2?\n File.exists?('/etc/orion_base')\n end",
"def path_boot\n case node['platform']\n when \"exherbo\", \"ubuntu\", \"arch\"\n return \"/etc/modules-load.d/#{new_resource.name}.conf\"\n when \"debian\", \"ubuntu\"\n return \"/etc/modules\"\n end\nend",
"def current\n return {} unless device && node[:filesystem] && node[:filesystem][ device ]\n curr = Mash.new(node[:filesystem][ device ].to_hash)\n curr['fstype'] ||= curr['fs_type']\n curr\n end",
"def filemoniker(io)\n c_anti, ansi_length = io.read(6).unpack('vV')\n ansi_path = io.read(ansi_length).unpack('Z*').first.encode(Encoding::ASCII, { invalid: :replace, undef: :replace }) # 0-terminated\n\n result = {\n cAnti: c_anti, # cAnti (2 bytes): An unsigned integer that specifies the number of parent directory indicators at the beginning of the ansiPath field.\n ansiLength: ansi_length, # ansiLength (4 bytes): An unsigned integer that specifies the number of ANSI characters in ansiPath, including the terminating NULL character. This value MUST be less than or equal to 32767.\n ansiPath: ansi_path, # ansiPath (variable): A null-terminated array of ANSI characters that specifies the file path. The number of characters in the array is specified by ansiLength.\n }\n\n end_server = io.read(2).unpack('v').first\n path_is_unc = end_server != 0xFFFF\n result[:endServer] = end_server if path_is_unc # endServer (2 bytes): An unsigned integer that specifies the number of Unicode characters used to specify the server portion of the path if the path is a UNC path (including the leading \"\\\\\"). If the path is not a UNC path, this field MUST equal 0xFFFF.\n\n result[:versionNumber] = io.read(2).unpack('v').first # versionNumber (2 bytes): An unsigned integer that specifies the version number of this file moniker serialization implementation. MUST equal 0xDEAD.\n\n io.read(20) # reserved1 (16 bytes): MUST be zero and MUST be ignored; reserved2 (4 bytes): MUST be zero and MUST be ignored.\n\n result[:cbUnicodePathSize] = io.read(4).unpack('V').first # cbUnicodePathSize (4 bytes): An unsigned integer that specifies the size, in bytes, of cbUnicodePathBytes, usKeyValue, and unicodePath.\n return result if result[:cbUnicodePathSize] == 0 # ansiPath can be fully specified in ANSI characters\n\n cb_unicode_path_bytes, _ = io.read(6).unpack('Vv')\n result[:cbUnicodePathBytes] = cb_unicode_path_bytes # cbUnicodePathBytes (4 bytes): An optional unsigned integer that specifies the size, in bytes, of the unicodePath field. This field exists if and only if cbUnicodePathSize is greater than zero.\n # (skipped) usKeyValue (2 bytes): An optional unsigned integer that MUST be 3 if present. This field exists if and only if cbUnicodePathSize is greater than zero.\n result[:unicodePath] = _db_unterminated(io, cb_unicode_path_bytes) # unicodePath (variable): An optional array of Unicode characters that specifies the complete file path. This path MUST be the complete Unicode version of the file path specified in ansiPath and MUST include additional Unicode characters that cannot be completely specified in ANSI characters. The number of characters in this array is specified by cbUnicodePathBytes/2. This array MUST NOT include a terminating NULL character. This field exists if and only if cbUnicodePathSize is greater than zero.\n\n result\n end",
"def available(fs = ?/.freeze)\n\t\t\t\ts = stat_raw(fs)\n\t\t\t\treturn nil if s.empty?\n\t\t\t\ts.default = 0\n\t\t\t\ts[:block_size] * s[:block_avail_unpriv]\n\t\t\tend",
"def get_partition_info\n # remove leading slash so it matches the packages.DU path\n remove_slash = true\n\n if !Stage.initial\n # read /proc/mounts as a list of maps\n # $[\"file\":\"/boot\", \"freq\":0, \"mntops\":\"rw\", \"passno\":0, \"spec\":\"/dev/sda1\", \"vfstype\":\"ext2\"]\n mounts = Convert.convert(\n SCR.Read(path(\".proc.mounts\")),\n :from => \"any\",\n :to => \"list <map <string, any>>\"\n )\n Builtins.y2milestone(\"mounts %1\", mounts)\n\n partitions = []\n Builtins.foreach(mounts) do |mpoint|\n name = Ops.get_string(mpoint, \"file\", \"\")\n if Builtins.substring(name, 0, 1) == \"/\" &&\n Builtins.substring(name, 0, 5) != \"/dev/\" && # filter out /dev/pts etc.\n Ops.get_string(mpoint, \"vfstype\", \"\") != \"rootfs\" # filter out duplicate \"/\" entry\n capacity = Pkg.TargetCapacity(name)\n if capacity != 0 # dont look at pseudo-devices (proc, shmfs, ...)\n used = Pkg.TargetUsed(name)\n partitions = Builtins.add(\n partitions,\n {\n \"name\" => name,\n \"free\" => Ops.subtract(capacity, used),\n \"used\" => used\n }\n )\n end\n end\n end\n Pkg.TargetInitDU(partitions)\n Builtins.y2milestone(\"get_partition_info: %1\", partitions)\n return deep_copy(partitions)\n end # !Stage::initial ()\n\n # remove the previous failures\n @failed_mounts = []\n\n # installation stage - Storage:: is definitely present\n # call Storage::GetTargetMap()\n targets = Convert.convert(\n WFM.call(\"wrapper_storage\", [\"GetTargetMap\"]),\n :from => \"any\",\n :to => \"map <string, map>\"\n )\n\n if targets == nil\n Builtins.y2error(\"Target map is nil, Storage:: is probably missing\")\n end\n\n if Mode.test\n targets = Convert.convert(\n SCR.Read(path(\".target.yast2\"), \"test_target_map.ycp\"),\n :from => \"any\",\n :to => \"map <string, map>\"\n )\n end\n\n target_partitions = []\n min_spare = 20 * 1024 * 1024 # minimum free space ( 20 MB )\n\n Builtins.foreach(targets) do |disk, diskinfo|\n part_info = Ops.get_list(diskinfo, \"partitions\", [])\n Builtins.foreach(part_info) do |part|\n Builtins.y2milestone(\"Adding partition: %1\", part)\n used_fs = Ops.get_symbol(part, \"used_fs\", :unknown)\n # ignore VFAT and NTFS partitions (bnc#)\n if used_fs == :vfat || used_fs == :ntfs\n Builtins.y2warning(\n \"Ignoring partition %1 with %2 filesystem\",\n Ops.get_string(part, \"device\", \"\"),\n used_fs\n )\n else\n free_size = 0\n\n if Ops.get(part, \"mount\") != nil &&\n Builtins.substring(Ops.get_string(part, \"mount\", \"\"), 0, 1) == \"/\"\n if Ops.get(part, \"create\") == true ||\n Ops.get(part, \"delete\") == false ||\n Ops.get(part, \"create\") == nil &&\n Ops.get(part, \"delete\") == nil\n Builtins.y2debug(\n \"get_partition_info: adding partition: %1\",\n part\n )\n\n # get free_size on partition in kBytes\n free_size = Ops.multiply(\n Ops.get_integer(part, \"size_k\", 0),\n 1024\n )\n free_size = Ops.subtract(free_size, min_spare)\n\n # free_size smaller than min_spare, fix negative value\n if Ops.less_than(free_size, 0)\n Builtins.y2milestone(\"Fixing free size: %1 to 0\", free_size)\n free_size = 0\n end\n\n used = 0\n if !(Ops.get_boolean(part, \"create\", false) ||\n Ops.get_boolean(part, \"format\", false))\n tmpdir = Convert.to_string(SCR.Read(path(\".target.tmpdir\")))\n tmpdir = Ops.add(tmpdir, \"/diskspace_mount\")\n SCR.Execute(\n path(\".target.bash\"),\n Builtins.sformat(\"test -d %1 || mkdir -p %1\", tmpdir)\n )\n\n # mount in read-only mode (safer)\n mount_options = [\"ro\"]\n\n # add \"nolock\" if it's a NFS share (bnc#433893)\n if used_fs == :nfs\n Builtins.y2milestone(\"Mounting NFS with 'nolock' option\")\n mount_options = Builtins.add(mount_options, \"nolock\")\n end\n\n # join the options\n mount_options_str = Builtins.mergestring(mount_options, \",\")\n\n mount_command = Builtins.sformat(\n \"/bin/mount -o %1 %2 %3\",\n mount_options_str,\n Ops.get_string(part, \"device\", \"\"),\n tmpdir\n )\n\n Builtins.y2milestone(\n \"Executing mount command: %1\",\n mount_command\n )\n\n result = Convert.to_integer(\n SCR.Execute(path(\".target.bash\"), mount_command)\n )\n Builtins.y2milestone(\"Mount result: %1\", result)\n\n if result == 0\n partition = Convert.convert(\n SCR.Read(path(\".run.df\")),\n :from => \"any\",\n :to => \"list <map <string, string>>\"\n )\n Builtins.foreach(partition) do |p|\n if Ops.get_string(p, \"name\", \"\") == tmpdir\n Builtins.y2internal(\"P: %1\", p)\n free_size = Ops.multiply(\n Builtins.tointeger(Ops.get_string(p, \"free\", \"0\")),\n 1024\n )\n used = Ops.multiply(\n Builtins.tointeger(Ops.get_string(p, \"used\", \"0\")),\n 1024\n )\n end\n end\n SCR.Execute(\n path(\".target.bash\"),\n Builtins.sformat(\"/bin/umount %1\", tmpdir)\n )\n else\n Builtins.y2error(\n \"Mount failed, ignoring partition %1\",\n Ops.get_string(part, \"device\", \"\")\n )\n @failed_mounts = Builtins.add(@failed_mounts, part)\n\n next\n end\n else\n # for formatted partitions estimate free system size\n # compute fs overhead\n used = EstimateFsOverhead(part)\n\n if Ops.greater_than(used, 0)\n Builtins.y2milestone(\n \"Partition %1: assuming fs overhead: %2kB\",\n Ops.get_string(part, \"device\", \"\"),\n Ops.divide(used, 1024)\n )\n end\n\n # journal size\n js = 0\n\n if ExtFs(used_fs)\n js = ExtJournalSize(part)\n reserved = ReservedSpace(part)\n\n if Ops.greater_than(reserved, 0)\n used = Ops.add(used, reserved)\n end\n elsif used_fs == :xfs\n js = XfsJournalSize(part)\n elsif used_fs == :reiser\n js = ReiserJournalSize(part)\n elsif used_fs == :jfs\n js = JfsJournalSize(part)\n else\n Builtins.y2warning(\n \"Unknown journal size for filesystem: %1\",\n used_fs\n )\n end\n\n if Ops.greater_than(js, 0)\n Builtins.y2milestone(\n \"Partition %1: assuming journal size: %2kB\",\n Ops.get_string(part, \"device\", \"\"),\n Ops.divide(js, 1024)\n )\n used = Ops.add(used, js)\n end\n\n # decrease free size\n free_size = Ops.subtract(free_size, used)\n\n # check for underflow\n if Ops.less_than(free_size, 0)\n Builtins.y2milestone(\"Fixing free size: %1 to 0\", free_size)\n free_size = 0\n end\n end\n\n # convert into kB for TargetInitDU\n free_size = Ops.divide(free_size, 1024)\n used = Ops.divide(used, 1024)\n\n Builtins.y2milestone(\n \"available partition: mount: %1, free: %2 KB, used: %3 KB\",\n Ops.get_string(part, \"mount\", \"\"),\n free_size,\n used\n )\n if !remove_slash\n target_partitions = Builtins.add(\n target_partitions,\n {\n \"name\" => Ops.get_string(part, \"mount\", \"\"),\n \"used\" => used,\n \"free\" => free_size\n }\n )\n else\n part_name = \"\"\n mount_name = Ops.get_string(part, \"mount\", \"\")\n\n if mount_name != \"/\"\n part_name = Builtins.substring(\n mount_name,\n 1,\n Builtins.size(mount_name)\n )\n else\n part_name = mount_name\n end\n\n target_partitions = Builtins.add(\n target_partitions,\n { \"name\" => part_name, \"used\" => used, \"free\" => free_size }\n )\n end\n end\n end\n end\n end # foreach (`part)\n end # foreach (`disk)\n\n # add estimated size occupied by non-package files\n target_partitions = EstimateTargetUsage(target_partitions)\n\n Builtins.y2milestone(\"get_partition_info: part %1\", target_partitions)\n Pkg.TargetInitDU(target_partitions)\n\n deep_copy(target_partitions)\n end",
"def using_nfs?\n !!synced_folders(@machine)[:nfs]\n end",
"def filesystem_usage\n\n usage = {}\n\n df = capture_command_output('df', '-k')[1..-1] # Don't include the column headers.\n df.each do |df_line|\n\n df_line.strip!\n device = df_line.match(/^(.*?)\\s{2,}/)[1]\n tokens = df_line.gsub(/^#{Regexp.quote(device)}\\s+/, '').split(/\\s+/, 5)\n \n # Convert all KB values to bytes.\n size = tokens[0].to_i * 1024\n used = tokens[1].to_i * 1024\n available = tokens[2].to_i * 1024\n used_percentage = tokens[3].to_i\n\n usage[device] = {\n :size => size,\n :used => used,\n :used_percentage => used_percentage,\n :available => available\n }\n\n end\n\n usage\n\n end",
"def file_system\n if !block_given?\n if @cached_file_system != nil\n return @cached_file_system\n end\n return @cached_file_system = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:fileSystem, []).call(),::Vertx::FileSystem)\n end\n raise ArgumentError, \"Invalid arguments when calling file_system()\"\n end",
"def installed?(tool)\n # first: check with updatedb\n if session.locate_updatedb? == true\n out = ''\n if (session.methods.include? :cache) && session.cache.exists?(\"ls_path\")\n out = session.cache.read(\"ls_path\")\n else\n out = ''\n env_paths = get_all_path\n for path in env_paths\n out << session.updatedb_search(path).join(\"\\n\").to_s\n end\n end\n session.cache.add(\"ls_path\", out) if session.methods.include? :cache\n\n out.each_line do |line|\n line.chomp!\n return line if line =~ /\\/#{tool}$/\n end\n end\n\n # second: if cache run ls for every path once and cache it\n if session.methods.include? :cache\n out = ''\n if session.cache.exists?(\"ls_path\")\n out = session.cache.read(\"ls_path\")\n else\n env_paths = get_all_path\n # ls:\n # -m fill width with a comma separated list of entries\n cmd = \"/bin/ls -m\"\n for path in env_paths\n # adding timeout because it may need some time if many\n # tools are installed\n # out << cmd_exec(\"#{cmd} #{path}/*\", 20, 60 * 2)\n tmp = session.shell_command_token(\"#{cmd} #{path}/*\", 20, 60 * 2)\n tmp.split(',').each do |tmp_tool|\n tmp_tool.chomp!\n tmp_tool.strip!\n out << tmp_tool + \"\\n\"\n end\n end\n # out.gsub!(\"\\t\", \"\\n\")\n session.cache.add(\"ls_path\", out)\n end\n out.each_line do |line|\n line.chomp!\n return line if line =~ /\\/#{tool}$/\n end\n\n return false\n end\n\n # third: fallback: using traditional which\n out = cmd_exec(\"which #{tool}\")\n if out[0, 1] == '/'\n return out\n else\n return nil\n end\n end",
"def filetype f\n return nil unless f\n\n f = Shellwords.escape(f)\n s = `file #{f}`\n return :text if s.index 'text'\n return :zip if s.index(/[Zz]ip/)\n return :zip if s.index('archive')\n return :image if s.index 'image'\n return :sqlite if s.index 'SQLite'\n # return :db if s.index 'database'\n return :text if s.index 'data'\n\n nil\nend",
"def get_existing_spec_location\n [ \n \"#{Dir.pwd}/#{Default.default_specfile_name}\",\n Dir[\"#{Dir.pwd}/*/#{Default.default_specfile_name}\"],\n \"#{Default.remote_storage_path}/#{Default.default_specfile_name}\", \n \"#{Default.default_specfile_name}\", \n \"#{Default.base_config_directory}/#{Default.default_specfile_name}\",\n \"#{Default.poolparty_home_path}/#{Default.default_specfile_name}\", \n ENV[\"POOL_SPEC\"]\n ].flatten.reject {|a| a.nil?}.reject do |f|\n f unless ::File.readable?(f)\n end.first\n end",
"def centos?\n File.exist?('/etc/centos-release')\nend",
"def create_filesystem(fstype, where, label)\n if fstype == 'fat32'\n execute!(\"mkfs.fat -F -F32 -n#{label} #{where}\")\n elsif fstype == 'fat16'\n execute!(\"mkfs.fat -F -F16 -n#{label} #{where}\")\n elsif fstype == 'swap'\n execute!(\"mkswap -L #{label} #{where}\")\n else\n execute!(\"mkfs.#{fstype} -L \\\"#{label}\\\" #{where}\")\n end\n end",
"def find_root\n pwd = Dir.pwd\n if pwd.end_with? \"rootfs\"\n \"\" # analysing a supportconfig\n elsif pwd =~ %r{/nts_} && File.directory?(\"rootfs\")\n \"rootfs/\" # analysing a supportconfig\n elsif File.exist? \"/var/log/crowbar/install.log\"\n \"/\" # on an actual admin server\n else\n abort \"Couldn't find log files; aborting.\"\n end\nend",
"def get_disk_util\n used_info = query_data(params[:host], 'df.1kblocks.used', params[:from_ts], params[:to_ts])\n total_info = query_data(params[:host], 'df.1kblocks.total', params[:from_ts], params[:to_ts])\n\n used_info.delete_if { |k, v|\n k.index(\"fstype=tmpfs\")\n }\n total_info.delete_if { |k, v|\n k.index(\"fstype=tmpfs\")\n }\n \n results = {}\n used_info.each { |k, v|\n matcher = /mount=([\\/\\w]+) /.match(k)\n if matcher\n path = matcher[1]\n\n if total_info.has_key?(k)\n total_v = total_info[k]\n total_v_map = Hash[total_v]\n results[path] = v.collect { |point|\n ts = point[0]\n if (total_v_map.has_key?(ts))\n [ts, format(\"%.2f\", point[1] * 100.0 / total_v_map[ts]).to_f]\n end\n }.keep_if { |v| v }\n end\n end\n }\n\n render json: results\n end",
"def mounted?(name)\n mount_loc = File.join(KVM_MOUNT_POINT, name)\n system(\"mount | grep #{mount_loc}\")\nend",
"def get_mounts\n mount_hash = {}\n mounts = File.open(\"/etc/mtab\", \"r\").read.split(\"\\n\").map{|l| l.split(/\\s+/)}\n mounts.each{|m| mount_hash[m[1]] = m[0] unless %w[devpts udev sysfs tmpfs none proc].include?(m[0])}\n mount_hash\nend",
"def disk?\n ! url?\n end",
"def stdlib_path?(file); end",
"def RunFSCKonJFS(mount_type, device, error_message)\n # #176292, run fsck before jfs is mounted\n if mount_type == \"jfs\" && device != \"\"\n if Builtins.contains(@already_checked_jfs_partitions, device)\n Builtins.y2milestone(\"Device %1 has been already checked...\", device)\n return true\n end\n\n UI.OpenDialog(\n Label(Builtins.sformat(_(\"Checking file system on %1...\"), device))\n )\n\n Builtins.y2milestone(\"Running fsck on %1\", device)\n # -n == Check read only, make no changes to the file system.\n cmd = Convert.to_map(\n SCR.Execute(\n path(\".target.bash_output\"),\n Builtins.sformat(\"fsck.jfs -n %1\", device)\n )\n )\n\n UI.CloseDialog\n\n # failed\n if Ops.get(cmd, \"exit\") != 0\n Builtins.y2error(\"Result: %1\", cmd)\n error_message.value = Builtins.tostring(Ops.get(cmd, \"stderr\"))\n\n details = \"\"\n if Ops.get_string(cmd, \"stdout\", \"\") != \"\"\n details = Ops.add(details, Ops.get_string(cmd, \"stdout\", \"\"))\n end\n if Ops.get_string(cmd, \"stderr\", \"\") != \"\"\n details = Ops.add(\n Ops.add(details == \"\" ? \"\" : \"\\n\", details),\n Ops.get_string(cmd, \"stderr\", \"\")\n )\n end\n\n return AnyQuestionAnyButtonsDetails(\n # popup headline\n _(\"File System Check Failed\"),\n Builtins.sformat(\n # popup question (continue/cancel dialog)\n # %1 is a device name such as /dev/hda5\n _(\n \"The file system check of device %1 has failed.\\n\" +\n \"\\n\" +\n \"Do you want to continue mounting the device?\\n\"\n ),\n device\n ),\n Label.ContinueButton,\n # button\n _(\"&Skip Mounting\"),\n details\n ) \n # succeeded\n else\n # add device into the list of already checked partitions (with exit status 0);\n @already_checked_jfs_partitions = Builtins.add(\n @already_checked_jfs_partitions,\n device\n )\n Builtins.y2milestone(\"Result: %1\", cmd)\n return true\n end\n end\n\n true\n end",
"def first_os_partition\n os_part = @partition_layout.detect { |p| p.os == true }\n return os_part if os_part\n\n # Next look for an OS in a LVM partition\n lvm_part = @partition_layout.detect { |p| p.lvm != nil }\n raise RuntimeError, 'OS and LVM partitions missing' unless lvm_part\n\n os_part = lvm_part.lvm.volumes.detect { |p| p.os == true }\n raise RuntimeError, 'No partitions marked as OS' unless os_part\n\n return os_part\n end",
"def file_info(path)\n if manifest_entry # have we loaded our manifest yet? if so, use that sucker\n result = [manifest_entry[path], manifest_entry.flags[path]]\n if result[0].nil?\n return [NULL_ID, '']\n else\n return result\n end\n end\n if manifest_delta || files[path] # check if it's in the delta... i dunno\n if manifest_delta[path]\n return [manifest_delta[path], manifest_delta.flags[path]]\n end\n end\n # Give us, just look it up the long way in the manifest. not fun. slow.\n node, flag = @repo.manifest.find(raw_changeset[0], path)\n if node.nil?\n return [NULL_ID, '']\n end\n return [node, flag]\n end",
"def nfs?\n if ENV.key? 'FREIGHTHOP_NFS'\n ['1','true','on'].include?(ENV['FREIGHTHOP_NFS'])\n else\n vmware?\n end\n end",
"def maybe_dtb()\n log(\"Looking for a DTB file...\")\n\n mapping_path = generation_file(\"mobile-nixos/dtb-mapping.json\", missing_allowed: true)\n unless mapping_path && File.exist?(mapping_path)\n log(\" DTB: dtb-mapping.json not found... skipping DTB mapping...\")\n return nil\n end\n\n log(\" DTB: Mappings from: `#{mapping_path}`...\")\n mapping = JSON.parse(File.read(mapping_path))\n\n # Work only off the first compatible name.\n # It is assumed that the loader uses the exact same scheme as the kernel\n # build does. If this assumption stops holding true, it will be a new\n # feature to implement.\n board_compatible = File.read(\"/proc/device-tree/compatible\").split(\"\\0\").first\n log(\" DTB: board_compatible: #{board_compatible}\")\n\n desired_dtb = mapping[board_compatible]\n if desired_dtb\n log(\" DTB: wants: #{desired_dtb}\")\n else\n log(\" DTB: no DTB mapping found for #{board_compatible}...\")\n return nil\n end\n\n # The desired_dtb path is an absolute path in the mounted system.\n file = File.join(SYSTEM_MOUNT_POINT, desired_dtb)\n\n if File.exist?(file)\n log(\" DTB: file `#{file}` found\")\n \"--dtb=#{forward_fdt_bootloader_info(file)}\"\n else\n log(\" DTB: file `#{file}` not found... skipping DTB mapping\")\n nil\n end\n end",
"def select_filesystem(name = nil)\n @@current_fake = @@fakes[name]\n end",
"def ftype(path)\n path = expand_path(path)\n begin\n str = self.stat('-c', '%F', path).strip\n case str\n when /no such file or directory/i\n raise Errno::ENOENT, \"#{self}:#{path} does not exist\"\n when 'regular file'\n 'file'\n when 'regular empty file'\n 'file'\n when 'directory'\n 'directory'\n when 'character special file'\n 'characterSpecial'\n when 'block special file'\n 'blockSpecial'\n when /link/\n 'link'\n when /socket/\n 'socket'\n when /fifo|pipe/\n 'fifo'\n else\n raise RuntimeError, \"unknown filetype #{str}\"\n end\n rescue\n raise RuntimeError, \"stat #{self}:#{path} failed - #{str}\"\n end\n end",
"def os_type\n\n if @ostype\n return @ostype\n end\n\n res = :invalid\n\n Rouster.os_files.each_pair do |os, f|\n [ f ].flatten.each do |candidate|\n if self.is_file?(candidate)\n next if candidate.eql?('/etc/os-release') and ! self.is_in_file?(candidate, os.to_s, 'i') # CentOS detection\n @logger.debug(sprintf('determined OS to be[%s] via[%s]', os, candidate))\n res = os\n end\n end\n break unless res.eql?(:invalid)\n end\n\n @logger.error(sprintf('unable to determine OS, looking for[%s]', Rouster.os_files)) if res.eql?(:invalid)\n\n @ostype = res\n res\n end",
"def secondary_storage\n unless ::File.exist?(@current_resource.nfs_path)\n directory @current_resource.nfs_path do\n owner \"root\"\n group \"root\"\n action :create\n recursive true\n end\n end\n end",
"def virtual_fs\n VirtualFS::Union.new(VirtualFS::Embedded.new(file),\n VirtualFS::Native.new(File.dirname(file)))\n end",
"def search(f_name) \r\n yield ENV['PATH'].split(';').map {|p| File.join p, f_name}.find {|p| File.file? p and File.executable? p}\r\nend",
"def file_exists?(name)\n\n #if file exists return true\n Chef::Log.debug \"DEBUG: Checking to see if the curent file: '#{ name }.conf' exists in pool directory #{ node[\"php_fpm\"][\"pools_path\"] }\"\n ::File.file?(\"#{ node[\"php_fpm\"][\"pools_path\"] }/#{ name }.conf\")\n\nend",
"def exist_and_supported()\n case session.platform\n when 'linux'\n user = session.shell_command(\"whoami\")\n print_status(\"Current user is #{user}\")\n\n if (user =~ /root/)\n user_base = \"/root/\"\n else\n user_base = \"/home/#{user}/\"\n end\n\n dbvis_file = \"#{user_base}.dbvis/config70/dbvis.xml\"\n when 'windows'\n user_profile = session.sys.config.getenv('USERPROFILE')\n dbvis_file = \"#{user_profile}\\\\.dbvis\\\\config70\\\\dbvis.xml\"\n end\n\n unless file?(dbvis_file)\n #File not found, we next try with the old config path\n print_status(\"File not found: #{dbvis_file}\")\n print_status(\"This could be an older version of dbvis, trying old path\")\n\n case session.platform\n when 'linux'\n dbvis_file = \"#{user_base}.dbvis/config/dbvis.xml\"\n when 'windows'\n dbvis_file = \"#{user_profile }\\\\.dbvis\\\\config\\\\dbvis.xml\"\n end\n\n unless file?(dbvis_file)\n print_error(\"File not found: #{dbvis_file}\")\n return\n end\n\n old_version = true\n end\n\n print_status(\"Reading : #{dbvis_file}\" )\n raw_xml = \"\"\n begin\n raw_xml = read_file(dbvis_file)\n rescue EOFError\n # If there's nothing in the file, we hit EOFError\n print_error(\"Nothing read from file: #{dbvis_file}, file may be empty\")\n return\n end\n\n db_found = false\n alias_found = false\n db_type = nil\n db_type_ok = false\n\n # fetch config file\n raw_xml.each_line do |line|\n\n if line =~ /<Database id=/\n db_found = true\n elsif line =~ /<\\/Database>/\n db_found = false\n end\n\n if db_found == true\n\n # checkthe alias\n if (line =~ /<Alias>([\\S+\\s+]+)<\\/Alias>/i)\n if datastore['DBALIAS'] == $1\n alias_found = true\n print_good(\"Alias #{datastore['DBALIAS']} found in dbvis.xml\")\n end\n end\n\n if (line =~ /<Userid>([\\S+\\s+]+)<\\/Userid>/i)\n if alias_found\n print_good(\"Username for this connection : #{$1}\")\n end\n end\n\n # check the type\n if (line =~ /<Type>([\\S+\\s+]+)<\\/Type>/i)\n if alias_found\n db_type = $1\n alias_found = false\n end\n end\n end\n end\n if db_type.blank?\n print_error(\"Database alias not found in dbvis.xml\")\n end\n return db_type # That is empty if DB is not supported\n end",
"def find_data_file(path)\n each_data_path(path).find { |full_path| File.file?(full_path) }\n end",
"def fetch_items_from_filesystem_or_zip\n unless in_zip?\n @items = Dir.foreach(current_dir).map {|fn|\n load_item dir: current_dir, name: fn\n }.to_a.partition {|i| %w(. ..).include? i.name}.flatten\n else\n @items = [load_item(dir: current_dir, name: '.', stat: File.stat(current_dir)),\n load_item(dir: current_dir, name: '..', stat: File.stat(File.dirname(current_dir)))]\n zf = Zip::File.new current_dir\n zf.each {|entry|\n next if entry.name_is_directory?\n stat = zf.file.stat entry.name\n @items << load_item(dir: current_dir, name: entry.name, stat: stat)\n }\n end\n end",
"def which(cmd)\n path = \"/usr/local/bin/#{cmd}\"\n if not File.exists?(path)\n path = \"/sw/bin/#{cmd}\"\n end\n return path;\nend",
"def get_device_mount_point( incoming_path )\n mount_lines = `mount`\n raise EBSRemoteExecException.new(nil,$?,mount_lines) if $? != 0\n path = File.ftype(incoming_path) != 'directory'? File.dirname(incoming_path) : incoming_path\n device=nil\n longest = \"\"\n mount_lines.each_line {|line|\n match = line =~ /(.+)\\son\\s(.+?)\\s.*/\n candidate = $2.strip\n candidate_device = $1.strip\n # Keep the longest prefix matching\n if match && path =~ /^#{candidate}/ && candidate.length > longest.length\n longest = candidate\n device = candidate_device\n end\n }\n unless device\n STDERR.puts \"Couldn't find the device for mount point #{path}\"\n Kernel.exit(-1)\n end\n device\n end",
"def file_matching_path\n !!container.stored_files.where(file_name: file_name, path: path).first\n end",
"def CheckPartition(partition)\n partition = deep_copy(partition)\n freshman = {\n :valid => false,\n :name => \"unknown\",\n :arch => \"unknown\",\n :label => Ops.get_string(partition, \"label\", \"\"),\n :fs => Ops.get_symbol(partition, \"detected_fs\", :unknown),\n :fstype => Ops.get_string(partition, \"fstype\", \"unknown\")\n }\n\n p_dev = Ops.get_string(partition, \"device\", \"error\")\n p_fsid = Ops.get_integer(partition, \"fsid\", 0)\n p_type = Ops.get_symbol(partition, \"type\", :primary)\n p_detect_fs = Ops.get_symbol(partition, \"detected_fs\", :unknown)\n\n # possible root FS\n if Builtins.contains(FileSystems.possible_root_fs, p_detect_fs)\n mt_map = {\n :ext2 => \"ext2\",\n :ext3 => \"ext3\",\n :ext4 => \"ext4\",\n :btrfs => \"btrfs\",\n :reiser => \"reiserfs\",\n :xfs => \"xfs\",\n :jfs => \"jfs\"\n }\n mount_type = Ops.get(mt_map, p_detect_fs, \"\")\n\n error_message = nil\n if !(\n error_message_ref = arg_ref(error_message);\n _RunFSCKonJFS_result = RunFSCKonJFS(\n mount_type,\n p_dev,\n error_message_ref\n );\n error_message = error_message_ref.value;\n _RunFSCKonJFS_result\n )\n Ops.set(freshman, :valid, false)\n return deep_copy(freshman)\n end\n\n # mustn't be empty and must be modular\n if mount_type != \"\" && !Builtins.contains(@non_modular_fs, mount_type)\n SCR.Execute(path(\".target.modprobe\"), mount_type, \"\")\n end\n # mount (read-only) partition to Installation::destdir\n Storage.RemoveDmMapsTo(p_dev)\n if Convert.to_boolean(\n SCR.Execute(\n path(\".target.mount\"),\n [p_dev, Installation.destdir, Installation.mountlog],\n \"-o ro\"\n )\n )\n # Is this a root partition, does /etc/fstab exists?\n if Ops.greater_than(\n SCR.Read(\n path(\".target.size\"),\n Ops.add(Installation.destdir, \"/etc/fstab\")\n ),\n 0\n )\n Builtins.y2milestone(\"found fstab on %1\", partition)\n\n fstab = []\n crtab = []\n\n fstab_ref = arg_ref(fstab)\n crtab_ref = arg_ref(crtab)\n read_fstab_and_cryptotab(fstab_ref, crtab_ref, p_dev)\n fstab = fstab_ref.value\n crtab = crtab_ref.value\n Update.GetProductName\n\n fstab = Builtins.filter(fstab) do |p|\n Ops.get_string(p, \"file\", \"\") == \"/\"\n end\n\n if Builtins.size(Ops.get_string(fstab, [0, \"spec\"], \"\")) == 0\n Builtins.y2warning(\"Cannot find / entry in fstab %1\", fstab)\n end\n\n Ops.set(\n freshman,\n :valid,\n Ops.greater_than(\n Builtins.size(Ops.get_string(fstab, [0, \"spec\"], \"\")),\n 0\n ) &&\n Storage.DeviceMatchFstab(\n p_dev,\n Ops.get_string(\n # bugzilla #304269\n # DeviceMatchFstab expects _old_ not _translated_ device\n fstab,\n [0, \"spec_old\"],\n Ops.get_string(fstab, [0, \"spec\"], \"\")\n )\n )\n )\n\n # Why this doesn't match?\n # Possible reasons:\n # - /var not mounted so hwinfo cannot translate device names\n if Ops.get_boolean(freshman, :valid, false) != true\n Builtins.y2warning(\n \"Device does not match fstab: '%1' vs. '%2'\",\n p_dev,\n Ops.get_string(fstab, [0, \"spec\"], \"\")\n )\n end\n if Mode.autoinst\n # we dont care about the other checks in autoinstallation\n SCR.Execute(path(\".target.umount\"), Installation.destdir)\n return deep_copy(freshman)\n end\n\n # Get installed release name\n release = OSRelease.ReleaseInformation(Installation.destdir)\n Builtins.y2debug(\"release: %1\", release)\n if release == \"?\"\n # label for an unknown installed system\n release = _(\"Unknown\")\n end\n Ops.set(freshman, :name, release)\n\n # Right architecture?\n Ops.set(\n freshman,\n :arch,\n GetArchOfELF(Ops.add(Installation.destdir, \"/bin/bash\"))\n )\n instsys_arch = GetArchOfELF(\"/bin/bash\")\n\n # `arch_valid, see bugzilla #288201\n # installed /bin/bash and the one from inst-sys are matching\n if Ops.get_string(freshman, :arch, \"unknown\") == instsys_arch\n Builtins.y2milestone(\"Architecture (%1) is valid\", instsys_arch)\n Ops.set(freshman, :arch_valid, true) \n\n # both are PPC, bugzilla #249791\n elsif Builtins.contains(\n [\"ppc\", \"ppc64\"],\n Ops.get_string(freshman, :arch, \"unknown\")\n ) &&\n Builtins.contains([\"ppc\", \"ppc64\"], instsys_arch)\n Builtins.y2milestone(\n \"Architecture for partition %1 is %2, upgrading %3\",\n p_dev,\n Ops.get_string(freshman, :arch, \"unknown\"),\n instsys_arch\n )\n Ops.set(freshman, :arch_valid, true) \n\n # Architecture is not matching\n else\n Builtins.y2milestone(\n \"Architecture for partition %1 is %2, upgrading %3\",\n p_dev,\n Ops.get_string(freshman, :arch, \"unknown\"),\n instsys_arch\n )\n Ops.set(freshman, :arch_valid, false)\n end\n\n # If architecture is not matching, the whole partition is considered to be wrong\n if Ops.get_boolean(freshman, :arch_valid, false) != true\n Builtins.y2milestone(\n \"Architecture is not valid -> the whole partition is not valid\"\n )\n Ops.set(freshman, :valid, false)\n end\n\n if IncompleteInstallationDetected(Installation.destdir)\n Builtins.y2milestone(\n \"Incomplete installation detected, partition is not valid\"\n )\n Ops.set(freshman, :valid, false)\n end\n\n Builtins.y2milestone(\n \"Partition is valid: %1, arch is valid: %2\",\n Ops.get_boolean(freshman, :valid, false),\n Ops.get_boolean(freshman, :arch_valid, false)\n )\n end\n\n # unmount partition\n SCR.Execute(path(\".target.umount\"), Installation.destdir)\n end\n end\n\n Builtins.y2milestone(\"%1 %2\", partition, freshman)\n\n deep_copy(freshman)\n end",
"def bsd_based?(node = __getnode)\n # we could use os, platform_family or platform here equally\n %w{netbsd freebsd openbsd dragonflybsd}.include?(node[\"platform\"])\n end",
"def ceph_chef_fsid_secret\n if node['ceph']['encrypted_data_bags']\n secret = Chef::EncryptedDataBagItem.load_secret(node['ceph']['fsid']['secret_file'])\n Chef::EncryptedDataBagItem.load('ceph', 'fsid', secret)['secret']\n elsif !ceph_chef_mon_nodes.empty?\n secret = ceph_chef_mon_nodes[0]['ceph']['fsid-secret']\n if !secret.nil? && !secret.empty?\n ceph_chef_save_fsid_secret(secret)\n ceph_chef_mon_nodes[0]['ceph']['fsid-secret']\n elsif node['ceph']['fsid-secret']\n node['ceph']['fsid-secret']\n else\n Chef::Log.info('No fsid secret found')\n nil\n end\n else\n Chef::Log.info('No fsid secret found')\n nil\n end\nend",
"def path\n if location =~ /^\\/dev/\n \"dev:#{location}\"\n elsif location =~ /iso$/\n \"iso:#{location}\"\n elsif location.is_a?(Integer)\n \"disc:#{location}\"\n elsif location =~ /^disc/\n location\n else\n raise RuntimeError\n end\n end",
"def path\n if location =~ /^\\/dev/\n \"dev:#{location}\"\n elsif location =~ /iso$/\n \"iso:#{location}\"\n elsif location.is_a?(Integer)\n \"disc:#{location}\"\n elsif location =~ /^disc/\n location\n else\n raise RuntimeError\n end\n end",
"def diff_types\n\t\t\tavailable = []\n\n\t\t\tif @parent.file_1.contains_found? and @parent.file_2.contains_found? then\n\t\t\t\tavailable.push :direct\n\t\t\tend\n\n\n\t\t\tif available.empty? then\n\t\t\t\tavailable.push :notAvailable\n\t\t\tend\n\t\t\treturn available\n\t\tend",
"def safeExists?(f)\r\n ret=false\r\n File.open(f,\"rb\") { ret=true } rescue nil\r\n return ret\r\nend",
"def check_disk\n super\n end",
"def remote_fs(arg = nil)\n set_or_return(:remote_fs, arg, kind_of: String)\n end",
"def get_ks_fusion_guest_os(options)\n guest_os = \"rhel6\"\n if options['arch'].to_s.match(/64/)\n guest_os = guest_os+\"-64\"\n else\n if !options['arch'].to_s.match(/i386/) && !options['arch'].to_s.match(/64/)\n guest_os = guest_os+\"-64\"\n end\n end\n return guest_os\nend"
] |
[
"0.6409167",
"0.6298371",
"0.62385446",
"0.6204947",
"0.6158275",
"0.60359377",
"0.5938951",
"0.5910641",
"0.58961666",
"0.58135825",
"0.5793706",
"0.5763402",
"0.56151956",
"0.5602559",
"0.5602408",
"0.55545163",
"0.55434644",
"0.5538523",
"0.55028903",
"0.54697496",
"0.5460651",
"0.5458063",
"0.54382986",
"0.5430152",
"0.54237884",
"0.54087204",
"0.53786653",
"0.537161",
"0.53602266",
"0.530839",
"0.52816784",
"0.52677596",
"0.52557546",
"0.52517784",
"0.525116",
"0.52490836",
"0.5245878",
"0.52399",
"0.5221772",
"0.52158695",
"0.52085",
"0.52069074",
"0.5206369",
"0.5190301",
"0.51774365",
"0.5174663",
"0.5174663",
"0.5170076",
"0.516933",
"0.5164195",
"0.5163351",
"0.5162611",
"0.51468676",
"0.5144254",
"0.51300657",
"0.5126725",
"0.51188606",
"0.5108849",
"0.51087177",
"0.5108298",
"0.5104621",
"0.5098861",
"0.5094683",
"0.50903356",
"0.5080629",
"0.50659454",
"0.5064299",
"0.50519603",
"0.5048369",
"0.5040795",
"0.5036074",
"0.5035384",
"0.5028652",
"0.50282204",
"0.50277",
"0.5025048",
"0.5002844",
"0.49746418",
"0.49742487",
"0.49697116",
"0.49647012",
"0.49362215",
"0.4926159",
"0.49171665",
"0.4910346",
"0.49089184",
"0.49068677",
"0.48999754",
"0.48992434",
"0.48988435",
"0.48956576",
"0.48901656",
"0.48871976",
"0.4883584",
"0.4883584",
"0.48790628",
"0.48670998",
"0.48474228",
"0.48474184",
"0.48469663"
] |
0.6442593
|
0
|
returns the versionrelease of an rpm installed, or nil if not present
|
def rpm_version(name)
if (self.centos? && !self.centos7?) || self.fedora? || self.redhat8? || self.oracle8? || self.redhat9?
# returns epoch.version
v = Chef::Provider::Package::Dnf::PythonHelper.instance.
package_query(:whatinstalled, name).version
unless v.nil?
v.split(':')[1]
end
elsif self.centos7? &&
(FB::Version.new(Chef::VERSION) > FB::Version.new('14'))
# returns epoch.version.arch
v = Chef::Provider::Package::Yum::PythonHelper.instance.
package_query(:whatinstalled, name).version
unless v.nil?
v.split(':')[1]
end
else
# return version
Chef::Provider::Package::Yum::YumCache.instance.
installed_version(name)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def el_version\n if File.exists?('/etc/fedora-release')\n nil\n elsif File.exists?('/etc/redhat-release')\n rpm = Pkg::Util::Tool.find_tool('rpm', :required => true)\n stdout, _, _ = Pkg::Util::Execution.capture3(\"#{rpm} -q --qf \\\"%{VERSION}\\\" $(#{rpm} -q --whatprovides /etc/redhat-release )\")\n stdout\n end\n end",
"def rpm_version\n @lead.rpm_version\n end",
"def get_released_version(date)\n @minor_versions.each do |pv|\n if pv.release_date == date then\n return pv\n end\n end\n return nil\n end",
"def get_current_version(package)\n command = \"apt-cache policy #{package} | grep --color=never 'Installed'\"\n raw = `#{command}`.strip\n return nil if raw == ''\n\n version = raw.gsub('Installed: ', '')\n return nil if version == '(none)'\n\n version\n end",
"def latest\n source = @resource[:source]\n unless source\n @resource.fail _(\"RPMs must specify a package source\")\n end\n\n cmd = [command(:rpm), \"-q\", \"--qf\", \"#{self.class::NEVRA_FORMAT}\", \"-p\", source]\n h = self.class.nevra_to_multiversion_hash(execute(cmd))\n h[:ensure]\n rescue Puppet::ExecutionFailure => e\n raise Puppet::Error, e.message, e.backtrace\n end",
"def get_puppet_version\n version = nil\n installed = self.is_in_path?('puppet')\n\n if installed\n raw = self.run('puppet --version')\n version = raw.match(/([\\d\\.]*)\\s/) ? $1 : nil\n else\n version = nil\n end\n\n version\n end",
"def latest_version(gem_name, pre: false)\n return versions(gem_name).first if pre\n versions(gem_name).find { |version| !version.prerelease? }\n end",
"def rpm_no_arch\n @rpm_no_arch\n end",
"def get_rpm_status(proj_info)\n if proj_info.type == :module\n # FIXME This ASSUMES the release qualifier is 0 instead of using\n # simp-core/build/rpm/dependencies.yaml.\n rpm = \"#{proj_info.rpm_name}-#{proj_info.version}-0.#{proj_info.arch}.rpm\"\n url_el6 = PCLOUD_URL_BASE + \"6/\" + rpm\n url_el7 = PCLOUD_URL_BASE + \"7/\" + rpm\n else\n # FIXME If the RPM release qualifier has a %dist macro in it, there\n # is no way to accurately extract it from the spec file. The logic\n # below is a hack!\n rpm = \"#{proj_info.rpm_name}-#{proj_info.version}-#{proj_info.release}.#{proj_info.arch}.rpm\"\n url_el6 = PCLOUD_URL_BASE + \"6/\" + rpm\n url_el6.gsub!('el7','el6')\n url_el7 = PCLOUD_URL_BASE + \"7/\" + rpm\n url_el7.gsub!('el6','el7')\n end\n\n # query PackageCloud to see if a release to both el6 and el7 repos has been made\n # Note that each URL is for a page with a download button, not the RPM itself.\n debug(\"Checking existence of #{url_el6}: #{url_exists?(url_el6) ? 'exists' : 'does not exist'}\")\n debug(\"Checking existence of #{url_el7}: #{url_exists?(url_el7) ? 'exists' : 'does not exist'}\")\n rpms_found = url_exists?(url_el6) && url_exists?(url_el7)\n rpms_found = url_exists?(url_el6) && url_exists?(url_el7)\n rpms_released = rpms_found ? :released : :unreleased\n rpms_released\n end",
"def get_rpm_status(proj_info)\n if proj_info.type == :module\n # FIXME This ASSUMES the release qualifier is 0 instead of using\n # simp-core/build/rpm/dependencies.yaml.\n rpm = \"#{proj_info.rpm_name}-#{proj_info.version}-0.#{proj_info.arch}.rpm\"\n url_el6 = PCLOUD_URL_BASE + \"6/\" + rpm\n url_el7 = PCLOUD_URL_BASE + \"7/\" + rpm\n else\n # FIXME If the RPM release qualifier has a %dist macro in it, there\n # is no way to accurately extract it from the spec file. The logic\n # below is a hack!\n rpm = \"#{proj_info.rpm_name}-#{proj_info.version}-#{proj_info.release}.#{proj_info.arch}.rpm\"\n url_el6 = PCLOUD_URL_BASE + \"6/\" + rpm\n url_el6.gsub!('el7','el6')\n url_el7 = PCLOUD_URL_BASE + \"7/\" + rpm\n url_el7.gsub!('el6','el7')\n end\n\n # query PackageCloud to see if a release to both el6 and el7 repos has been made\n # Note that each URL is for a page with a download button, not the RPM itself.\n debug(\"Checking existence of #{url_el6}: #{url_exists?(url_el6) ? 'exists' : 'does not exist'}\")\n debug(\"Checking existence of #{url_el7}: #{url_exists?(url_el7) ? 'exists' : 'does not exist'}\")\n rpms_found = url_exists?(url_el6) && url_exists?(url_el7)\n rpms_found = url_exists?(url_el6) && url_exists?(url_el7)\n rpms_released = rpms_found ? :released : :unreleased\n rpms_released\n end",
"def installed_version\n capture(\"#{chef_solo} -v || true\") =~ /Chef: (\\d+\\.\\d+\\.\\d+)/ ? $1 : nil\n end",
"def latest\n ## make hcmbcs jump through hoops to give us latest pkg version\n begin\n output = hcmbcs \"--search\", \"--xml\", \"--package=#{self.name}\"\n rescue Puppet::ExecutionFailure\n raise Puppet::Error, \"failed hcmbcs --search\"\n end\n\n ## scan with group gives array of arrays\n version = output.scan(/<hcm_release_fq_hcm_pn>#{self.name}-([^<]+)<\\/hcm_release_fq_hcm_pn>/).last.first\n self.debug version\n\n return version\n end",
"def latest\n version = nil\n pkg(:list, \"-Ha\", @resource[:name]).each_line do |line|\n v = parse_line(line.chomp)[:status]\n case v\n when \"known\"\n return v\n when \"installed\"\n version = v\n else\n Puppet.warn \"unknown package state for #{@resource[:name]}: #{v}\"\n end\n end\n version\n end",
"def latest\n version = nil\n pkg(:list, \"-Ha\", @resource[:name]).each_line do |line|\n v = self.class.parse_line(line.chomp)[:status]\n case v\n when \"known\"\n return v\n when \"installed\"\n version = v\n when \"i--\"\n version = self.class.parse_line(line.chomp)[:version]\n else\n Puppet.warn \"unknown package state for #{@resource[:name]}: #{v}\"\n end\n end\n version\n end",
"def yum_releasever\n platform?('amazon') ? '7' : '$releasever'\n end",
"def installed_version\n res = Chef::Resource::Package.new('chefdk', run_context)\n prov = Chef::Provider::Package::Dpkg.new(res, run_context)\n ver = prov.load_current_resource.version.first\n return false if ver.nil?\n ver = ver.split('-').first\n ver == package_metadata[:version] ? 'latest' : ver\n end",
"def get_rem_ver(app_name)\n app_url = get_app_url(app_name)\n if $verbose == 1\n puts \"Getting version (or date) of latest release from #{app_url}\"\n end\n rem_ver = eval(\"get_#{app_name.downcase.gsub(/ |-/,'_')}_rem_ver(app_name,app_url)\")\n if rem_ver.to_s !~ /[0-9]/\n puts \"Remote build version (or date) not found\"\n exit\n end\n if !rem_ver.class.to_s.match(/Date/)\n rem_ver = rem_ver.gsub(/\\.$/,\"\")\n end\n return rem_ver\nend",
"def latest\n output = aurget \"-Si\", @resource[:name]\n\n if output =~ /Version\\s+:\\s+(\\S+)$/\n return $1\n else\n self.err \"Could not find latest version\"\n return nil\n end\n end",
"def yum_releasever\n platform?('amazon') ? '6' : '$releasever'\n end",
"def get_latest_rpm_url(debug_show=false)\n xml_result = get_latest_task_info['result']\n puts xml_result if debug_show\n # Do some fast and loose xml parsing... (TODO: be less fast and less loose)\n rpm_location = REXML::Document.new(xml_result).elements.to_a('//string').map{ |e| e.text }.grep(/errata-rails.*\\.el6eso\\.noarch\\.rpm$/).first\n raise \"Can't find noarch rpm!\" unless rpm_location\n \"http://download.devel.redhat.com/brewroot/work/#{rpm_location}\"\n end",
"def rpm_installed?(name)\n system_command(\"rpm\", args: [\"-q\", \"--qf\", \"%{NAME}-%{VERSION}\", name]).success?\nend",
"def version_from_gem_lock_file\n shell_return = run_shell(\"grep -A 1 RUBY Gemfile.lock\")\n shell_return.nil? ? nil : shell_return.stdout.split(\"\\n\")[1].strip.split(\" \")[1]\n end",
"def available_version(i)\n p_data = package_info(i)\n\n # nothing is available\n return nil if p_data.empty?\n\n p_data[\"versions\"][\"stable\"]\n end",
"def pdb_get_os_major_release(facts)\n if facts.is_a?(Hash) && !facts['operatingsystemmajrelease'].nil? && !facts['operatingsystemmajrelease']['value'].nil?\n os_major_release = facts['operatingsystemmajrelease']['value']\n Puppet.info(\"#{log_prefix} puppet os major release for node is: os major release=#{os_major_release}\")\n os_major_release\n else\n \"Unknown\"\n end\n end",
"def latest_version\n (Release.where(:manifest_id => manifest_id).max(:version) || 0)\n end",
"def find_stemcell_release(version, product_name)\n version = OpsManager::Semver.new(version)\n releases = stemcell_releases(product_name).collect do |r|\n {\n release_id: r['id'],\n version: OpsManager::Semver.new(r['version']),\n }\n end\n releases.keep_if{ |r| r[:version].major == version.major }\n exact_version = releases.select {|r| r[:version] == version }\n return exact_version.first[:release_id] unless exact_version.empty?\n releases_sorted_by_version = releases.sort_by{ |r| r[:version].minor }.reverse\n return releases_sorted_by_version.first[:release_id] unless releases_sorted_by_version.empty?\n end",
"def installed_version\n sh = shell_out('pkgutil --pkg-info com.getchef.pkg.chefdk')\n return false if sh.exitstatus.nonzero?\n ver = sh.stdout.match(/^version:\\W+([0-9]+\\.[0-9]+\\.[0-9]+)$/)[1]\n ver == package_metadata[:version] ? 'latest' : ver\n end",
"def latest_version_matching(dep)\n version = versions_matching(dep).collect { |v| ::Gem::Version.new v }.max\n version.nil? ? nil : version.to_s\n end",
"def version_number\n self.name =~ /RHEL-([0-9]+)/\n return $1.to_i\n end",
"def latest\n # Refresh package metadata before looking for latest versions\n pkg(:refresh)\n\n lines = pkg(:list, \"-Hvn\", @resource[:name]).split(\"\\n\")\n\n # remove certificate expiration warnings from the output, but report them\n cert_warnings = lines.select { |line| line =~ /^Certificate/ }\n unless cert_warnings.empty?\n Puppet.warning(_(\"pkg warning: %{warnings}\") % { warnings: cert_warnings.join(', ') })\n end\n\n lst = lines.select { |line| line !~ /^Certificate/ }.map { |line| self.class.parse_line(line) }\n\n # Now we know there is a newer version. But is that installable? (i.e are there any constraints?)\n # return the first known we find. The only way that is currently available is to do a dry run of\n # pkg update and see if could get installed (`pkg update -n res`).\n known = lst.find { |p| p[:status] == 'known' }\n if known\n options = ['-n']\n options.concat(join_options(@resource[:install_options])) if @resource[:install_options]\n return known[:ensure] if exec_cmd(command(:pkg), 'update', *options, @resource[:name])[:exit].zero?\n end\n\n # If not, then return the installed, else nil\n (lst.find {|p| p[:status] == 'installed' } || {})[:ensure]\n end",
"def fetch_linux_os_version\n `lsb_release -rs`.strip\nend",
"def package_repository(package_name, desired_version, arch = nil)\n package(package_name, arch, true, false) do |pkg|\n return pkg.repoid if desired_version == pkg.version.to_s\n end\n\n nil\n end",
"def determine(distro, release)\n return distro_releases[[distro, release]] if distro_releases.has_key? [distro, release]\n return distros[distro] if distros.has_key? distro\n default\n end",
"def published_version\n Rails.cache.fetch(\"published_version_for_#{name}\", expires_in: 10.minutes) do\n f = open(\"http://download.opensuse.org/factory/repo/oss/media.1/build\")\n matchdata = %r{openSUSE-(.*)-i586-.*}.match(f.read)\n matchdata[1]\n end\n end",
"def rpm_install\n @rpm_install\n end",
"def installed_version\n lines = powershell_out!('Get-WmiObject -Class win32_product')\n .stdout.lines\n idx = lines.index do |l|\n l.match(/^\\W*Name\\W+:\\W+Chef Development Kit/)\n end\n return false if idx.nil?\n ver = lines[idx + 2].match(/:\\W+([0-9]+\\.[0-9]+\\.[0-9]+)\\.[0-9]+/)[1]\n ver == package_metadata[:version] ? 'latest' : ver\n end",
"def get_latest_release_tag\n\trooturl = get_svn_repo_root()\n\treleaseurl = rooturl + \"/#{SVN_RELEASES_DIR}\"\n\t\n\ttags = svn_ls( releaseurl ).grep( RELEASE_VERSION_PATTERN ).sort_by do |tag|\n\t\ttag[RELEASE_VERSION_PATTERN].split('.').collect {|i| Integer(i) }\n\tend\n\treturn nil if tags.empty?\n\n\treturn releaseurl + '/' + tags.last\nend",
"def latest\n client = XMLRPC::Client.new2(\"http://pypi.python.org/pypi\")\n client.http_header_extra = {\"Content-Type\" => \"text/xml\"}\n client.timeout = 10\n result = client.call(\"package_releases\", @resource[:name])\n result.first\n rescue Timeout::Error => detail\n raise Puppet::Error, \"Timeout while contacting pypi.python.org: #{detail}\";\n end",
"def latest\n client = XMLRPC::Client.new2(\"http://pypi.python.org/pypi\")\n client.http_header_extra = {\"Content-Type\" => \"text/xml\"}\n client.timeout = 10\n result = client.call(\"package_releases\", @resource[:name])\n result.first\n rescue Timeout::Error => detail\n raise Puppet::Error, \"Timeout while contacting pypi.python.org: #{detail}\";\n end",
"def version\n exec(:version).readline =~ /^gpg \\(GnuPG\\) (.*)$/ ? $1 : nil\n end",
"def get_release( dbh, name )\n\tstmta = \"SELECT id, COUNT(id) AS count FROM releases WHERE name = '#{name}'\"\n\trsa = dbh.query( stmta )\n\tif rsa.any?\n\t rsa.each do |release|\n\t c = release['count']\n\t return release['id'] unless c == 0\n\t end\n\tend\n\treturn nil\nend",
"def get_ai_repo_version(options)\n options = get_ai_publisherurl(options)\n if options['test'] == true || options['host-os-name'].to_s.match(/Darwin/)\n version = \"0.175.1\"\n else\n message = \"Information:\\tDetermining if available repository version from \"+options['publisherurl']\n command = \"pkg info -g #{options['publisherurl']} entire |grep Branch |awk \\\"{print \\\\\\$2}\\\"\"\n version = execute_command(options,message,command)\n version = version.chomp\n version = version.split(/\\./)[0..2].join(\".\")\n end\n return version\nend",
"def latest_version\n versions.reverse_each.detect do | version|\n version_dir = SERVER_TOP_DIR + \"r#{version}\"\n path = Pathname.new(\"bin.tools\") + @s.p4ruby.basename\n if remote_file_exists?(version_dir, path)\n puts \"Found latest version: #{version}\"\n return version\n end\n end\n LAST_VALID_VERSION\n end",
"def get_release(release_id)\n query_and_build \"releases/#{release_id}\"\n end",
"def platform_version_for_package\n if platform == 'rhel'\n platform_version[/([\\d]+)\\..+/, 1]\n else\n platform_version\n end\n end",
"def get_max_available_version(package)\n raw = `apt-cache policy #{package} | grep 'Candidate'`.strip\n raw.gsub('Candidate: ', '')\n end",
"def installed_version(i)\n p_data = package_info(i)\n\n if p_data[\"keg_only\"]\n if p_data[\"installed\"].empty?\n nil\n else\n p_data[\"installed\"].last[\"version\"]\n end\n else\n p_data[\"linked_keg\"]\n end\n end",
"def required_version\n fetch(:chef_version) || nil\n end",
"def latest\n # If there's no \"latest\" version, we just return a placeholder\n result = :latest\n oldversion = properties[:ensure]\n case portstatus\n when '>', '='\n result = oldversion\n when '<'\n raise Puppet::Error, \"Could not match version info #{portinfo.inspect}.\" \\\n unless (m = portinfo.match(/\\((\\w+) has (.+)\\)/))\n source, newversion = m[1, 2]\n debug \"Newer version in #{source}\"\n result = newversion\n when '?'\n warning \"The installed package '#{pkgname}' does not appear in the \" \\\n 'ports database nor does its port directory exist.'\n when '!'\n warning \"The installed package '#{pkgname}' does not appear in the \" \\\n 'ports database, the port directory actually exists, but the ' \\\n 'latest version number cannot be obtained.'\n when '#'\n warning \"The installed package '#{pkgname}' does not have an origin \" \\\n 'recorded.'\n else\n warning \"Invalid status flag #{portstatus.inspect} for package \" \\\n \"'#{pkgname}' (returned by portversion command).\"\n end\n result\n end",
"def find_version\n\t\tversion_file = self.version_from\n\n\t\tunless version_file.readable?\n\t\t\tself.prompt.warn \"Version could not be read from %s\" % [ version_file ]\n\t\t\treturn nil\n\t\tend\n\n\t\tversion_line = version_file.readlines.find {|l| l =~ VERSION_PATTERN } or\n\t\t\tabort \"Can't read the VERSION from #{version_file}!\"\n\t\tversion = version_line[ VERSION_PATTERN, :version ] or\n\t\t\tabort \"Couldn't find a semantic version in %p\" % [ version_line ]\n\n\t\treturn Gem::Version.new( version )\n\tend",
"def release_info\n @release_info ||= @connection.get(RELEASE_INFO_PATH)['release']\n end",
"def version\n output = @filer.invoke(\"system-get-version\")\n if(output.results_errno() != 0)\n r = output.results_reason()\n raise \"Failed : \\n\" + r\n else \n output.child_get_string(\"version\")\n end\n end",
"def installed_version(packagename)\n\t\t\t\treturn(installed_packages()[packagename].version)\t\t\t\t\n\t\t\tend",
"def latest\n # If there's no \"latest\" version, we just return a placeholder\n result = :latest\n status, info, portname, oldversion = [nil, nil, nil, nil]\n oldversion = properties[:ensure]\n case portstatus\n when '>','='\n result = oldversion\n when '<'\n if m = portinfo.match(/\\((\\w+) has (.+)\\)/)\n source, newversion = m[1,2]\n debug \"Newer version in #{source}\"\n result = newversion\n else\n raise Puppet::Error, \"Could not match version info #{portinfo.inspect}.\"\n end\n when '?'\n warning \"The installed package '#{pkgname}' does not appear in the \" +\n \"ports database nor does its port directory exist.\"\n when '!'\n warning \"The installed package '#{pkgname}' does not appear in the \" +\n \"ports database, the port directory actually exists, but the latest \" +\n \"version number cannot be obtained.\"\n when '#'\n warning \"The installed package '#{pkgname}' does not have an origin recorded.\"\n else\n warning \"Invalid status flag #{portstatus.inspect} for package \" +\n \"'#{pkgname}' (returned by portversion command).\"\n end\n result\n end",
"def minor_version(version = nil)\n version ||= installed_version?\n return \"0.0\" if version.nil?\n\n version.sub(/\\.\\d+$/, '')\n end",
"def installed_version\n logger.trace(\"#{new_resource} checking package version\")\n current_installed_version\n end",
"def get_linux_distro\n distribution_regex = /^ID=\\W*(\\w+)\\W*/\n File.open('/etc/os-release') do |release_file|\n release_file.each do |line|\n return line.match(distribution_regex)[1].downcase if line =~ distribution_regex\n end\n end\n ''\n end",
"def read(rpm_repository_version_href, opts = {})\n data, _status_code, _headers = read_with_http_info(rpm_repository_version_href, opts)\n data\n end",
"def latest\n output = aptcache :policy, @resource[:name]\n\n if output =~ /Candidate:\\s+(\\S+)\\s/\n return $1\n else\n self.err \"Could not find latest version\"\n return nil\n end\n end",
"def latest\n url = \"https://pypi.python.org/pypi/#{URI.encode(@resource[:name])}/json\"\n result = self.open_jsonurl(url)\n result['info']['version'] if result != nil\n rescue Timeout::Error => detail\n raise Puppet::Error, \"Error in contacting pypi.python.org: #{detail}\"\n end",
"def get_version(gem)\n lockfile_specs.find { |s| s.name == gem }&.version\n end",
"def puppet_gem_version\n Gem::Version.create(puppet_version.split(' ').first.strip.gsub('-', '.'))\n end",
"def latest\n upd = latest_info\n unless upd.nil?\n # FIXME: there could be more than one update for a package\n # because of multiarch\n return \"#{upd[:epoch]}:#{upd[:version]}-#{upd[:release]}\"\n else\n # Yum didn't find updates, pretend the current\n # version is the latest\n raise Puppet::DevError, \"Tried to get latest on a missing package\" if properties[:ensure] == :absent\n return properties[:ensure]\n end\n end",
"def latest\n upd = latest_info\n unless upd.nil?\n # FIXME: there could be more than one update for a package\n # because of multiarch\n return \"#{upd[:epoch]}:#{upd[:version]}-#{upd[:release]}\"\n else\n # Yum didn't find updates, pretend the current\n # version is the latest\n raise Puppet::DevError, \"Tried to get latest on a missing package\" if properties[:ensure] == :absent\n return properties[:ensure]\n end\n end",
"def get_current_version(module_name)\n module_name = module_name.sub('/', '-')\n version = nil\n version = get_version(@cache[module_name]) if @cache.key?(module_name)\n\n if !version && check_module_exists(module_name)\n version = get_version(get_module_data(module_name))\n end\n\n version\n end",
"def get_release_version(storage: :ebs, arch: :amd64)\n fail ArgumentError, \"storage can only be one of #{STORAGE}\" unless STORAGE.include? storage\n fail ArgumentError, \"arch can only be one of #{ARCH}\" unless ARCH.include? arch\n fetch_versions\n .select { |r| r.root_storage == storage && r.arch == arch }\n .map { |v| v.version.to_s }.uniq.first\n .gsub(/[-][\\w\\d]/, '')\n end",
"def latest_version_of(name)\n remote_versions_for(name).collect { |v| ::Gem::Version.new v }.max.to_s\n end",
"def get_release(project)\n info = get_github_api(project, \"releases\")\n release = 'master'\n if info.length > 0\n unpublishedDraftLimit = 5\n x = 0\n release = info[x]['tag_name']\n # Unpublished drafts need to be skipped.\n while (unpublishedDraftLimit > x) && info[x]['draft']\n release = info[x]['tag_name']\n x += 1\n end\n end\n release\n end",
"def latest_version(module_name)\n versions(module_name).last\n end",
"def prerelease_tag\n prerelease_regex = if commits_since_tag > 0\n /^\\d+\\.\\d+\\.\\d+(?:-|\\.)([0-9A-Za-z.-]+)-\\d+-g[0-9a-f]+$/\n else\n /^\\d+\\.\\d+\\.\\d+(?:-|\\.)([0-9A-Za-z.-]+)$/\n end\n match = prerelease_regex.match(git_describe)\n match ? match[1] : nil\n end",
"def version\n @version ||= begin\n m = /^Terraform v(?<version>[^\\s]+)/.match(`terraform version`)\n m && m[:version]\n end\n rescue Errno::ENOENT\n nil\n end",
"def version_from_ruby_version_file\n shell_return = run_shell(\"cat .ruby-version\")\n shell_return.nil? ? nil : shell_return.stdout\n end",
"def get_last_release\n r = api_get(\"/releases\")\n\n return r[0]['tag_name']\nend",
"def lastest_package_release\n self.packages.where(:latest => 1).order(:release_date => :desc).first\n end",
"def detect_installed_version\n return @installed_version unless self.class.method_defined?(:installed_version_file)\n\n version_match = find_first_match(:matching => installed_version_regexp, :in_file => installed_version_file)\n\n # if multiple parts are matched, join them back\n version = version_match.captures.reject(&:nil?).join(\".\")\n\n # convert commas into dots so Versionomy can parse them too\n version = version.gsub(',', '.')\n\n if version\n @installed_version_text = version.strip\n @installed_version = Versionomy.parse(@installed_version_text).change({}, :optional_fields => [:tiny])\n end\n end",
"def requirement\n Gem::Requirement.new('~>' + pharos_version.segments.first(2).join('.') + (pharos_version.prerelease? ? '.0-a' : '.0'))\n end",
"def query\n #NOTE: Prior to a fix for issue 1243, this method potentially returned a cached value\n #IF YOU CALL THIS METHOD, IT WILL CALL RPM\n #Use get(:property) to check if cached values are available\n cmd = [\"-q\", @resource[:name], \"#{self.class.nosignature}\", \"#{self.class.nodigest}\", \"--qf\", \"#{self.class::NEVRA_FORMAT}\"]\n\n begin\n output = rpm(*cmd)\n rescue Puppet::ExecutionFailure\n return nil unless @resource.allow_virtual?\n\n # rpm -q exits 1 if package not found\n # retry the query for virtual packages\n cmd << '--whatprovides'\n begin\n output = rpm(*cmd)\n rescue Puppet::ExecutionFailure\n # couldn't find a virtual package either\n return nil\n end\n end\n @property_hash.update(self.class.nevra_to_multiversion_hash(output))\n\n @property_hash.dup\n end",
"def available_version(package_name, arch = nil)\n version(package_name, arch, true, false)\n end",
"def installed_version(package_name, arch = nil)\n version(package_name, arch, false, true)\n end",
"def installed_version?\n symlink_path = node['otrs']['prefix'] + \"/otrs\"\n\n if installed?\n symlink_target = File.readlink(symlink_path)\n symlink_target.sub(/.*-/, '')\n else\n nil\n end\n end",
"def get_version_build\n version = self.peers_version\n if version[\"success\"]\n return version[\"build\"]\n else\n return nil\n end\n end",
"def resource_version\n version_file = ::File.join(install_dir, '.ts3-version')\n if ::File.exist?(version_file)\n result = ::File.read(version_file)\n else\n result = '0'\n end\n result\nend",
"def prerelease?\n unless instance_variable_defined? :@prerelease\n @prerelease = !!(@version =~ /[a-zA-Z]/)\n end\n @prerelease\n end",
"def version\n @version ||= if token.nil? || Array(packages).empty?\n '0.1.0'\n else\n packages.map do |p|\n Gem::Version.new(p['version'])\n end.sort.last.bump.to_s << '.0'\n end\n end",
"def version\n @gemspec.version || @version_helper.to_s\n end",
"def is_rpm?\n return !!@name.match(/^(aix|cisco-wrlinux|el|eos|fedora|sles|redhat|redhatfips)-.*$/)\n end",
"def required_rubygems_version\n spec.required_rubygems_version || Gem::Requirement.default\n end",
"def rpm_arch\n @lead.arch\n end",
"def remote_version\n rubygem_api = JSON.parse open(\"https://rubygems.org/api/v1/versions/osa.json\").read\n rubygem_api.first[\"number\"]\n rescue Exception => e\n puts \"[!] \".yellow + \" Couldn't check the latest version, please check internet connectivity.\"\n exit!\n end",
"def latest_version?\n @requirement.none?\n end",
"def latest_version?\n @requirement.none?\n end",
"def earliest_version_matching(dep)\n version = versions_matching(dep).collect { |v| ::Gem::Version.new v }.min\n version.nil? ? nil : version.to_s\n end",
"def latest_version?\n if (res = _latest_version?)\n Gem.unversioned(@name)\n end\n res\n end",
"def scm_version(ref)\n return nil unless File.exist?(git_dir)\n\n version = `git --git-dir=#{safe_git_dir} describe --tags #{ref}`\n\n if $CHILD_STATUS.to_i.positive?\n # HEAD is not a tagged version, get the short SHA1 instead\n version = `git --git-dir=#{safe_git_dir} show #{ref} --format=format:\"%h\" -s`\n else\n # HEAD is a tagged version, if version is prefixed with \"v\" it will be stripped off\n version.gsub!(/^v/, \"\")\n end\n\n version.strip!\n rescue RuntimeError\n nil\n end",
"def version\n return @version if defined?(@version)\n \n @version = JSON.parse(File.read('package.json'))['version']\nend",
"def linux_version\n case ENV['MACHTYPE']\n when \"s390x-suse-linux\"\n :sles_zlnx\n when /^i[356]86/\n if File.exist? \"/etc/fedora-release\"\n :linux_ia32_cell\n else\n :linux_ia32\n end\n else\n if File.exist? \"/etc/rhel-release\"\n :rhel\n elsif File.exist? \"/etc/redhat-release\"\n `awk '/release 5/||/release 4.9/{v=5};/release 4/{v=4}; END {print \"rhel\" v}' /etc/redhad-release`.to_sym\n elsif File.exist? \"/etc/SuSE-release\"\n `awk '$1==\"VERSION\" { v=$3}; END { print \"sles\" v}' /etc/SuSE-release`.to_sym\n elsif File.exist? \"/etc/yellowdog-release\"\n :yhpc\n else\n :rhel\n end\n end\nend",
"def retrieve_version(name, version)\n path = downloaded_gem_path name, version\n parse :gem => path\n end",
"def only_if_rpmbuild_found(t)\n if rpmbuild_found?\n return t\n else\n return Proc.new {}\n end\nend",
"def get_current_version(version)\n # 0 would be if we are looking for latest\n if version.to_s.eql?('0')\n Chef::Log.debug(\n 'No version filtering. Grabbing the highest version from disk',\n )\n # Current_resource.version is string.\n return Gem::Version.new(current_resource.version.max)\n else\n Chef::Log.debug(\"Grabbing the highest version of v#{version} from disk.\")\n # Grab the highest version that meets the major, minor, build given\n list = current_resource.version.map { |v| Gem::Version.new(v) }\n Chef::Log.debug(\"Installed versions found: #{list.join(', ')}\")\n\n # Reducing by version can result in nil array.\n max = reduce_by_version(list, version).max\n return max.nil? ? Gem::Version.new(0) : max\n end\n end",
"def monit_version\n @monit_version ||= begin\n cmd = shell_out([monit_binary, '-V'])\n if !cmd.error? && /version ([0-9.]+)$/ =~ cmd.stdout\n Gem::Version.create($1)\n else\n nil\n end\n end\n end"
] |
[
"0.73902994",
"0.69928986",
"0.6868143",
"0.6667904",
"0.66559",
"0.6363557",
"0.63081396",
"0.6286012",
"0.6278648",
"0.6278648",
"0.6228528",
"0.6159336",
"0.61371917",
"0.6126809",
"0.6117446",
"0.6108582",
"0.6106775",
"0.605658",
"0.60458213",
"0.6038254",
"0.6030145",
"0.60165626",
"0.601622",
"0.598138",
"0.5962073",
"0.5940745",
"0.593482",
"0.58910054",
"0.5876403",
"0.58636934",
"0.5862813",
"0.586039",
"0.58553517",
"0.5849341",
"0.5830511",
"0.58220696",
"0.58133614",
"0.58087254",
"0.58087254",
"0.5804225",
"0.5777835",
"0.5728735",
"0.57269424",
"0.5725214",
"0.57195514",
"0.5709052",
"0.5707261",
"0.56912863",
"0.5673783",
"0.56712514",
"0.5671065",
"0.56642133",
"0.56435865",
"0.56422925",
"0.5611589",
"0.5608617",
"0.56057364",
"0.5603039",
"0.5601498",
"0.5600042",
"0.55999184",
"0.5599466",
"0.5592664",
"0.5592664",
"0.5591001",
"0.55861056",
"0.55681133",
"0.5567978",
"0.55679476",
"0.5547464",
"0.5546072",
"0.55360204",
"0.5530818",
"0.55242556",
"0.5523385",
"0.5518358",
"0.5517258",
"0.5508297",
"0.5502131",
"0.54898065",
"0.54822546",
"0.5475387",
"0.5471212",
"0.54687",
"0.54631305",
"0.54612696",
"0.5455021",
"0.5450483",
"0.54443645",
"0.54423434",
"0.54423434",
"0.54290307",
"0.54218245",
"0.5421044",
"0.54196465",
"0.54185003",
"0.54119617",
"0.54089004",
"0.54056305",
"0.5399261"
] |
0.73622614
|
1
|
Safely dig through the node's attributes based on the specified `path`, with the option to provide a default value in the event the key does not exist.
|
def attr_lookup(path, delim: '/', default: nil)
return default if path.nil?
node_path = path.split(delim)
# implicit-begin is a function of ruby2.5 and later, but we still
# support 2.4, so.... until then
node_path.inject(self) do |location, key|
if key.respond_to?(:to_s) && location.respond_to?(:attribute?)
location.attribute?(key.to_s) ? location[key] : default
else
default
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fetch_attribute(path, default = nil)\n node.dig(*path.split('.')) || default\nend",
"def get_attribute_from_path(obj, attribute_path, default=nil)\n for attr in attribute_path.split(\".\") do\n case obj\n when Hash\n obj = !obj[attr.to_sym].nil? ? obj[attr.to_sym] : obj[attr]\n else\n obj = obj.send(attr)\n end\n return default if obj.nil?\n end\n obj\n end",
"def get(path, default: nil, error: false)\n target = self\n\n path.split('.').each() do | key |\n k_sym = key.to_sym()\n if(target.has_key?(k_sym))\n target = target.get_key(k_sym)\n else\n raise ArgumentError.new(\"Value #{path} not found.\") unless !error\n return default\n end\n\n end\n\n return target\n end",
"def [](key)\n key = key.to_sym if key.respond_to?(:to_sym)\n unless key.to_s.empty?\n val = data_bag_item(key) if lookup_allowed?(key)\n if val\n val.delete('id')\n atr = Chef::Node::Attribute.new(\n node.normal_attrs,\n node.default_attrs,\n Chef::Mixin::DeepMerge.merge(\n node.override_attrs,\n Mash.new(key => val.to_hash)\n ),\n node.automatic_attrs\n )\n res = atr[key]\n end\n res || node[key]\n end\n end",
"def tree_at_path(_path, with_attrs: true)\n raise NotImplementedError\n end",
"def get_attribute(dict_name, key, default_value = nil)\n end",
"def load_attributes(path, key)\n Atlas::Parser::TextToHash::Base.new(path.read).to_hash\n rescue Atlas::ParserError => ex\n ex.path = path\n fail ex\n end",
"def extract_attr_value(xml)\n raw = {}\n default_when_xpath_err {\n @path.each(xml) do |node|\n raw[node.name] = node.text\n end\n }\n raw\n end",
"def attribute(option_key, default_value=:__UNDEFINED__, opts={}, &block)\n ret = _pair(option_key, default_value, opts, &block)\n return if ret[2] # ignore\n @attributes[ret[0]] = ret[1]\n end",
"def get_node(root, path)\n return root[path] if path.is_a?(Symbol)\n\n path = path.to_s.split('.') unless path.is_a?(Array)\n node = root\n\n path.each { |key|\n if node.is_a?(Hash)\n node = node[key.to_sym]\n elsif node.is_a?(Array)\n i = key.to_i\n return nil if i.zero? && key != i && key != i.to_s\n node = node[i]\n else\n return nil\n end\n }\n\n node\n end",
"def get(path, default=nil)\n path = path.split('.') if path.is_a?(String)\n return default if path.nil? or (path.respond_to?(:empty?) and path.empty?)\n\n # flatten/arrayify all path components\n path = [*path]\n\n # stringify keys and set root to self\n root = self.stringify_keys()\n key = path.first.to_s\n rest = path[1..-1]\n\n # if current path component is in this hash...\n if root.has_key?(key)\n # if the value is a hash\n if root[key].is_a?(Hash)\n # return default or value if no more path components are left\n return (root[key].nil? ? default : root[key]) if rest.empty?\n\n # otherwise recurse into sub-hash\n return root[key].get(rest, default)\n\n # if the value is an array of hashes\n elsif root[key].is_a?(Array) and root[key].first.is_a?(Hash)\n # return default or value if no more path components are left\n return (root[key].nil? ? default : root[key]) if rest.empty?\n\n # otherwise, for each array item, recurse and return array of sub-hashes\n return root[key].collect{|v|\n v.get(rest, default)\n }.flatten()\n else\n # value is a scalar, return value or default\n return (root[key].nil? ? default : root[key])\n end\n else\n # short circuit to default\n return default\n end\n end",
"def read(*path)\n read!(*path)\n rescue Chef::Exceptions::NoSuchAttribute\n nil\n end",
"def read!(*path)\n raise Chef::Exceptions::NoSuchAttribute.new(path.join \".\") unless exist?(*path)\n\n path.inject(self) do |memo, key|\n memo[key]\n end\n end",
"def method_missing(name, *args, &block)\n @attributes ? @attributes[name.to_s] : nil\n end",
"def find_attributes(node, &block); end",
"def dig(hash, path)\n keys = path.sub(/\\A\\//, '').split('/')\n keys.length > 0 ? hash.dig(*keys) : hash\nend",
"def get(key)\n @attrs[key].present? ? @attrs[key] : nil\n end",
"def [](path, default = nil)\n _, cmap = dir_walk(path.kind_of?(Path) ? path : Path.new(path), DW_Nil) || [0, default]\n cmap\n end",
"def method_missing(symbol, *args)\n if symbol == :to_ary\n merged_attributes.send(symbol, *args)\n elsif args.empty?\n Chef.deprecated :attributes, %q{method access to node attributes (node.foo.bar) is deprecated and will be removed in Chef 13, please use bracket syntax (node[\"foo\"][\"bar\"])}\n self[symbol]\n elsif symbol.to_s =~ /=$/\n Chef.deprecated :attributes, %q{method setting of node attributes (node.foo=\"bar\") is deprecated and will be removed in Chef 13, please use bracket syntax (node[\"foo\"]=\"bar\")}\n key_to_set = symbol.to_s[/^(.+)=$/, 1]\n self[key_to_set] = (args.length == 1 ? args[0] : args)\n else\n raise NoMethodError, \"Undefined node attribute or method `#{symbol}' on `node'\"\n end\n end",
"def get_path( source_node, *path )\n h = source_node.to_hash\n path.inject(h) { |obj, item| obj[item.to_s] || break }\nend",
"def try_parse_attr\n cur = @tokens.first || (return nil)\n\n case cur.ty\n when :dot\n [\"class\", AttrValue.new(parse_css_class())]\n when :hash\n [\"id\", AttrValue.new(parse_elem_id())]\n when :id \n name = cur.value\n @tokens.shift\n cur = @tokens.first || raise(\"= expected\")\n case cur.ty\n when :assign\n @tokens.shift\n expr = parse_expr()\n return [name, AttrValue.new(parse_expr())]\n else\n raise \"= expected\"\n end\n else\n return nil\n end\n end",
"def [](key, default=nil)\n attributes.has_key?(key) ? attributes[key] : default\n end",
"def fetch_xml_attr(path, xml, attribute = \"id\") # :doc:\n XML::Parser.parse(xml.body, \"/pairwise/#{path}\", attribute)\n end",
"def attr_of target, key, &default\n begin\n (target.attr key, :none).to_i\n rescue NoMethodError\n if not default.nil? then default.call else 0 end\n end\n end",
"def path\n @attributes.fetch('path', nil)\n end",
"def attribute_value(key, node = @current_node)\n\t\tif is_valid(node) && node.key?(key) then\n\t\t\treturn node.attribute(key).to_s\n\t\telse\n\t\t\treturn ''\n\t\tend\n\tend",
"def set_default_attribute(key, value)\n attr_hash = HashWithIndifferentAccess.from_dotted_path(key, value)\n self.default = self.default.merge(attr_hash)\n end",
"def get(path)\n key, subkeys = split_path(path)\n if subkeys.any?\n if self[key].is_a?(Droom::LazyHash)\n self[key].get(subkeys)\n else\n nil\n end\n elsif self.key?(key)\n self[key]\n else\n nil\n end\n end",
"def get_attribute(node, attr_name)\n #There has been a method shift between 0.5 and 0.7\n if defined?(node.property) == nil\n return node.attributes[attr_name]\n else\n if defined?(node[attr_name])\n return node[attr_name]\n else\n return node.property(attr_name)\n end\n end\n end",
"def _read_attribute(key); end",
"def build_default_map(options, path='')\n options.each_pair { |k,v|\n next unless v.is_a?(Hash)\n key_path = path.empty? ? k.to_s : \"#{path}.#{k}\"\n if v.has_key?(:val)\n set(key_path, v[:val])\n else\n build_default_map(v, key_path)\n end\n }\n end",
"def scan_path(path)\n assigns = {}\n node = self\n path.each do |p|\n new_node = node.children.find do |child| \n res = @@find_compare.call(child,to_node(p))\n assigns = assigns.merge(res) if res.instance_of?(Hash) \n res \n end\n if !new_node \n return nil\n end\n node = new_node\n end\n { :node => node, :assigns => assigns }\n end",
"def select_node(dict)\n if simple_path?\n [path, dict]\n else\n traverse_path(path,dict)\n end\n\n end",
"def ensure_attribute(root_element, key, type = nil, prefix = nil)\n value = get_attribute(root_element, key, type, prefix)\n label = prefix ? \"#{prefix}.#{key}\" : key\n raise \"Attribute '#{label}' is missing\" if value.nil?\n value\n end",
"def get_attr(at, default=nil)\n if @data.nil?\n return default\n end\n \n return @data[at] || default\n end",
"def method_missing(name, *args)\n return @values[name] if @values.key? name\n return nil if optional_attributes.include? name\n super\n end",
"def attr_rw_path(*attrs)\n attrs.each do |attr|\n class_eval %{\n def self.#{attr}(value = nil)\n if value.nil?\n return @#{attr} if instance_variable_defined?(:@#{attr})\n @#{attr} = InheritableAttr.inherit_for(self, :#{attr})\n else\n @#{attr} = value\n end\n end\n def self.#{attr}=(value)\n @#{attr} = FPM::Cookery::Path.new(value)\n end\n def #{attr}=(value)\n self.class.#{attr} = value\n end\n def #{attr}(path = nil)\n self.class.#{attr}(path)\n end\n }\n end\n\n register_attrs(:path, *attrs)\n end",
"def path(arg=nil)\n # set_or_return is a magic function from Chef that does most of the heavy\n # lifting for attribute access.\n set_or_return(:path, arg, kind_of: [String])\n end",
"def traverse_element(value, path)\n return unless value\n\n value_here = value\n el_parts = path.split('.')\n el_parts.each do |seg|\n if value_here.is_a?(Hash)\n value_here = value_here.stringify_keys[seg]\n elsif value_here.is_a?(Array)\n seg = 0 if seg == 'first'\n seg = seg.to_i\n value_here = value_here[seg]\n end\n end\n value_here\n end",
"def method_missing(sym, *args, &block)\n return attribute(sym.to_s) if not sym.to_s =~ /\\?$/\n super\n end",
"def method_missing(name, *args, &block)\n # FIXME: In case of returning nil\n if attr(name, args[0])\n self\n else\n super(name, *args, &block)\n end\n end",
"def _check_required_attr(object_missing, attr_path, attr_options, fname)\n attr_obj = KeyPath.new(attr_path)\n\n attr_name = attr_obj.key\n case attr_options[:type]\n when :data\n _check_required_attr_data(attr_name, attr_options, fname)\n when :CloudObject\n if attr_options[:required] &&\n @object_data.type?(attr_name) != :DataObject\n object_missing << attr_name\n end\n end\n end",
"def options_for_node(path)\n x = find_descendant_by_option_path(path)\n find_descendant_by_option_path(path).try(:child_options) || []\n end",
"def method_missing(name, *args, &block)\n return attributes[name.to_sym] if attributes.include?(name.to_sym)\n return super\n end",
"def strict_path val = nil\n begin\n strict_path! val\n rescue PathNotFound\n nil\n end\n end",
"def set_attribute_from_path(api_version, obj, attribute_path, builder, value)\n attrs = attribute_path.split(\".\")\n last = attrs.pop\n i = 0\n for attr in attrs do\n case obj\n when Hash\n obj = !obj[attr.to_sym].nil? ? obj[attr.to_sym] : obj[attr]\n else\n obj = obj.send(attr)\n end\n builder = DatadogAPIClient.const_get(api_version).const_get(builder.openapi_types[attr.to_sym]) if i > 0\n obj = builder.new if obj.nil?\n i += 1\n end\n case obj\n when Hash\n obj[last.to_sym] = value\n else\n obj.send(last + \"=\", value)\n end\n end",
"def initialize opts={}\n @regex_opts = opts[:regex_opts]\n @recursive = !!opts[:recursive]\n\n @key = nil\n @key = parse_node opts[:key] if\n opts[:key] && !opts[:key].to_s.empty?\n\n @value = nil\n @value = parse_node opts[:value] if\n opts[:value] && !opts[:value].to_s.empty?\n end",
"def get(path)\n unless path.empty?\n root = path.getRoot\n return nil unless self.keys.include? root\n if path.hasChild? then\n return self[root].get(path.getChild)\n else\n return self[root]\n end\n end\n nil\n end",
"def at *paths\n t = self \n paths.each do |p|\n if t.respond_to? :at # if it's a branch nodejkeep looking\n t = (t.__send__ :_delegate_hash)[p]\n else\n #other wise resturn the default\n return self.root.default\n end\n end\n t\n end",
"def check_for_auto_attr\n auto_attr = @presenter.extract_nested_value(node.automatic, @attr_spec)\n if ! auto_attr.nil?\n @collected_warnings << \"Attribute is set at automatic level. This means it is likely set by Ohai.\"\n end\n end",
"def initialize(path, defaults={})\n @data = nil\n @path = File.absolute_path(path)\n unless File.exist? path\n @data = {}\n defaults.each_pair{ |k,v| self[k]=v }\n create\n end\n end",
"def path_for(attribute, object = ScimRails.config.mutable_group_attributes_schema, path = [])\n at_path = path.empty? ? object : object.dig(*path)\n return path if at_path == attribute\n\n case at_path\n when Hash\n at_path.each do |key, value|\n found_path = path_for(attribute, object, [*path, key])\n return found_path if found_path\n end\n nil\n when Array\n at_path.each_with_index do |value, index|\n found_path = path_for(attribute, object, [*path, index])\n return found_path if found_path\n end\n nil\n end\n end",
"def path\n @attributes[:path]\n end",
"def path\n @attributes[:path]\n end",
"def path\n @attributes[:path]\n end",
"def path\n @attributes[:path]\n end",
"def path\n @attributes[:path]\n end",
"def path\n @attributes[:path]\n end",
"def path\n @attributes[:path]\n end",
"def path\n @attributes[:path]\n end",
"def path\n @attributes[:path]\n end",
"def path\n @attributes[:path]\n end",
"def path\n @attributes[:path]\n end",
"def path\n @attributes[:path]\n end",
"def dig(path_map, expected_value)\n -> hash {\n segments = path_map.split('.')\n\n expected_value === hash.dig(*segments) ||\n expected_value === hash.dig(*segments.map(&:to_sym))\n }\n end",
"def method_missing( attribute, value=nil, additional_attributes={} )\n\t\treturn super( attribute ) if value.nil?\n\t\treturn self.traverse_branch( attribute, value, additional_attributes )\n\tend",
"def get_with_path(path)\n get(*key_paths(path))\n end",
"def attribute(name, options={:strip => true, :null_if_blank => true})\n\t\t\treturn @attributes[name.to_sym] if @attributes && @attributes[name.to_sym]\n\t\t\treturn nil unless @node.attribute(name)\n\t\t\t@attributes = {} unless @attributes\n\t\t\t@attributes[name] = @node.attribute(name).evaluate(@node, :attrs => true).to_s\n\t\t\t@attributes[name].strip! if options[:strip]\n\t\t\t@attributes[name] = nil if @attributes[name].blank? && options[:null_if_blank]\n\t\t\t@attributes[name]\n\t\tend",
"def attr(key,name)\n value = nil\n\n if NOKOGIRI\n element=@xml.xpath(key.to_s.upcase)\n if element.size == 0\n return nil\n end\n\n attribute = element.attr(name)\n\n value = attribute.text if attribute != nil\n else\n element=@xml.elements[key.to_s.upcase]\n\n value = element.attributes[name] if element != nil\n end\n\n return value\n end",
"def meta_walk(path = nil, map = @meta)\n return map unless path and (path.length > 0)\n path.length.times do |i|\n str = path[i]\n unless map.kind_of?(Hash) and map[:dir]\n raise Error.new(Error::NoPath, path[0..i])\n end\n if !(m = map[str]) and !(m = map[:skel])\n raise Error.new(Error::NoPath, path[0..i])\n end\n map = m\n end\n map\n end",
"def attributes_for_node(node_name)\n node(node_name).attributes\nend",
"def node_get(node)\n nodes.fetch prepare_key(node), nil\n end",
"def get_attribute(node, attr_name)\n node.attribute(attr_name)\n end",
"def attrs_or_default(attrs)\n options = attrs.extract_options!\n attrs = yield if attrs.blank?\n attrs << options\n end",
"def get_node(node,path)\n name = path.split(\"/\")[0]\n rest = path.split(\"/\")\n rest.delete(name)\n rest = rest.join(\"/\")\n node.each_element do |element|\n if element.name == name\n if rest == \"\"\n return element\n else\n return get_node(element,rest)\n end\n end\n end\n end",
"def value_at_path(path)\n\t\t\t\tif path =~ %r{^/}\n\t\t\t\t\tnormalized_path = path\n\t\t\t\telse\n\t\t\t\t\tnormalized_path = \"/#{path}\"\n\t\t\t\tend\n\n\t\t\t\tputs \"[MacroDeck::TurkResponseTree::Tree] Getting value at path: #{normalized_path}\"\n\n\t\t\t\treturn @values_at_paths[normalized_path] if @values_at_paths.key?(normalized_path)\n\n\t\t\t\t# Look up!\n\t\t\t\tpath_components = normalized_path.split(\"/\")[1..-1]\n\n\t\t\t\troot = @hash\n\t\t\t\tval = nil\n\t\t\t\tpath_components.each do |p|\n\t\t\t\t\tputs \"[MacroDeck::TurkResponseTree::Tree] Processing path component: #{p}\"\n\n\t\t\t\t\t# See if this is the last path component (we need the value)\n\t\t\t\t\tif p == path_components.last\n\t\t\t\t\t\tputs \"[MacroDeck::TurkResponseTree::Tree] Last path component - getting value\"\n\n\t\t\t\t\t\tif p.include?(\"=\")\n\t\t\t\t\t\t\tif !root.nil? && root.key?(p.split(\"=\")[0])\n\t\t\t\t\t\t\t\troot = root[p.split(\"=\")[0]]\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\traise InvalidPathError, \"#{p.split(\"=\")[0]} not found\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tif !root.nil? && root.key?(p)\n\t\t\t\t\t\t\t\troot = root[p]\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\traise InvalidPathError, \"#{p} not found\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tputs \"[MacroDeck::TurkResponseTree::Tree] Not last path component - traversing tree\"\n\n\t\t\t\t\t\tif p.include?(\"=\")\n\t\t\t\t\t\t\tif root.key?(p)\n\t\t\t\t\t\t\t\troot = root[p]\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\traise InvalidPathError, \"#{p} not found\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tif root.key?(\"#{p}=\")\n\t\t\t\t\t\t\t\troot = root[\"#{p}=\"]\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\traise InvalidPathError, \"#{p}= not found\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t@values_at_paths[normalized_path] = root\n\t\t\t\treturn @values_at_paths[normalized_path]\n\t\t\tend",
"def initialize(node, attrs={})\n @node = node\n\n @attributes = {tag: node.name}\n ATTRIBUTES.each do |k|\n if node.key?(k.to_s)\n attributes[k] = node[k]\n end\n end\n update_attributes(attrs)\n end",
"def parse_attribute(attribute, default, opts)\n opts, default = default, nil if default.is_a?(Hash)\n # Merge-in default opts!\n opts = {upcase: true}.merge!(opts)\n caseattr = opts[:upcase] == true ? attribute.to_s.upcase : attribute.to_s\n value = ENV[opts[:from] || caseattr]\n if opts[:reset]\n # don't parse env variable, just set value\n [caseattr, default, opts]\n elsif value == \"\"\n # use default, when passed env is empty\n [caseattr, default, opts]\n else\n [caseattr, value || default, opts]\n end\n end",
"def attr_val(xpath)\n Utilities::attr_val(@entry, xpath)\n end",
"def method_missing(name, *args, &block)\n @attributes[name]\n end",
"def get_attribute(root_element, key, type = nil, prefix = nil)\n key_parts = key.split('.')\n output_entry = key_parts[0...-1].inject(root_element.to_hash) { |element, k| element.nil? ? nil : element[k] }\n return nil unless output_entry\n value = output_entry[key_parts.last]\n return nil if value.nil?\n label = prefix ? \"#{prefix}.#{key}\" : key\n raise \"The value of attribute '#{label}' is '#{value.inspect}' and this is not of the expected type #{type.inspect}\" if type && !(type.is_a?(Array) ? type : [type]).any? { |t| value.is_a?(t) }\n value\n end",
"def set_option(o, d, name, path)\n o[name] = d.elements[path].text if d.elements[path]\nend",
"def method_missing(name, *args)\n n = name.to_s\n @attr.key?(n) ? @attr[n] : super\n end",
"def get_node(key); end",
"def default_value(attr)\n\t\t\t@defaults ||= {}\n\t\t\t@defaults[attr.to_sym]\n\t\tend",
"def [](key_name)\n read_attribute(key_name)\n rescue MissingAttribute\n nil\n end",
"def default(key = nil)\n @default_proc ? @default_proc.call(tree, key) : @default\n end",
"def fill_properties(model, item_path, args)\n hash = properties\n hash.keys.each do |key|\n prop = hash[key]\n if args.include?(key)\n prop.set(model, item_path, args[key])\n elsif hash[key].default\n prop.set(model, item_path, prop.default)\n end\n end\n end",
"def get(path)\n node = Utils.get_node(@root, path)\n\n return node unless node.is_a?(Hash) || node.is_a?(Array)\n Data.new(node, false, false)\n end",
"def defaulted_attrs\n given_attrs.reject {|attr| send(\"given_#{attr}?\")}\n end",
"def load(key, *dig_keys, **options)\n super\n options[:default]\n end",
"def get_attribute_or_element_value(xml, attr, default = nil, &f)\n val = default\n begin\n snip = xml.elements[attr]\n if snip.elements.size > 0\n if snip.elements.size == 1 && snip.elements['object']\n # must be an otml reference to a different OTObject\n # return the refid\n val = snip.elements['object'].attributes['refid'].to_s\n else\n # otherwise just return the whole snippet\n val = snip.to_s\n end\n else\n val = snip.get_text.to_s\n end\n rescue\n begin\n val = xml.attributes[attr].to_s\n rescue\n # logger.warn(\"Couldn't find attribute or element: #{attr}\")\n end\n end\n begin\n if f\n val = yield(val)\n end\n rescue\n val = default\n end\n return val\n end",
"def get(key, opt = {})\n if (attrs = real_get(key, opt)).empty?\n nil\n else\n new(key, attrs)\n end\n end",
"def get(key, opt = {})\n if (attrs = real_get(key, opt)).empty?\n nil\n else\n new(key, attrs)\n end\n end",
"def _check_required_attr_data(attr_name, attr_options, fname)\n default = attr_options.rh_get(:default_value)\n\n return unless attr_options[:required]\n\n if attr_options.key?(:extract_from)\n unless @object_data.exist?(attr_options[:extract_from])\n PrcLib.runtime_fail(\"key '%s' was not extracted from '%s'\"\\\n \". '%s' requirement failed.\",\n attr_name, attr_options[:extract_from], fname)\n end\n elsif @config.get(attr_name, default).nil?\n section = Lorj.defaults.get_meta_section(attr_name)\n section = 'runtime' unless section\n PrcLib.runtime_fail(\"key '%s/%s' is not set. '%s' requirement\"\\\n ' failed.', section, attr_name, fname)\n end\n end",
"def get_value(item, key, default: nil, **)\n return if key.blank?\n if key.is_a?(Array)\n key.find { |k| (v = get_value(item, k)) and break v }\n elsif item.respond_to?(key)\n item.send(key)\n elsif item.respond_to?(:emma_metadata) # Upload, etc.\n item.emma_metadata&.dig(key.to_sym)\n elsif item.is_a?(Hash)\n item[key.to_sym] || item[key.to_s]\n end.presence || default\n end",
"def create_or_update_path(path_attrs)\n path = Path.where(title: path_attrs[:title]).first\n\n if path.nil?\n path = Path.create!(path_attrs)\n Rails.logger.info \">>>> Created new path: #{path_attrs[:title]}!\"\n elsif path.attributes == path_attrs\n Rails.logger.info \"No changes to existing path: #{path_attrs[:title]}\"\n else\n path.update_attributes(path_attrs)\n Rails.logger.info \"Updated existing << PATH >>: #{path_attrs[:title]}\"\n end\n\n path\nend",
"def [](name)\n @_node.hasAttribute(name.to_s) ? @_node.getAttribute(name.to_s) : nil\n end",
"def node_for(path_or_key)\n key = PathEx::Key.new(path_or_key)\n return nil if key.blank?\n\n child = self.children.find { |c| c.name == key.head }\n child.nil? ? nil : key.has_tail? ? child.node_for(key.tail) : child\n end",
"def [](key)\n a = @attrs_hash[key.intern]\n if a\n a.value\n else\n nil\n end\n end"
] |
[
"0.73300654",
"0.6849942",
"0.57888705",
"0.5745849",
"0.5479487",
"0.5461313",
"0.54462945",
"0.54340315",
"0.5425057",
"0.5383187",
"0.5359801",
"0.5353659",
"0.53333986",
"0.5269127",
"0.52258873",
"0.5223862",
"0.5156812",
"0.5145474",
"0.5112456",
"0.5112202",
"0.50996804",
"0.50935125",
"0.5049424",
"0.5039871",
"0.5038302",
"0.50374156",
"0.50042135",
"0.4995836",
"0.49691606",
"0.4943518",
"0.49309012",
"0.49225688",
"0.49195576",
"0.49184847",
"0.49175668",
"0.48769775",
"0.4853363",
"0.48452643",
"0.48229095",
"0.48095584",
"0.48058337",
"0.48054752",
"0.4797786",
"0.47795734",
"0.47586846",
"0.47483426",
"0.4747439",
"0.47427377",
"0.47293583",
"0.4699919",
"0.46984917",
"0.4682226",
"0.4674642",
"0.4674642",
"0.4674642",
"0.4674642",
"0.4674642",
"0.4674642",
"0.4674642",
"0.4674642",
"0.4674642",
"0.4674642",
"0.4674642",
"0.4674642",
"0.46732596",
"0.46681985",
"0.466525",
"0.46599412",
"0.46584973",
"0.46477285",
"0.46458468",
"0.46387345",
"0.4628476",
"0.46255827",
"0.4625477",
"0.46240836",
"0.4617786",
"0.46122992",
"0.4609821",
"0.46044856",
"0.46002063",
"0.45966884",
"0.45941374",
"0.45923987",
"0.4591496",
"0.4589391",
"0.45829737",
"0.45717037",
"0.4558347",
"0.45565003",
"0.45556736",
"0.4549939",
"0.45493546",
"0.45493546",
"0.4543863",
"0.45425633",
"0.45172998",
"0.45128056",
"0.45096156",
"0.45084408"
] |
0.6996469
|
1
|
We can change interface configs if nw_changes_allowed? or we are operating on a DSR VIP
|
def interface_change_allowed?(interface)
method = node['fb_helpers']['interface_change_allowed_method']
if method
return method.call(node, interface)
else
return self.nw_changes_allowed? ||
['ip6tnl0', 'tunlany0', 'tunl0'].include?(interface) ||
interface.match(Regexp.new('^tunlany\d+:\d+'))
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update!(**args)\n @network_interfaces = args[:network_interfaces] if args.key?(:network_interfaces)\n end",
"def config_update( name )\n @ndev_res.update name\n @@netdev.edit_config( @ndev_res, \"xml\" )\n end",
"def update_network_interfaces(name, address)\n default_nm = '255.255.255.0'\n (parts = address.split('.')).last.replace('1')\n default_gw = parts.join('.')\n File.open(File.join(KVM_MOUNT_POINT, name, 'etc', 'network', 'interfaces'), 'w') do |file|\n file.puts \"auto lo eth0\"\n file.puts \"iface lo inet loopback\"\n file.puts \"iface eth0 inet static\"\n file.puts \" address #{address}\"\n file.puts \" gateway #{conf['gateway'] || default_gw}\"\n file.puts \" netmask #{conf['netmask'] || default_nm}\"\n file.puts \" dns-nameservers #{Array(conf['nameserver'] || default_gw).join(' ')}\"\n end\n File.open(pinger = File.join(KVM_MOUNT_POINT, name, 'etc', 'network', 'if-up.d', '001base-pinger'), 'w') do |file|\n file.puts \"#!/bin/sh\"\n file.puts \"/bin/ping -c 1 #{local_ip_address} > /dev/null\"\n end\n File.chmod(0755, pinger)\n File.open(File.join(KVM_MOUNT_POINT, name, 'etc', 'cron.d', 'base-pinger'), 'w') do |file|\n file.puts \"* * * * * root /bin/ping -c 1 #{local_ip_address} > /dev/null\"\n file.puts \"\"\n end\n hosts = File.readlines(hosts_path = File.join(KVM_MOUNT_POINT, name, 'etc', 'hosts'))\n File.open(hosts_path, 'w') do |file|\n file.write hosts.join(\"\\n\")\n file.puts \"127.0.0.1 #{name}\"\n end\nend",
"def ipsettings=(value)\n Puppet.debug \"Updating ip configuration of specified port group\"\n begin\n @networksystem=host.configManager.networkSystem\n vnics=@networksystem.networkInfo.vnic\n vnicdevice = nil\n\n vnics.each do |vnic|\n if (vnic.portgroup && resource[:portgrp] == vnic.portgroup)\n vnicdevice=vnic.device\n if (resource[:ipsettings] == :static)\n if (resource[:ipaddress] == nil || resource[:subnetmask] == nil)\n raise Puppet::Error, \"ipaddress and subnetmask are required in case of static IP configuration.\"\n elsif( resource[:ipaddress].length == 0 || resource[:subnetmask].length == 0)\n raise Puppet::Error, \"ipaddress and subnetmask are required in case of static IP configuration.\"\n end\n ipconfiguration=RbVmomi::VIM.HostIpConfig(:dhcp => 0, :ipAddress => resource[:ipaddress], :subnetMask => resource[:subnetmask])\n elsif (resource[:ipsettings] == :dhcp)\n ipconfiguration = RbVmomi::VIM.HostIpConfig(:dhcp => 1)\n end\n hostvirtualnicspec = RbVmomi::VIM.HostVirtualNicSpec(:ip => ipconfiguration)\n if (vnicdevice != nil)\n actualnicspec = vnic.spec\n if (actualnicspec!= nil )\n actualnicspec.ip = ipconfiguration\n else\n actualnicspec = hostvirtualnicspec\n end\n @networksystem.UpdateVirtualNic(:device => vnicdevice, :nic => actualnicspec)\n end\n end\n end\n return \"true\"\n rescue Exception => e\n # Not failing here as this happens when we configure the management network\n Puppet.err \"Unable to configure the IP settings on a port group because the following exception occurred: -\\n #{e.message}\"\n end\n end",
"def configure_interfaces\n node_servers.each do |svinfo|\n gretap_interfaces(svinfo).each do |ifname, ifcfg|\n host_name = svinfo['hostname']\n virtual_addr = virtual_address(ifcfg)\n\n cloudconductor_server_interface \"#{host_name}_#{ifname}\" do\n action :create\n hostname host_name\n if_name ifname\n network ifcfg['network']\n security_groups ifcfg['security_groups']\n virtual_address virtual_addr\n end\n end\n end\nend",
"def config_network(instance, vm_config)\n\n vm_config[\"networks\"].each do |network, config|\n if config[\"type\"] == \"private\" then\n if config[\"ip\"] then\n instance.vm.network :private_network, ip: config[\"ip\"]\n end\n elsif config[\"type\"] == \"public\" then\n instance.vm.network :public_network\n end\n end if vm_config[\"networks\"]\n\n vm_config[\"ports\"].each do |port, config|\n\n raise \"At least the guest port is needed in 'guest_port' variable\" \\\n if config[\"guest_port\"].nil?\n\n instance.vm.network \"forwarded_port\",\n guest: config[\"guest_port\"],\n host: config[\"host_port\"] || config[\"guest_port\"],\n protocol: config[\"protocol\"] || \"tcp\",\n auto_correct: config[\"auto_correct\"] || true\n end if vm_config[\"ports\"]\n\nend",
"def update!(**args)\n @advanced_networking = args[:advanced_networking] if args.key?(:advanced_networking)\n @island_mode_cidr = args[:island_mode_cidr] if args.key?(:island_mode_cidr)\n @multiple_network_interfaces_config = args[:multiple_network_interfaces_config] if args.key?(:multiple_network_interfaces_config)\n @sr_iov_config = args[:sr_iov_config] if args.key?(:sr_iov_config)\n end",
"def interfaces\n iflist = `ifconfig | egrep \"^[a-z0-9]+:\" | awk '{print $1}' | sed 's/://'`.split\n interfaces = Hash.new\n interfaces['carp'] = []; interfaces['logical'] = []; interfaces['pfsync'] = []; interfaces['tunnel'] = []\n interfaces['vlan'] = []; interfaces['trunk'] = []; interfaces['physical'] = []\n\n iflist.each do |interface|\n ifconfig = `ifconfig #{interface}`\n iface = Hash.new\n iface['ip'] = Array.new\n iface['name'] = interface\n\n ifconfig.each do |line|\n case\n when line =~ /flags=\\d+\\<(.*)\\>\\s+mtu\\s+([0-9]+)/\n iface['mtu'] = $2\n iface['flags'] = $1.split(\",\")\n iface[\"up?\"] = iface['flags'].to_a.include?(\"UP\") ? \"up\" : \"down\"\n when line =~ /^\\s*media:\\s+(.*)/\n iface['media'] = $1\n when line =~ /lladdr\\s+(.*)/\n iface['lladdr'] = $1\n when line =~ /description: (.*)/\n iface['description'] = $1\n when line =~ /^\\s+inet ([0-9\\.]+) netmask ([0-9\\.a-fx]+) broadcast ([0-9\\.])/\n ip_address = $1\n broadcast = $3\n $2 =~ /(0x..)(..)(..)(..)/\n netmask = $1.hex.to_s + \".\" + $2.hex.to_s + \".\" + $3.hex.to_s + \".\" + $4.hex.to_s\n \n # Add a nice (dhcp) tag if the address has been given using dhcp\n ip_address += \" (dhcp)\" if `ps -ax | egrep \"dhclient: #{iface['name']} \" | grep -v grep | wc -l`.to_i > 0\n iface['ip'] << { \"address\" => ip_address, \"netmask\" => netmask, \"broadcast\" => broadcast }\n end\n end\n\n case iface['name']\n when /^carp/ then interfaces['carp'] << iface\n when /^(tun|gif)/ then interfaces['tunnel'] << iface\n when /^(enc|pflog|lo)[0-9]+/ then interfaces['logical'] << iface\n when /^pfsync/ then interfaces['pfsync'] << iface\n when /^vlan/ then interfaces['vlan'] << iface\n when /^trunk/ then interfaces['trunk'] << iface\n else interfaces['physical'] << iface\n end\n end\n interfaces\n end",
"def update_dvs(dvs, pnics, mtu)\n # Prepare spec for DVS creation\n spec = RbVmomi::VIM::VMwareDVSConfigSpec.new\n changed = false\n\n orig_spec = RbVmomi::VIM::VMwareDVSConfigSpec.new\n orig_spec.maxMtu = dvs['config.maxMtu']\n orig_spec.uplinkPortPolicy = RbVmomi::VIM::DVSNameArrayUplinkPortPolicy.new\n orig_spec.uplinkPortPolicy.uplinkPortName = []\n (0..dvs['config.uplinkPortgroup'].length-1).each { |index|\n orig_spec.uplinkPortPolicy.uplinkPortName[index]=\"dvUplink#{index+1}\"\n }\n\n # Add more uplinks to default uplink port group according to number of pnics\n if pnics\n pnics = pnics.split(\",\")\n if !pnics.empty? && dvs['config.uplinkPortgroup'].length != pnics.size\n spec.uplinkPortPolicy = RbVmomi::VIM::DVSNameArrayUplinkPortPolicy.new\n spec.uplinkPortPolicy.uplinkPortName = []\n (dvs['config.uplinkPortgroup'].length..num_pnics-1).each { |index|\n spec.uplinkPortPolicy.uplinkPortName[index]=\"dvUplink#{index+1}\"\n }\n changed = true\n end\n end\n\n #Set maximum MTU\n if mtu != dvs['config.maxMtu']\n spec.maxMtu = mtu\n changed = true\n end\n\n # The DVS must be created in the networkFolder of the datacenter\n if changed\n spec.configVersion = dvs['config.configVersion']\n\n begin\n dvs.item.ReconfigureDvs_Task(:spec => spec).wait_for_completion\n rescue Exception => e\n raise \"The Distributed switch #{dvs['name']} could not be updated. \"\\\n \"Reason: #{e.message}\"\n end\n\n @net_rollback << {:action => :update_dvs, :dvs => dvs.item, :name => dvs['name'], :spec => orig_spec}\n end\n end",
"def config_firewall\n\t\t`iptables -I INPUT 1 -s 10.0.0.0/8 -p tcp -m tcp --dport 389 -j ACCEPT`\n \t\t`iptables -I INPUT 1 -s 10.0.0.0/8 -p udp -m udp --dport 389 -j ACCEPT`\n\t\t`iptables -I INPUT 1 -s 10.0.0.0/8 -p tcp -m tcp --dport 636 -j ACCEPT`\n \t\t`iptables -I INPUT 1 -s 10.0.0.0/8 -p udp -m udp --dport 636 -j ACCEPT`\n\t\t`service iptables save`\n\t\t`service iptables restart`\n\t\t\n\tend",
"def update_rib(conf)\n if conf[:status] == :alive\n IPRoute.add_nexthop conf[:gateway], conf[:interface], conf[:provider], conf[:weight]\n IPRoute.add_src_route conf[:network], conf[:gateway], conf[:interface], conf[:address], conf[:provider]\n IPRoute.add_rule conf[:network], conf[:interface], conf[:provider]\n else\n IPRoute.del_nexthop conf[:gateway], conf[:interface], conf[:provider]\n IPRoute.del_route conf[:network], conf[:gateway], conf[:interface], conf[:provider]\n IPRoute.del_rule conf[:network], conf[:interface], conf[:provider]\n end\n end",
"def update_state_with_new_local_ip\n # First, find out this machine's private IP address. If multiple eth devices\n # are present, use the same one we used last time.\n all_local_ips = HelperFunctions.get_all_local_ips()\n new_private_ip = all_local_ips[@eth_interface]\n\n # Next, find out this machine's public IP address. In a cloud deployment, we\n # have to rely on the metadata server, while in a cluster deployment, it's\n # the same as the private IP.\n if [\"ec2\", \"euca\"].include?(@creds[\"infrastructure\"])\n new_public_ip = HelperFunctions.get_public_ip_from_aws_metadata_service()\n elsif @creds[\"infrastructure\"] == \"gce\"\n new_public_ip = HelperFunctions.get_public_ip_from_gce_metadata_service()\n else\n new_public_ip = new_private_ip\n end\n\n # Finally, replace anywhere that the old public or private IP addresses were\n # used with the new one.\n old_public_ip = @my_public_ip\n old_private_ip = @my_private_ip\n\n if @userappserver_public_ip == old_public_ip\n @userappserver_public_ip = new_public_ip\n end\n\n if @userappserver_private_ip == old_private_ip\n @userappserver_private_ip = new_private_ip\n end\n\n @nodes.each { |node|\n if node.public_ip == old_public_ip\n node.public_ip = new_public_ip\n end\n\n if node.private_ip == old_private_ip\n node.private_ip = new_private_ip\n end\n }\n\n if @creds[\"hostname\"] == old_public_ip\n @creds[\"hostname\"] = new_public_ip\n end\n\n if !is_cloud?\n nodes = JSON.load(@creds[\"ips\"])\n nodes.each { |node|\n if node['ip'] == old_private_ip\n node['ip'] == new_private_ip\n end\n }\n @creds[\"ips\"] = JSON.dump(nodes)\n end\n\n @app_info_map.each { |appid, app_info|\n if app_info['appengine'].nil?\n next\n end\n\n changed = false\n new_app_info = []\n app_info['appengine'].each { |location|\n host, port = location.split(\":\")\n if host == old_private_ip\n host = new_private_ip\n changed = true\n end\n new_app_info << \"#{host}:#{port}\"\n\n if changed\n app_info['appengine'] = new_app_info\n end\n }\n }\n\n @all_stats = []\n\n @my_public_ip = new_public_ip\n @my_private_ip = new_private_ip\n end",
"def set_vapp_port_forwarding_rules(vappid, network_name, config={})\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.NetworkConfigSection(\n \"xmlns\" => \"http://www.vmware.com/vcloud/v1.5\",\n \"xmlns:ovf\" => \"http://schemas.dmtf.org/ovf/envelope/1\") {\n xml['ovf'].Info \"Network configuration\"\n xml.NetworkConfig(\"networkName\" => network_name) {\n xml.Configuration {\n xml.ParentNetwork(\"href\" => \"#{@api_url}/network/#{config[:parent_network]}\")\n xml.FenceMode(config[:fence_mode] || 'isolated')\n xml.Features {\n xml.NatService {\n xml.IsEnabled \"true\"\n xml.NatType \"portForwarding\"\n xml.Policy(config[:nat_policy_type] || \"allowTraffic\")\n config[:nat_rules].each do |nat_rule|\n xml.NatRule {\n xml.VmRule {\n xml.ExternalPort nat_rule[:nat_external_port]\n xml.VAppScopedVmId nat_rule[:vm_scoped_local_id]\n xml.VmNicId(nat_rule[:nat_vmnic_id] || \"0\")\n xml.InternalPort nat_rule[:nat_internal_port]\n xml.Protocol(nat_rule[:nat_protocol] || \"TCP\")\n }\n }\n end\n }\n }\n }\n }\n }\n end\n\n params = {\n 'method' => :put,\n 'command' => \"/vApp/vapp-#{vappid}/networkConfigSection\"\n }\n\n response, headers = send_request(params, builder.to_xml, \"application/vnd.vmware.vcloud.networkConfigSection+xml\")\n\n task_id = headers[:location].gsub(\"#{@api_url}/task/\", \"\")\n task_id\n end",
"def insync?(is)\n replace = @resource && @resource[:mode] == :replace\n\n should_yang = should\n\n if is == :unknown\n # if the current config is unknown, assume configs are not in-sync\n insync = false\n else\n if replace\n insync = Cisco::Netconf.insync_for_replace(should_yang, is)\n else\n insync = Cisco::Netconf.insync_for_merge(should_yang, is)\n end\n end\n\n if insync\n debug '**************** IDEMPOTENT -- NO CHANGES DETECTED ****************'\n elsif debug '**************** IS vs SHOULD CHANGES DETECTED ****************'\n end\n\n insync\n end",
"def configure_private_network(config, ips, net_name)\n ips.each do |ip|\n config.vm.network 'private_network',\n ip: ip,\n netmask: '255.255.255.0',\n virtualbox__intnet: net_name\n end\nend",
"def dhcp_update_required?\n # IP Address / name changed\n return true if ((old.ip != ip) or (old.hostname != hostname) or (old.mac != mac) or (old.subnet != subnet))\n # Handle jumpstart\n #TODO, abstract this way once interfaces are fully used\n if self.kind_of?(Host::Base) and jumpstart?\n if !old.build? or (old.medium != medium or old.arch != arch) or\n (os and old.os and (old.os.name != os.name or old.os != os))\n return true\n end\n end\n false\n end",
"def config_changed?\n Origen.app.session.origen_sim[\"#{id}_config\"] != config.except(*NON_DATA_CONFIG_ATTRIBUTES)\n end",
"def check_netif_syntax_of vip_and_netif\n known_vn = {}\n known_netifs = []\n node['lvs-real-server']['service'].values.each do |n|\n known_netifs += n['vip_and_netif'].values\n known_vn = known_vn.merge n['vip_and_netif']\n end\n\n Hash[\n vip_and_netif.map do |vip, netif|\n if not known_vn[vip].nil?\n Chef::Log.warn \"#{vip} already defined with netif #{known_vn[vip]}. Use that settings\"\n [vip, known_vn[vip]]\n\n elsif netif !~ /^lo:/ or known_netifs.include? netif\n new_netif = gen_new_netif_with known_netifs\n Chef::Log.warn \"Network interface: #{netif} - not started with 'lo:' or already exists, Automatically replaced to #{new_netif}\"\n known_netifs << new_netif\n [vip, new_netif]\n\n else\n known_netifs << netif\n [vip, netif]\n\n end\n end\n ]\n end",
"def config_changed?\n Origen.app.session.origen_sim[\"#{id}_config\"] != config\n end",
"def adjust_nicSettingMap(spec)\n return if spec.blank?\n\n requested_network_adapter_count = options[:requested_network_adapter_count].to_i\n nic_count = Array.wrap(spec.nicSettingMap).length\n\n if requested_network_adapter_count < nic_count\n # Remove nicSettings to match network adapter count\n nic_count.downto(requested_network_adapter_count + 1) { spec.nicSettingMap.pop }\n elsif requested_network_adapter_count > nic_count\n # Add DHCP nicSettings to match network adapter count\n spec.nicSettingMap ||= VimArray.new(\"ArrayOfCustomizationAdapterMapping\")\n nic_count.upto(requested_network_adapter_count - 1) do\n adapter_map = VimHash.new(\"CustomizationAdapterMapping\")\n adapter = find_build_spec_path(adapter_map, 'CustomizationIPSettings', 'adapter')\n adapter.ip = VimHash.new(\"CustomizationDhcpIpGenerator\")\n spec.nicSettingMap << adapter_map\n end\n end\n end",
"def wi_fi_connect_only_to_configured_networks=(value)\n @wi_fi_connect_only_to_configured_networks = value\n end",
"def wi_fi_connect_only_to_configured_networks\n return @wi_fi_connect_only_to_configured_networks\n end",
"def read_host_only_interfaces\n end",
"def configure(dry_run = false)\n changes = 0\n prefix = self.prefix # prevent exists? check on each use\n\n local_primary, *local_aliases = local_ips\n meta_primary, *meta_aliases = meta_ips\n\n # ensure primary ip address is correct\n if name != 'eth0' && local_primary != meta_primary\n unless dry_run\n deconfigure\n cmd(\"addr add #{meta_primary}/#{prefix} brd + dev #{name}\")\n end\n changes += 1\n end\n\n # add missing secondary ips\n (meta_aliases - local_aliases).each do |ip|\n cmd(\"addr add #{ip}/#{prefix} brd + dev #{name}\") unless dry_run\n changes += 1\n end\n\n # remove extra secondary ips\n (local_aliases - meta_aliases).each do |ip|\n cmd(\"addr del #{ip}/#{prefix} dev #{name}\") unless dry_run\n changes += 1\n end\n\n # add and remove source-ip based rules\n unless name == 'eth0'\n rules_to_add = meta_ips || []\n cmd(\"rule list\").lines.grep(/^([0-9]+):.*\\s([0-9\\.]+)\\s+lookup #{route_table}/) do\n unless rules_to_add.delete($2)\n cmd(\"rule delete pref #{$1}\") unless dry_run\n changes += 1\n end\n end\n rules_to_add.each do |ip|\n cmd(\"rule add from #{ip} lookup #{route_table}\") unless dry_run\n changes += 1\n end\n end\n\n @clean = nil\n changes\n end",
"def push_config\n command = ['VBoxManage', 'modifyvm', uid]\n command.concat board.to_params\n nics.each_with_index do |nic, index|\n if nic.nil?\n command.push \"--nic#{index + 1}\", 'none'\n else\n command.concat nic.to_params(index + 1)\n end\n end\n VirtualBox.run_command! command\n \n io_buses.each { |bus| bus.add_to self }\n \n self\n end",
"def apply_network_settings container, networking\n OpenNebula.log_debug \"Configuring network\"\n nic = {:ifname => 'eth0', :host_mac => 'FE:FF:FF:FF:FF:FF'}\n\n container.add_veth nic\n OpenVZ::Util.execute \"brctl addif #{networking[:bridge]} veth#{container.ctid}.0\" unless networking[:bridge].nil?\n\n container.command \"ifconfig eth0 #{networking[:ip]}\"\n container.command \"ifconfig eth0 up\"\n end",
"def set_vapp_port_forwarding_rules(vappid, network_name, config={})\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.NetworkConfigSection(\n \"xmlns\" => \"http://www.vmware.com/vcloud/v1.5\",\n \"xmlns:ovf\" => \"http://schemas.dmtf.org/ovf/envelope/1\") {\n xml['ovf'].Info \"Network configuration\"\n xml.NetworkConfig(\"networkName\" => network_name) {\n xml.Configuration {\n xml.ParentNetwork(\"href\" => \"#{@api_url}/network/#{config[:parent_network]}\")\n xml.FenceMode(config[:fence_mode] || 'isolated')\n xml.Features {\n xml.NatService {\n xml.IsEnabled \"true\"\n xml.NatType \"portForwarding\"\n xml.Policy(config[:nat_policy_type] || \"allowTraffic\")\n config[:nat_rules].each do |nat_rule|\n xml.NatRule {\n xml.VmRule {\n xml.ExternalPort nat_rule[:nat_external_port]\n xml.VAppScopedVmId nat_rule[:vm_scoped_local_id]\n xml.VmNicId(nat_rule[:nat_vmnic_id] || \"0\")\n xml.InternalPort nat_rule[:nat_internal_port]\n xml.Protocol(nat_rule[:nat_protocol] || \"TCP\")\n }\n }\n end\n }\n }\n }\n }\n }\n end\n\n params = {\n 'method' => :put,\n 'command' => \"/vApp/vapp-#{vappid}/networkConfigSection\"\n }\n\n response, headers = send_request(params, builder.to_xml, \"application/vnd.vmware.vcloud.networkConfigSection+xml\")\n\n task_id = headers[:location].gsub(/.*\\/task\\//, \"\")\n task_id\n end",
"def configureStartup\n `chkconfig --add nagios`\n `chkconfig --level 35 nagios on`\n `chkconfig --add httpd`\n `chkconfig --level 35 httpd on`\n `iptables -I INPUT 1 -s #{@ips[0]}/#{@mask} -p tcp -m tcp --dport 80 -j ACCEPT`\n `iptables -I INPUT 1 -s #{@ips[0]}/#{@mask} -p udp -m udp --dport 80 -j ACCEPT`\n `service iptables save`\n `service iptables restart`\n end",
"def network_config\n @network_config ||= begin\n raw_config = network_params[\"network_configuration\"] || {\"interfaces\" => []}\n config = NetworkConfiguration.new(raw_config)\n config.add_nics!(device_config, :add_partitions => true) if dell_server?\n config\n end\n end",
"def enable_nat(bridge, ui)\n\tbridge_name \t= get_interface_name(bridge)\n\treturn if execute(true, \"ifconfig #{bridge_name} | grep inet\") == 0\n\n\tdirectory\t= @data_dir\n\t# Choose a subnet for this bridge\n\tindex = bridge_name =~ /\\d/\n\tbridge_num = bridge_name[index..-1]\n\tsub_net = \"172.16.\" + bridge_num\n\n\t# Config IP for the bridge\n\texecute(false, \"#{@sudo} ifconfig #{bridge_name} #{sub_net}.1/24\")\n\n\t# Get default gateway\n\tgateway = execute(false, \"netstat -4rn | grep default | awk '{print $4}'\")\n\tstore_attr('gateway', gateway)\n\t# Add gateway as a bridge member\n\t#execute(false, \"#{@sudo} ifconfig #{bridge_name} addm #{gateway}\")\n\n\t# Enable forwarding\n\texecute(false, \"#{@sudo} sysctl net.inet.ip.forwarding=1 >/dev/null 2>&1\")\n\texecute(false, \"#{@sudo} sysctl net.inet6.ip6.forwarding=1 >/dev/null 2>&1\")\n\n\t# Change pf's configuration\n\tpf_conf = directory.join(\"pf.conf\")\n\tpf_conf.open(\"w\") do |pf_file|\n\t pf_file.puts \"set skip on #{bridge_name}\"\n\t pf_file.puts \"nat on #{gateway} from {#{sub_net}.0/24} to any -> (#{gateway})\"\n\tend\n\tpf_bridge_conf = \"/usr/local/etc/pf.#{bridge_name}.conf\"\n\tcomment_mark = \"# vagrant-bhyve #{bridge_name}\"\n\texecute(false, \"#{@sudo} mv #{pf_conf.to_s} #{pf_bridge_conf}\")\n\tif execute(true, \"test -s /etc/pf.conf\") == 0\n\t if execute(true, \"grep \\\"#{comment_mark}\\\" /etc/pf.conf\") != 0\n\t execute(false, \"#{@sudo} sed -i '' '1i\\\\\\n#{comment_mark}\\n' /etc/pf.conf\")\n\t execute(false, \"#{@sudo} sed -i '' '2i\\\\\\ninclude \\\"#{pf_bridge_conf}\\\"\\n' /etc/pf.conf\")\n\t end\n\telse\n\t execute(false, \"echo \\\"#{comment_mark}\\\" | #{@sudo} tee -a /etc/pf.conf\")\n\t execute(false, \"echo \\\"include \\\\\\\"#{pf_bridge_conf}\\\\\\\"\\\" | #{@sudo} tee -a /etc/pf.conf\")\n\tend\n\trestart_service('pf')\n\t# Use pfctl to enable pf rules\n\t#execute(false, \"#{@sudo} cp #{pf_conf.to_s} /usr/local/etc/pf.#{bridge_name}.conf\")\n\t#execute(false, \"#{@sudo} pfctl -a '/vagrant_#{bridge_name}' -f /usr/local/etc/pf.#{bridge_name}.conf\")\n\t# execute(false, \"#{@sudo} pfctl -a '/vagrant_#{bridge_name}' -sr\")\n\n\t# Create a basic dnsmasq setting\n\t# Basic settings\n\tcheck_and_install('dnsmasq', 'dnsmasq', ui)\n\tdnsmasq_conf = directory.join(\"dnsmasq.conf\")\n\tdnsmasq_conf.open(\"w\") do |dnsmasq_file|\n\t dnsmasq_file.puts <<-EOF\n\t domain-needed\n\t except-interface=lo0\n\t bind-interfaces\n\t local-service\n\t dhcp-authoritative\n\t EOF\n\t # DHCP part\n\t dnsmasq_file.puts \"interface=#{bridge_name}\"\n\t dnsmasq_file.puts \"dhcp-range=#{sub_net + \".10,\" + sub_net + \".254\"}\"\n\t dnsmasq_file.puts \"dhcp-option=option:dns-server,#{sub_net + \".1\"}\"\n\tend\n\texecute(false, \"#{@sudo} cp #{dnsmasq_conf.to_s} /usr/local/etc/dnsmasq.#{bridge_name}.conf\")\n\tdnsmasq_cmd = \"dnsmasq -C /usr/local/etc/dnsmasq.#{bridge_name}.conf -l /var/run/dnsmasq.#{bridge_name}.leases -x /var/run/dnsmasq.#{bridge_name}.pid\"\n\texecute(false, \"#{@sudo} #{dnsmasq_cmd}\")\n\n end",
"def configure_networks(server_id, network_spec)\n with_thread_name(\"configure_networks(#{server_id}, ...)\") do\n raise Bosh::Clouds::NotSupported,\n format('network configuration change requires VM recreation: %s', network_spec)\n end\n end",
"def check\n uri = URI.parse(\"https://ifconfig.co/ip\")\n begin\n response = Net::HTTP.get_response(uri)\n if response.code == \"200\" || response.code == 200\n current_ip = \"#{response.body}\".strip\n saved_ip = \"#{read_current_ip}\".strip\n if current_ip != saved_ip\n logger.log(\"New IP: #{current_ip}\")\n slack_notifier.log(\"New IP: #{current_ip}\")\n write_current_ip(current_ip)\n end\n else\n logger.log(\"Cannot Reach ifconfig.co\")\n end\n rescue => e\n logger.log(\"Error checking IFCONFIG\")\n logger.log(\"#{e.inspect}\")\n end\n nil\n end",
"def update_configuration\n if @@initialized\n url = 'http://'+ENV['CONSUL_IP']+':8500/v1/kv/docker_nodes?raw'\n #log_message('Updating configuration from: ' + url)\n response = HTTPService.get_request(url)\n log_message('Dynamo changed, updating configuration to: ' + response.body)\n response = JSON.parse(response.body)\n replicate_data(response)\n end\n respond_to do |format|\n format.json { render :json => { :configuration => @@dynamo_nodes } }\n end\n end",
"def sync_nics(option = :none, execute = true)\n device_change = []\n\n if option == :all\n dchange = []\n\n # detached? condition indicates that\n # the nic exists in OpeNebula but not\n # in vCenter\n nics_each(:detached?) do |nic|\n dchange << {\n :operation => :remove,\n :device => nic.vc_item\n }\n end\n if !dchange.empty?\n dspec_hash = { :deviceChange => dchange }\n dspec = RbVmomi::VIM.VirtualMachineConfigSpec(dspec_hash)\n @item.ReconfigVM_Task(:spec => dspec).wait_for_completion\n end\n end\n\n # no_exits? condition indicates that\n # the nic does not exist in vCenter\n nics_each(:no_exists?) do |nic|\n device_change << calculate_add_nic_spec(nic.one_item)\n end\n\n return device_change unless execute\n\n spec_hash = { :deviceChange => device_change }\n\n spec = RbVmomi::VIM.VirtualMachineConfigSpec(spec_hash)\n @item.ReconfigVM_Task(:spec => spec).wait_for_completion\n\n info_nics\n end",
"def set_vapp_network_config(vappid, network_name, config={})\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.NetworkConfigSection(\n \"xmlns\" => \"http://www.vmware.com/vcloud/v1.5\",\n \"xmlns:ovf\" => \"http://schemas.dmtf.org/ovf/envelope/1\") {\n xml['ovf'].Info \"Network configuration\"\n xml.NetworkConfig(\"networkName\" => network_name) {\n xml.Configuration {\n xml.FenceMode(config[:fence_mode] || 'isolated')\n xml.RetainNetInfoAcrossDeployments(config[:retain_net] || false)\n xml.ParentNetwork(\"href\" => config[:parent_network])\n }\n }\n }\n end\n\n params = {\n 'method' => :put,\n 'command' => \"/vApp/vapp-#{vappid}/networkConfigSection\"\n }\n\n response, headers = send_request(params, builder.to_xml, \"application/vnd.vmware.vcloud.networkConfigSection+xml\")\n\n task_id = headers[:location].gsub(\"#{@api_url}/task/\", \"\")\n task_id\n end",
"def config_options\n {\n 'datacenter' => new_resource.datacenter,\n 'template_path' => new_resource.template_path,\n 'power_on' => true,\n 'datastore' => new_resource.datastore,\n 'wait' => true,\n 'hostname' => new_resource.hostname,\n 'name' => new_resource.name,\n 'customization_spec' => {\n 'domain' => new_resource.domain,\n 'ipsettings' => {\n 'ip' => new_resource.ip || node['vcac_vm']['ip'],\n 'gateway' => new_resource.gateway,\n 'subnetMask' => new_resource.subnet_mask,\n },\n }\n }\nend",
"def config_fwrules(filtertype, srcaddr, dstaddr, sport, dport, protocol, action, svc_negate, interface,\n int, sub, filter, term, dscp)\n\n\n # Initialize\n newaddobj = false\n\n # Currently an \"input filter\" (v4 or v6) is being translated to a FG interface policy\n # interface policies can only specifically allow traffic (aka no action can be specified)\n if filtertype == :ipv4_input_filter || filtertype == :ipv6_input_filter\n unless action == :accept\n p \"config_fwrules: action type must be accept for interface policy\" if $opts[:verbose]\n return ''\n end\n end\n\n # if action not specified then assume it is accept. *update* This should be verified.\n action = :accept if action == ''\n\n if filtertype == :ipv4_output_filter || filtertype == :ipv6_output_filter\n unless action == :accept || action == :discard\n p \"config_fwrules: action type must be accept or discard, was #{action} for outbound policy filter: #{filter},\\\\\n term: #{term}\" if $opts[:verbose]\n\n return ''\n end\n end\n\n # Initialize local vars, strings, hashes, sets, arrays\n fwconfig = String.new\n # fwconfig += \"### From Filter: #{filter}, Term: #{term}\\n\"\n fwconfig += \" edit 0\\n\"\n fwconfig += \" set comment \\\"From Filter: #{filter}, Term: #{term}\\\" \\n\"\n srcaddr_out = String.new\n dstaddr_out = String.new\n service_out = String.new\n dscp_out = String.new\n\n # Put the srcaddr and dstaddrs in a string format acceptable for applying\n # to a FG firewall policy as srcaddr or dstaddr setting. (aka no punctuation, spaces only)\n if srcaddr.count > 0\n srcaddr.each do |x|\n srcaddr_out += x.to_s + ' '\n end\n else\n srcaddr_out = 'all'\n end\n\n if dstaddr.count > 0\n dstaddr.each do |x|\n dstaddr_out += x.to_s + ' '\n end\n else\n if $opts[:map2sub]\n ### When map2sub enabled, any rules with dstaddr any will be changed from any to the subnet\n ### that the associated interfaces IP is in\n case filtertype\n when :ipv4_output_filter\n if $h_interfaces[int.to_sym][sub.to_sym][:'address_v4_primary'] == nil\n $h_interfaces[int.to_sym][sub.to_sym][:vrrp].each_key do |x|\n unless $h_interfaces[int.to_sym][sub.to_sym][:vrrp][x][:'intf-address'] == nil\n intip = IPAddress $h_interfaces[int.to_sym][sub.to_sym][:vrrp][x][:'intf-address'].to_s\n dstaddr_out = intip.network.to_s + '/' + intip.prefix.to_s\n newaddobj = true\n end\n end\n else\n intip = IPAddress $h_interfaces[int.to_sym][sub.to_sym][:address_v4_primary].to_s\n dstaddr_out = intip.network.to_s + '/' + intip.prefix.to_s\n newaddobj = true\n end\n when :ipv6_output_filter\n if $h_interfaces[int.to_sym][sub.to_sym][:'address_v6_primary'] == nil\n $h_interfaces[int.to_sym][sub.to_sym][:vrrp].each_key do |x|\n unless $h_interfaces[int.to_sym][sub.to_sym][:vrrp][x][:'intf-address'] == nil\n intip = IPAddress $h_interfaces[int.to_sym][sub.to_sym][:vrrp][x][:'intf-address'].to_s\n dstaddr_out = intip.network.to_s + '/' + intip.prefix.to_s\n newaddobj = true\n end\n end\n else\n intip = IPAddress $h_interfaces[int.to_sym][sub.to_sym][:address_v6_primary].to_s\n dstaddr_out = intip.network.to_s + '/' + intip.prefix.to_s\n newaddobj = true\n end\n else\n dstaddr_out = 'all'\n end\n else\n dstaddr_out = 'all'\n end\n end\n\n # For input filters we are creating an inbound interface policy\n if filtertype == :ipv4_input_filter || filtertype == :ipv6_input_filter\n fwconfig += \" set interface #{interface}\\n\"\n fwconfig += \" set srcaddr #{srcaddr_out}\\n\"\n fwconfig += \" set dstaddr #{dstaddr_out}\\n\"\n elsif filtertype == :ipv4_output_filter || filtertype == :ipv6_output_filter\n fwconfig += \" set srcintf any\\n\"\n fwconfig += \" set dstintf #{interface}\\n\"\n fwconfig += \" set srcaddr #{srcaddr_out}\\n\"\n fwconfig += \" set dstaddr #{dstaddr_out}\\n\"\n fwconfig += \" set action #{action}\\n\"\n fwconfig += \" set schedule always\\n\"\n else\n p \"config_fwrules: filtertype not supported, skipping #{filtertype}\"\n end\n\n ## Create the source and/or destination services fg config\n if protocol.include?(:tcp)\n dport.each do |x|\n service_out += \"#{x}-tcp \"\n end\n sport.each do |x|\n service_out += \"#{x}-tcp_source \"\n end\n end\n if protocol.include?(:udp)\n dport.each do |x|\n service_out += \"#{x}-udp \"\n end\n sport.each do |x|\n service_out += \"#{x}-udp_source \"\n end\n end\n\n # If no protocol is specified in the term, then we will add tcp and udp.\n if !(protocol.include?(:tcp) || protocol.include?(:udp) || protocol.include?(:icmp))\n dport.each do |x|\n service_out += \"#{x}-tcp \"\n end\n sport.each do |x|\n service_out += \"#{x}-tcp_source \"\n end\n dport.each do |x|\n service_out += \"#{x}-udp \"\n end\n sport.each do |x|\n service_out += \"#{x}-udp_source \"\n end\n elsif (protocol.include?(:tcp) || protocol.include?(:udp) || protocol.include?(:icmp)) &&\\\n (dport.count == 0 && sport.count == 0)\n protocol.each do |x|\n service_out += \"#{x.to_s.upcase} \"\n end\n elsif protocol.include?(:icmp) && !(protocol.include?(:tcp) || protocol.include?(:udp))\n dport.each do |x|\n service_out += \"ICMP-#{x} \"\n end\n end\n\n service_out = 'ALL' if service_out == ''\n fwconfig += \" set service #{service_out} \\n\"\n\n if svc_negate == 'true'\n fwconfig += \" set service-negate enable \\n\"\n end\n\n # if dscp acls in configured create the dscp fg value\n if dscp.count > 0\n dscp.each do |x|\n\n if $h_dscp_map[x.to_s]\n dscpval = $h_dscp_map[x.to_s]\n dscp_out += dscpval + ' '\n else\n p \"config_fw_fules: No DSCP mapping found for dscp: #{x.to_s}\"\n next\n end\n\n fwconfig += \" set dscp-match enable \\n\"\n fwconfig += \" set dscp-value #{dscp_out} \\n\"\n fwconfig += \" set diffserv-forward enable \\n\"\n fwconfig += \" set diffserv-reverse enable \\n\"\n end\n end\n\n fwconfig += \" next\\n\"\n\n return fwconfig, dstaddr_out if newaddobj == true\n return fwconfig, nil\nend",
"def update(is = {}, should = {})\n Puppet.debug(\"Updating interface #{name}\")\n command('conf t')\n command(\"interface #{name}\")\n\n # apply changes in a defined order for cisco IOS devices\n [is.keys, should.keys].flatten.uniq.sort { |a, b| COMMANDS[a][0] <=> COMMANDS[b][0] }.each do |property|\n # Work around for old documentation which shows :native_vlan used for access vlan\n if property == :access_vlan && should[:mode] != :trunk && should[:access_vlan].nil?\n should[:access_vlan] = should[:native_vlan]\n end\n\n Puppet.debug(\"comparing #{property}: #{is[property]} == #{should[property]}\")\n\n # They're equal, so do nothing.\n next if is[property] == should[property]\n\n # We're deleting it\n if should[property] == :absent || should[property].nil?\n execute(property, is[property], 'no ')\n next\n end\n\n # We're replacing an existing value or creating a new one\n execute(property, should[property])\n end\n\n command('exit')\n command('exit')\n end",
"def refresh_whitelisted_ips\n config.allowed_ips.merge([\"127.0.0.0/8\", \"::1/128\"])\n config.allowed_ips&.each do |ip|\n begin\n ActiveAccess::Middleware.allow_ip!(ip)\n ensure\n next # windows ruby doesn't have ipv6 support\n end\n end\n end",
"def get_as_interface_config(access_config = nil)\n network_interface = { :network => self_link }\n network_interface[:access_configs] = [access_config] if access_config\n network_interface\n end",
"def update_config(watchers)\n # if we support updating backends, try that whenever possible\n if @opts['do_socket']\n update_backends(watchers)\n else\n @restart_required = true\n end\n\n # generate a new config\n generate_config(watchers)\n\n end",
"def update_gateway(config)\n changed = false\n lines = IO.readlines config\n File.open(config, \"w\") do |file|\n lines.each do |s|\n if /^[\\s]*cloud_controller_uri:/ =~ s\n changed = true unless /#{@uri}[\\s]*$/ =~ s\n file.puts \"cloud_controller_uri: http://#{@uri}\\n\"\n else\n file.puts s\n end\n end\n end\n changed\n end",
"def update_click_config\n if @mobiles.length > 0\n if @bstype == 'nec'\n new_config = gen_nec_config\n else\n new_config = gen_airspan_config\n end\n else\n new_config = ''\n end\n\n debug(\"Loading new click configuration for datapath #{name}\")\n begin\n @click_socket.send(\"WRITE hotconfig #{new_config}\\n\", 0)\n rescue Errno::EPIPE => e\n # click has probably crashed, so don't do anything because\n # it will be automatically restarted with the new config\n debug(\"Error writing on control socket: #{e.message}\")\n else\n while line = @click_socket.gets\n case line\n when /^2\\d\\d/\n debug(\"New config loaded successfully\")\n break\n when /^5\\d\\d/\n error(\"Could not load new config, old config still running: #{line}\")\n break\n end\n end\n end\n end",
"def configure_networks(instance_id, network_spec)\n raise Bosh::Clouds::NotSupported, 'configure_networks is no longer supported'\n end",
"def options_update_config(event, hash)\n return if(@test_running)\n $conf.update_config(hash)\n clear_gui_and_results() if(hash.has_key?(:scan_mode) || hash.has_key?(:scan_type) )\n ws_sync_from_conf() if(hash.has_key?(:sslv2) || hash.has_key?(:tlsv1)|| hash.has_key?(:sslv3) )\n event.skip\n end",
"def sync(refresh=false)\n\t\t\tself.refresh if !ready? or refresh\n\t\t\tsys_network = `ip ad sh`\n\n\t\t\t# use `ip addr ...` commands to list and validate the local network\n\t\t\t# interface config and compare it to our internal model, then add ips and\n\t\t\t# routing config such that the local config matches our model.\n\t\t\t# also ensure old ips and routes are excised from the config when they are\n\t\t\t# no longer in our model.\n\n\t\t\t# see http://engineering.silk.co/post/31923247961/multiple-ip-addresses-on-amazon-ec2\n\t\t\t# once configured, one should be able to run the following command for any\n\t\t\t# ip address with an associated public ip and not have the packets dropped\n\t\t\t# $ curl --interface ip.add.re.ss ifconfig.me\n\n\t\t\t# should be able to get by with only instance metadata and no AWS API\n\t\t\t# calls for this command\n\n\t\t\t# return the number of local entries which were updated (e.g. return 2 if\n\t\t\t# one private ip was added and another is removed from the local config)\n\t\tend",
"def send_change_ip(new_ip)\n @conn.send_msg({ :type => 'change_ip', :client => @current_name, :ip_old => @current_ip, :ip_new => new_ip }.to_json)\n @current_ip == new_ip\n end",
"def configure_networking(\n machine,\n instance_profile,\n provider = 'virtualbox'\n)\n\n instance_networking = lookup_values_yaml(instance_profile, ['providers', provider, 'instance', 'networking'])\n\n return false unless instance_networking\n\n name = replace_characters_string(lookup_values_yaml(instance_profile, ['name']))\n\n configure_interfaces(machine, name, instance_networking)\n\n configure_forwarded_ports(machine, name, instance_networking)\n\nend",
"def configure_networks(instance_id, network_spec)\n raise Bosh::Clouds::NotSupported, \"configure_networks is no longer supported\"\n end",
"def configure_networks(instance_id, network_spec)\n raise Bosh::Clouds::NotSupported, \"configure_networks is no longer supported\"\n end",
"def on_rpl_isupport(m)\n @server_config.set(m)\n end",
"def manage_address\n enable_dhcp if new_resource.bootproto == 'dhcp' && current_resource.bootproto != 'dhcp'\n return unless new_resource.bootproto == 'static'\n\n config_static unless new_resource.address.nil? || (current_resource.bootproto == 'static' && ip_subnet_exist?)\n config_gateway unless new_resource.gateway.nil? || (current_resource.bootproto == 'static' && current_resource.gateway == new_resource.gateway)\n end",
"def eth_sw_en; eth_ctrl_bit(0); end",
"def manage_netbios\n config_netbios unless current_resource.netbios == new_resource.netbios\n end",
"def network_interfaces\n @network_interfaces ||= init_network_interfaces\n end",
"def network_interfaces\n sans = san_network_ports\n n = clusters.map{|x| x.vlan}.sort\n if has_mgmt? then\n n << 4000\n end\n app = n.map{|x| \"vlan#{x}\"}\n app.concat(sans)\n end",
"def read_shared_interface\n net_info = json do\n execute_prlsrvctl('net', 'info', read_shared_network_id, '--json')\n end\n\n iface = {\n nat: [],\n status: 'Down'\n }\n adapter = net_info['Parallels adapter']\n\n if adapter\n iface[:ip] = adapter['IPv4 address']\n iface[:netmask] = adapter['IPv4 subnet mask']\n iface[:status] = 'Up'\n end\n\n if net_info.key?('DHCPv4 server')\n iface[:dhcp] = {\n ip: net_info['DHCPv4 server']['Server address'],\n lower: net_info['DHCPv4 server']['IP scope start address'],\n upper: net_info['DHCPv4 server']['IP scope end address']\n }\n end\n\n net_info['NAT server'].each do |group, rules|\n rules.each do |name, params|\n iface[:nat] << {\n name: name,\n protocol: group == 'TCP rules' ? 'tcp' : 'udp',\n guest: params['destination IP/VM id'],\n hostport: params['source port'],\n guestport: params['destination port']\n }\n end\n end\n\n iface\n end",
"def config_ddns\n converge_it(\"#{new_resource.ddns ? 'Enabling' : 'Disabling'} dynamic DNS registration\") do\n nic.SetDynamicDNSRegistration(new_resource.ddns)\n end\n end",
"def remove_network_interface_properties\n properties = []\n properties << :SourceDestCheck\n properties << :Tags\n add_patch Patches::RemoveProperty.new 'AWS::EC2::NetworkInterface', properties\n end",
"def publish_switch_config(mapping)\n nutella.net.publish('currentConfig/switched', mapping)\n puts 'Sent currentConfig/switched'\nend",
"def rename_netif(opts)\n\n end",
"def rename_netif(opts)\n\n end",
"def rename_netif(opts)\n\n end",
"def replace_administrative_ip(opts)\n opts = check_params(opts,[:old_ips,:new_ips,:netmasks])\n super(opts)\n end",
"def state_on_updateclient\n @log.debug(\"Net_state: change to state state_on_updateclient\")\n @network_state = :state_on_updateclient\n make_state_change_ntfy(:ntfy_state_onupdate)\n end",
"def implement_workarounds(hosts)\n # workaround for dbus config file mismatch error:\n #\n # \"dbus[562]: [system] Unable to reload configuration: Configuration file\n # needs one or more <listen> elements giving addresses\"\n on hosts, 'systemctl restart dbus'\nend",
"def assign_proxy_switch(dvs, switch_name, pnics, pnics_available)\n dvs = dvs.item\n\n # Return if host is already assigned\n return dvs if !dvs['config.host'].select { |host| host.config.host._ref == self['_ref'] }.empty?\n\n # Prepare spec for DVS reconfiguration\n configSpec = RbVmomi::VIM::VMwareDVSConfigSpec.new\n configSpec.name = switch_name\n configSpec.configVersion = dvs['config.configVersion']\n\n # Check if host is already assigned to distributed switch\n operation = \"add\"\n ##operation = \"edit\" if !dvs['config.host'].select { |host| host.config.host._ref == self['_ref'] }.empty?\n\n # Add host members to the distributed virtual switch\n host_member_spec = RbVmomi::VIM::DistributedVirtualSwitchHostMemberConfigSpec.new\n host_member_spec.host = @item\n host_member_spec.operation = operation\n host_member_spec.backing = RbVmomi::VIM::DistributedVirtualSwitchHostMemberPnicBacking.new\n host_member_spec.backing.pnicSpec = []\n\n # If pnics are needed assign pnics for uplinks\n if pnics\n pnics = pnics.split(\",\")\n # Get uplink portgroup from dvswitch\n uplink_key = dvs['config.uplinkPortgroup'].select{\n |ul| ul.name == \"#{switch_name}-uplink-pg\"}.first.key rescue nil\n\n raise \"Cannot find the uplink portgroup for #{switch_name}\" if !uplink_key\n\n pnics.each {|pnic|\n pnicSpec = RbVmomi::VIM::DistributedVirtualSwitchHostMemberPnicSpec.new\n pnicSpec.pnicDevice = pnic\n pnicSpec.uplinkPortgroupKey = uplink_key\n host_member_spec.backing.pnicSpec << pnicSpec\n }\n end\n\n configSpec.host = [host_member_spec]\n\n # The DVS must be reconfigured\n dvs_reconfigure_task = dvs.ReconfigureDvs_Task(:spec => configSpec)\n dvs_reconfigure_task.wait_for_completion\n if dvs_reconfigure_task.info.state != 'success'\n raise \"It wasn't possible to assign host #{self[\"name\"]} as a member of #{switch_name}'\"\n end\n\n return dvs\n end",
"def configure_networks(vm_id, network_spec)\n raise Bosh::Clouds::NotSupported.new(false),\n 'configure_networks is not supported.'\n end",
"def gen_nec_config\n config = \"switch :: EtherSwitch; \\\nFromDevice(#{@netif}, PROMISC true) -> [0]switch; \\\nswitch[0] -> Queue -> ToDevice(#{@netif}); \"\n\n i = 1\n @mobiles.each do |mac, client|\n next unless client.ul && client.dl && client.ip\n config << \"AddressInfo(c_#{i} #{client.ip} #{client.mac}); \\\narr_#{i} :: ARPResponder(c_#{i}); \\\narq_#{i} :: ARPQuerier(c_#{i}); \\\n\\\nScript(write arq_#{i}.gateway #{@defgw}, write arq_#{i}.netmask #{@netmask}); \\\n\\\nulgre_#{i} :: FromDevice(#{client.ul}); \\\ndlgre_#{i} :: ToDevice(#{client.dl}); \\\n\\\nswitch[#{i}] -> cf_#{i} :: Classifier(12/0806 20/0001, 12/0806 20/0002, -); \\\ncf_#{i}[0] -> arr_#{i} -> [#{i}]switch; \\\ncf_#{i}[1] -> [1]arq_#{i}; \\\ncf_#{i}[2] -> Strip(14) -> dlgreq_#{i} :: Queue -> dlgre_#{i}; \\\nulgre_#{i} -> GetIPAddress(16) -> arq_#{i} -> [#{i}]switch; \"\n i += 1\n end\n config\n end",
"def update_vss(switch, name, pnics, num_ports, mtu)\n pnics = pnics.split(\",\") rescue []\n\n #Backup switch spec for rollback\n orig_spec = switch.spec\n\n #Compare current configuration and return if switch hasn't changed\n same_switch = false\n\n switch_has_pnics = switch.spec.respond_to?(:bridge) && switch.spec.bridge.respond_to?(:nicDevice)\n\n\n\n same_switch = switch.spec.respond_to?(:mtu) && switch.spec.mtu == mtu &&\n switch.spec.respond_to?(:numPorts) && switch.spec.numPorts == num_ports &&\n (!switch_has_pnics && pnics.empty? ||\n switch_has_pnics && switch.spec.bridge.nicDevice.uniq.sort == pnics.uniq.sort)\n return if same_switch\n\n # Let's create a new spec and update the switch\n vswitchspec = nil\n hostbridge = nil\n nws = self['configManager.networkSystem']\n hostbridge = RbVmomi::VIM::HostVirtualSwitchBondBridge(:nicDevice => pnics) if !pnics.empty?\n vswitchspec = RbVmomi::VIM::HostVirtualSwitchSpec(:bridge => hostbridge, :mtu => mtu, :numPorts => num_ports)\n\n begin\n nws.UpdateVirtualSwitch(:vswitchName => name, :spec => vswitchspec)\n rescue Exception => e\n raise \"The standard switch with name #{name} could not be updated. Reason: #{e.message}\"\n end\n\n @net_rollback << {:action => :update_sw, :name => name, :spec => orig_spec}\n end",
"def offloads_in_sync?\n get_config_changes\n additions = @changes['whole'].merge(@changes['partial'])\n offload_attrs = ['FCoEOffloadMode', 'iScsiOffloadMode']\n nic_changes = additions.select do |k,v|\n k.include?('NIC.') && offload_attrs.any? {|attr| v[attr]}\n end\n nic_changes.each do |nic_fqdd, attrs|\n attrs.each do |attr, value|\n if offload_attrs.include?(attr)\n existing_value = find_attribute_value(xml_base, nic_fqdd, attr, true)\n unless existing_value == value\n return false\n end\n end\n end\n end\n true\n end",
"def update_network_adapter(ip, tld)\n # Need to defer loading to ensure cross OS compatibility\n require 'win32/registry'\n if admin_mode?\n network_name = get_network_name(ip)\n if network_name.nil?\n info(\"unable to determine network interface for #{ip}. DNS on host cannot be configured. Try manual configuration.\")\n return\n else\n info(\"adding Landrush'es DNS server to network '#{network_name}' using DNS IP '#{ip}'' and search domain '#{tld}'\")\n end\n network_guid = get_guid(network_name)\n if network_guid.nil?\n info(\"unable to determine network GUID for #{ip}. DNS on host cannot be configured. Try manual configuration.\")\n return\n end\n interface_path = INTERFACES + \"\\\\{#{network_guid}}\"\n Win32::Registry::HKEY_LOCAL_MACHINE.open(interface_path, Win32::Registry::KEY_ALL_ACCESS) do |reg|\n reg['NameServer'] = '127.0.0.1'\n reg['Domain'] = tld\n end\n else\n run_with_admin_privileges(__FILE__.to_s, ip, tld)\n end\n end",
"def prompt_network_interfaces(zone_id, provision_type_id, pool_id, options={})\n #puts \"Configure Networks:\"\n no_prompt = (options[:no_prompt] || (options[:options] && options[:options][:no_prompt]))\n network_interfaces = []\n api_params = {zoneId: zone_id, provisionTypeId: provision_type_id}.merge(options[:api_params] || {})\n if pool_id\n api_params[:poolId] = pool_id \n end\n\n zone_network_options_json = api_client.options.options_for_source('zoneNetworkOptions', api_params)\n # puts \"zoneNetworkOptions JSON\"\n # puts JSON.pretty_generate(zone_network_options_json)\n zone_network_data = zone_network_options_json['data'] || {}\n networks = zone_network_data['networks']\n network_groups = zone_network_data['networkGroups']\n if network_groups\n networks = network_groups + networks\n end\n network_subnets = zone_network_data['networkSubnets']\n if network_subnets\n networks += network_subnets\n end\n network_interface_types = (zone_network_data['networkTypes'] || []).sort { |x,y| x['displayOrder'] <=> y['displayOrder'] }\n enable_network_type_selection = (zone_network_data['enableNetworkTypeSelection'] == 'on' || zone_network_data['enableNetworkTypeSelection'] == true)\n has_networks = zone_network_data[\"hasNetworks\"] == true\n max_networks = (zone_network_data[\"maxNetworks\"].to_i > 0) ? zone_network_data[\"maxNetworks\"].to_i : nil\n\n # skip unless provision type supports networks\n if !has_networks\n return nil\n end\n\n # no networks available, shouldn't happen\n if networks.empty?\n return network_interfaces\n end\n\n network_options = []\n networks.each do |opt|\n if !opt.nil?\n network_options << {'name' => opt['name'], 'value' => opt['id']}\n end\n end\n\n network_interface_type_options = []\n network_interface_types.each do |opt|\n if !opt.nil?\n network_interface_type_options << {'name' => opt['name'], 'value' => opt['id']}\n end\n end\n\n interface_index = 0\n add_another_interface = true\n while add_another_interface do\n # if !no_prompt\n # if interface_index == 0\n # puts \"Configure Network Interface\"\n # else\n # puts \"Configure Network Interface #{interface_index+1}\"\n # end\n # end\n\n # networkInterfaces may be passed as objects from blueprints or via -O networkInterfaces='[]'\n field_context = interface_index == 0 ? \"networkInterface\" : \"networkInterface#{interface_index+1}\"\n network_interface = {}\n if options[:options] && options[:options]['networkInterfaces'] && options[:options]['networkInterfaces'][interface_index]\n network_interface = options[:options]['networkInterfaces'][interface_index]\n end\n\n default_network_id = network_interface['networkId'] || network_interface['id']\n if default_network_id.nil? && network_interface['network'].is_a?(Hash) && network_interface['network']['id']\n default_network_id = network_interface['network']['id']\n end\n # JD: this for cluster or server prompting perhaps?\n # because zoneNetworkOptions already returns foramt like \"id\": \"network-1\"\n if !default_network_id || !default_network_id.to_s.include?(\"-\")\n if network_interface['network'] && network_interface['network']['id']\n if network_interface['network']['subnet']\n default_network_id = \"subnet-#{network_interface['network']['subnet']}\"\n elsif network_interface['network']['group']\n default_network_id = \"networkGroup-#{network_interface['network']['group']}\"\n else\n default_network_id = \"network-#{network_interface['network']['id']}\"\n end\n end\n end\n\n default_network_value = (network_options.find {|n| n['value'] == default_network_id} || {})['name']\n\n # choose network\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'networkId', 'type' => 'select', 'fieldLabel' => \"Network\", 'selectOptions' => network_options, 'required' => true, 'skipSingleOption' => false, 'description' => 'Choose a network for this interface.', 'defaultValue' => default_network_value}], options[:options], api_client, {}, no_prompt, true)\n network_interface['network'] = {}\n network_interface['network']['id'] = v_prompt[field_context]['networkId'].to_s\n selected_network = networks.find {|it| it[\"id\"].to_s == network_interface['network']['id'] }\n #network_options.reject! {|it| it['value'] == v_prompt[field_context]['networkId']}\n\n if !selected_network\n print_red_alert \"Network not found by id #{network_interface['network']['id']}!\"\n exit 1\n end\n\n # choose network interface type\n if enable_network_type_selection && !network_interface_type_options.empty?\n default_interface_type_value = (network_interface_type_options.find {|t| t['value'].to_s == network_interface['networkInterfaceTypeId'].to_s} || {})['name']\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'networkInterfaceTypeId', 'type' => 'select', 'fieldLabel' => \"Network Interface Type\", 'selectOptions' => network_interface_type_options, 'required' => true, 'skipSingleOption' => true, 'description' => 'Choose a network interface type.', 'defaultValue' => default_interface_type_value}], options[:options])\n network_interface['networkInterfaceTypeId'] = v_prompt[field_context]['networkInterfaceTypeId'].to_i\n end\n\n # choose IP if network allows it\n # allowStaticOverride is only returned in 4.2.1+, so treat null as true for now..\n ip_available = selected_network['allowStaticOverride'] == true || selected_network['allowStaticOverride'].nil?\n ip_required = true\n if selected_network['id'].to_s.include?('networkGroup')\n #puts \"IP Address: Using network group.\" if !no_prompt\n ip_available = false\n ip_required = false\n elsif selected_network['pool']\n #puts \"IP Address: Using pool '#{selected_network['pool']['name']}'\" if !no_prompt\n ip_required = false\n elsif selected_network['dhcpServer']\n #puts \"IP Address: Using DHCP\" if !no_prompt\n ip_required = false\n end\n\n if ip_available\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'ipAddress', 'type' => 'text', 'fieldLabel' => \"IP Address\", 'required' => ip_required, 'description' => 'Enter an IP for this network interface. x.x.x.x', 'defaultValue' => network_interface['ipAddress']}], options[:options])\n if v_prompt[field_context] && !v_prompt[field_context]['ipAddress'].to_s.empty?\n network_interface['ipAddress'] = v_prompt[field_context]['ipAddress']\n end\n end\n\n if ip_required == false && network_interface['ipAddress'] == nil && selected_network['dhcpServer'] == true\n network_interface['ipMode'] = 'dhcp'\n end\n\n network_interfaces << network_interface\n interface_index += 1\n if options[:options] && options[:options]['networkInterfaces'] && options[:options]['networkInterfaces'][interface_index]\n add_another_interface = true\n elsif (max_networks && network_interfaces.size >= max_networks) || network_options.count == 0\n add_another_interface = false\n else\n has_another_interface = options[:options] && options[:options][\"networkInterface#{interface_index+1}\"]\n add_another_interface = has_another_interface || (!no_prompt && Morpheus::Cli::OptionTypes.confirm(\"Add another network interface?\", {:default => false}))\n end\n\n end\n\n return network_interfaces\n\n end",
"def before_update(params_to_update=[])\n transport.command(\"enable\")\n transport.command(\"conf\", :prompt => /\\(conf\\)#\\s?\\z/n)\n end",
"def update_kvm_ip(name)\n new_ip = (available_ips - used_ips).pop\n raise 'no ips available' unless new_ip\n update_network_interfaces(name, new_ip)\n new_ip\nend",
"def update_config(watchers)\n # if we support updating backends, try that whenever possible\n if @opts['do_socket']\n update_backends(watchers)\n else\n @restart_required = true\n end\n \n # generate new config\n new_config = generate_config(watchers)\n new_config = new_config.flatten.join(\"\\n\")\n \n # if we write config files, lets do that and then possibly restart\n if @opts['do_writes']\n write_config(new_config)\n restart if @opts['do_reloads'] && @restart_required\n end\n end",
"def get_interface_cleanup_config(intf_name)\n if platform == :ios_xr\n [\"no interface #{intf_name}\", \"interface #{intf_name} shutdown\"]\n else\n [\"default interface #{intf_name}\"]\n end\n end",
"def configure_ports(interface, min_port)\n interface ||= \"127.0.0.1\"\n min_port ||= 8080\n unless env[:riak_core][:http]\n env[:riak_core][:http] = [Tuple[interface, min_port]]\n min_port += 1\n end\n env[:riak_core][:http] = env[:riak_core][:http].map {|pair| Tuple[*pair] }\n env[pb_config_section][:pb_ip] = interface unless env[pb_config_section][:pb_ip]\n unless env[pb_config_section][:pb_port]\n env[pb_config_section][:pb_port] = min_port\n min_port += 1\n end\n unless env[:riak_core][:handoff_port]\n env[:riak_core][:handoff_port] = min_port\n min_port += 1\n end\n end",
"def interface_add(network_interfaces, node_uid, interfaces)\n num1 = node_uid.split('-')[1].to_i\n if network_interfaces.has_value?(interfaces) == false\n network_interfaces[[num1]] = interfaces\n else\n num2 = network_interfaces.key(interfaces)\n network_interfaces.delete(num2)\n network_interfaces[num2.push(num1)] = interfaces\n end\n end",
"def apply_ConnectChange(inst_inf,signal_db,add_signal_db=nil,priority)\n # get taget macro info\n module_name = nil, inst_name = nil\n case inst_inf.MacroType\n when \"Add\",\"ADD\",\"add\",\"KeepChange\",\"KEEPCHANGE\"\n module_name = inst_inf.ModuleName\n inst_name = inst_inf.InstName\n when \"Replace\",\"REPLACE\",\"replace\"\n module_name = inst_inf.ReplaceModuleName\n inst_name = inst_inf.InstName\n end\n \n # Get Connect List ( ex: [[\"MOD_CON\", \"./tp/ADD_MODULE.mod_con\"],[\"INST_CON\", \"./tp/ADD_MODULE.inst_con\"]] )\n connect_list = inst_inf.get_ConnectList\n\n connect_list.each do |connect|\n connect_file_type = connect[0] # MOD_CON/ADD_MOD_CON/INST_CON/ADD_INST_CON\n connect_file = connect[1] # File name \n \n # Get Conenct Inforamtion ( read & analyze conf )\n printf(\"@I:read Connect File(%s)\\n\",connect_file)\n connect = FMakeConnect.new(\n :file_type => connect_file_type,\n :con_file => connect_file,\n :module_name => module_name,\n :inst_name => inst_name\n )\n con_db = connect.analyze\n\n printf \"[Apply(change/add) Connection]\\n\"\n # XML Add/Modify each Port\n signal_db.each do |name,sig_all|\n if sig_all == nil\n if con_db.PIN_INF == {} # There is no change connection\n # Error : not enough to signal connect infomation\n FMakeMessage.PrintError( :category => \"CONNECT\", :no => 224, :inst_name => inst_name, :pin_name => name, :conf_file => con_db.CONNECT_FILE) \n else\n # New Port\n sig_all = add_signal_db[name]\n printf(\"@I:make new connect for %s\\n\",name)\n connect_change(sig_all,con_db,inst_name,connect_file_type,inst_inf,priority)\n end\n else\n # There is no change connection\n if con_db.PIN_INF == {} \n# sig_all.each do |sig|\n# connect = connect + \" \" + sig.Name\n# end\n printf(\"@I:Make connection(%s.%s) Indication:No-Change\\n\",inst_name,name)\n else\n printf(\"------------------------------------------------------\\n\")\n printf(\"@I:change connect for %s.%s\\n\",inst_name,name)\n printf(\"------------------------------------------------------\\n\")\n connect_change(sig_all,con_db,inst_name,connect_file_type,inst_inf,priority)\n end\n end\n end\n end\n \n end",
"def read_network_interfaces\n end",
"def add_nonbridged_network_to_vbox_vm(client_name,nic_name)\n message = \"Adding:\\t\\tNetwork \"+nic_name+\" to \"+client_name\n if nic_name.match(/vboxnet/)\n command = \"VBoxManage modifyvm #{client_name} --hostonlyadapter1 #{nic_name} ; VBoxManage modifyvm #{client_name} --nic1 hostonly\"\n else\n command = \"VBoxManage modifyvm #{client_name} --nic1 #{nic_name}\"\n end\n execute_command(message,command)\n return\nend",
"def interface_xml\n prefix_old = @xpath_prefix\n @xpath_prefix = \"TEMPLATE/NIC[ATTACH='YES']/\"\n\n model = @xml[\"#{@xpath_prefix}MODEL\"]\n model = env('DEFAULT_ATTACH_NIC_MODEL') if model.empty?\n model.encode!(:xml => :attr) unless model.empty?\n\n filter = @xml[\"#{@xpath_prefix}FILTER\"]\n filter = env('DEFAULT_ATTACH_NIC_FILTER') if filter.empty?\n filter.encode!(:xml => :attr) unless filter.empty?\n\n if exist? 'BRIDGE'\n dev = '<interface type=\"bridge\">'\n\n if @xml[\"#{@xpath_prefix}BRIDGE_TYPE\"] =~ /openvswitch/\n dev << '<virtualport type=\"openvswitch\"/>'\n end\n\n dev << xputs('<source bridge=%s/>', 'BRIDGE')\n else\n dev = '<interface type=\"ethernet\">'\n end\n\n dev << xputs('<mac address=%s/>', 'MAC')\n dev << xputs('<script path=%s/>', 'SCRIPT')\n\n dev << xputs('<target dev=%s/>', 'TARGET')\n dev << xputs('<boot order=%s/>', 'ORDER')\n dev << \"<model type=#{model}/>\" unless model.empty?\n\n if model == 'virtio'\n dev << xputs('<driver name=\"vhost\" queues=%s/>',\n 'VIRTIO_QUEUES')\n end\n\n if exist?('IP') && !filter.empty?\n dev << \"<filterref filter=#{filter}>\"\n dev << xputs('<parameter name=\"IP\" value=%s/>', 'IP')\n dev << xputs('<parameter name=\"IP\" value=%s/>', 'VROUTER_IP')\n dev << '</filterref>'\n end\n\n inb_keys = ['INBOUND_AVG_BW', 'INBOUND_PEAK_BW', 'INBOUND_PEAK_KB']\n inbound = inb_keys.any? {|e| exist? e }\n\n outb_keys = ['OUTBOUND_AVG_BW', 'OUTBOUND_PEAK_BW', 'OUTBOUND_PEAK_KB']\n outbound = outb_keys.any? {|e| exist? e }\n\n if inbound || outbound\n dev << '<bandwidth>'\n\n if inbound\n dev << '<inbound'\n dev << xputs(' average=%s', 'INBOUND_AVG_BW')\n dev << xputs(' peak=%s', 'INBOUND_PEAK_BW')\n dev << xputs(' burst=%s', 'INBOUND_PEAK_KB')\n dev << '/>'\n end\n\n if outbound\n dev << '<outbound'\n dev << xputs(' average=%s', 'OUTBOUND_AVG_BW')\n dev << xputs(' peak=%s', 'OUTBOUND_PEAK_BW')\n dev << xputs(' burst=%s', 'OUTBOUND_PEAK_KB')\n dev << '/>'\n end\n\n dev << '</bandwidth>'\n end\n\n dev << '</interface>'\n\n @xpath_prefix = prefix_old\n\n dev\n end",
"def read_network_interfaces\n nics = {}\n\n # Get enabled VM's network interfaces\n ifaces = read_settings.fetch('Hardware', {}).keep_if do |dev, params|\n dev.start_with?('net') and params.fetch('enabled', true)\n end\n ifaces.each do |name, params|\n adapter = name.match(/^net(\\d+)$/)[1].to_i\n nics[adapter] ||= {}\n\n case params['type']\n when 'shared'\n nics[adapter][:type] = :shared\n when 'host'\n nics[adapter][:type] = :hostonly\n nics[adapter][:hostonly] = params.fetch('iface', '')\n when 'bridged'\n nics[adapter][:type] = :bridged\n nics[adapter][:bridge] = params.fetch('iface', '')\n end\n end\n nics\n end",
"def genConf\n conf=\"auto #{@device}\\n\"\n if (ip != nil && netmask != nil)\n conf+=%(iface #{@device} inet static\n address #{@ip}\n netmask #{@netmask}\n)\n else\n conf+=\"iface #{@device} inet dhcp\\n\"\n end\n end",
"def update!(**args)\n @enable_internet_access = args[:enable_internet_access] if args.key?(:enable_internet_access)\n @network = args[:network] if args.key?(:network)\n @subnetwork = args[:subnetwork] if args.key?(:subnetwork)\n end",
"def options_changeable?\n network_state = @model_net_data.network_state\n if network_state == :state_on_localgame or\n network_state == :state_on_netgame\n return false\n else\n return true\n end\n end",
"def apply_grip_config(config)\n if !config.is_a?(Array)\n config = [config]\n end\n config.each do |entry|\n if !entry.key?('control_uri')\n next\n end\n client = PubControlClient.new(entry['control_uri'])\n if entry.key?('control_iss')\n client.set_auth_jwt({'iss' => entry['control_iss']}, entry['key'])\n end\n super_add_client(client)\n end\n end",
"def configure_private_network_ip(config, ip, vm_name)\n if ip\n config.vm.network :private_network, :ip => ip, :netmask => \"255.255.255.0\"\n else\n puts \" NO HOSTONLY IP defined for VM #{vm_name}.\"\n end\n end",
"def update_network_connection_section(xml, networks)\n array_wrap(networks).reject { |n| n[:new_idx] == -1 || n[:idx].nil? }.each { |nic| update_network_connection_section_by_index(xml, **nic) }\n array_wrap(networks).select { |n| n[:new_idx] == -1 }.each { |nic| remove_network_connection_section_by_index(xml, :idx => nic[:idx]) }\n array_wrap(networks).select { |n| n[:idx].nil? }.each { |nic| add_network_connection_section(xml, **nic) }\n end",
"def network_interface\n node = 'AWS_NETWORK_INTERFACE'\n q = []\n\n # network interface\n q.push(_upsert({ node: node, id: @name }))\n\n # vpc node and relationship\n if @data.vpc_id\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_VPC',\n child_name: @data.vpc_id,\n relationship: 'MEMBER_OF_VPC'\n }\n\n q.push(_upsert_and_link(opts))\n end\n\n # security_groups and relationship\n @data.groups.each do |sg|\n opts = {\n node: 'AWS_SECURITY_GROUP',\n id: sg.group_id,\n headless: true\n }\n\n q.push(_merge(opts))\n\n # network_interface -> security_group\n opts = {\n from_node: 'AWS_NETWORK_INTERFACE',\n from_name: @name,\n to_node: 'AWS_SECURITY_GROUP',\n to_name: sg.group_id,\n relationship: 'IN_SECURITY_GROUP',\n headless: true\n }\n q.push(_link(opts))\n end\n\n q\n end",
"def management_ip_static_configured?\n !!running_config.match(%r{interface ManagementEthernet \\d+/\\d+.*?\\s+ip address\\s+\\d+.\\d+.\\d+.\\d+\\/\\d+})\n end",
"def check_osx_pfctl(options,gw_if_name,if_name)\n output = check_osx_ip_forwarding(options,gw_if_name)\n if not output.to_s.match(/#{gw_if_name}/) or not output.to_s.match(/#{if_name}/) or output.to_s.match(/killswitch/) or options['force'] == true\n pf_file = options['workdir']+\"/pfctl_config\"\n if File.exist?(pf_file)\n File.delete(pf_file)\n end\n output = File.open(pf_file,\"w\")\n if options['verbose'] == true\n handle_output(options,\"Information:\\tEnabling forwarding between #{gw_if_name} and #{if_name}\")\n end\n output.write(\"nat on #{gw_if_name} from #{if_name}:network to any -> (#{gw_if_name})\\n\")\n output.write(\"pass inet proto icmp all\\n\")\n output.write(\"pass in on #{if_name} proto udp from any to any port domain keep state\\n\")\n output.write(\"pass in on #{if_name} proto tcp from any to any port domain keep state\\n\")\n output.write(\"pass quick on #{gw_if_name} proto udp from any to any port domain keep state\\n\")\n output.write(\"pass quick on #{gw_if_name} proto tcp from any to any port domain keep state\\n\")\n output.close\n message = \"Enabling:\\tPacket filtering\"\n command = \"sudo sh -c \\\"pfctl -e\\\"\"\n execute_command(options,message,command)\n message = \"Loading:\\yFilters from \"+pf_file\n command = \"sudo sh -c \\\"pfctl -F all -f #{pf_file}\\\"\"\n execute_command(options,message,command)\n end\n return\nend",
"def modify_KeepChange(inst_inf,mode)\n\n case mode\n when \"MODULE\"\n # Do nothing\n when \"CONNECT-HIGH\"\n signal = XMLParse::get_PortList(@root,inst_inf.ModuleName)\n signal_db = Hash.new\n signal.each do |key,value|\n signal_db[key] = [value]\n end\n # Connect Change\n apply_ConnectChange(inst_inf,signal_db,nil,\"High\")\n when \"CONNECT-NORMAL\"\n signal = XMLParse::get_PortList(@root,inst_inf.ModuleName)\n signal_db = Hash.new\n signal.each do |key,value|\n signal_db[key] = [value]\n end\n # Connect Change\n apply_ConnectChange(inst_inf,signal_db,nil,\"Normal\")\n end\n\n return true\n end",
"def update\n return nil unless ipv4_available?\n\n last_ipv4 = @last_ipv4 ? @last_ipv4 : get_gandi_ipv4\n\n update_config = false\n\n if @last_ipv4.nil?\n update_config = true\n else\n update_config = true if @last_ipv4.empty?\n update_config = true if last_ipv4 != @last_ipv4\n end\n\n print_debug \"Last IPv4 (form config file or Gandi):#{last_ipv4}\", 1\n\n # TODO: save it in YAML file to reduce Gandi queries\n ip_resolv = IpResolver.new\n cur_ipv4 = ipv4_available? ? ip_resolv.get_ipv4 : ''\n\n if !cur_ipv4.empty? && cur_ipv4 != last_ipv4\n to_update = cur_ipv4\n update_config = true\n else\n to_update = ''\n end\n\n print_debug to_update.inspect, 2\n retval = update_ips to_update\n if retval and update_config\n retval = update_config_file cur_ipv4\n end\n retval\n end",
"def gen_airspan_config\n # first of all we declare the main switch element\n # and all the sources/sinks that we're going to use\n config = \"switch :: EtherSwitch; \\\nfrom_bs :: FromDevice(#{@bsif}, PROMISC true); \\\nto_bs :: ToDevice(#{@bsif}); \\\nfrom_net :: FromDevice(#{@netif}, PROMISC true); \\\nto_net :: ToDevice(#{@netif}); \"\n\n # then the two filter compounds for whitelisting\n # clients based on their mac address\n filter_first_output = []\n filter_second_output = []\n network_filter = 'filter_from_network :: { '\n bs_filter = 'filter_from_bs :: { '\n i = 1\n @mobiles.each_key do |mac|\n network_filter << \"filter_#{i} :: HostEtherFilter(#{mac}, DROP_OWN false, DROP_OTHER true); \"\n bs_filter << \"filter_#{i} :: HostEtherFilter(#{mac}, DROP_OWN true, DROP_OTHER false); \"\n filter_first_output << \"filter_#{i}[0]\"\n filter_second_output << \"filter_#{i}[1]\"\n i += 1\n end\n network_filter << 'input -> filter_1; '\n network_filter << filter_first_output.join(', ') << ' -> output; '\n network_filter << filter_second_output.join(' -> ') << ' -> Discard; } '\n bs_filter << 'input -> filter_1; '\n bs_filter << filter_second_output.join(', ') << ' -> output; '\n bs_filter << filter_first_output.join(' -> ') + ' -> Discard; } '\n config << network_filter << bs_filter\n\n # finally we plug everything into the switch\n config << \"from_net -> filter_from_network -> [0]switch[0] -> Queue -> to_net; \\\nfrom_bs -> filter_from_bs -> [1]switch[1] -> Queue -> to_bs;\"\n end",
"def check_osx_nat(options,gw_if_name,if_name)\n output = check_osx_ip_forwarding(gw_if_name)\n if not output.match(/#{gw_if_name}/)\n message = \"Information:\\tEnabling NATd to forward traffic on \"+gw_if_name\n if options['host-os-release'].split(\".\")[0].to_i < 14\n command = \"sudo sh -c \\\"ipfw add 100 divert natd ip from any to any via #{gw_if_name}\\\"\"\n execute_command(options,message,command)\n else\n check_osx_pfctl(options,gw_if_name,if_name)\n end\n end\n if options['host-os-release'].split(/\\./)[0].to_i < 13\n message = \"Information:\\tChecking NATd is running\"\n command = \"ps -ef |grep '#{gw_if_name}' |grep natd |grep 'same_ports'\"\n output = execute_command(options,message,command)\n if not output.match(/natd/)\n message = \"Information:\\tStarting NATd to foward packets between \"+if_name+\" and \"+gw_if_name\n command = \"sudo sh -c \\\"/usr/sbin/natd -interface #{gw_if_name} -use_sockets -same_ports -unregistered_only -dynamic -clamp_mss -enable_natportmap -natportmap_interface #{if_name}\\\"\"\n execute_command(options,message,command)\n end\n end\n return\nend",
"def apply_config!\n if self.connect then\n @ssh_connection.exec!(\"/usr/etc/rc.d/rc.softrestart\") or raise\n #@ssh_connection.exec!(\"ubntconf -c /tmp/system.cfg\") or raise\n #@ssh_connection.exec!(\"cfgmtd -p /etc/\") or raise\n #@ssh_connection.exec!(\"reboot\") or raise\n end\n end",
"def ipsettings\n Puppet.debug \"Retrieving ip configuration of specified portgroup.\"\n begin\n @networksystem=host.configManager.networkSystem\n\n vnics=@networksystem.networkInfo.vnic\n\n vnics.each do |vnic|\n if (vnic.portgroup && resource[:portgrp] == vnic.portgroup)\n if (resource[:ipsettings] == :static)\n ipaddressonportgroup = vnic.spec.ip.ipAddress\n subnetmaskonportgroup = vnic.spec.ip.subnetMask\n if (ipaddressonportgroup != resource[:ipaddress] || subnetmaskonportgroup != resource[:subnetmask])\n return \"false\"\n elsif (ipaddressonportgroup == resource[:ipaddress] && subnetmaskonportgroup == resource[:subnetmask])\n return resource[:ipsettings]\n #return same as manifest file because the port group has same values hence no need to go into setter\n end\n elsif (resource[:ipsettings] == :dhcp)\n dhcpflagonportgroup = vnic.spec.ip.dhcp\n if (dhcpflagonportgroup == false)\n return \"false\"\n elsif (dhcpflagonportgroup == true)\n return \"dhcp\"\n end\n end\n end\n end\n return resource[:ipsettings]\n rescue Exception => e\n fail \"Unable to retrieve ip configuration of the specified portgroup because the following exception occured: -\\n #{e.message}\"\n end\n end",
"def read_bridged_interfaces\n host_hw_info = read_host_info.fetch('Hardware info', {})\n net_list = host_hw_info.select do |name, attrs|\n # Get all network interfaces except 'vnicXXX'\n attrs.fetch('type') == 'net' and name !~ /^(vnic(.+?))$/\n end\n\n bridged_ifaces = []\n net_list.keys.each do |iface|\n info = {}\n ifconfig = execute('ifconfig', iface)\n # Assign default values\n info[:name] = iface\n info[:ip] = '0.0.0.0'\n info[:netmask] = '0.0.0.0'\n info[:status] = 'Down'\n\n info[:ip] = $1.to_s if ifconfig =~ /(?<=inet\\s)(\\S*)/\n if ifconfig =~ /(?<=netmask\\s)(\\S*)/\n # Netmask will be converted from hex to dec:\n # '0xffffff00' -> '255.255.255.0'\n info[:netmask] = $1.hex.to_s(16).scan(/../).each.map { |octet| octet.hex }.join('.')\n end\n info[:status] = 'Up' if ifconfig =~ /\\W(UP)\\W/ and ifconfig !~ /(?<=status:\\s)inactive$/\n\n bridged_ifaces << info\n end\n bridged_ifaces\n end"
] |
[
"0.6173955",
"0.60474354",
"0.5944021",
"0.5873205",
"0.5819781",
"0.5768081",
"0.57122844",
"0.570934",
"0.57059175",
"0.56624365",
"0.565729",
"0.5625125",
"0.55513424",
"0.5550935",
"0.5538155",
"0.55335784",
"0.5512803",
"0.55036944",
"0.5495416",
"0.54888123",
"0.54761237",
"0.54625505",
"0.5439977",
"0.5435104",
"0.5434965",
"0.5418619",
"0.5413709",
"0.54096204",
"0.5398817",
"0.5385867",
"0.535697",
"0.53388846",
"0.5337143",
"0.5335955",
"0.5334872",
"0.53303677",
"0.5318444",
"0.53125685",
"0.5306209",
"0.5291285",
"0.5277176",
"0.5267875",
"0.5267701",
"0.5257598",
"0.52574235",
"0.52547914",
"0.524462",
"0.52428263",
"0.5236163",
"0.5236163",
"0.5235332",
"0.52319634",
"0.5229332",
"0.5227559",
"0.52224076",
"0.52173525",
"0.5216132",
"0.5211025",
"0.5208539",
"0.52084595",
"0.52062076",
"0.52062076",
"0.52062076",
"0.51934993",
"0.5186095",
"0.51772654",
"0.5161722",
"0.51610005",
"0.51581866",
"0.5150592",
"0.5146918",
"0.51457745",
"0.5141134",
"0.5125875",
"0.5120584",
"0.5114796",
"0.51140654",
"0.51118433",
"0.51065814",
"0.5106128",
"0.51031864",
"0.51000625",
"0.5100058",
"0.5097771",
"0.5096694",
"0.5096628",
"0.5094519",
"0.5085639",
"0.5077952",
"0.5071488",
"0.5065092",
"0.5064595",
"0.50597346",
"0.5059683",
"0.50591505",
"0.5058039",
"0.504111",
"0.5037763",
"0.50336087",
"0.50274146"
] |
0.68822914
|
0
|
A gate which can be used to limit dangerous code to only run during provisioning or upon boot
|
def disruptable?
@disruptable ||=
node.firstboot_any_phase? || ENV['CHEF_BOOT_SERVICE'] == 'true'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def taint() end",
"def provision!; end",
"def sharded?; true; end",
"def sharded?; false; end",
"def allow_production=(_arg0); end",
"def sandbox?; end",
"def sandbox?; end",
"def allow_in_post_mortem; end",
"def allowed?; true end",
"def distracted?\n false\n end",
"def one_gradable_ex_only\n end",
"def tainted?() end",
"def allow_production; end",
"def security_prevent_install_apps_from_unknown_sources\n return @security_prevent_install_apps_from_unknown_sources\n end",
"def guard; end",
"def policy; end",
"def enable!; end",
"def run_warned; end",
"def can_use_ill?\n !virginia_borrower?\n end",
"def call &block\n return true if before(@action)\n return true if send(@action)\n raise Lux::Error.unauthorized('Access disabled in policy')\n rescue Lux::Error\n error = $!.message\n error += \" - #{self.class}.#{@action}\" if Lux.config(:dump_errors)\n raise Lux::Error.unauthorized(error) unless block\n block.call(error)\n false\n end",
"def ridicule_faultfully_prerevision()\n end",
"def gate_for(thing)\n gates.detect { |gate| gate.protects?(thing) } ||\n raise(GateNotFound.new(thing))\n end",
"def allow_anon\n end",
"def chargeable?; true; end",
"def whiny; end",
"def haveStolen\n @canISteal = false\n\n end",
"def execute_in_protected_mode(&block)\n run_as_user do\n shield.with_protected_mode(&block)\n end\n end",
"def allow_more_estate_privileges!\n warn \"Experimental code #{__method__}. Do not enable in release. #{__FILE__}:#{__LINE__}\"\n\n # 5 in 1.30.3\n # 4 in 1.30.4\n soft_patch_defines_lua!(\"fun_and_balance_more_privileges\",\n [\"NCountry.ESTATE_PRIVILEGES_MAX_CONCURRENT\", 5, 10],\n )\n end",
"def protects?(thing)\n false\n end",
"def eval_policy(policy_type) \n\n # Bail out on the policy evaluation if 'override_policy' is defined \n # in the current Thread. This indicates that there is some function \n # privileging that should take the place of the actual policy.\n\n return Thread.current['override_policy'].call unless Thread.current['override_policy'].nil?\n\n # If there is no policy object defined, then we assume that \n # access should be allowed. This is part of our philopsophy that\n # GuardRails should not interfere with existing functionality\n # unless explicity told to do so.\n\n if policy_object.nil?\n if policy_type == :append_access\n # Not sure whether defering to :write_access in this case\n # actually does anything since the entire object is nil\n return eval_policy(:write_access)\n else\n return true\n end\n end\n\n # If there is a policy_object, but it has no rule for the \n # specific type of access we are concerned with, true is the\n # default response, except in the case of append access, which\n # should defer to write access if undefined. After all, if\n # you do not have write access, you should not be able to\n # append anything.\n\n function = policy_object[policy_type]\n if function.nil?\n if policy_type == :append_access\n return eval_policy(:write_access)\n else\n return true\n end\n end\n\n # Loopbreak is a thread variable that prevents infinite loops\n # from occuring when an access control check occurs within\n # an annotation's function that are mutually dependent.\n # For now, we just run the annotation functions in a universally\n # privileged environment.\n\n return true if Thread.current['loopbreak'] == true\n Thread.current['loopbreak'] = true\n\n # The number of parameters passed to the policy's function depends\n # on how many parameters it wants. It can have no parameters, the\n # current user if it has one parameter, and the current user and \n # response information if it has two.\n\n func = eval(function)\n if func.arity == 0\n ret = eval(function).call\n elsif func.arity == 1\n ret = eval(function).call(Thread.current['user'])\n elsif func.arity == 2\n ret = eval(function).call(Thread.current['user'], Thread.current['response'])\n else\n raise GuardRailsError, \"Annotation Policy Requires Too Many Parameters\"\n end\n\n # Turn of the extra privileges\n Thread.current['loopbreak'] = false\n\n # Return true if the access is allowed, false otherwise\n ret\n end",
"def allow_service_check_state\n super\n end",
"def blockdev?() end",
"def awaken!\n\t\traise 'Not implemented'\n\tend",
"def allow_in_post_mortem=(_arg0); end",
"def denied\n end",
"def smart?; self.permission_level = 2; end",
"def taint_mode=(_arg0); end",
"def early_launch_anti_malware_driver_enabled\n return @early_launch_anti_malware_driver_enabled\n end",
"def conditionally(*) end",
"def conditionally(*) end",
"def permitted?; end",
"def disabled_feature\n\tatm = AtmMachine.new(100, PinValidator)\n\tcard = CreditCard.new(1234, 30)\n\tatm.insert_card(card, 666)\n\tatm.insert_card(card, 1234)\nend",
"def allow_in_control=(_arg0); end",
"def make_safe!\n return false\n end",
"def disallow(*methods)\n methods.each do |meth|\n define_method(meth) do |*, **|\n raise \"#{meth} not expected to be called\" if not_deployed?\n end\n end\nend",
"def chef_only!\n\tif !current_user || !current_user.chef\n\t\tredirect \"/\"\n\tend\nend",
"def stand_alone?; end",
"def stand_alone?; end",
"def privileged(&block)\n ensure_mode(:privileged)\n instance_eval(&block)\n end",
"def unstable?\n harm > 3\n end",
"def early_launch_anti_malware_driver_enabled=(value)\n @early_launch_anti_malware_driver_enabled = value\n end",
"def can_define_cutoffs\n if !@contest.completed? || !@contest.medal || (@contest.gold_cutoff > 0 && !current_user.sk.root)\n render 'errors/access_refused' and return\n end\n end",
"def application_guard_block_non_enterprise_content\n return @application_guard_block_non_enterprise_content\n end",
"def semiprotect(reason = nil, expiry = 'infinite') \n protect(reason, expiry, 'edit=autoconfirmed|move=autoconfirmed')\n #possible errors: user doesn't have privileges\n end",
"def circuit_breaker; end",
"def can_serve_booze?\n self.age >= 19\n end",
"def test_nonhero_is_vulnerable\n end",
"def pbCriticalOverride(attacker,opponent)\n return false\n end",
"def protects?(_thing)\n false\n end",
"def activation_lock_allow_when_supervised\n return @activation_lock_allow_when_supervised\n end",
"def check_security(people)\n found_miscreant(people)\n some_later_code(found)\nend",
"def ygg_attacker() ; return nil ; end",
"def secure?\n #debugger\n false\n end",
"def sandbox; end",
"def sandbox; end",
"def enforce_permissions\n bounce unless is_admin?\n end",
"def deny\n throw(:return)\n end",
"def noSecret()\r\n puts \"I won’t tell you our secret\"\r\n end",
"def attack_effect_setup\r\n self.critical = false\r\n end",
"def warden; end",
"def warden; end",
"def warden; end",
"def sandbox &code\n proc {\n $SAFE = 2\n yield\n }.call\nend",
"def `(*args); forbidden(__method__); end",
"def spam?( env ); raise NotImplementedError; end",
"def is_offensive?\n self.status == 1\n end",
"def advice\n end",
"def pre_run_check\n Puppet.warning(\"#{self[:name]}: Doing some pre-run checks\")\n binding.pry if defined?(Pry)\n end",
"def allow_own_actions_while_proxied?\n true\n end",
"def regular?\n !administrative? && !stub?\n end",
"def deny_yin_yang(prock, diagnostic = nil, &block)\n source = reflect_source(&block)\n fuss = [diagnostic, \"fault before calling:\", source].compact.join(\"\\n\")\n assert fuss, &prock\n block.call\n fuss = [diagnostic, \"fault after calling:\", source].compact.join(\"\\n\")\n assert fuss, &prock\n end",
"def secret_method_1\n end",
"def requested_flow_control\n super\n end",
"def mycelial_gristmilling()\n xenopteri_shebang(sectwise_cessor, ungular_pietism)\n end",
"def can_xp?\n false\n end",
"def allow_kick_bomb\n @kick_bomb = true\n end",
"def blocked?\n false\n end",
"def semact?; false; end",
"def user_verification?; end",
"def safe; end",
"def check_for_requirements; end",
"def warden(&block); end",
"def can_request_scanning?\n true # TODO: Should this be !virginia_borrower? ?\n end",
"def allowDamage _obj, _args\n \"_obj allowDamage _args;\" \n end",
"def activation_lock_allow_when_supervised=(value)\n @activation_lock_allow_when_supervised = value\n end",
"def invention; end",
"def agent_should_start?\n !blacklisted_constants? &&\n !blacklisted_executables? &&\n !in_blacklisted_rake_task?\n end",
"def hard?\n !soft?\n end",
"def base_recipe()\n warn \"#{self} hasn't been overridden to return a Proc!!\"\n lambda {\n # put your capistrano config and tasks in here\n }\n end",
"def can_make_reserves?\n !undergraduate? && !virginia_borrower?\n end",
"def trust_cache?\n !node['cloudflare']['threat_control']['disable_cache'] \\\n && !Chef::Config[:solo]\nend"
] |
[
"0.62861425",
"0.62122357",
"0.6168107",
"0.6159649",
"0.6132658",
"0.6076362",
"0.6076362",
"0.6048164",
"0.6006247",
"0.5969954",
"0.59371656",
"0.59067506",
"0.5905686",
"0.5878779",
"0.5870758",
"0.57948",
"0.5752462",
"0.5741829",
"0.57318795",
"0.57315296",
"0.5708797",
"0.5706663",
"0.56906366",
"0.5686585",
"0.56606126",
"0.5654377",
"0.5649854",
"0.5634635",
"0.5620516",
"0.5610248",
"0.5608028",
"0.55991095",
"0.55848205",
"0.55792236",
"0.5572957",
"0.556814",
"0.5566615",
"0.5540385",
"0.5533556",
"0.5533556",
"0.5523635",
"0.55216163",
"0.55190045",
"0.55133027",
"0.55001235",
"0.5499374",
"0.54975265",
"0.54975265",
"0.5497139",
"0.5496247",
"0.54911685",
"0.54843056",
"0.5482993",
"0.5479534",
"0.5477324",
"0.5471956",
"0.5467842",
"0.5462114",
"0.5460848",
"0.5458773",
"0.54516995",
"0.54493207",
"0.54482585",
"0.5447328",
"0.5447328",
"0.544717",
"0.54445976",
"0.5436566",
"0.5428824",
"0.5411352",
"0.5411352",
"0.5411352",
"0.54074514",
"0.54045737",
"0.54045093",
"0.54044616",
"0.53993505",
"0.53958786",
"0.5392986",
"0.5392103",
"0.5377109",
"0.5374986",
"0.53749216",
"0.5371595",
"0.5371537",
"0.535971",
"0.5354288",
"0.53499347",
"0.5347868",
"0.5344027",
"0.5340958",
"0.5340491",
"0.5340081",
"0.5335195",
"0.53179747",
"0.5314503",
"0.53133965",
"0.53099877",
"0.5307107",
"0.5306035",
"0.5303221"
] |
0.0
|
-1
|
Creates and initialize new instance of the HttpOperationResponse class.
|
def initialize(request, response, body = nil)
@request = request
@response = response
@body = body
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_response(request, http_response, body = nil)\n HttpOperationResponse.new(request, http_response, body)\n end",
"def initialize(http_response, request)\n @http_response = http_response\n @request = request\n end",
"def initialize(http_resp)\n @content = http_resp.body\n @data = JSON.parse(http_resp.body, symbolize_names: true)\n @status_code = http_resp.code.to_i\n end",
"def initialize(http_options = {})\n @http_options = http_options\n end",
"def initialize(options)\n initialize_options(options)\n initialize_headers\n http_request\n end",
"def initialize(http, _code, _path) # @private\n @success, @body, @errors = http.success, http.response, http.errors\n @code, @path, @params = _code, _path\n end",
"def initialize\n @isRequest = nil\t# true, false and nil\n @httpVersion = 'HTTP/1.1'\n @bodyType = nil\n @bodyCharset = nil\n @bodySize = nil\n @bodyDate = nil\n @headerItem = []\n @chunked = false\n @responseStatusCode = nil\n @reasonPhrase = nil\n @requestMethod = nil\n @requestUri = nil\n @requestQueryUri = nil\n @requestViaProxy = false\n end",
"def initialize(http_response, http_response_code, http_raw_response)\n @http_status_code = http_response_code\n @http_raw_response = http_raw_response\n\n # only set these variables if a message-body is expected.\n if not @http_raw_response.kind_of? Net::HTTPNoContent\n @body = MultiJson.load(http_response) unless http_response.nil?\n @request = MultiJson.load(@body[\"request\"].to_s) if @body[\"request\"]\n @api_status = @body[\"status\"].to_i if @body[\"status\"]\n @api_error_message = @body[\"error_message\"].to_s if @body[\"error_message\"]\n end\n end",
"def initialize(status, header, http_version, body = '')\n\n @http_version = http_version\n @status = status\n @header = header\n @body = body\n end",
"def initialize(request, response)\n @request = request\n @response = response\n end",
"def initialize(*args)\n @body = nil\n @headers = {}\n @http_version = '1.1'\n\n super\n end",
"def initialize(status, headers, body, protocol = nil)\n\t\t\t\tsuper(nil, status, headers, body, protocol)\n\t\t\tend",
"def initialize(response)\n @response = response\n @headers = response.headers\n @status = response.status\n @body = response.body || ''\n end",
"def initialize(response, request)\n @response = response\n @request = request\n end",
"def initialize(http)\n @http = http\n end",
"def initialize(status = nil, headers = nil, body = nil)\n super()\n\n self.status = status if status # Don't set @status directly!\n update_headers(headers) if headers\n @body = body if body\n end",
"def initialize(response, status)\n @response = response\n @status = status\n end",
"def initialize(request:, response: nil)\n @request = request\n @response = response\n end",
"def initialize(http_response, collection)\n super\n\n pagination = http_response[\"pagination\"]\n @page = pagination[\"current_page\"]\n @per_page = pagination[\"per_page\"]\n @total_entries = pagination[\"total_entries\"]\n @total_pages = pagination[\"total_pages\"]\n end",
"def initialize(status, headers, body)\n @status = status.to_i\n @headers = sanitize_http_headers(headers)\n @body = body\n end",
"def initialize\n self.http_client = HTTPClient.new(:base_url => Rdioid::BASE_URL, :force_basic_auth => true)\n\n http_client.set_auth(Rdioid::OAUTH_TOKEN_ENDPOINT, Rdioid.config.client_id, Rdioid.config.client_secret)\n end",
"def initialize\n @format = 'json'\n @scheme = 'https'\n @host = 'api.taxamo.com'\n @base_path = ''\n @user_agent = \"ruby-swagger\"\n @inject_format = true\n @force_ending_format = false\n @camelize_params = false\n end",
"def initialize(*args, **opt)\n @http_response = @http_status = @cause = nil\n args.map! do |arg|\n case arg\n when Integer then (@http_status = arg) and next\n when Exception then @cause = arg\n when Faraday::Response then faraday_response(arg)\n else arg\n end\n end\n args.flatten!\n args.compact!\n # noinspection RailsParamDefResolve\n case @cause\n when nil\n # Ignore\n when Api::Error\n @http_response ||= @cause.http_response\n @http_status ||= @cause.http_status\n when Faraday::Error\n @http_status ||= @cause.response&.dig(:status)\n args = faraday_error(*@cause.message) + args\n @cause = @cause.wrapped_exception || @cause\n when Exception\n @http_status ||= @cause.try(:code)\n else\n Log.warn { \"Api::Error#initialize: @cause #{@cause.class} unexpected\" }\n end\n @http_status ||= @http_response&.status\n super(*args, **opt)\n rescue => error\n Log.error { \"Api::Error#initialize: #{error.class}: #{error.message}\" }\n re_raise_if_internal_exception(error)\n super('ERROR')\n end",
"def initialize(options = {})\n self.http_connection_factory = options.delete(:http_connection_factory) || Net::HTTP\n end",
"def initialize(opts)\n @version = opts.fetch(:version)\n @request = init_request(opts)\n @status = HTTP::Response::Status.new(opts.fetch(:status))\n @headers = HTTP::Headers.coerce(opts[:headers] || {})\n @proxy_headers = HTTP::Headers.coerce(opts[:proxy_headers] || {})\n\n if opts.include?(:body)\n @body = opts.fetch(:body)\n else\n connection = opts.fetch(:connection)\n encoding = opts[:encoding] || charset || default_encoding\n\n @body = Response::Body.new(connection, :encoding => encoding)\n end\n end",
"def initialize\n @mparams = BasicHttpParams.new\n @cparams = BasicHttpParams.new\n\n @manager_params = ConnManagerParamBean.new( @mparams )\n @client_params = ClientParamBean.new( @cparams )\n @connection_params = HttpConnectionParamBean.new( @cparams )\n\n @client = nil\n @connection_manager = nil\n @retry_handler = nil\n end",
"def initialize(http_client, metric)\n super(http_client, entity_name: 'method', collection_name: 'methods')\n @service = metric.service\n @metric = metric\n @resource_instance = Method\n end",
"def net_http_init(net_http_response)\n\n @original = net_http_response\n @status = net_http_response.code.to_i\n @body = net_http_response.body\n @headers = {}\n net_http_response.each { |k, v|\n @headers[k.split('-').collect { |s| s.capitalize }.join('-')] = v\n }\n end",
"def initialize\n @action = :get\n @headers = {}\n @timeout = 0\n @connect_timeout = 0\n @max_redirects = -1\n end",
"def initialize(headers, errors, status_code)\n @headers = headers\n\n if errors.is_a?(Array) || !errors\n @errors = (errors || []).map do |error|\n OpenStruct.new(error['error'])\n end\n else\n @errors = [OpenStruct.new(message: 'The API returned an unexpected '\\\n 'response. This is likely due to an incorrectly defined base URL.')]\n end\n\n @status_code = status_code\n end",
"def initialize\n ext_initialize\n @headers = {}\n @timeout = 5\n @connect_timeout = 1\n @max_redirects = 5\n @auth_type = :basic\n end",
"def initialize(credentials = nil, base_url = nil, options = nil)\n super(credentials, options)\n @base_url = base_url || 'https://management.azure.com'\n\n fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?\n @credentials = credentials\n\n @api = Api.new(self)\n @api_revision = ApiRevision.new(self)\n @api_release = ApiRelease.new(self)\n @api_operation = ApiOperation.new(self)\n @api_operation_policy = ApiOperationPolicy.new(self)\n @tag = Tag.new(self)\n @api_product = ApiProduct.new(self)\n @api_policy = ApiPolicy.new(self)\n @api_schema = ApiSchema.new(self)\n @api_diagnostic = ApiDiagnostic.new(self)\n @api_issue = ApiIssue.new(self)\n @api_issue_comment = ApiIssueComment.new(self)\n @api_issue_attachment = ApiIssueAttachment.new(self)\n @api_tag_description = ApiTagDescription.new(self)\n @operation_operations = OperationOperations.new(self)\n @api_version_set = ApiVersionSet.new(self)\n @authorization_server = AuthorizationServer.new(self)\n @backend = Backend.new(self)\n @cache = Cache.new(self)\n @certificate = Certificate.new(self)\n @api_management_operations = ApiManagementOperations.new(self)\n @api_management_service_skus = ApiManagementServiceSkus.new(self)\n @api_management_service = ApiManagementService.new(self)\n @diagnostic = Diagnostic.new(self)\n @email_template = EmailTemplate.new(self)\n @group = Group.new(self)\n @group_user = GroupUser.new(self)\n @identity_provider = IdentityProvider.new(self)\n @issue = Issue.new(self)\n @logger = Logger.new(self)\n @network_status = NetworkStatus.new(self)\n @notification = Notification.new(self)\n @notification_recipient_user = NotificationRecipientUser.new(self)\n @notification_recipient_email = NotificationRecipientEmail.new(self)\n @open_id_connect_provider = OpenIdConnectProvider.new(self)\n @policy = Policy.new(self)\n @policy_snippet = PolicySnippet.new(self)\n @sign_in_settings = SignInSettings.new(self)\n @sign_up_settings = SignUpSettings.new(self)\n @delegation_settings = DelegationSettings.new(self)\n @product = Product.new(self)\n @product_api = ProductApi.new(self)\n @product_group = ProductGroup.new(self)\n @product_subscriptions = ProductSubscriptions.new(self)\n @product_policy = ProductPolicy.new(self)\n @property = Property.new(self)\n @quota_by_counter_keys = QuotaByCounterKeys.new(self)\n @quota_by_period_keys = QuotaByPeriodKeys.new(self)\n @region = Region.new(self)\n @reports = Reports.new(self)\n @subscription = Subscription.new(self)\n @tag_resource = TagResource.new(self)\n @tenant_access = TenantAccess.new(self)\n @tenant_access_git = TenantAccessGit.new(self)\n @tenant_configuration = TenantConfiguration.new(self)\n @user = User.new(self)\n @user_group = UserGroup.new(self)\n @user_subscription = UserSubscription.new(self)\n @user_identities = UserIdentities.new(self)\n @user_confirmation_password = UserConfirmationPassword.new(self)\n @api_export = ApiExport.new(self)\n @api_version = '2019-01-01'\n @accept_language = 'en-US'\n @long_running_operation_retry_timeout = 30\n @generate_client_request_id = true\n add_telemetry\n end",
"def initialize(object, response = nil)\n @object = object\n\n @action = object['action']\n @created_at = object['created_at']\n @details = object['details']\n @id = object['id']\n @links = object['links']\n @metadata = object['metadata']\n @resource_type = object['resource_type']\n @response = response\n end",
"def initialize(options={})\n @api_key = options[:api_key] || config.api_key\n @path = options[:path]\n @params = options[:params]\n @http_request_options = options[:http_request_options] || {}\n end",
"def initialize(status, body, headers, message = nil)\n @status = status\n @body = body\n @headers = headers\n @message = message\n end",
"def initialize(req, res, route_params = {})\n @request, @response = req, res\n @params = Params.new(@request, route_params)\n @already_built_response = false\n end",
"def initialize(options = {})\n options = DEFAULT_ARGS.merge(options)\n\n @client = Faraday.new(\n faraday_options(options),\n ) do |conn|\n conn.response(:json)\n conn.adapter(Faraday.default_adapter)\n end\n end",
"def initialize\n begin\n @api_methods = Api_methods\n @api_version = Api_version\n rescue StandardError => e\n $log.error(sprintf(\"%s: %s\", __method__, e.message))\n raise\n end\n end",
"def initialize(options = {})\n options = DEFAULT_ARGS.merge(options)\n\n @client = Faraday.new(\n faraday_options(options),\n ) do |f|\n f.adapter :net_http\n end\n end",
"def initialize(code, object = nil, status = nil, aditional_data = nil, data_root = :message)\n aditional_data = {} unless aditional_data\n response = {\n :status => status || \"success\",\n :code => code,\n :message => Response::message(code)\n }.merge(aditional_data)\n\n if object\n @_object = object\n response[:data] = {data_root => @_object}\n end\n\n @object = OpenStruct.new(response)\n end",
"def initialize(base = nil, opts = nil) # :yields: self\n opts =\n if base.nil? && opts.nil?\n {}\n elsif base.nil? && opts.is_a?(Hash)\n opts\n elsif base.is_a?(Hash) && opts.nil?\n base\n elsif base.is_a?(self.class) && opts.nil?\n base.to_hash\n elsif (base.is_a?(Hash) || base.is_a?(self.class)) && opts.is_a?(Hash)\n hash =\n if base.is_a?(self.class)\n base.to_hash\n else\n base\n end\n hash.update(opts)\n end\n\n @header, @http_header = format_header_name(\n opts[:header] || opts[:correlation_header] || CORRELATION_HEADER\n )\n\n @handler = opts.fetch(:handler, :clean)\n @return = opts.fetch(:return, true)\n @action_dispatch = opts.fetch(:action_dispatch, false)\n\n yield self if block_given?\n\n freeze\n end",
"def initialize(response)\n @response = response\n end",
"def initialize(http_response, result_format = :mashie)\n @result_format = result_format\n @headers = parse_headers(http_response.to_hash)\n @body = parse_body(http_response.body)\n end",
"def initialize(options = {})\n options = { :access_token => options } if options.is_a? String\n options = self.class.options.merge(options)\n\n # Parse `api_url` option\n if url = options.delete(:api_url)\n uri = URI.parse(url)\n options[:api_scheme] = uri.scheme\n options[:api_host] = uri.host + (uri.port != 80 && uri.port != 443 ? \":#{uri.port}\" : '')\n end\n\n @access_token = options[:access_token] if options[:access_token]\n @api_scheme = options[:api_scheme]\n @api_host = options[:api_host]\n @api_version = options[:api_version]\n @api_prefix = options[:api_prefix]\n @client_token = options[:client_token] if options[:client_token]\n @transport = options[:transport]\n @result_format = options[:result_format]\n\n # Include transport\n transport_module = Lapse::Transport::TRANSPORT_MAP[@transport]\n raise 'Invalid transport' unless transport_module\n self.extend transport_module\n end",
"def initialize(response)\n @response = response\n end",
"def initialize(response)\n @response = response\n end",
"def initialize(response)\n @response = response\n end",
"def initialize(response)\n @response = response\n end",
"def initialize(api_response_formatter_class, cookies, is_sub_env_specific, headers = {})\n\n @api_response_formatter_class = api_response_formatter_class\n @cookies = cookies\n @is_sub_env_specific = is_sub_env_specific\n @headers = headers\n\n @request_class = nil\n @service_base_route = nil\n @api_url = nil\n \n end",
"def initialize(object, response = nil)\n @object = object\n\n @actions = object['actions']\n @created_at = object['created_at']\n @fallback_enabled = object['fallback_enabled']\n @id = object['id']\n @links = object['links']\n @mandate_request = object['mandate_request']\n @metadata = object['metadata']\n @payment_request = object['payment_request']\n @purpose_code = object['purpose_code']\n @resources = object['resources']\n @status = object['status']\n @response = response\n end",
"def initialize\n @headers = HeaderHash.new\n @trace = []\n self.code = 200\n self.redirect = false\n end",
"def initialize(http_response)\n @http_response = http_response\n @uri = http_response.uri\n @status_code = http_response.status_code\n parse_response\n # Use reason phrase as the description if description is empty\n @description = http_response.reason_phrase if (@description.nil? || @description.empty?) && http_response.reason_phrase\n super(\"#{type} (#{status_code}): #{description}\")\n end",
"def initialize(options)\n @options = options\n @result = Hash.from_xml(Net::HTTP.get(URI.parse(SERVICE_URL % self.params)))\n return self\n end",
"def create_new_http_request\n # Create a new HTTP request instance\n request_spec = @data[:request][:instance]\n http_class = \"Net::HTTP::#{request_spec.verb._camelize}\"\n http_request = http_class._constantize::new(request_spec.path)\n # Set the request body\n if request_spec.is_io?\n http_request.body_stream = request_spec.body\n else\n http_request.body = request_spec.body\n end\n # Copy headers\n request_spec.headers.each { |header, value| http_request[header] = value }\n # Save the new request\n request_spec.raw = http_request\n # Set user-agent\n if @data[:options].has_key?(:connection_user_agent)\n http_request['user-agent'] ||= @data[:options][:connection_user_agent]\n end\n http_request\n end",
"def initialize(response, envelope = [])\n @response = response\n @envelope = envelope\n end",
"def initialize(config)\n @config = config\n @api_client = ApiClient.new(config)\n @access_token = nil\n end",
"def initialize(config)\n @config = config\n @api_client = ApiClient.new(config)\n @access_token = nil\n end",
"def initialize(&block)\n super(transport)\n\n @parameters = {}\n @query = {}\n @headers = Headers[HEADERS]\n @method = :get\n @asynchronous = true\n @binary = false\n @cacheable = true\n @opened = false\n @sent = false\n @completed = false\n @callbacks = Hash.new { |h, k| h[k] = [] }\n\n if block.arity == 0\n instance_exec(&block)\n else\n block.call(self)\n end if block\n end",
"def initialize(status, headers, body)\n @status = status.to_i\n @headers = Rack::Utils::HeaderHash.new(headers)\n @body = body\n @now = Time.now\n @headers['Date'] ||= @now.httpdate\n end",
"def api\n @http ||= Http.new(config)\n end",
"def initialize(options = {})\n super\n @http_post_format = options[:http_post_format]\n end",
"def initialize(object, response = nil)\n @object = object\n\n @action = object['action']\n @created_at = object['created_at']\n @customer_notifications = object['customer_notifications']\n @details = object['details']\n @id = object['id']\n @links = object['links']\n @metadata = object['metadata']\n @resource_type = object['resource_type']\n @response = response\n end",
"def initialize(response, url, query_params = {})\n @response_status = response.status\n @response_body = response.body\n @response_headers = response.headers\n message = \"Status code #{response.status} on resource #{url}\"\n message += \" with params: #{query_params.inspect}\" if query_params.present?\n super(message)\n end",
"def initialize(options =\n {\n :type => :GET,\n :base_url => '',\n :api_path => '',\n :headers => {},\n :body => nil,\n :params => {}\n })\n options.each do |key, value|\n instance_variable_set(\"@#{key}\", value)\n end\n yield(self) if block_given?\n end",
"def initialize(credentials = nil, base_url = nil, options = nil)\n super(credentials, options)\n @base_url = base_url || 'https://management.azure.com'\n\n fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?\n @credentials = credentials\n\n @operations = Operations.new(self)\n @accounts = Accounts.new(self)\n @pools = Pools.new(self)\n @volumes = Volumes.new(self)\n @mount_targets = MountTargets.new(self)\n @snapshots = Snapshots.new(self)\n @api_version = '2019-06-01'\n @accept_language = 'en-US'\n @long_running_operation_retry_timeout = 30\n @generate_client_request_id = true\n add_telemetry\n end",
"def initialize(service, url_chunk, options = {})\n @service = service\n @url_chunk = url_chunk\n @method = options.delete(:method) || :get\n @format = options.delete(:format) || :auto\n @query = options.delete(:query)\n @params = options.delete(:params)\n @options = options\n end",
"def initialize(url = nil, options = {})\n if url.is_a?(Hash)\n options = url\n url = options[:url]\n end\n @headers = Headers.new\n @params = {}\n @options = options[:request] || {}\n @ssl = options[:ssl] || {}\n @parallel_manager = options[:parallel]\n self.url_prefix = url if url\n proxy(options[:proxy])\n merge_params @params, options[:params] if options[:params]\n merge_headers @headers, options[:headers] if options[:headers]\n\n if block_given?\n @builder = Builder.create { |b| yield b }\n else\n @builder = options[:builder] || Builder.new\n end\n end",
"def initialize(api_obj)\n @api_obj = api_obj\n end",
"def initialize(verb, uri, &callback)\n @webmock_stub = ::WebMock::RequestStub.new(verb, uri)\n @callback = callback\n end",
"def initialize(trip, http_request_bundler)\n @trip = trip\n @lyft_api_service = LyftApiService.new(Config.lyft_client_token)\n @http_request_bundler = http_request_bundler\n\n # add http calls to bundler based on services\n request = prepare_http_requests\n @http_request_bundler.add(request[:label], request[:url], request[:action], request[:options])\n end",
"def initialize(httparty)\n @data = httparty.parsed_response\n @http = httparty.response\n end",
"def initialize\n @headers = {}\n @trace = []\n self.code = 200\n self.redirect = false \n end",
"def initialize(status_code, headers={}, body='')\n @status_code = status_code.to_i\n @headers = headers\n @body = body\n end",
"def initialize(object, response = nil)\n @object = object\n\n @created_at = object['created_at']\n @id = object['id']\n @scheme = object['scheme']\n @status = object['status']\n @response = response\n end",
"def initialize\n @response_format = 'json'\n @scheme = 'http'\n @host = 'api.wordnik.com'\n @hosts = []\n @load_balancer = nil\n @base_path = '/v4'\n @user_agent = \"ruby-#{Wordnik::VERSION}\"\n # Build the default set of resource names from the filenames of the API documentation\n begin\n api_docs_path = File.join(File.dirname(__FILE__), '../../api_docs')\n @resource_names = Dir.glob(File.join(api_docs_path, '*.json')).map {|f| f.split('/').last.sub('.json', '') }.sort\n true\n rescue\n raise 'Problem loading the resource files in ./api_docs/'\n end\n end",
"def initialize(method, path, body = nil)\n super\n @warn = false\n content_length = body ? body.bytesize.to_s : '0'\n @headers.update({\n 'x-ms-version' => '2014-06-01',\n 'Content-Type' => 'application/xml',\n 'Content-Length' => content_length\n })\n @uri = URI.parse(Azure.config.management_endpoint + Azure.config.subscription_id + path)\n @key = Azure.config.http_private_key\n @cert = Azure.config.http_certificate_key\n end",
"def initialize(options = {})\n @options = options\n @request_options = {}\n end",
"def initialize(msg, api_response = nil)\n super(msg)\n\n # Automatically use included response object if possible\n @api_response = api_response.respond_to?(:response) ? api_response.response : api_response\n\n # Parse response and set instance vars\n parse_response unless @api_response.nil?\n end",
"def http_request\n @http_request ||= begin\n request = request_for_verb\n add_post_data(request)\n add_bearer_token(request)\n add_headers(request)\n request\n end\n end",
"def create_http_client\n c = DefaultHttpClient.new( @connection_manager, @cparams )\n c.http_request_retry_handler = @retry_handler if @retry_handler\n c\n end",
"def initialize(response)\n raise ArgumentError, \"Response doesnot exist\" if ((response.nil? || response.empty?) && response.code.nil? && response.code.empty?)\n @_response = response\n @_statusCode = response.code\n @_responseBody = response.body\n end",
"def initialize(client, res)\n @client = client\n @status = res.status\n @headers = res.headers\n @env = res.env\n @body = res.body\n end",
"def initialize(options = {})\n @headers = options[:headers] || HEADERS\n @retries = options[:retries] || RETRIES\n @backoff_policy =\n options[:backoff_policy] || Sumologic::Metrics::BackoffPolicy.new\n\n uri = URI(options.fetch(:uri))\n http = Net::HTTP.new(uri.host, uri.port)\n http.set_debug_output(logger) if logger.level == Logger::DEBUG\n http.use_ssl = uri.scheme == 'https'\n http.read_timeout = 8\n http.open_timeout = 4\n\n @path = uri.path\n @http = http\n end",
"def initialize(operation, client)\n @operation = operation\n @roomorama_client = client\n end",
"def post_init\n @request = Request.new\n @response = Response.new\n end",
"def initialize(service, url_chunk, options = {})\n @service = service\n @url_chunk = url_chunk\n @method = options[:method] || :get\n @format = options[:format] || :auto\n @query = options[:query]\n end",
"def http\n # TODO: Deal with proxies and such\n unless @http\n @http = HTTPClient.new\n # TODO: This should be on the class level\n @http.connect_timeout = ApiResource::Base.open_timeout\n @http.receive_timeout = ApiResource::Base.timeout\n end\n\n return @http\n end",
"def initialize(hash = {})\n super(hash)\n\n @action = extract_value(hash, :action)\n @responseContent = extract_value(hash, :responseContent)\n @accessToken = extract_value(hash, :accessToken)\n @accessTokenExpiresAt = extract_integer_value(hash, :accessTokenExpiresAt)\n @accessTokenDuration = extract_integer_value(hash, :accessTokenDuration)\n @idToken = extract_value(hash, :idToken)\n @authorizationCode = extract_value(hash, :authorizationCode)\n end",
"def build_object\n response = make_request\n body = JSON.load(response.body) if response.body \n body = { response: body } if body.is_a? Array\n hash = body.to_snake_keys if body\n response_object = Hashie::Mash.new(hash)\n response_object.status_code = response.code.to_i unless response_object.status_code\n response_object\n end",
"def initialize(method, uri, body: nil, headers: nil, opts: {})\n @tag = 0\n method = method.downcase.to_sym\n unless method == :get || method == :put || method == :post || method == :delete\n raise ArgumentError, \"Invalid method #{method} for request : '#{uri}'\"\n end\n self.method = method\n self.path = uri\n self.body = body\n self.headers = headers || {}\n self.opts = opts || {}\n end",
"def initialize(host, operation, client)\n @host = host\n @operation = operation\n @roomorama_client = client\n end",
"def initialize(host, operation, client)\n @host = host\n @operation = operation\n @roomorama_client = client\n end",
"def initialize(response)\n @status = response.code.to_i\n @headers = response.each_header { |_, _| }\n @body = extract_body(response.body, *headers[Futile::Headers::CONTENT_ENCODING])\n @status = response.code.to_i\n end",
"def initialize(options = {}, &block)\n @api_key = options.fetch(:api_key)\n @url = options.fetch(:url)\n @method = options.fetch(:method)\n @body = options[:body]\n @request = typhoeus_request\n @block = block\n end",
"def initialize(options={})\n @web_client = options.fetch(:http_client)\n @parser = options[:parser] || JSON\n @proxy_factory_class = options[:factory] || ProxyFactory\n @url_encoder = options[:url_encoder] || CGI\n if options.has_key?(:proxy_cache)\n @proxy_cache = options[:proxy_cache]\n else\n @proxy_cache = ProxyCache.new\n end\n\n @metadata = options[:metadata]\n if @metadata\n configure_with_metadata(@metadata)\n else\n @metadata_factory = options[:metadata_factory] || Metadata\n end\n end",
"def initialize(options = {})\n options[:host] ||= Defaults::Request.host\n options[:port] ||= Defaults::Request.port\n options[:ssl] ||= Defaults::Request.ssl\n options[:headers] ||= Defaults::Request.headers\n @path = options[:path] || Defaults::Request.path\n\n http = Net::HTTP.new(options[:host], options[:port])\n http.use_ssl = options[:ssl]\n http.read_timeout = 8\n http.open_timeout = 4\n\n @http = http\n end",
"def initialize\n super\n\n self.callbacks = ::ActiveSupport::HashWithIndifferentAccess.new\n self.callbacks_queue = []\n\n self.responses = ::ActiveSupport::HashWithIndifferentAccess.new\n self.responses_queue = []\n\n self.client = ::Syncano::Clients::Sync.instance\n self.received_data = ''\n end",
"def initialize(user_context:, http_method:, route:, route_params: {}, query_params: {}, headers: {}, content_type: {}, payload: nil)\n @user_context = user_context\n @app_context = user_context.app_context\n @http_method = http_method.upcase\n @route = route\n @route_params = route_params\n @query_params = query_params\n @headers = headers\n @content_type = content_type\n @payload = payload\n\n raise \"HTTP Method #{@http_method} is unsupported\" unless %w(GET PUT POST DELETE).include? @http_method\n end",
"def initialize success, body\n @success = success || false\n @body = body.fetch('RESPONSE', {})\n end",
"def initialize(params = {})\n @response = {\n has_errors: false,\n errors: []\n }\n @injected_params = params\n end"
] |
[
"0.72643906",
"0.66876644",
"0.64851916",
"0.6429136",
"0.6403305",
"0.6398606",
"0.6334115",
"0.6333564",
"0.6221711",
"0.61988544",
"0.6135737",
"0.6125259",
"0.6037016",
"0.6036697",
"0.60138065",
"0.6012002",
"0.59961396",
"0.59953105",
"0.5988709",
"0.59845096",
"0.5964462",
"0.5943028",
"0.5925477",
"0.5921424",
"0.59198695",
"0.5915318",
"0.5890058",
"0.58803165",
"0.58717144",
"0.58699805",
"0.5858313",
"0.58469105",
"0.5830052",
"0.5819702",
"0.58118176",
"0.57919765",
"0.57866615",
"0.5777443",
"0.5776492",
"0.5774761",
"0.5773944",
"0.5762639",
"0.5760719",
"0.5758296",
"0.57559896",
"0.57559896",
"0.57559896",
"0.57559896",
"0.57433057",
"0.57234",
"0.5706341",
"0.5705398",
"0.5705086",
"0.5699966",
"0.56997395",
"0.56980973",
"0.56980973",
"0.5693659",
"0.5690379",
"0.5687101",
"0.5676394",
"0.5664059",
"0.5651897",
"0.5646412",
"0.56287533",
"0.5621402",
"0.5621321",
"0.5620528",
"0.5614721",
"0.5612477",
"0.56122637",
"0.5611182",
"0.5606379",
"0.5604956",
"0.56025714",
"0.56019413",
"0.5596986",
"0.55910367",
"0.55901885",
"0.5578308",
"0.55781966",
"0.55733055",
"0.5566941",
"0.55662996",
"0.5561244",
"0.5555227",
"0.55493236",
"0.55479217",
"0.55379647",
"0.55338126",
"0.55328023",
"0.55328023",
"0.5522661",
"0.55219096",
"0.55144924",
"0.5511594",
"0.5508606",
"0.5505948",
"0.55021536",
"0.5500431"
] |
0.6204797
|
9
|
show method specific page for opportunity
|
def show
@opp = Opp.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n end",
"def show\n\n \n end",
"def show\r\n\r\n end",
"def show\r\n\r\n end",
"def show\r\n\r\n end",
"def show\n # TODO\n end",
"def show\n # TODO\n end",
"def show\n \n # \n end",
"def show\n @page_id = \"opinions\"\n @opinion = Opinion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @opinion }\n end\n end",
"def show\n #\n end",
"def show\n #\n end",
"def show\n \n \n end",
"def show\n \n \n end",
"def show\n \n \n end",
"def show\n \n \n end",
"def show\n \n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n \n \n end",
"def show\t\t\t\t\n\t\t\tend",
"def show\n\n end",
"def show\n \n end",
"def show\n \n end",
"def show \n\n end",
"def show\n # no se que hace\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n\n \n\n end",
"def show\n\n\tend",
"def show\n\n\tend",
"def show\n\n\tend",
"def show\n\n end",
"def show\n \tend",
"def show\n \tend",
"def show\n\t\t\n\tend",
"def show\n\t\t\n\tend",
"def show\n\t\t\n\tend",
"def show \n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n\t end",
"def show\n end",
"def show\n end",
"def show\r\n end",
"def show\r\n end",
"def show\r\n end",
"def show\r\n end",
"def show\n \t\n end",
"def show\n \t\n end",
"def show\n \n\n end",
"def show \n \n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end"
] |
[
"0.7210297",
"0.7163404",
"0.7162369",
"0.7162369",
"0.7162369",
"0.71623135",
"0.71623135",
"0.71586764",
"0.7130144",
"0.71261644",
"0.71261644",
"0.71208555",
"0.71208555",
"0.71208555",
"0.71208555",
"0.71186465",
"0.7117115",
"0.7117115",
"0.7117115",
"0.7115804",
"0.7108335",
"0.70994395",
"0.7098002",
"0.7098002",
"0.7092496",
"0.70816445",
"0.7077026",
"0.7077026",
"0.7077026",
"0.70762104",
"0.7076092",
"0.7076092",
"0.7076092",
"0.70722514",
"0.7070563",
"0.7070563",
"0.70604885",
"0.70604885",
"0.70604885",
"0.70604163",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.70532024",
"0.7048374",
"0.7048374",
"0.7048374",
"0.7048374",
"0.7048374",
"0.7048374",
"0.7048374",
"0.7048374",
"0.7045138",
"0.70451254",
"0.70451254",
"0.70441896",
"0.70441896",
"0.70441896",
"0.70441896",
"0.7035034",
"0.7035034",
"0.7034803",
"0.70316166",
"0.70306194",
"0.70306194",
"0.70306194",
"0.70306194"
] |
0.0
|
-1
|
Time field on form sets year to 2000 so this will give correct date
|
def update_time_date
start_year = self.start_at.change(:year => self.lesson_date.year)
start_month = start_year.change(:month => self.lesson_date.month)
start_day = start_month.change(:day => self.lesson_date.day)
self.start_at = start_day
end_year = self.end_at.change(:year => self.lesson_date.year)
end_month = end_year.change(:month => self.lesson_date.month)
end_day = end_month.change(:day => self.lesson_date.day)
self.end_at = end_day
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def form_date\n \"#{date.month}/#{date.day}/#{date.year - 2000}\"\n end",
"def datetime_select_jp(form, method, options ={})\n options[:use_month_numbers].nil? and options[:use_month_numbers] = true\n options[:end_year] ||= (form.object.send(method) || @show_time).year + 10 \n form.datetime_select(method, options)\n end",
"def year\n return @t_year\n end",
"def year\n @date_time_value.year\n end",
"def year\n @date_time_value.year\n end",
"def submitted_date_time=(value)\n @submitted_date_time = value\n end",
"def submitted_date_time=(value)\n @submitted_date_time = value\n end",
"def job_time(value)\n @form['581'] = value\n end",
"def date_field_enter(date)\n my_date = Date.parse(date)\n year = my_date.year\n month = my_date.strftime('%b')\n day = my_date.strftime('%d')\n\n day_field = @field.all(:css, 'input[id$=\"DayValue\"]').first\n day_field.set \"#{day}\"\n\n month_drop_down = @field.all(:css, 'select[id$=\"MonthLongValue\"]').first[:id]\n select(month, :from => month_drop_down)\n\n year_field = @field.all(:css, 'input[id$=\"YearValue\"]').first\n year_field.set \"#{year}\"\n end",
"def end_year\n Time.now.year \n end",
"def time_field field = nil\n @time_field = field if field\n @time_field\n end",
"def get_year\n @year ||= params[:year] ? params[:year].to_i : Time.now.year\n end",
"def fill_in_date_time(field, with:)\n # date time picker can't be found by label\n # so we need to find it by input id\n input_id = page.find('label', text: field)['for']\n input = find_field(input_id)\n input.set(with)\n input.send_keys(:enter)\n end",
"def get_date_time_for_display(date_time_value)\n formatted_date = \"\"\n if(date_time_value != nil)\n d = DateTime.parse(date_time_value)\n formatted_date = d.strftime(\"%Y\")\n end\n return formatted_date\n end",
"def build_time\n time = Time.now\n \"#{time.month}-#{time.day}-#{time.year}\"\n end",
"def start_year\n Time.now.year - 75\n end",
"def start_year\n Time.now.year - 18\n end",
"def set_time_of_year\n @time_of_year = TimeOfYear.find(params[:id])\n end",
"def set_year\n @year = params[:year].blank? ? @today.year : params[:year].to_i\n end",
"def year\n Time.zone.now.year\n end",
"def year\n return @year\n end",
"def form_partial_locals(args)\n output = super\n output[:date_options] = { \n :start_year => Time.now.year - 70,\n :default => get_datetime_or_today(args[:value])\n }\n return output\n end",
"def year\n @year ||= TODAY.year\n end",
"def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end",
"def year\n 2020\n end",
"def get_date()\n @time\n end",
"def unsubmitted_date_time=(value)\n @unsubmitted_date_time = value\n end",
"def date_field_with_time(actual_date, object_name, method, options={})\n actual_date = Time.now if actual_date == nil\n if actual_date != nil\n hash = separate_date_time(actual_date)\n date_part = date_field(object_name, method+'_date', :size => 15, :value => hash[:date])\n time_part = text_field object_name, method+'_time', :size => 4,:value => hash[:time]\n else\n date_part= \"* SHOULD BE DATE STUFF HERE * \"\n time_part= \"* SHOULD BE TIME STUFF HERE * \"\n end\n return date_part+' ' + time_part\n end",
"def raw_year\n start_on.year\n end",
"def current_year\n Time.current.year\n end",
"def year; end",
"def year; end",
"def date_field_with_time_allowing_blank(date, object_name, method, options={})\n hash = { :date => '', :time => '' } \n \n\thash = separate_date_time(date) if date != nil\n\t\n date_part = date_field(object_name, method+'_date', :size => 15, :value => hash[:date])\n time_part = text_field object_name, method+'_time', :size => 4, :value => hash[:time]\n \n return date_part+' ' + time_part\n end",
"def date_posted\n @date_posted ||= begin\n case raw = params[:date_posted].strip\n when %r{^(\\d{1,2})[./-](\\d{1,2})$} # if they excluded the year, add it for them\n raw = [$1,$2,Time.now.year].join(\"/\")\n end\n time = Chronic.parse(raw)\n time && time.to_date\n end\n end",
"def submitted_date_time\n return @submitted_date_time\n end",
"def submitted_date_time\n return @submitted_date_time\n end",
"def year\n end",
"def year\n return @year\n end",
"def build_form(form_builder, options)\n set_value_in_hash options\n value = CckForms::ParameterTypeClass::Time::date_object_from_what_stored_in_database(options[:value])\n form_element_options, form_element_html = CckForms::ParameterTypeClass::Time.default_options_for_date_time_selectors(value, options)\n form_element_options.merge!({minute_step: 5})\n form_element_html.merge!({required: options[:required]})\n ('<div class=\"form-inline\">%s</div>' % form_builder.fields_for(:value) { |datetime_builder| datetime_builder.datetime_select '', form_element_options, form_element_html})\n end",
"def year() end",
"def html_for_date_field(object, field)\n \"<p>\n <label for = '#{field}' >\n Select your #{field}:\n </label>\n <input type = 'date' \n name = create_form[#{field}]\n placeholder = 'mm/dd/yy'\n value = '#{date_humanized(object.send(field))}'>\n </input>\n </p>\"\n end",
"def years\n Thread.current[:datet_mode] = :years\n return self\n end",
"def form_partial_locals(args)\n output = super\n output[:date_options] = { \n :start_year => Time.now.year - 70,\n :default => get_date_or_today(args[:value])\n }\n return output\n end",
"def date_time=(dt)\n @value = dt.strftime('%Y%m%d')\n end",
"def date(name)\n input(name + \"_m\", 2, 2) + \" / \" +\n input(name + \"_d\", 2, 2) + \" / \" +\n input(name + \"_y\", 4, 4)\n end",
"def get_date\n format_date DateTime.new(2011, 1, 1, 17, 9, 59)\n end",
"def to_time(form = :utc)\n ::Time.send(\"#{form}\", year, month, day)\n end",
"def before_save\n if self.fecha_nac\n self.anio_nac = self.fecha_nac.year if (self.fecha_nac.year && self.anio_nac == Time.now.year.to_s)\n end\n end",
"def reporthelp_start_time( form )\n return form.calendar_date_select(\n :range_start,\n {\n :embedded => false,\n :year_range => Timesheet.used_range()\n }\n )\n end",
"def fine_giorno\n Time.new(self.year, self.month, self.day, 23, 59, 59)\n end",
"def set_year\n if set_month > 2 and set_month < 13\n @year.to_i\n else\n @year.to_i - 1\n end\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def easy_date; date; end",
"def year(input) = new_year(input).year - 621",
"def year=(value)\n @year = value\n end",
"def inizio_giorno\n Time.new(self.year, self.month, self.day)\n end",
"def date; end",
"def date; end",
"def date; end",
"def date; end",
"def end_year\n Time.now.year - 90\n end",
"def time_field_tag(name, value = nil, options = {})\n text_field_tag(name, value, options.merge(type: :time))\n end",
"def cwyear\n end",
"def w_year; end",
"def year=(newyear)\n @t_year = newyear.to_i\n end",
"def year=(value)\n set_date(value, @month, @day)\n end",
"def year\n @year = params[:year].to_i\n @first_month = 1\n @last_month = (Date.today.year == @year) ? Date.today.month : 12\n end",
"def unsubmitted_date_time\n return @unsubmitted_date_time\n end",
"def select_year(date, options = T.unsafe(nil), html_options = T.unsafe(nil)); end",
"def input_date_month_year(name, date = Time.zone.today)\n field = field_content(name)\n id = field_id(name)\n {\n id: id,\n name: name,\n name_dd: \"#{id}_dd\",\n name_mm: \"#{id}_mm\",\n name_yy: \"#{id}_yy\",\n description: prop(field, 'description'),\n label: prop(field, 'label'),\n date: date,\n }\n end",
"def datetime_field_tag(name, value = nil, options = {})\n text_field_tag(name, value, options.merge(type: \"datetime-local\"))\n end",
"def set_Year(value)\n set_input(\"Year\", value)\n end",
"def set_Year(value)\n set_input(\"Year\", value)\n end",
"def year\n self.range('year')\n end",
"def upload_date_time=(value)\n @upload_date_time = value\n end",
"def sanitize_date_time(value)\n value.strftime(\"%Y-%m-%d\")\n end",
"def set_StartYear(value)\n set_input(\"StartYear\", value)\n end",
"def set_EndYear(value)\n set_input(\"EndYear\", value)\n end",
"def default_year\n Time.now.month <= 5 ? Time.now.year : Time.now.year + 1 \n end",
"def test04_EditEvent_time_date\n\t\t@date = \"#{next_year}-01-12\"\n\t\t@time = \"2:30 PM\"\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_new_event)\n\t\tcreate_event \"Event for Edit Date/Time #{random}\"\n\t\t\n\t\t$post_edit_post.click\n\t\t$post_event_calendar_start_text.when_present.set(@date) \n \t\tsleep 2\n \t\t$post_event_time_start_field.when_present.click\n \t\t$post_event_select_time.when_present.select(@time)\n\t\t$post_now_event.fire_event(\"onclick\")\n\t\t\n\t\t$browser.text.include? @date\n\t\t$browser.text.include? @time\n\tend",
"def beginning_year=(string)\n frm.select(:id=>\"release_year\").select(string)\n end",
"def get_arrival_time\n DateTime.new(\n params[:date][:year].to_i,\n params[:date][:month].to_i,\n params[:date][:day].to_i,\n params[:date][:hour].to_i,\n params[:date][:minute].to_i\n )\n end",
"def car_listing_date(date_text)\n\tlisting_date = Date.parse date_text.css('time')[0]['datetime']\n\tlisting_date.to_s\nend",
"def year\n created.strftime '%Y'\n end",
"def remember_time\n 1.year\n end",
"def born_date\n super.to_s(:long)\n end",
"def datetime_local_field(name, *args)\n options = args.extract_options!.symbolize_keys!\n prepare_options(name, options)\n options[:input_group][:data].merge!({'date-extra-formats' => [BootstrapForm::DATE_FORMAT_JS+\"THH:mm\"+(options[:include_seconds] ? ':ss' : '')]}.merge(options[:data] || {}))\n append_min_max(BootstrapForm::DATE_FORMAT_RUBY+\"T%T\", options)\n args << options\n super\n end",
"def due_date\n frm.div(:class=>\"tier2\").table(:index=>0)[0][0].text\n end",
"def deadline\n \"July 4, 2014\"\n end",
"def set_FromDateTime(value)\n set_input(\"FromDateTime\", value)\n end",
"def set_FromDateTime(value)\n set_input(\"FromDateTime\", value)\n end",
"def set_FromDateTime(value)\n set_input(\"FromDateTime\", value)\n end",
"def set_FromDateTime(value)\n set_input(\"FromDateTime\", value)\n end",
"def set_FromDateTime(value)\n set_input(\"FromDateTime\", value)\n end",
"def this_year\n year(Time.now)\n end"
] |
[
"0.7463294",
"0.63760287",
"0.63396454",
"0.6309744",
"0.6309744",
"0.628385",
"0.628385",
"0.62558466",
"0.61991215",
"0.61755955",
"0.6175128",
"0.6150757",
"0.6073218",
"0.6043121",
"0.6036899",
"0.603354",
"0.60294235",
"0.60194415",
"0.59884024",
"0.59841526",
"0.59548753",
"0.59548616",
"0.5950849",
"0.594833",
"0.5930617",
"0.5905724",
"0.5896087",
"0.58753693",
"0.58659554",
"0.58554476",
"0.58515847",
"0.58515847",
"0.58408993",
"0.58273304",
"0.5824615",
"0.5824615",
"0.58216065",
"0.5819642",
"0.58136094",
"0.5794398",
"0.57937914",
"0.579017",
"0.57830215",
"0.5769802",
"0.57333446",
"0.57242954",
"0.5717152",
"0.5716985",
"0.57155603",
"0.57063407",
"0.57058215",
"0.57028806",
"0.57028806",
"0.57028806",
"0.57028806",
"0.57028806",
"0.57028806",
"0.57028806",
"0.5698438",
"0.5695838",
"0.5677476",
"0.56765085",
"0.5668133",
"0.5668133",
"0.5668133",
"0.5668133",
"0.566549",
"0.56609035",
"0.5650186",
"0.56466365",
"0.5642752",
"0.5642303",
"0.5632927",
"0.5629821",
"0.56287694",
"0.56281507",
"0.562295",
"0.5607988",
"0.5607988",
"0.5598532",
"0.559743",
"0.5595764",
"0.5585746",
"0.558375",
"0.55753624",
"0.5571228",
"0.55706704",
"0.55644363",
"0.5563667",
"0.55634373",
"0.55566025",
"0.555313",
"0.5547986",
"0.5546506",
"0.55436146",
"0.55418605",
"0.55418605",
"0.55418605",
"0.55418605",
"0.55418605",
"0.5538174"
] |
0.0
|
-1
|
Gives total lesson time in hours
|
def lesson_length
seconds = self.end_at - self.start_at
seconds / 3600.0
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hours() 60 * minutes end",
"def hours\n self.to_i * 3_600\n end",
"def hours\n return \"There are #{self * (60 * 60)} seconds in #{self} hours\"\n end",
"def total_hours\n ('%.02f' % ((ends_at - starts_at) / 1.hour)).to_f\n end",
"def hours\n self * SECONDS_IN_HOUR\n end",
"def hours\n _nudge[0]\n end",
"def hours ; self * 60.minutes ; end",
"def total_time\n minutes_to_human_readable_time(entries.internal.sum(:duration) + expected_remaining_work * 60)\n end",
"def hours\n \n end",
"def hours\n seconds / 3600\n end",
"def hours ; Duration[self * 3600] ; end",
"def spent_hours\n @spent_hours ||= time_entries.sum(:hours) || 0\n end",
"def get_total_trip_durations_in_hours\n return RideShare.get_all_trip_durations_in_seconds(trips).to_f / 60 / 60\n end",
"def hrs\n self / 24.0\n end",
"def hours; self * HOUR; end",
"def hours; self * HOUR; end",
"def total_time; end",
"def remaining_hours\n \n end",
"def total_minutes\n hours * 60 + minutes\n end",
"def hours\n\t\treturn self * 60.minutes\n\tend",
"def hours\n\t\treturn self * 60.minutes\n\tend",
"def total_spent_hours\n @total_spent_hours ||= TimeEntry.where(:meeting_id => id).sum(:hours).to_f\n end",
"def hours_spent\n \thours_spent = 0\n \tinputs.each do |input|\n \t\thours_spent += input.hours\n \tend\n \thours_spent\n end",
"def index\n time = time_spent\n hours = ( (1.0/60.0).to_f * time ).round(2)\n\n puts \"Time spent: #{time} minutes (#{hours} hours)\"\n end",
"def weekly_hours\n worked_hours\n end",
"def total_hours\n approved_flights.sum(:duration)\n end",
"def hours_spent\n hours_spent = 0\n project_tasks.each do |project_task|\n hours_spent += project_task.hours_spent\n end\n hours_spent\n end",
"def hours_planned\n hours_planned = 0\n project_tasks.each do |project_task|\n hours_planned += project_task.hours_planned\n end\n hours_planned\n end",
"def get_total_time\n return RideShare.get_all_trip_durations_in_seconds(@trips)\n end",
"def article_age_in_hours title\n $_time_ ||= Time.now.to_i\n fullrow = get_full_row title\n return 10000 unless fullrow\n age = fullrow[6].to_i\n hours = (($_time_ - age)/3600).to_i\n return hours\nend",
"def get_working_hours_total\n @total_hours = 0.0\n unless @saved_time_entries.empty?\n @total_hours = @saved_time_entries.map(&:actual_duration).inject(0) do |total,duration|\n actual_duration = @dur_setng_is_one100th ? one_hundredth_timediffernce(duration) : one_tenth_timediffernce(duration)\n total.to_f.roundf2(2) + actual_duration.to_f\n end\n @total_hours = @total_hours.to_f.roundf2(2)\n end\n @total_hours || 0.0\n end",
"def sum_hours\n @hours.each do |row|\n @cycling[0] += row[0].to_f\n @entertainment[0] += row[1].to_f\n @programming[0] += row[2].to_f\n @reading[0] += row[3].to_f\n @yoga[0] += row[4].to_f\n end\n end",
"def in_hours\n Duration::new(seconds: @seconds).to_hours\n end",
"def getDurationHours\r\n\t\t\t\t\treturn @durationHour\r\n\t\t\t\tend",
"def calculate_time\n if @event.present? && @event.ends != nil\n event_time = @event.ends - @event.starts\n \n if event_time < 3600\n difference = ((event_time / 60) % 60)\n @event_difference = \"#{difference.round(0)} minutes\"\n else\n difference = event_time / (60 * 60)\n if difference == 1 \n @event_difference = \"#{difference.round(0)} hour\"\n else\n @event_difference = \"#{difference.round(1)} hours\"\n end\n end\n end\n end",
"def get_hour\n self.hr.strftime(\"%H\").to_i + self.hr.strftime(\"%M\").to_d/60\n end",
"def total_hours_per_week\n exsisting_shift_hour = Schedule.where(start_time: Date.today-7..Date.today, employee_id: self.employee_id).sum('shift_hour')\n current_shift_hour = self.id.present? ? 0 : (self.end_time - self.start_time)/3600\n if (current_shift_hour + exsisting_shift_hour) > 40\n errors.add(:start_time, 'must be less than equal to 40 per week')\n end\n 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 hours(ctx)\n return ctx.shift_hours if earning_tests.none?\n\n earning_tests.map { |test| test.hours(ctx) }.min\n end",
"def get_works_total_hours\n res_hours =0\n self.works.each do |w|\n res_hours+=w.workhours unless w.workhours.nil?\n end\n return res_hours\n end",
"def travel_time\n travel_time = 0\n @solution.each { |route| travel_time += route.travel_time_and_cost[1] }\n return travel_time\n end",
"def minutes_to_hours(minutes)\n minutes / 60\nend",
"def total_time_exercise_workouts\n self.exercise_workouts.select do |ex|\n ex.duration\n end\n end",
"def hours\n @seconds.abs / 60 / 60 * (@seconds < 0 ? -1 : 1)\n end",
"def fuel_hours\n (fuel_blocks / fuel_per_hour).floor\n end",
"def total_time\n entries.reduce(0) do |acc, entry|\n acc + entry.total_minutes\n end\n end",
"def duration\n if @end_time.nil?\n raise StandardError.new(\"Cannot calculate trip duration. Trip is still in progress.\")\n else\n time_in_seconds = @end_time - @start_time\n time_in_hours = time_in_seconds / 3600\n end\n end",
"def number_of_hours\n hours_per_week = application_for_offering.hours_per_week\n return nil if hours_per_week.blank?\n hours_per_week.to_d * Activity::WEEKS_PER_QUARTER\n end",
"def report_time_spent(entry)\n if Setting.plugin_redmine_spent_time_in_issue_description['time_format'].eql? 'human'\n humanized_time(entry.hours)\n else\n entry.hours\n end\n end",
"def get_activity_spent_time\n datetime_start = Datetime.get_opened_one(current_user).start\n activity_spent_seconds = Time.now - datetime_start\n [ activity_spent_seconds.to_i / 3600, activity_spent_seconds.to_i / 60 % 60 ].map{ |t| t.to_s.rjust(2, '0') }.join(':')\n end",
"def entry_duration(entry)\n (entry.scheduled_datetime - entry.completed_datetime) / 1.hour\n end",
"def total_time(distance, mph)\n time = distance / mph \nend",
"def get_hours()\n\n return self.hours\n\nend",
"def hours(user_id)\n return self.user_events.find_by(user_id: user_id).hours || 0\n end",
"def calc_hours_till\n (calc_mins_till / 60.00).round(2)\n end",
"def sum_total_playing_time\n sum_total = 0 \n self.lib.songs.each do |song|\n sum_total += (song.metadata['total_time'].to_i)/1000\n end\n hour_total = ((sum_total)/3600)\n puts \"The total playing time is #{hour_total} hour\" #converts to hours\n ((sum_total)/3600)\n end",
"def get_route_duration\n return duration.div(3600)+\"Stunden\"+(duration % 60)+ \"Minuten\" \n end",
"def hours\n response[\"hours\"]\n end",
"def get_duration\n ((finish - start) / 60 / 60) - (break_length / 60)\n end",
"def total(entries)\n seconds = entries.inject(0) { |sum, entry| sum + (entry[:end] - entry[:start]) }\n hours = seconds / 3600\nend",
"def adjusted_duration\n duration + assignment.submission_rule.periods.pluck(:hours).sum.hours\n end",
"def duration\n if leg_a_answered_at.nil?\n return 0\n else\n if hangup? \n (leg_a_hangup_at - leg_a_answered_at).round\n else\n (Time.now - leg_a_answered_at).round\n end\n end\n end",
"def number_of_hours\n return read_attribute(:number_of_hours) unless read_attribute(:number_of_hours).nil? || read_attribute(:number_of_hours).zero?\n hours_per_week.to_i * Activity::WEEKS_PER_QUARTER\n end",
"def as_hours hours\n minutes = hours.to_f * 60.0\n sprintf \"%d:%02d\", (minutes / 60).to_i, (minutes % 60).to_i\n end",
"def time_length\n (end_time.hour - start_time.hour) + (end_time.min - start_time.min) / 60.0\n end",
"def ticket_estimate_in_hours(estimated_minutes)\n (estimated_minutes.to_f / 60).round\n end",
"def hour_thc\n hour = @t_hour\n hour -= 12 if hour > 12\n return hour\n end",
"def duration\n (finish - start)/3600\n end",
"def get_worked_hours start_time, end_time\n start_time = DateTime.new(start_time.year, start_time.month, start_time.day, start_time.hour, start_time.min, start_time.sec)\n end_time = DateTime.new(end_time.year, end_time.month, end_time.day, end_time.hour, end_time.min, end_time.sec)\n hours_diff = ((end_time.to_time - start_time.to_time) / 1.hours ).round(2)\n hours_diff *= -1 if hours_diff < 0\n return hours_diff\n end",
"def duration(quest)\n created = quest.created_at\n updated = quest.updated_at\n minutes = (updated - created) / 1.minutes\n return minutes.round\n end",
"def time_diff(start_time, end_time)\n seconds_diff = (start_time - end_time).to_i.abs\n hours = seconds_diff / 3600\n return hours\n end",
"def time_to_solve\n 1.hour\n end",
"def hours\n value_parts[0]\n end",
"def hours\n value_parts[0]\n end",
"def h # human\n \"%02d:%02d:%02d\" % [total/3600%24, total/60%60, total%60]\n end",
"def hours\n fail \"A value is required for #{__method__}\" unless @value\n return \"0/#{@value}:0:0\"\n end",
"def total_time_spent\n\n time_spent = Trip.total_time(trips)\n\n return time_spent\n end",
"def gametime\n \"#{self.gametime_maths/60} minutes\"\n end",
"def time_elapsed\n if !self.finished.blank?\n ((self.finished - self.started) / 60).to_i\n end\n end",
"def get_semesters_hours\n\t\t@plans_courses_hash = get_semesters_courses\n\t\t@plan_semester_hours = Hash.new\n\t\t@plans_courses_hash.each do |key, array|\n\t\t\t@plan_semester_hours[\"#{key}\"] = 0\n\t\t\tarray.each do |course|\n\t\t\t\t@plan_semester_hours[\"#{key}\"] += course.hr_low\n\t\t\tend\n\t\tend\n\t\treturn @plan_semester_hours\n\tend",
"def total_time_spent\n return trips.sum {|trip| trip.duration}\n end",
"def total_hours(start,finish)\n total=0\n start.upto(finish) {|day|\n total+=@values[day].total\n }\n return total\n end",
"def total_time\n self.measurement.total_time\n end",
"def calc_raw_hours(job, task_name, effort)\n if $op_cyclo\n ## The cyclo can be used instead of cyclo, the relationship depends on the coding style, but\n ## a linear seems to hold\n hour = 6*job.cyclo()\n else\n hour = job.each_loc()\n end\n\n hour = hour/effort.to_f\n\n ## Adjust to each product/company coding style (flatness)\n hour = hour * $op_coding_style\n\n hour = 1.5 if hour < 1.5 # .5 hour work is the min for each file\n\n return hour\n end",
"def total_time\n Time.now - @now\n end",
"def calculate_worktime\n times = retrieve_worktime\n if (times[:over] > 0)\n time = times[:over]\n else\n time = times[:during] + times[:into] + times[:beyond]\n end\n \"Worktime:; #{time} h\"\n end",
"def duration; ((endtime()- starttime()) / 60).to_i; end",
"def hour\n return @t_hour\n end",
"def time_hour; Time.now.hour; end",
"def hours_for_week(date)\n start_date = date.monday - 1.week - 1.day\n end_date = (date - 1.week).sunday - 1.day\n users_shifts = WorkshiftAssignment.where(workshifter_id: id,\n date: start_date..end_date)\n hours = 0\n users_shifts.each do |shift|\n hours += shift.hours * shift.hours_multiplier\n end\n hours - required_hours\n end",
"def time_diff\n return ((time_2 - time_1) / 3600).round\n end",
"def hours\n @msecs / HOUR_TO_MS_F\n end",
"def hour() end",
"def hours_in_year\n return DAYS_IN_YEAR * 24\nend",
"def hps\n self.total_healing.to_f / self.encounter.duration_in_seconds\n end",
"def hours_logged(user)\n\t\ttime_range = set_time\n\t\ttotal_hours = 0\n\t\tuser.log_hours.where(updated_at: time_range).each do |t|\n\t\t\ttotal_hours = total_hours + t.hours\n\t\tend\n\n\t\treturn total_hours\n\tend",
"def total_spent_hours(options = {})\n conditions = options[:user] ? \"#{TimeEntry.table_name}.user_id = #{options[:user].id}\" : \"1=1\"\n @total_spent_hours ||= self_and_descendants.sum(\"#{TimeEntry.table_name}.hours\",\n :joins => \"LEFT JOIN #{TimeEntry.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id\",\n :conditions => conditions).to_f || 0.0\n end",
"def lead_time\n 4\n end",
"def time_slot_duration(time_slot)\n diff = time_slot.ends_at - time_slot.starts_at\n diff += 2400 if diff < 0\n hour, minute = diff.divmod 100\n result = \"#{hour}hr\"\n result << \" #{minute}min\" unless minute == 0\n result\n end",
"def audit_hours\n @attributes[:audit_hours]\n end"
] |
[
"0.74050367",
"0.72218186",
"0.7165386",
"0.7143947",
"0.7096685",
"0.7079745",
"0.7073863",
"0.707299",
"0.70044774",
"0.69709665",
"0.69577",
"0.6931018",
"0.68911767",
"0.68692887",
"0.6864626",
"0.6863891",
"0.6857693",
"0.68430966",
"0.6816562",
"0.6813651",
"0.6813651",
"0.679449",
"0.6785342",
"0.6736567",
"0.6730857",
"0.6722784",
"0.67060995",
"0.6700648",
"0.66559684",
"0.6641963",
"0.6637409",
"0.6632875",
"0.6632111",
"0.6619976",
"0.65928805",
"0.6590678",
"0.65687597",
"0.6543874",
"0.6533457",
"0.652948",
"0.6517662",
"0.65074104",
"0.649686",
"0.64559084",
"0.64523154",
"0.6441614",
"0.6439225",
"0.6426059",
"0.64249974",
"0.6412057",
"0.6404707",
"0.6397913",
"0.6394831",
"0.63829017",
"0.63805234",
"0.63752174",
"0.6364169",
"0.6361612",
"0.6361207",
"0.6346518",
"0.634525",
"0.63350254",
"0.6333724",
"0.63323843",
"0.6318141",
"0.6298077",
"0.6296452",
"0.62940925",
"0.62891006",
"0.62605804",
"0.62549496",
"0.6251575",
"0.6250654",
"0.6250654",
"0.6248408",
"0.62292236",
"0.622749",
"0.62181044",
"0.6217809",
"0.6217481",
"0.62167823",
"0.6206731",
"0.6197357",
"0.61903375",
"0.6186124",
"0.6185276",
"0.6173937",
"0.61716443",
"0.6161973",
"0.6160184",
"0.6156977",
"0.61520743",
"0.61446005",
"0.6140015",
"0.61271155",
"0.6125883",
"0.6125711",
"0.61225426",
"0.61177933",
"0.61120206"
] |
0.75305045
|
0
|
If you have extra params to permit, append them to the sanitizer.
|
def configure_sign_in_params
# devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :company_id])
devise_parameter_sanitizer.for(:sign_up).push(:company_id, :user_id)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def devise_parameter_sanitizer; end",
"def update_sanitized_params\n\t\t\tdevise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:name, :email, :password, :password_confirmation)}\n\t\tend",
"def sign_up_params\n devise_parameter_sanitizer.sanitize(:sign_up)\n end",
"def update_sanitized_params\n devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:password_confirmation ,:password ,:email, :role, :avatar, :avatar_cache, :remove_avatar, :invite_code, :firstname, :lastname)}\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def permit(*permitted)\n hardened_params = params.dup\n\n hardened_params.keep_if { |k, _v| permitted.flatten.include?(k.to_sym) }\n\n hardened_params.symbolize_keys\n end",
"def update_sanitized_params\n devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:name, :email, :approved , :password, :password_confirmation,:approved, :role_ids => [], affiliate_person_attributes: [:name], :performer_attributes => [ :first_name, :avatar, :photo_id, :profile_thumb, :profile_gif, :photo_id, :location_id, :avatar, :id, :white_label_id, :twitter_sign_in, :video_upload_twitter, :order_placed_twitter] )}\n devise_parameter_sanitizer.for(:account_update) {|u| u.permit(:name, :email, :password, :password_confirmation,:approved, :sign_in_twitter, :video_upload_twitter, :order_placed_twitter, :performer => [], :role_ids => [], :performer_attributes => [ :first_name, :avatar, :photo_id, :profile_thumb, :profile_gif, :photo_id, :location_id, :avatar, :id, :white_label_id])}\n end",
"def update_sanitized_params\n devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:email, :password, :password_confirmation, :phone)}\n devise_parameter_sanitizer.for(:account_update) {|u| u.permit(:email, :password, :password_confirmation, :phone)}\n end",
"def strong_params\n params.require(:team_member).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 safe_params\n params.require(:user).permit(:name)\n end",
"def permit_all_params options = {}\n prepend_before_filter do\n self.params.deep_permit!\n end\n end",
"def sanitize_params\n if valid_lease?\n sanitize_lease_params\n elsif valid_embargo?\n sanitize_embargo_params\n elsif !wants_lease? && !wants_embargo?\n sanitize_unrestricted_params\n else\n @attributes\n end\n end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def sanitized_allowed_attributes=(attributes); end",
"def sanitized_allowed_attributes=(attributes); end",
"def update_sanitized_params\n\t\tdevise_parameter_sanitizer.for(:sign_up) \t\t\t\t{ |u| u.permit(:name, :email, :password, :password_confirmation, :company, :role_type, :celp_no, :approval, :authorize) }\n\t\tdevise_parameter_sanitizer.for(:account_update) { |u| u.permit(:name, :email, :password, :password_confirmation, :current_password, :company, :role_type, :celp_no, :approval, :authorize) }\n\tend",
"def student_params(*args) #is the helper method \n\n\t\tparams.require(:student).permit(*args)\n\t\t#uses .require and .permit methods as stronger params to prevent hacks through inspect element right click edit html \n\t\t#require restricts, permit allows, and *args is for the custom arguments\n\tend",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def strong_params\n params.require(:experience).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 whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def devise_parameter_sanitizer\n if resource_class == User\n User::ParameterSanitizer.new(User, :user, params)\n else\n super\n end\n end",
"def devise_parameter_sanitizer\n if resource_class == User\n User::ParameterSanitizer.new(User, :user, params)\n else\n super\n end\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def sanitize_attrs(attrs = {}, permitted = [])\n sanitized = {}\n attrs.each do |key, value|\n sanitized[key.to_s] = value if permitted.include?(key.to_s)\n end\n sanitized\n end",
"def additional_permitted_params\n []\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def student_params\n params.require(:student).permit(:name, :sex, :birthplace, :birthdate, :phone, :email, :employment,\n :street_address, :district, :regency_city, :religion, :registered_at,\n :avatar, :crop_x, :crop_y, :crop_w, :crop_h).tap do |whitelisted|\n if params[:student][:biodata]\n whitelisted[:biodata] = params[:student][:biodata]\n end\n end\n end",
"def user_strong_params\n html_safe(params[:user]).strip\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def update_sanitized_params\n\t\t\tif \"#{resource_name}\" == \"lecturer\"\n\t\t\t\tdevise_parameter_sanitizer.for(:sign_up) {\n\t\t\t\t\t|lecturer| lecturer.permit(:name, :email,\n\t\t\t\t\t\t:password, :password_confirmation,\n\t\t\t\t\t\t:university, :department)\n\t\t\t\t}\n\t\t\t\tdevise_parameter_sanitizer.for(:account_update) {\n\t\t\t\t\t|lecturer| lecturer.permit(:name, :current_password,\n\t\t\t\t\t\t:password, :password_confirmation,\n\t\t\t\t\t\t:university, :department,\n\t\t\t\t\t\t:profile_image, :profile_image_cache)\n\t\t\t\t}\n\t\t\telsif \"#{resource_name}\" == \"student\"\n\t\t\t\tdevise_parameter_sanitizer.for(:sign_up) {\n\t\t\t\t\t|student| student.permit(:name, :email,\n\t\t\t\t\t\t:password, :password_confirmation,\n\t\t\t\t\t\t:university, :faculty, :major, :semester,\n\t\t\t\t\t\t:advising, :probation)\n\t\t\t\t}\n\t\t\t\tdevise_parameter_sanitizer.for(:account_update) {\n\t\t\t\t\t|student| student.permit(:name, :current_password,\n\t\t\t\t\t\t:password, :password_confirmation,\n\t\t\t\t\t\t:university, :faculty, :major, :semester,\n\t\t\t\t\t\t:advising, :probation, :profile_image,\n\t\t\t\t\t\t:profile_image_cache)\n\t\t\t\t}\n\t\t\telsif \"#{resource_name}\" == \"teaching_assistant\"\n\t\t\t\tdevise_parameter_sanitizer.for(:sign_up) {\n\t\t\t\t\t|teaching_assistant| teaching_assistant.permit(:name,\n\t\t\t\t\t\t:email, :password, :password_confirmation,\n\t\t\t\t\t\t:graduated_from, :graduated_year, :degree,\n\t\t\t\t\t\t:university, :department)\n\t\t\t\t}\n\t\t\t\tdevise_parameter_sanitizer.for(:account_update) {\n\t\t\t\t\t|teaching_assistant| teaching_assistant.permit(:name,\n\t\t\t\t\t\t:current_password, :password, :password_confirmation,\n\t\t\t\t\t\t:graduated_from, :graduated_year, :degree,\n\t\t\t\t\t\t:university, :department, :profile_image,\n\t\t\t\t\t\t:profile_image_cache)\n\t\t\t\t}\n\t\t\tend\n\t\tend",
"def quote_params\n params.permit!\n end",
"def configure_permitted_parameters\n extra_params = [:full_name, :programme, :student_number]\n devise_parameter_sanitizer.for(:sign_up).push(*extra_params)\n devise_parameter_sanitizer.for(:account_update).push(*extra_params)\n end",
"def post_card_params\n params[:post_card].permit!\n end",
"def sanitize_params(params = params)\n params = walk_hash(params) if params\n end",
"def expected_permitted_parameter_names; end",
"def white_params\n params.require(:therapist).permit(Therapist.therapist_whitelist, \n therapist_availability_attributes:Therapist.therapist_availability_whitelist, \n therapist_availability_rec_attributes:Therapist.therapist_recurring_whitelist)\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def permit_params_on_create *keys\n filter_strong_params :permit, [:create], keys\n end",
"def sanitize_params(params = params)\n params = walk_hash(params) if params\n end",
"def surgery_params\n params.require(:surgery).permit(:name)\n end",
"def safe_params\n params.require(:youtube_search).permit(:search_terms, :alert_on_new_result)\n end",
"def post_params\n permit_params\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def update_sanitized_params\n devise_parameter_sanitizer.permit(:account_update) do |user_params|\n user_params.permit(:name, :last_name, :login, :about, :adress, :email, :country,:avatar,:terms_of_service, :birth_date,:current_password, :password, :password_confirmation, :zip_code, :city, :phone)\n end\n\n devise_parameter_sanitizer.permit(:sign_up) do |user_params|\n user_params.permit(:name, :last_name, :login, :about, :email, :country,:avatar,:terms_of_service, :birth_date,:current_password, :password, :password_confirmation, :zip_code, :city, :phone)\n end\n\n devise_parameter_sanitizer.permit(:sign_in) do |user_params|\n user_params.permit(:name, :last_name, :login, :about, :email, :country,:avatar,:terms_of_service, :birth_date,:current_password, :password, :password_confirmation, :zip_code, :city, :phone)\n end\n \n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def sanitize!(request)\n [ :path, :query, :body ].each do |name|\n send(\"#{name}_parameters\").sanitize_object!(request.params)\n end\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 strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def surgical_params\n params.require(:surgical).permit(Surgical.safe_attributes)\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 secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) << :terms_of_service << :first_name << :last_name\n devise_parameter_sanitizer.for(:account_update) << :first_name << :last_name\n end",
"def safe_params\n safe_attributes = %i[name key]\n params.require(:role).permit(safe_attributes)\n end",
"def permitted_params\n if is_singleton?\n singleton_permitted_params\n else\n params.require(:data).permit(allowed_resource_params.to_a)\n end\n end",
"def submission_params\n allowed = :student_number, :last_name, :first_name, :week, :hours, :comments, :email, :github, :challenging\n (1..Course.current.exercises_max).each do |i|\n allowed << \"a#{i}\".to_s\n end\n params.require(:submission).permit(allowed)\n end",
"def less_active_member_params\n clean_params = params.require(:less_active_member).permit(:surname, :given_name, :current_address, :new_address, :new_phone, :reference, :new_note, :resources, tag_list: [])\n clean_params.merge!({current_user_id: current_user.id}) unless current_user.nil?\n end",
"def csrfattack_params\n params.require(:csrfattack).permit(:professor, :vote)\n end",
"def sanitize_params(form_params)\n super.tap do |params|\n params['title'] = Array.wrap(params['title']) if params.key?('title')\n params['description'] = Array.wrap(params['description']) if params.key?('description')\n end\n end",
"def configure_permitted_parameters\n \tdevise_parameter_sanitizer.permit(:sign_up, keys: %i[first_name last_name username technology_id secondary_technology])\n end",
"def build_permitted_params\n super + [\n { date_of_work_attributes: permitted_time_span_params },\n { inscription_attributes: permitted_inscription_params },\n { additional_credit_attributes: permitted_additional_credit_params },\n after: [],\n artist: [],\n attributed_to: [],\n author: [],\n addressee: [],\n creator_of_work: [],\n contributor: [],\n editor: [],\n engraver: [],\n interviewee: [],\n interviewer: [],\n manner_of: [],\n school_of: [],\n manufacturer: [],\n photographer: [],\n printer: [],\n printer_of_plates: [],\n publisher: [],\n place_of_interview: [],\n place_of_manufacture: [],\n place_of_publication: [],\n place_of_creation: [],\n ]\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:fname, :lname, :avatar, :avatar_cache, :bio, :school, :job, :nickname, :grade, :major, :hometown])\n end",
"def post_params(*args)\n params.require(:student).permit(*args)\n end",
"def anonymous_filter_params\n p = params.required('payload')\n # p.permit!('controls_params')\n # p.permit!('columns_params')\n # p.permit!('sorting')\n # p.permit!('global_config')\n p.permit(\n 'name',\n 'controls_list' => [],\n 'controls_hl_mode' => [],\n 'controls_params' => {},\n 'columns_list' => [],\n 'columns_params' => {},\n 'sorting' => {},\n 'global_config' => {}\n ).merge(permit_hashes(p, [\n 'controls_params',\n 'columns_params',\n 'sorting',\n 'global_config'\n ]))\n end",
"def additional_subject_params\n params.permit(:name)\n end",
"def hack_params\n params.require(:hack).permit(:title, :body, :tag_list, :tag)\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up,\n keys: [:face_image, :worker_number, :name, :name_kana, :trade_name, :phone, :address_zip, :address, :warehouse_zip, :warehouse, :warehouse_info, :inaba,\n :yodo, :takubo, :ykkap, :sankyo, :lixil])\n end",
"def permit_attributes\n params.require(resource_as_param_key).permit(*permitted_attributes)\n end",
"def student_params\n params.require(:student).permit!\n end",
"def visit_params\n params.require(:visit).permit(*allowable)\n end",
"def special_params\n params.require(:special).permit(:info)\n end",
"def safe_movie_params\n\t\treturn params.require(:movie).permit(:title, :description, :year_released)\n\tend",
"def user_pleasure_params\n params.permit(:title)\n end",
"def full_sanitizer=(_arg0); end",
"def full_sanitizer=(_arg0); end",
"def full_sanitizer=(_arg0); end",
"def configure_account_update_params\n devise_parameter_sanitizer.for(:account_update) << :first_name << :last_name << :phone_number\n end",
"def surgery_params\n\t\t# Permitting the profile photo params\n\t\tparams.require(:surgery).permit(:name)\n\tend",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def configure_account_update_params\n devise_parameter_sanitizer.permit(:account_update, keys: [:fname, :lname, :avatar, :bio, :school, :job, :nickname, :grade, :major, :hometown])\n end",
"def string_enforcer_params\n params.fetch(:string_enforcer, {})\n end",
"def update_params\n permitted = params.permit(*common_params,\n annotated_students_attributes:\n %i[id student_id _destroy])\n permitted[:annotated_students_attributes] = [] if @annotation.is_group\n permitted\n end",
"def sanitizer\n if options = sanitization\n @sanitizer ||= options.to_sanitize\n end\n end",
"def configure_account_update_params\n devise_parameter_sanitizer.permit(:account_update, keys: [:username, :fname, :lname, :avatar, :bio, :street, :city, :state, :country, :lat, :lng])\n end",
"def configure_permitted_parameters\n added_attrs = [:email, :password, :password_confirmation, :name, :description, :age, :gender,\n :favorite_movie, :favorite_food, :favorite_song, :job_title, :hobbies, :school, :social_media_link,\n :snap_chat_name, :allow_male, :allow_female, :allow_other]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << [\n :name, :current_profession, :years_experience,\n :desired_profession, :desired_location, :work_status\n ]\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:practice, :last_name, :first_name, :email, :phone, :birthday, :gender, :password,\n :password_confirmation, :avatar, :avatar_cache, :remove_avatar, address_attributes: [ :id, :postcode, :prefecture, :city, :street, :building ]])\n end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:api_key, :home_zip_code, :full_name, :found_option])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:account_update) do |u|\n u.permit(:name, :email, :password, :password_confirmation, :current_password, :role_ids, :performer_attributes => [:first_name, :avatar, :photo_id, :profile_thumb, :profile_gif, :photo_id, :location_id, :avatar, :id ,:description, :white_label_id, :clip_category_performers_attributes => [:id, :clip_category_ids]])\n end\n Rails.logger.info'****************************************'\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) << [:firstname, :lastname, :ucard, :course, :level]\n devise_parameter_sanitizer.for(:account_update) << [:firstname, :lastname, :ucard, :course, :level]\n\n end",
"def unsanitised_user_params\n params.require(:user).permit(\n :name,\n :email,\n :organisation_id,\n :invitation_token,\n :password,\n :password_confirmation,\n :require_2sv,\n :role,\n supported_permission_ids: [],\n ).to_h\n end",
"def param_whitelist\n [:rating, :review]\n end"
] |
[
"0.6905034",
"0.683687",
"0.68280804",
"0.67889357",
"0.6674015",
"0.66522104",
"0.66448265",
"0.6595933",
"0.65606564",
"0.64921725",
"0.6489163",
"0.64781183",
"0.64483696",
"0.64394945",
"0.6419598",
"0.6419251",
"0.63999707",
"0.63977224",
"0.63977224",
"0.63934815",
"0.6381383",
"0.63552105",
"0.6351666",
"0.63470167",
"0.6263344",
"0.62456423",
"0.6201932",
"0.6201932",
"0.61927104",
"0.61919683",
"0.6170647",
"0.6156662",
"0.61398244",
"0.61027503",
"0.6095907",
"0.6092075",
"0.60888684",
"0.60829175",
"0.6078085",
"0.6074742",
"0.6032367",
"0.5991786",
"0.597175",
"0.5967426",
"0.59671617",
"0.596185",
"0.5957206",
"0.5954368",
"0.5938198",
"0.59285605",
"0.5927781",
"0.59138155",
"0.59032714",
"0.58997184",
"0.58978087",
"0.5896996",
"0.58940434",
"0.5887589",
"0.5887006",
"0.588294",
"0.58775926",
"0.58737236",
"0.5871206",
"0.5870724",
"0.586412",
"0.58603865",
"0.5850765",
"0.58469373",
"0.5843961",
"0.58388746",
"0.5837621",
"0.58303636",
"0.5808892",
"0.5802483",
"0.57949424",
"0.5791214",
"0.5791014",
"0.57847995",
"0.5782731",
"0.5781977",
"0.57755154",
"0.5772579",
"0.5772579",
"0.5772579",
"0.5769446",
"0.5766719",
"0.5758603",
"0.575704",
"0.5756578",
"0.57548386",
"0.57541984",
"0.57518667",
"0.5751863",
"0.5748482",
"0.5746564",
"0.5744878",
"0.5743098",
"0.5728885",
"0.5727657",
"0.57257277",
"0.572434"
] |
0.0
|
-1
|
default 4.times do |i| WS2801.set :pixel => i3, :r => 127 WS2801.set :pixel => (i3)+1, :g => 127 WS2801.set :pixel => (i3)+2, :b => 127 end sleep(1)
|
def guage(n)
r = (255 * n) / 100
g = (255 * (100 - n)) / 100
b = 0
return { :r => r, :g => g, :b => b }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_one_pixel(pixelno,r,g,b)\n# puts \"Set one pixel length packetdata in \" + @@packetdata.size.to_s\n pixelno = pixelno % @@numpixels\n if r < 256 then\n temp = [r]\n @@packetdata[pixelno * 3] = temp.pack(\"C\")\n end\n if g < 256 then\n temp = [g]\n @@packetdata[(pixelno * 3) + 1] = temp.pack(\"C\")\n end\n if b < 256 then\n temp = [b]\n @@packetdata[(pixelno * 3) + 2] = temp.pack(\"C\") \n end \nend",
"def restart\n pbBGMStop(0)\n 51.times do\n @viewport.tone.red-=5\n @viewport.tone.green-=5\n @viewport.tone.blue-=5\n self.updateElements\n Graphics.update\n end\n raise Reset.new\n end",
"def pbCaveEntranceEx(exiting)\n sprite = BitmapSprite.new(Graphics.width,Graphics.height)\n sprite.z = 100000\n totalBands = 15\n totalFrames = 15\n bandheight = ((Graphics.height/2)-10).to_f/totalBands\n bandwidth = ((Graphics.width/2)-12).to_f/totalBands\n grays = []\n tbm1 = totalBands-1\n for i in 0...totalBands\n grays.push(exiting ? 0 : 255)\n end\n totalFrames.times do |j|\n x = 0\n y = 0\n rectwidth = Graphics.width\n rectheight = Graphics.height\n for k in 0...j\n t = (255.0)/totalFrames\n if exiting\n t = 1.0-t\n t *= 1.0+((k)/totalFrames.to_f)\n else\n t *= 1.0+0.3*(((totalFrames-k)/totalFrames.to_f)**0.7)\n end\n grays[k] -= t\n grays[k] = 0 if grays[k]<0\n end\n for i in 0...totalBands\n currentGray = grays[i]\n sprite.bitmap.fill_rect(Rect.new(x,y,rectwidth,rectheight),\n Color.new(currentGray,currentGray,currentGray))\n x += bandwidth\n y += bandheight\n rectwidth -= bandwidth*2\n rectheight -= bandheight*2\n end\n Graphics.update\n Input.update\n end\n if exiting\n pbToneChangeAll(Tone.new(255,255,255),0)\n else\n pbToneChangeAll(Tone.new(-255,-255,-255),0)\n end\n for j in 0..15\n if exiting\n sprite.color = Color.new(255,255,255,j*255/15)\n else\n sprite.color = Color.new(0,0,0,j*255/15) \n end\n Graphics.update\n Input.update\n end\n pbToneChangeAll(Tone.new(0,0,0),8)\n for j in 0..5\n Graphics.update\n Input.update\n end\n sprite.dispose\nend",
"def inf_loop(fps, xzoom, f)\n s = Screen.new(W, H)\n for x in 1...WI do\n y = f.call(x/xzoom.to_f)\n s.set(x, y)\n s.print()\n #s.unset(x, y)\n sleep(1.0/fps)\n end\nend",
"def set_pixel_range(offset, width, r,g,b)\n # Generate a new - zero filled buffer string\n # But just for colours <\n buffer = zero_filled_buffer(r, g, b)\n #copy across the offset * width pixels from the original buffer string\n pointer = offset * 3\n# puts \"offset =>\" + offset.to_s\n# puts \"width =>\" + width.to_s\n# puts \"buffer =>\" + buffer.bytes.to_s\n# puts \"@@packetdata =>\" + @@packetdata.bytes.to_s\n while pointer.to_i < (offset.to_i + (width.to_i * 3))\n buffer[pointer.to_i] = @@packetdata[pointer.to_i]\n pointer = pointer + 1\n end\n @@packetdata = buffer\n# set the required new pixels\n# puts \"@@packetdata before set_one_pixel =>\" + @@packetdata.bytes.to_s\n pointer = offset\n while pointer.to_i < (offset.to_i + (width))\n set_one_pixel(pointer,r,g,b)\n pointer = pointer + 1\n end \n# puts \"header + @@packetdata =>\" + buildheader + \"-\"+ @@packetdata.bytes.to_s\n write_pixel_buffer(buildheader + @@packetdata) \nend",
"def setup_test\n # Flash lights\n fill(Color.new(red: 128, green: 250, blue: 128))\n sleep(3)\n fill(Color.new(red: 128, green: 128, blue: 128))\n end",
"def bumpspark( results )\r\n white, red, grey = [0xFF,0xFF,0xFF], [0,0,0xFF], [0x99,0x99,0x99]\r\n ibmp = results.inject([]) do |ary, r|\r\n ary << [white]*15 << [white]*15\r\n ary.last[r/9,4] = [(r > 50 and red or grey)]*4\r\n ary\r\n end.transpose.map do |px|\r\n px.flatten!.pack(\"C#{px.length}x#{px.length%4}\")\r\n end.join\r\n [\"BM\", ibmp.length + 54, 0, 0, 54, 40, results.length * 2, 15, 1, 24, 0, 0, 0, 0, 0, 0].pack(\"A2ISSIIiiSSIIiiII\") + ibmp\r\nend",
"def setup\n size 200, 200 \n no_stroke\n background 0 \n c = load_image \"cait.jpg\" \n xoff, yoff = 0, 0\n p = 2\n pix = p * 3 \n (c.width * c.height).times do |i| \n pixel = c.pixels[i] \n fill red( pixel ), 0, 0\n rect xoff, yoff, p, pix \n fill 0, green( pixel ), 0\n rect xoff+p, yoff, p, pix \n fill 0, 0, blue( pixel )\n rect xoff+p*2, yoff, p, pix \n xoff += pix\n if xoff >= (width-pix)\n xoff = 0\n yoff += pix\n end\n end \nend",
"def sync_2600_with(color_clock)\n riot.tick if color_clock % 3 == 0\n @graphics.each &:tick\n cpu.tick if color_clock % 3 == 2\n end",
"def run(speed)\r\n printf 'Rasterising';\r\n rasterise;\r\n puts \" Done! [Hit any key]\"\r\n gets\r\n @canvases.each_index do |i|\r\n canvas = @canvases[i];\r\n #canvas.add(' Frame '+i.to_s+' ', 0, 0);\r\n canvas.print;\r\n sleep 0.1;\r\n end\r\n end",
"def increment_pixel(rgb_color)\n #and get the value of the last pixel.\n aggregate_pixel = @pixel_count\n #Set the rgb color of a pixel and send it to the writer\n self.write_pixel(rand(@pixel_count),rgb_color)\n #and increment the count tracking the number of pixels we've updated\n @count_of_color_changes += 1\n #Take the number of color changes we've processed, and see if it's a multiple of 33\n if (@count_of_color_changes % 33) == 0\n #if it is, set the white value to be the result of the division\n white_value = @count_of_color_changes / 33\n #create a string formatted to the rgb color string\n white_rgb_color = Array.new(3,white_value).join ','\n #and set the aggregation pixel (our last pixel) to the new white level\n self.write_pixel(aggregate_pixel,white_rgb_color)\n end\n end",
"def setup\n\t\tbackground(0)\n\t\tzahlen = (2*3*5*7)-1# <-- change integer here. # what is biggest array?\n\t\t@table = color_it(rsa_group(zahlen))\n\t\tsquare = [1000] * 2 ; size(*square)\n\t\tframe_rate 1 ; colorMode(HSB,360,100,100)\n\tend",
"def create_storm_bitmap\r\n @storm_bitmap = Bitmap.new(34, 64)\r\n 32.times do |i|\r\n @storm_bitmap.fill_rect(33-i, i*2, 1, 2, particle_color2)\r\n @storm_bitmap.fill_rect(32-i, i*2, 1, 2, particle_color1)\r\n @storm_bitmap.fill_rect(31-i, i*2, 1, 2, particle_color2)\r\n end\r\n end",
"def _beam1\n b = Bitmap.new(24, 1)\n (1...12).each {|i|\n b.fill_rect(i, 0, 1, 1, Color.new(255, 255, 255, i**2*3))\n b.fill_rect(23-i, 0, 1, 1, Color.new(255, 255, 255, i**2*3))}\n return b\n end",
"def draw_gif(frames, value)\n\t#An image list to put all the frames in\n\tgif = ImageList.new()\n\n\t#generates the final value of the gif\n\tlast_value = value\n\tframes.times do\n\t\tlast_value = next_number(last_value)\n\tend\n\n\t#gets the color for the first frame\n\tr1, g1, b1 = get_colors(value)\n\t#gets the color for the final frame\n\tr2, g2, b2 = get_colors(last_value)\n\n\t#Repeats this process for every frame\n\tfor k in 0...frames\n\t\t#gets the next image\n\t\tvalue = next_number(value)\n\t\t#makes a new image to put it in\n\t\tgrid = Image.new(TM_SQUARE_SIZE*5, TM_SQUARE_SIZE*5) {self.background_color = \"white\"}\n\t\t#makes a new draw to hold everything we'll be drawing\n\t\tsquares = Magick::Draw.new\n\t\t#sets the color so that over the course of the gif it transitions from the starting coloring to the ending one\n\t\tr = tween(r1, r2, k.to_f/frames)\n\t\tg = tween(g1, g2, k.to_f/frames)\n\t\tb = tween(b1, b2, k.to_f/frames)\n\t\tsquares.fill(\"rgb(#{r},#{g},#{b})\")\n\n\t\t#checks each digit for being a one or zero, just like above\n\t\tfor i in 0...5\n\t\t\tfor j in 0...5\n\t\t\t\tif value & 2 ** (j + i*5) != 0\n\t\t\t\t\t#This image doesn't get scrambled because it looks better this way\n\t\t\t\t\tsquares.rectangle(TM_SQUARE_SIZE*i, TM_SQUARE_SIZE*j, TM_SQUARE_SIZE*(i+1), TM_SQUARE_SIZE*(j+1))\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#puts all the drawings on the grid\n\t\tsquares.draw(grid)\n\t\t#saves it in the imageList\n\t\tgif << grid\n\tend\n\t#sets the gif delay\n\tgif.delay = FRAME_LENGTH\n\t#saves the gif\n\tgif.write(\"gif#{value}.gif\")\n\t#and we return the last value of this gif\n\treturn value\nend",
"def delay(frame)\n (frame*40).to_i.times {Graphics.update}\n end",
"def sync_2600_with(color_clock)\n @riot.tick if color_clock % 3 == 0\n @tia.tick\n @cpu.tick if color_clock % 3 == 2\n end",
"def setup \n size 640, 360 \n no_stroke\n rect_mode CENTER \n frame_rate 30 \n @a, @s = 0.0, 0.0\nend",
"def main()\n img = ImageList.new($input)\n convert = ImageList.new\n page = Magick::Rectangle.new(0,0,0,0)\n $total_ops = (img.rows * img.columns).to_f\n\n for i in 0..img.rows\n for j in 0..img.columns\n pixel = generate_hex_pixel(rgb_to_hex(img.pixel_color(j,i)))\n convert << pixel\n page.x = j * pixel.columns\n page.y = i * pixel.rows\n pixel.page = page\n progress()\n end\n end\n\n puts 'Writing image, this could take a while...'\n convert.mosaic.write($output)\nend",
"def rainbow\n (0..256).each{ |color| \n print Paint[' ',48,5,color] # print empty bg color field\n }\n puts\n end",
"def upload_state\n 0.upto(ROWS - 1) do |row|\n 0.upto(COLUMNS - 1) do |column|\n state = @cell_state[row * ROWS + column]\n @lp.set_led_colors(column, row, *@colors[state])\n end\n end\n @lp.set_led_colors(0, -1, *((@iteration % 2) == 0) ? [1,3] : [3,3])\n @lp.update\n @lp.flip_buffers\n end",
"def update_pre_transition_flash\n if @counter % 15 == 0\n col = @viewport.color.red == 0 ? 255 : 0\n @viewport.color.set(col, col, col)\n end\n @viewport.color.alpha = (Math.sin(2 * Math::PI * @counter / 30).abs2.round(2) * 180).to_i\n end",
"def create_rain_bitmap\r\n @rain_bitmap = Bitmap.new(7, 42)\r\n 7.times {|i| @rain_bitmap.fill_rect(6-i, i*6, 1, 6, particle_color1) }\r\n end",
"def rasterise \r\n @frames.each do |frame|\r\n printf '.';\r\n canvas = Canvas.new(@width, @height);\r\n @canvases.push(canvas);\r\n if frame.pixmaps.length == 0 then next; end;\r\n frame.pixmaps.each do |pixmap|\r\n img = pixmap.sprite.getImage(pixmap.frame);\r\n pixmap.frame = (pixmap.frame + 1) % (pixmap.sprite.images.length);\r\n canvas.add(img, pixmap.x, pixmap.y);\r\n end\r\n end \r\n end",
"def paint_world4\r\n show_sun2\r\n\t@logger.write(\"\") # puts ''\r\n count = 0\r\n @height.times do\r\n @width.times do\r\n @logger.pwrite(\"#{@positions[count].symbol}\") # print @positions[count].symbol\r\n count += 1\r\n end\r\n @logger.write(\"\") # puts ''\r\n end\r\n @logger.write(\"\") # puts '------------'\r\n end",
"def chaser(interval=0.03)\n i = 0\n step = 1\n glow = 0\n glow_step = 1\n while true do\n while i >= 0 && i < 32 do\n self.clear!\n self[i] = [rand(255-glow),rand(255-glow),rand(255-glow)]\n self.write!\n i = i + step\n sleep(interval)\n glow += glow_step*rand(10)\n if glow > 230\n glow = 230\n glow_step = -1\n end\n if glow < 0\n glow = 0\n glow_step = 1\n end\n end\n\n # reverse direction\n i = i - step\n step *= -1\n end\n end",
"def test05()\n begin\n pixelDataSavePath = nil\n theCommands = CommandModule::SmigCommands.new\n theSize = MIShapes.make_size(200,200)\n bitmapObject = theCommands.make_createbitmapcontext(\n size: theSize,\n addtocleanup: true,\n preset: \"AlphaPreMulLastRGB32bpcFloat\")\n drawGradientFill = MILinearGradientFillElement.new\n drawGradientFill.startpoint = MIShapes.make_point(0, 0)\n locations = [0, 1]\n colors = [MIColor.make_rgbacolor(1,0,0), MIColor.make_rgbacolor(0,1,0)]\n drawGradientFill.set_arrayoflocations_andarrayofcolors(locations, colors)\n thePath = MIPath.new\n thePath.add_rectangle(MIShapes.make_rectangle(size: theSize))\n drawGradientFill.arrayofpathelements = thePath.patharray\n startPoint = MIShapes.make_point(0, 100)\n endPoint = MIShapes.make_point(200, 100)\n drawGradientFill.line = MIShapes.make_line(startPoint, endPoint)\n drawCommand = CommandModule.make_drawelement(\n bitmapObject,\n drawinstructions: drawGradientFill)\n theCommands.add_command(drawCommand)\n pixelDataRect = MIShapes.make_rectangle(xloc: 0, yloc: 100,\n width: 200, height: 1)\n pixelDataSavePath = File.join(Dir.tmpdir, SecureRandom.uuid + \".json\")\n # pixelDataSavePath = File.expand_path(\"~/pixeldata.json\")\n getPixelDataCommand = CommandModule.make_getpixeldata(\n bitmapObject,\n rectangle: pixelDataRect,\n resultstype: :jsonfile,\n savelocation: pixelDataSavePath)\n theCommands.add_command(getPixelDataCommand)\n theResult = Smig.perform_commands(theCommands)\n originalPath = File.join($directory, \"miscellaneous\", \"test013\",\n \"pixeldata.json\")\n unless FileUtils.identical?(pixelDataSavePath, originalPath)\n raise \"Pixel data has changed.\"\n end\n \n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: #{Smig.exitstring}\"\n end\n puts e.message\n puts e.backtrace.to_s\n puts #{Smig.exitstring}\"\n# exit 240\n ensure\n FileUtils.rm_f(pixelDataSavePath) unless pixelDataSavePath.nil?\n # Open3.capture2(\"open\", pixelDataSavePath)\n # Open3.capture2(\"open\", originalPath)\n end\nend",
"def reboot\n img = ['blue_flower', 'red_flower', 'white_flower', 'pink_flower'].sample\n @image = Gosu::Image.new window, 'images/flowers/' + img +'.png', true\n @drawing = true\n end",
"def setup_ghost_colors(num, color)\n # Add 10 to each num to create a new number and assign the opacity-altered color values\n opacity = 0.5\n num += 10\n\n Curses.init_color(num, *color.map { |c| ((c * opacity) / 255.0 * 1000).to_i })\n Curses.init_pair(num, num, num)\nend",
"def setup\n size 640, 360\n stroke_weight 10\n no_loop\nend",
"def pbSweetScent\n if $game_screen.weather_type!=PBFieldWeather::None\n Kernel.pbMessage(_INTL(\"The sweet scent faded for some reason...\"))\n return\n end\n viewport = Viewport.new(0,0,Graphics.width,Graphics.height)\n viewport.z = 99999\n count = 0\n viewport.color.alpha -= 10 \n begin\n if viewport.color.alpha<128 && count==0\n viewport.color.red = 255\n viewport.color.green = 0\n viewport.color.blue = 0\n viewport.color.alpha += 8\n else\n count += 1\n if count>10\n viewport.color.alpha -= 8 \n end\n end\n Graphics.update\n Input.update\n pbUpdateSceneMap\n end until viewport.color.alpha<=0\n viewport.dispose\n encounter = nil\n enctype = $PokemonEncounters.pbEncounterType\n if enctype<0 || !$PokemonEncounters.isEncounterPossibleHere? ||\n !pbEncounter(enctype)\n Kernel.pbMessage(_INTL(\"There appears to be nothing here...\"))\n end\nend",
"def cycle\n allOn(0.1)\n allOff(0.1)\n \n \"hello\".chars.each do |letter|\n writeLetter(letter.to_sym)\n sleep(0.5)\n allOff()\n sleep(0.25)\n end\n end",
"def rainbow; end",
"def set_mouse_speed pixels\r\n command 'setMouseSpeed', pixels\r\n end",
"def setup\n size 640, 360\n background 0\n stroke_weight 8\n (5 ... width/2).step(5) do |i|\n i.even? ? draw_short(i) : draw_long(i)\n end\nend",
"def run_blinky\n\t\twhile @i<10**3\n\t\t\t@i += 1\n\t\t\t# sleep(0.3)\n\t\t\tsystem(\"clear\")\n\t\t\tpretty_print\n\t\t\tgo_team\n\t\tend\n\tend",
"def update\n update_flow\n update_sprites\n update_weather\n update_timer\n update_viewports\n @brightness -= 15 if @brightness > 0\n end",
"def setup \n size 200, 200 \n @y = 100 \n stroke 255\n no_loop\nend",
"def bright; end",
"def bright; end",
"def initialize texture_size = [512,512]\n @texture_size = texture_size\n @texture = Array.new(@texture_size[0]) { Array.new(@texture_size[1]) { Array.new(3){1} } }\n @windows = [@texture_size[0]/8, @texture_size[1]/8]\n @texture_link = [0]\n \n @windows[0].times do |i|\n @windows[1].times do |j|\n px_origin = i*8\n py_origin = j*8\n # Got a little 8x8 window with pixel coords starting in px/py origin being topleft corner of window\n \n # Walls\n 8.times do |x|\n @texture[px_origin + x][py_origin] = [0,0,0]\n @texture[px_origin + x][py_origin+7] = [0,0,0]\n @texture[px_origin][py_origin + x] = [0,0,0]\n @texture[px_origin + 7][py_origin + x] = [0,0,0]\n end\n \n # Inside color, either mostly on or mostly off\n if rand > DARK_TO_LIGHT_RATIO\n cr = rand/4.0\n else\n cr = 3.0/4 + rand/4.0\n end\n c = [cr,cr,cr]\n \n # Inside\n 6.times do |x|\n 6.times do |y|\n px = px_origin + 1 + x\n py = py_origin + 1 + y\n \n @texture[px][py] = c\n end\n end \n end\n end\n \n loadTexture\n end",
"def light1000(num)\n lights = []\n counter = 1\n\n num.times { |i| lights << false} # initalize lights\n\n while counter <= num\n light_switcher(lights, counter)\n counter += 1\n end\n\n lights\nend",
"def create_snow_bitmap\r\n @snow_bitmap = Bitmap.new(6, 6)\r\n @snow_bitmap.fill_rect(0, 1, 6, 4, particle_color2)\r\n @snow_bitmap.fill_rect(1, 0, 4, 6, particle_color2)\r\n @snow_bitmap.fill_rect(1, 2, 4, 2, particle_color1)\r\n @snow_bitmap.fill_rect(2, 1, 2, 4, particle_color1)\r\n end",
"def cycle colors=[], delay=0.5\n unless colors.all? {|c| COLORS.include? c}\n raise \"Invalid color\"\n end\n\n reset\n\n @thread = Thread.new do\n i = 0\n loop do\n set_color_raw colors[i]\n i = (i+1) % colors.length\n sleep delay\n end\n end\n end",
"def set_colour(r,g,b)\n\t\t@colour_r = LoopedArray.new [*r].map {|i| i % 256}\n\t\t@colour_g = LoopedArray.new [*g].map {|i| i % 256}\n\t\t@colour_b = LoopedArray.new [*b].map {|i| i % 256}\n\tend",
"def fill_pot()\r\n sample (:drum_splash_hard)\r\n sleep(1)\r\nend",
"def makeImage\n for i in 0...@width\n ti = 2.0*Math::PI*i/ImageWidth.to_f\n for j in 0...@height\n tj = 2.0*Math::PI*j/ImageHeight.to_f\n\n $image[3 * (@height * i + j)] = 127*(1.0 + Math::sin(ti))\n $image[3 * (@height * i + j) +1] = 127*(1.0 + Math::cos(2*tj))\n $image[3 * (@height * i + j) +2] = 127*(1.0 + Math::cos(ti+tj))\n end\n end\n end",
"def setup\n size(750, 200)\n background(255)\n smooth\n\n @r = 0\n @theta = 0\nend",
"def run\n failed_attempts = 0\n failed_white_attempts = 0\n x = 0\n y = 0\n loop do\n # If white just sail through until we hit another color\n if @current_color == 1\n x_next, y_next = move_direction(x, y)\n\n # If in white and hit boundary or black then step through dp\n if restricted?(x_next, y_next)\n toggle_cc\n step_dp\n failed_white_attempts += 1\n else\n x = x_next\n y = y_next\n @current_color = @image.color(x, y)\n failed_attempts = 0\n failed_white_attempts = 0\n end\n\n break if failed_white_attempts == 4\n else\n @size = 0\n temp_x = x\n temp_y = y\n x, y, @size = block_fill(x, y)\n # puts \"CURR: #{temp_x+1}, #{temp_y+1}, NEXT: #{x+1}, #{y+1}\"\n x_next, y_next = move_direction(x, y)\n # If we are hitting the edge or a black codel try another direction\n if restricted?(x_next, y_next)\n update_movement(failed_attempts)\n failed_attempts += 1\n else # here we move into the next color block after processing the action\n next_color = @image.color(x_next, y_next)\n process_action(@current_color, next_color)\n x = x_next\n y = y_next\n @current_color = next_color\n failed_attempts = 0\n failed_white_attempts = 0\n end\n\n break if failed_attempts == 8\n end\n end\n end",
"def update_animation\n if @wait != 0\n @wait -= 1\n if @wait == 0\n @wait = 6\n #update frame every six updates\n @p_index += 1 \n if @p_index == @pattern.size\n @p_index = 0\n end\n end\n end\n end",
"def setup \n size 640, 360\n no_stroke\n frame_rate 30 \n @x, @y = 0.0, 0.0\n @size = 80.0\nend",
"def rgbForSeconds(s)\n case s\n when 1..10\n return {r: 229, g: 0, b: 0}\n when 11..20\n return {r: 229, g: 149, b: 0}\n when 21..30\n return {r: 229, g: 217, b: 0}\n when 31..40\n return {r: 2, g: 190, b: 1}\n when 41..50\n return {r: 0, g: 50, b: 199}\n when 51..60\n return {r: 130, g: 0, b: 128}\n else\n return {r: 255, g: 255, b: 255}\n end\nend",
"def setup\n size 200, 200\n stroke 255\n frame_rate 30\n @a = 0\t\t# Create an instance variable \"a\" of class Integer\n @b = 0.0\t# Create an instance variable \"b\" of class Float (because of \"0.0\")\nend",
"def test055()\n begin\n theCommands = CommandModule::SmigCommands.new\n theSize = MIShapes.make_size(4, 1)\n bitmapObject = theCommands.make_createbitmapcontext(\n size: theSize,\n addtocleanup: true,\n preset: \"AlphaPreMulFirstRGB8bpcInt\")\n fillRect = MIDrawElement.new(:fillrectangle)\n fillRect.rectangle = MIShapes.make_rectangle(size: theSize)\n fillRect.fillcolor = MIColor.make_rgbacolor(1,0,0)\n\n drawCommand = CommandModule.make_drawelement(bitmapObject,\n drawinstructions: fillRect)\n theCommands.add_command(drawCommand)\n pixelDataRect = MIShapes.make_rectangle(xloc: 0, yloc: 0,\n width: 1, height: 1)\n getPixelDataCommand = CommandModule.make_getpixeldata(\n bitmapObject,\n rectangle: pixelDataRect)\n theCommands.add_command(getPixelDataCommand)\n theResult = Smig.perform_commands(theCommands)\n previousResult = '{\"pixeldata\":[[0,0,255,255,0,0]],\"contextinfo\":{\"alphainfo\":16386,\"bitspercomponent\":8,\"colorspace\":\"kCGColorSpaceSRGB\",\"bitsperpixel\":32},\"columnnames\":[\"x\",\"y\",\"Alpha\",\"Red\",\"Green\",\"Blue\"]}'\n if theResult != previousResult\n puts theResult\n raise \"Pixel data has changed.\"\n end\n \n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: #{Smig.exitstring}\"\n end\n puts e.message\n puts e.backtrace.to_s\n puts #{Smig.exitstring}\"\n ensure\n end\nend",
"def paint_world3\r\n show_sun\r\n\tputs ''\r\n count = 0\r\n\tx_count = 0\r\n\th_count = 0\r\n @height.times do\r\n @width.times do\r\n #print @positions[count].symbol\r\n\t\tif @positions[count].temperature > -10 && @positions[count].temperature < 60\r\n\t\t print \"h\" \r\n\t\t h_count += 1\r\n\t\telse\r\n\t\t print \"x\" \r\n\t\t x_count += 1\r\n\t\tend\r\n #@positions[count].fneighbours = []\r\n\t\t#@positions[count].sneighbours = []\r\n count += 1\r\n end\r\n puts ''\r\n end\r\n puts '------------'\r\n\t[h_count,x_count]\r\n end",
"def test04()\n begin\n origModes = \"kCGBlendModeNormal kCGBlendModeMultiply kCGBlendModeScreen \"+\n \"kCGBlendModeOverlay kCGBlendModeDarken kCGBlendModeLighten \" + \n \"kCGBlendModeColorDodge kCGBlendModeColorBurn kCGBlendModeSoftLight \" +\n \"kCGBlendModeHardLight kCGBlendModeDifference kCGBlendModeExclusion \" +\n \"kCGBlendModeHue kCGBlendModeSaturation kCGBlendModeColor \" +\n \"kCGBlendModeLuminosity kCGBlendModeClear kCGBlendModeCopy \" +\n \"kCGBlendModeSourceIn kCGBlendModeSourceOut kCGBlendModeSourceAtop \" +\n \"kCGBlendModeDestinationOver kCGBlendModeDestinationIn \" +\n \"kCGBlendModeDestinationOut kCGBlendModeDestinationAtop kCGBlendModeXOR \" +\n \"kCGBlendModePlusDarker kCGBlendModePlusLighter\"\n blendModes = MIMeta.listcgblendmodes\n unless origModes.eql? blendModes\n raise \"Blend modes are different, new:\" + blendModes\n end\n\n origPresets = \"AlphaOnly8bpcInt Gray8bpcInt Gray16bpcInt Gray32bpcFloat \" +\n \"AlphaSkipFirstRGB8bpcInt AlphaSkipLastRGB8bpcInt \"+\n \"AlphaPreMulFirstRGB8bpcInt AlphaPreMulBGRA8bpcInt AlphaPreMulLastRGB8bpcInt \" +\n \"AlphaPreMulLastRGB16bpcInt AlphaSkipLastRGB16bpcInt \" +\n \"AlphaSkipLastRGB32bpcFloat AlphaPreMulLastRGB32bpcFloat \" +\n \"CMYK8bpcInt CMYK16bpcInt CMYK32bpcFloat PlatformDefaultBitmapContext\"\n presets = MIMeta.listpresets\n unless origPresets.eql? presets\n raise \"Presets are different, new:\" + presets\n end\n\n origCommands = [:getproperty, :setproperty, :getproperties, :setproperties,\n :create, :close, :closeall, :addimage, :export, :drawelement, :snapshot,\n :finalizepage, :getpixeldata, :calculategraphicsizeoftext, :renderfilterchain,\n :assignimagetocollection, :removeimagefromcollection, :processframes,\n :createtrack, :addinputtowriter, :addimagesampletowriter,\n :finishwritingframes, :cancelwritingframes, :addmovieinstruction,\n :inserttracksegment, :insertemptytracksegment]\n\n commands = MIMeta.listallcommands\n unless origCommands.eql? commands\n raise \"Command lists are different, new:\" + commands.to_s\n end\n\n origObjects = [:bitmapcontext, :imageimporter, :imageexporter,\n :imagefilterchain, :pdfcontext, :nsgraphiccontext,\n :movieimporter, :movieeditor, :videoframeswriter]\n objectTypes = MIMeta.listobjecttypes\n\n unless origObjects.eql? objectTypes\n raise \"List of objects is different, new:\" + commands.to_s\n end\n\n origInputVideoWriterPresets = \"h264preset_sd jpegpreset h264preset_hd \" +\n \"prores4444preset prores422preset\"\n \n videoWriterPresets = MIMeta.listvideoframewriterpresets\n unless origInputVideoWriterPresets.eql? videoWriterPresets\n raise \"List of video writer presets is different, new:\" + videoWriterPresets.to_s\n end\n\n origUserInterfaceFonts = \"kCTFontUIFontMiniEmphasizedSystem \" +\n \"kCTFontUIFontSmallToolbar kCTFontUIFontWindowTitle \" +\n \"kCTFontUIFontMenuTitle kCTFontUIFontSystem kCTFontUIFontMenuItem \" +\n \"kCTFontUIFontEmphasizedSystem kCTFontUIFontToolbar kCTFontUIFontMessage \" +\n \"kCTFontUIFontEmphasizedSystemDetail kCTFontUIFontSmallEmphasizedSystem \" +\n \"kCTFontUIFontUserFixedPitch kCTFontUIFontMiniSystem kCTFontUIFontLabel \" +\n \"kCTFontUIFontControlContent kCTFontUIFontSystemDetail kCTFontUIFontViews \"+\n \"kCTFontUIFontUser kCTFontUIFontSmallSystem kCTFontUIFontApplication\" +\n \"kCTFontUIFontToolTip\"\n \n userInterfaceFonts = MIMeta.listuserinterfacefonts\n unless userInterfaceFonts.eql? userInterfaceFonts\n raise \"User iterface fonts are different, new:\" + userInterfaceFonts\n end\n\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: #{Smig.get_exitstring}\"\n end\n puts e.message\n puts e.backtrace.to_s\n puts #{Smig.exitstring}\"\n# exit 240\n end\nend",
"def shades_of_grey(n)\n 1.upto([254,n].min).map {|i| p format '#%02x%02x%02x', i, i, i}\nend",
"def blink; end",
"def blink; end",
"def light_up(quad)\n case quad\n when 1\n (0..3).each do |x_index|\n (0..3).each do |y_index|\n @device.change :grid, :x => x_index, :y => y_index, :green => :high\n end\n end\n when 2\n (4..7).each do |x_index|\n (0..3).each do |y_index|\n @device.change :grid, :x => x_index, :y => y_index, :green => :high, :red => :high\n end\n end\n when 3\n (0..3).each do |x_index|\n (4..7).each do |y_index|\n @device.change :grid, :x => x_index, :y => y_index, :red => :high\n end\n end\n when 4\n (4..7).each do |x_index|\n (4..7).each do |y_index|\n @device.change :grid, :x => x_index, :y => y_index, :green => :low, :red => :medium\n end\n end\n end\n end",
"def setup \n size 640, 360 \n\tbackground 127 \n\tno_stroke\t\n\t(0...height).step(20) do |i|\n\t\tfill 0 \n\t\trect 0, i, width, 10 \n\t\tfill 255 \n\t\trect i, 0, 10, height \n\tend\nend",
"def write_to_channel()\n store_button()\n sleep(0.5)\n store_button()\n sleep(0.5)\nend",
"def loop\n blink_twice if read_input button_one\n blink_three_times if read_input button_two\n button_three.read_and_toggle led # \n blink_three_times_basic if read_input button_four\n blink_with_a_twist if read_input button_five\n end",
"def load(n,m)\n n.times {\n puts \"*\"\n sleep(m)\n}\n \nend",
"def step\n # Draw everything\n @image.draw @screen\n end",
"def test_pattern\n [@window, @sprite, @bitmap].each{|container|\n uc = UCGraph.new(container, 100, 180, 50, @elements, \"%d%%\", 100, -100, Font.normal_font,\n Color.hp_gauge_color1, Color.hp_gauge_color2,\n Color.mp_gauge_color1, Color.mp_gauge_color2)\n uc.draw()\n }\n return true\n end",
"def animate() %x{convert -delay 20 -loop 1 #{base}*.png #{base}.gif} end",
"def packet(color_name, pow)\n case color_name.downcase\n when 'red' then rgb(r: pow)\n when 'blue' then rgb(b: pow)\n when 'green' then rgb(g: pow)\n when 'yellow' then rgb(r: pow, g: pow * 0.6)\n when 'aqua' then rgb(g: pow, b: pow)\n when 'pink' then rgb(b: pow, r: pow)\n else rgb(brightness: 8)\n end\nend",
"def change_color\n @color = Gosu::Color.rgb(rand * 255, rand * 255, rand * 255)\n end",
"def write_pixel(pixel,rgb_color)\n rgb_vals = rgb_color.split(',')\n #Maximum value for these fields is 255, set it to 255 if a greater values is passed\n rgb_vals.map! {|value| [value.to_f, 255].min}\n #Set the standard update string Cp,r,g,b\n update_string = \"C#{pixel},#{rgb_vals.join ','}\"\n #Update the alamode pixels using the standard update string filled in with the pixel and rgb values.\n @serial_device.write update_string\n end",
"def round_trip(color = nil, rate = 0.1, looped = true)\n counter = 0\n increasing = true\n rt = Thread.new do \n loop do\n break unless looped\n clear_lights() if @clear\n unless @color.nil?\n color ||= Color.new(red: @color[\"red\"], \n blue: @color[\"blue\"], \n green: @color[\"green\"])\n end\n @lights_array.each_with_index do |light, i|\n if counter == i or counter == i - 1\n light.color = color\n else\n light.color = Color.off\n end\n end\n increasing ? counter += 2 : counter -= 2\n if counter > NUM_OF_LIGHTS - 2 and increasing\n counter = NUM_OF_LIGHTS - 1\n increasing = false\n end\n if counter < 0 and !increasing\n counter = 0\n increasing = true\n end\n # Write to LED strip\n msg = led_message()\n PiPiper::Spi.begin do\n write((msg))\n end\n sleep(rate)\n end\n end\n @animation_threads.push(rt)\n rt\n end",
"def rainbowIntro(viewport=nil)\n @viewport = viewport if !@viewport && !viewport.nil?\n @sprites = {} if !@sprites\n # takes screenshot\n bmp = Graphics.snap_to_bitmap\n # creates non-blurred overlay\n @sprites[\"bg1\"] = Sprite.new(@viewport)\n @sprites[\"bg1\"].bitmap = Bitmap.new(@viewport.width, @viewport.height)\n @sprites[\"bg1\"].bitmap.blt(0, 0, bmp, @viewport.rect)\n @sprites[\"bg1\"].center!(true)\n # creates blurred overlay\n @sprites[\"bg2\"] = Sprite.new(@viewport)\n @sprites[\"bg2\"].bitmap = @sprites[\"bg1\"].bitmap.clone\n @sprites[\"bg2\"].blur_sprite(3)\n @sprites[\"bg2\"].center!(true)\n @sprites[\"bg2\"].opacity = 0\n # creates rainbow rings\n for i in 1..2\n z = [0.35, 0.1]\n @sprites[\"glow#{i}\"] = Sprite.new(@viewport)\n @sprites[\"glow#{i}\"].bitmap = pbBitmap(\"Graphics/EBDX/Transitions/Common/glow\")\n @sprites[\"glow#{i}\"].ox = @sprites[\"glow#{i}\"].bitmap.width/2\n @sprites[\"glow#{i}\"].oy = @sprites[\"glow#{i}\"].bitmap.height/2\n @sprites[\"glow#{i}\"].x = @viewport.width/2\n @sprites[\"glow#{i}\"].y = @viewport.height/2\n @sprites[\"glow#{i}\"].zoom_x = z[i-1]\n @sprites[\"glow#{i}\"].zoom_y = z[i-1]\n @sprites[\"glow#{i}\"].opacity = 0\n end\n # main animation\n for i in 0...32.delta_add\n # zooms in the two screenshots\n @sprites[\"bg1\"].zoom_x += 0.02/self.delta\n @sprites[\"bg1\"].zoom_y += 0.02/self.delta\n @sprites[\"bg2\"].zoom_x += 0.02/self.delta\n @sprites[\"bg2\"].zoom_y += 0.02/self.delta\n # fades in the blurry screenshot\n @sprites[\"bg2\"].opacity += 12/self.delta\n # fades to white\n if i >= 16.delta_add\n @sprites[\"bg2\"].tone.all += 16/self.delta\n end\n # zooms in rainbow rings\n if i >= 28.delta_add\n @sprites[\"glow1\"].opacity += 64/self.delta\n @sprites[\"glow1\"].zoom_x += 0.02/self.delta\n @sprites[\"glow1\"].zoom_y += 0.02/self.delta\n end\n Graphics.update\n end\n @viewport.color = Color.new(255, 255, 255, 0)\n # second part of animation\n for i in 0...48.delta_add\n # zooms in rainbow rings\n @sprites[\"glow1\"].zoom_x += 0.02/self.delta\n @sprites[\"glow1\"].zoom_y += 0.02/self.delta\n if i >= 8.delta_add\n @sprites[\"glow2\"].opacity += 64/self.delta\n @sprites[\"glow2\"].zoom_x += 0.02/self.delta\n @sprites[\"glow2\"].zoom_y += 0.02/self.delta\n end\n # fades viewport to white\n if i >= 32.delta_add\n @viewport.color.alpha += 16/self.delta\n end\n Graphics.update\n end\n @viewport.color = Color.white\n # disposes of the elements\n pbDisposeSpriteHash(@sprites)\n EliteBattle.set(:colorAlpha, 255)\n return true\n end",
"def transform \n \n @pixel_location = get_pixel_points \n puts \"px loc : #{@pixel_location}\"\n \n while @pixel_location.size != 0 \n transform_pixel_points(@pixel_location)\n @pixel_location.shift\n @pixel_location.shift\n end\n end",
"def SS2_1 args\r\n\targs.state.tick_timer ||= args.state.tick_count\r\n\r\n\tif args.state.tick_count >= (args.state.tick_timer + 20) && args.state.tick_count < (args.state.tick_timer + 40)\r\n\t\t#white screen\r\n\t\targs.outputs.solids << [0, 0, 1280, 720, 255, 255, 255]\r\n\t\targs.outputs.labels << my_red_label(args, 605, 14, \"3\")\r\n\tend\r\n\tif args.state.tick_count >= (args.state.tick_timer + 40) && args.state.tick_count < (args.state.tick_timer + 60)\r\n\t\t#black screen\r\n\t\targs.outputs.solids << [0, 0, 1280, 720, 0, 0, 0]\r\n\t\targs.outputs.labels << my_red_label(args, 605, 14, \"3\")\r\n\tend\r\n\tif args.state.tick_count >= (args.state.tick_timer + 60) && args.state.tick_count < (args.state.tick_timer + 80)\r\n\t\t#white screen\r\n\t\targs.outputs.solids << [0, 0, 1280, 720, 255, 255, 255]\r\n\t\targs.outputs.labels << my_red_label(args, 605, 14, \"3\")\r\n\tend\r\n\tif args.state.tick_count >= (args.state.tick_timer + 80) && args.state.tick_count < (args.state.tick_timer + 100)\r\n\t\t#black screen\r\n\t\targs.outputs.solids << [0, 0, 1280, 720, 0, 0, 0]\r\n\t\targs.outputs.labels << my_red_label(args, 605, 14, \"3\")\r\n\tend\r\n\tif args.state.tick_count >= (args.state.tick_timer + 100) && args.state.tick_count < (args.state.tick_timer + 120)\r\n\t\t#white screen\r\n\t\targs.outputs.solids << [0, 0, 1280, 720, 255, 255, 255]\r\n\t\targs.outputs.labels << my_red_label(args, 605, 14, \"2\")\r\n\tend\r\n\tif args.state.tick_count >= (args.state.tick_timer + 120) && args.state.tick_count < (args.state.tick_timer + 140)\r\n\t\t#black screen\r\n\t\targs.outputs.solids << [0, 0, 1280, 720, 0, 0, 0]\r\n\t\targs.outputs.labels << my_red_label(args, 605, 14, \"2\")\r\n\tend\r\n\tif args.state.tick_count >= (args.state.tick_timer + 140) && args.state.tick_count < (args.state.tick_timer + 160)\r\n\t\t#white screen\r\n\t\targs.outputs.solids << [0, 0, 1280, 720, 255, 255, 255]\r\n\t\targs.outputs.labels << my_red_label(args, 605, 14, \"2\")\r\n\tend\r\n\tif args.state.tick_count >= (args.state.tick_timer + 160) && args.state.tick_count < (args.state.tick_timer + 180)\r\n\t\t#black screen\r\n\t\targs.outputs.solids << [0, 0, 1280, 720, 0, 0, 0]\r\n\t\targs.outputs.labels << my_red_label(args, 605, 14, \"2\")\r\n\tend\r\n\tif args.state.tick_count >= (args.state.tick_timer + 180) && args.state.tick_count < (args.state.tick_timer + 200)\r\n\t\t#white screen\r\n\t\targs.outputs.solids << [0, 0, 1280, 720, 255, 255, 255]\r\n\t\targs.outputs.labels << my_red_label(args, 605, 14, \"1\")\r\n\tend\r\n\tif args.state.tick_count >= (args.state.tick_timer + 200) && args.state.tick_count < (args.state.tick_timer + 220)\r\n\t\t#black screen\r\n\t\targs.outputs.solids << [0, 0, 1280, 720, 0, 0, 0]\r\n\t\targs.outputs.labels << my_red_label(args, 605, 14, \"1\")\r\n\tend\r\n\tif args.state.tick_count >= (args.state.tick_timer + 220) && args.state.tick_count < (args.state.tick_timer + 240)\r\n\t\t#white screen\r\n\t\targs.outputs.solids << [0, 0, 1280, 720, 255, 255, 255]\r\n\t\targs.outputs.labels << my_red_label(args, 605, 14, \"1\")\r\n\tend\r\n\tif args.state.tick_count >= (args.state.tick_timer + 240) && args.state.tick_count < (args.state.tick_timer + 260)\r\n\t\t#black screen\r\n\t\targs.outputs.solids << [0, 0, 1280, 720, 0, 0, 0]\r\n\t\targs.outputs.labels << my_red_label(args, 605, 14, \"1\")\r\n\tend\r\n\r\n\t#After moving characters finished, transition to SS2_2\r\n\tif args.state.tick_count >= (args.state.tick_timer + 260)\r\n\t\targs.state.tick_timer = nil\r\n\t\targs.state.screen_select = 2.2\r\n\tend\r\nend",
"def init(num_of_pixels)\n @@packetdata = String.new\n @@numpixels = num_of_pixels \n i = 0\n p = [0.to_i]\n while i < (@@numpixels * 3)\n @@packetdata[i] = p.pack(\"C\")\n i = i + 1\n end\nend",
"def simulateGameLoad\n i = 3\n sleep(0.5)\n while i > 0 do\n i -= 1\n print '.'\n sleep(0.5)\n end\nend",
"def setup\n\t\tsize(displayWidth, displayHeight)\n\t\tcolorMode(HSB,360,100,100,60)\n\t\t@w, @h = [width/2.0, 0]\n\t\t@i = 0 ; @t = 0\n frame_rate 20\n\t\tbackground(0)\n\n\t\t@monster = Monster.new 7, width, height\n\t\tstroke_width(160)\n\tend",
"def draw_board_start\n #Places the pawns\n 8.times do |x|\n @b[x][1] = @WP\n @b[x][6] = @BP\n end\n #white, on bottom, the opaque pieces\n @b[0][0] = @WR; @b[7][0] = @WR\n @b[1][0] = @WK; @b[6][0] = @WK\n @b[2][0] = @WB; @b[5][0] = @WB\n @b[3][0] = @WQ\n @b[4][0] = @WKg\n #black, on top, the filled in pieces\n @b[0][7] = @BR; @b[7][7] = @BR\n @b[1][7] = @BK; @b[6][7] = @BK\n @b[2][7] = @BB; @b[5][7] = @BB\n @b[3][7] = @BQ\n @b[4][7] = @BKg\n \n #TESTING PIECES HERE\n\n\n draw_board\n end",
"def graphic(number)\n File.open(\"#{frame_id(number)}.svg\", \"w\") do |file|\n file.write render(\"bit101_style.erb\")\n end\n\n system(\"convert #{frame_id(number)}.svg #{frame_id(number)}.jpg\")\n # system(\"java -jar ~/Downloads/batik-1.7/batik-rasterizer.jar #{frame_id(number)}.svg\")\n File.unlink(\"#{frame_id(number)}.svg\")\n\n print \"+\"\nend",
"def loading\n chars = %w[| / ― \\\\]\n fps = 10\n delay = 1.0/fps\n\n fps.round.times do |i|\n print chars[ i % chars.length]\n sleep delay\n print \"\\b\"\n end\nend",
"def set_pixel(pos, color, brightness = @brightness)\n idx = pos * 4\n if color.is_a?(Integer)\n @led_frames[idx] = led_frame_hdr(brightness)\n @led_frames[idx + @led_frame_rgb_offsets[:red]] = (color & 0xFF0000) >> 16\n @led_frames[idx + @led_frame_rgb_offsets[:green]] = (color & 0x00FF00) >> 8\n @led_frames[idx + @led_frame_rgb_offsets[:blue]] = (color & 0x0000FF)\n elsif color.is_a?(Array)\n @led_frames[idx] = led_frame_hdr(brightness)\n @led_frames[idx + @led_frame_rgb_offsets[:red]] = color[0]\n @led_frames[idx + @led_frame_rgb_offsets[:green]] = color[1]\n @led_frames[idx + @led_frame_rgb_offsets[:blue]] = color[2]\n else\n raise 'Invalid color'\n end\n end",
"def wait_animation\n sleep 0.8\n end",
"def main\n sei\n set 0xdc0d, 0x7f #shortcut for lda 0x7f; sta 0xdc0d\n set 0xdd0d #without second argument its simply a sta 0xdd0d\n lda 0xdc0d\n lda 0xdd0d\n set 0xd01a, 1\n set 0xd012, 20\n set 0xd011, 0x1b\n lda 0x35\n sta 0x01, :zeropage => true #TODO: this is not so pretty\n irq #shortcut for: address :irq, :irq\n cli\n label :self\n jmp :self\n \n label :irq\n border 0\n lda 22\n label :raster_fix\n cmp 0xd012\n bne :raster_fix\n nop 27\n [:darkgrey, :red, :grey, :pink, :lightgrey, :white, :lightgrey, :pink, :grey, :red, :darkgrey, :black].each do |color|\n border color\n nop 60\n end\n border 0\n set 0xd019, 0xff\n rti\n end",
"def updateWeather\n self.setWeather\n harsh = [:HEAVYRAIN, :HARSHSUN].include?(@battle.pbWeather)\n # snow particles\n for j in 0...72\n next if !@sprites[\"w_snow#{j}\"]\n if @sprites[\"w_snow#{j}\"].opacity <= 0\n z = rand(32)\n @sprites[\"w_snow#{j}\"].param = 0.24 + 0.01*rand(z/2)\n @sprites[\"w_snow#{j}\"].ey = -rand(64)\n @sprites[\"w_snow#{j}\"].ex = 32 + rand(@sprites[\"bg\"].bitmap.width - 64)\n @sprites[\"w_snow#{j}\"].end_x = @sprites[\"w_snow#{j}\"].ex\n @sprites[\"w_snow#{j}\"].toggle = rand(2) == 0 ? 1 : -1\n @sprites[\"w_snow#{j}\"].speed = 1 + 2/((rand(5) + 1)*0.4)\n @sprites[\"w_snow#{j}\"].z = z - (@focused ? 0 : 100)\n @sprites[\"w_snow#{j}\"].opacity = 255\n end\n min = @sprites[\"bg\"].bitmap.height/4\n max = @sprites[\"bg\"].bitmap.height/2\n scale = (2*Math::PI)/((@sprites[\"w_snow#{j}\"].bitmap.width/64.0)*(max - min) + min)\n @sprites[\"w_snow#{j}\"].opacity -= @sprites[\"w_snow#{j}\"].speed\n @sprites[\"w_snow#{j}\"].ey += @sprites[\"w_snow#{j}\"].speed\n @sprites[\"w_snow#{j}\"].ex = @sprites[\"w_snow#{j}\"].end_x + @sprites[\"w_snow#{j}\"].bitmap.width*0.25*Math.sin(@sprites[\"w_snow#{j}\"].ey*scale)*@sprites[\"w_snow#{j}\"].toggle\n end\n # rain particles\n for j in 0...72\n next if !@sprites[\"w_rain#{j}\"]\n if @sprites[\"w_rain#{j}\"].opacity <= 0\n z = rand(32)\n @sprites[\"w_rain#{j}\"].param = 0.24 + 0.01*rand(z/2)\n @sprites[\"w_rain#{j}\"].ox = 0\n @sprites[\"w_rain#{j}\"].ey = -rand(64)\n @sprites[\"w_rain#{j}\"].ex = 32 + rand(@sprites[\"bg\"].bitmap.width - 64)\n @sprites[\"w_rain#{j}\"].speed = 3 + 2/((rand(5) + 1)*0.4)\n @sprites[\"w_rain#{j}\"].z = z - (@focused ? 0 : 100)\n @sprites[\"w_rain#{j}\"].opacity = 255\n end\n @sprites[\"w_rain#{j}\"].opacity -= @sprites[\"w_rain#{j}\"].speed*(harsh ? 3 : 2)\n @sprites[\"w_rain#{j}\"].ox += @sprites[\"w_rain#{j}\"].speed*(harsh ? 8 : 6)\n end\n # starstorm particles\n for j in 0...72\n next if !@sprites[\"w_starstorm#{j}\"]\n if @sprites[\"w_starstorm#{j}\"].opacity <= 0\n z = rand(32)\n @sprites[\"w_starstorm#{j}\"].param = 0.24 + 0.01*rand(z/2)\n @sprites[\"w_starstorm#{j}\"].ox = 32 + rand(@sprites[\"bg\"].bitmap.width - 64)\n @sprites[\"w_starstorm#{j}\"].ey = 0\n @sprites[\"w_starstorm#{j}\"].ex = 0\n @sprites[\"w_starstorm#{j}\"].speed = 3 + 2/((rand(5) + 1)*0.4)\n @sprites[\"w_starstorm#{j}\"].z = z - (@focused ? 0 : 100)\n @sprites[\"w_starstorm#{j}\"].opacity = 255\n end\n @sprites[\"w_starstorm#{j}\"].opacity -= @sprites[\"w_starstorm#{j}\"].speed\n @sprites[\"w_starstorm#{j}\"].ex += @sprites[\"w_starstorm#{j}\"].speed*2\n end\n # volcanic ash particles\n for j in 0...72\n next if !@sprites[\"w_volc#{j}\"]\n if @sprites[\"w_volc#{j}\"].opacity <= 0\n z = rand(32)\n @sprites[\"w_volc#{j}\"].param = 0.24 + 0.01*rand(z/2)\n @sprites[\"w_volc#{j}\"].ox = 0\n @sprites[\"w_volc#{j}\"].ey = -rand(64)\n @sprites[\"w_volc#{j}\"].ex = 32 + rand(@sprites[\"bg\"].bitmap.width - 64)\n @sprites[\"w_volc#{j}\"].speed = 3 + 1/((rand(8) + 1)*0.4)\n @sprites[\"w_volc#{j}\"].z = z - (@focused ? 0 : 100)\n @sprites[\"w_volc#{j}\"].opacity = 255\n end\n @sprites[\"w_volc#{j}\"].opacity -= @sprites[\"w_volc#{j}\"].speed\n @sprites[\"w_volc#{j}\"].ox += @sprites[\"w_volc#{j}\"].speed*2\n end\n # sun particles\n for j in 0...3\n next if !@sprites[\"w_sunny#{j}\"]\n #next if j > @shine[\"count\"]/6\n @sprites[\"w_sunny#{j}\"].zoom_x += 0.04*[0.5, 0.8, 0.7][j]\n @sprites[\"w_sunny#{j}\"].zoom_y += 0.03*[0.5, 0.8, 0.7][j]\n @sprites[\"w_sunny#{j}\"].opacity += @sprites[\"w_sunny#{j}\"].zoom_x < 1 ? 8 : -12\n if @sprites[\"w_sunny#{j}\"].opacity <= 0\n @sprites[\"w_sunny#{j}\"].zoom_x = 0\n @sprites[\"w_sunny#{j}\"].zoom_y = 0\n @sprites[\"w_sunny#{j}\"].opacity = 0\n end\n end\n # sandstorm particles\n for j in 0...2\n next if !@sprites[\"w_sand#{j}\"]\n @sprites[\"w_sand#{j}\"].update\n end\n end",
"def pbBGSFade(x=0.0); pbBGSStop(x);end",
"def wait(frames = 1)\n frames.times do\n self.update\n Graphics.update\n end\n end",
"def force_wait(frames)\n frames.times do\n Graphics.update\n Input.update\n end\n end",
"def fast_green_typer(string)\n string.chars.each do |x|\n print x.colorize(@@colours[0])\n sleep(0.003)\n end\n br\n end",
"def get_green_to_red_scala n\n colors = []\n r = 0; g = 150; b = 0\n max = 255\n\n #se empieza en un g oscuro en 150 y se aclarece añadiendo g hasta 255\n #ni = numero iteraciones\n ni = (1*n/3)\n for i in 1..(1*n/3.to_f).floor\n g = 150 + (i*(max - 150)/ni.to_f).floor\n colors << rgb(r, g, b)\n end\n\n #una vez g esta en 255 se añade r desde 150 hasta 255 hasta llegar a amarillo\n #ni = numero iteraciones\n g = 255\n ni = 1 + (2*n/3.to_f).floor - (1*n/3.to_f).ceil\n for j in (1*n/3.to_f).ceil..(2*n/3.to_f).floor\n i = j - (1*n/3.to_f).ceil + 1\n r = 150 + (i*(max - 150)/ni.to_f).floor\n colors << rgb(r, g, b)\n end\n\n #una vez g y r estan en 255 se quita g hasta 0 hasta llegar a rojo\n #ni = numero iteraciones\n g = r = 255\n ni = 1 + n - (2*n/3.to_f).ceil\n for i in (2*n/3.to_f).ceil..n\n g = ((n - i)*(max/ni.to_f)).floor\n colors << rgb(r, g, b)\n end\n\n #se entrega la escala de verde a rojo\n colors\n end",
"def start\r\n puts `cat starting_board.txt`\r\n new_board = next_turn(@board)\r\n 300.times do\r\n save_board(new_board)\r\n puts '========='\r\n puts `cat new_board.txt`\r\n sleep(0.1)\r\n new_board = next_turn(new_board)\r\n end\r\n end",
"def update\n if @step_count == 20 # 3 times / s\n @board.step!\n @step_count = 0\n else\n @step_count += 1\n end\n end",
"def paint_world\r\n show_sun\r\n\tputs ''\r\n count = 0\r\n @height.times do\r\n @width.times do\r\n print @positions[count].symbol\r\n count += 1\r\n end\r\n puts ''\r\n end\r\n puts '------------'\r\n end",
"def update\n loop do\n if (Time.now.to_f - @_ntime.to_f) >= @time.to_f\n Graphics.update \n terminate\n break \n return\n end\n Input.update\n if Input.trigger?(Input::C) && $game_temp.mskip\n terminate\n break \n return\n end\n if @refreshTime >= rtime\n Graphics.update \n @refreshTime = 0\n end\n @refreshTime += 1\n end\n end",
"def flash(color, duration); end",
"def setDrawColorViaRGB(r, g, b)\n while r > 255\n r -= 255\n end\n while g > 255\n g -= 255\n end\n while b > 255\n b -= 255\n end\n puts(\"draw color set to RGB values: (\" + r.to_s + \", \" + g.to_s + \", \" + b.to_s + \")\")\n @drawColor = FXRGB(r, g, b)\n end",
"def time_for_new_paint(new_color)\n @color = new_color\n ahh_fresh_paint\nend",
"def render_block x,y,i,a=255\n boxsize = 30\n grid_x = (1280 - (@grid_w * boxsize)) / 2\n grid_y = (720 - ((@grid_h-2) * boxsize)) / 2\n @args.outputs.solids << [grid_x + (x*boxsize), (720-grid_y) - (y*boxsize),boxsize,boxsize,*@color_index[i],a]\n if i != 8\n @args.outputs.borders << [grid_x + (x*boxsize), (720-grid_y) - (y*boxsize),boxsize,boxsize,*@color_index[8],a]\n else\n @args.outputs.borders << [grid_x + (x*boxsize), (720-grid_y) - (y*boxsize),boxsize,boxsize,*@color_index[7],a]\n end\n end",
"def initialize(pixels)\n @red = @green = @blue = 0\n pixels.each do |pixel|\n @red += pixel.red.to_f / pixels.length\n @green += pixel.green.to_f / pixels.length\n @blue += pixel.blue.to_f / pixels.length\n end\n end",
"def SS0_1 args\r\n\targs.state.tick_timer ||= args.state.tick_count\r\n\r\n\targs.outputs.sprites << [0, 0, 1280, 720, \"sprites/Intro-Background-1.png\"]\r\n\r\n\tif args.state.tick_count >= (args.state.tick_timer + 60) && args.state.tick_count < (args.state.tick_timer + 68)\r\n\t\targs.outputs.sprites << [0, 0, 1280, 720, \"sprites/Intro-Background-2.png\"]\r\n\tend\r\n\r\n\tif args.state.tick_count >= (args.state.tick_timer + 83) && args.state.tick_count < (args.state.tick_timer + 91)\r\n\t\targs.outputs.sprites << [0, 0, 1280, 720, \"sprites/Intro-Background-3.png\"]\r\n\tend\r\n\r\n\r\n\t#After moving characters finished, transition to SS0_2\r\n\tif args.state.tick_count >= (args.state.tick_timer + 160)\r\n\t\targs.state.tick_timer = nil\r\n\t\targs.state.screen_select = 0.2\r\n\tend\r\nend",
"def run()\n while(true)\n cycle() ;\n sleep(2) ;\n end\n end",
"def draw_squares()\n 0.upto(@w / 2) { |x|\n 0.upto(@h / 2) { |y|\n (0..1).each { |i|\n rect = [x * @bw * 2 + @bw * i, y * @bh * 2 + @bh * i, @bw, @bh]\n @im.fill_rect rect, @fg\n }\n }\n }\n end"
] |
[
"0.6504237",
"0.61832976",
"0.6111973",
"0.6099334",
"0.6056286",
"0.60539997",
"0.5939408",
"0.58347994",
"0.5831059",
"0.57764095",
"0.57642883",
"0.5759403",
"0.5722849",
"0.571854",
"0.5703995",
"0.5685345",
"0.5659769",
"0.56507176",
"0.56322813",
"0.56197083",
"0.5615777",
"0.5597491",
"0.5588498",
"0.5583102",
"0.558141",
"0.5566108",
"0.55264544",
"0.55151534",
"0.54885143",
"0.5486945",
"0.548652",
"0.5480892",
"0.54776627",
"0.546889",
"0.5468306",
"0.54562074",
"0.54155713",
"0.5415189",
"0.54093945",
"0.54093945",
"0.54037964",
"0.54022616",
"0.53985685",
"0.5397418",
"0.53660405",
"0.5357906",
"0.5344558",
"0.5341674",
"0.5341249",
"0.5318311",
"0.5315284",
"0.5302666",
"0.5301494",
"0.5300286",
"0.53001845",
"0.52917033",
"0.52915365",
"0.5276937",
"0.5276937",
"0.52753204",
"0.5271829",
"0.52714455",
"0.5262906",
"0.5260066",
"0.52585286",
"0.52582246",
"0.52545446",
"0.5253831",
"0.5250055",
"0.52415",
"0.52272874",
"0.52265406",
"0.522253",
"0.5221378",
"0.5218686",
"0.5213009",
"0.52119744",
"0.52113926",
"0.52080125",
"0.52079666",
"0.51893306",
"0.5186288",
"0.5184605",
"0.5184406",
"0.51805526",
"0.51793617",
"0.5169428",
"0.5161493",
"0.5151818",
"0.5139346",
"0.51379234",
"0.5136897",
"0.5129974",
"0.5129266",
"0.51263624",
"0.5124561",
"0.51238585",
"0.5116159",
"0.51160026",
"0.5112226",
"0.5110674"
] |
0.0
|
-1
|
The position of the task in the board list determines its priority This method sets the position of the task in the list (acts_as_list gem) According to the index passed by the ajax call.
|
def set_position(index)
first_item_position = board.tasks.by_status(self.status)[index].position
insert_at(first_item_position)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def change_position\n\n puts params[:tasks].to_json\n\n @tasksvalues = params[:tasks].values.map do |task|\n @task = Task.find_by(id: task[:id])\n @task.update(position:task[:position])\n end\n\n\n\n end",
"def update_position\n if self.simple_acts_as_list_scope.length == 0\n self.position = 1\n else\n self.position = self.simple_acts_as_list_scope.last.position + 1\n end\n end",
"def create\n @task_list = TaskList.find(params[:task_list_id])\n @task = Task.new({ :attributes => params[:task], :task_list => @task_list }) \n \n respond_to do |format|\n if @task.valid? && @task_list.tasks << @task \n add_to_top = params[:task][:add_to_top_of_list] == \"1\" ? true : false\n if add_to_top\n @task.move_to_top\n else\n @task.move_to_bottom\n end\n @task_list.reload\n \n format.html { redirect_to(@task_list, :notice => \"task successfully added to the #{add_to_top ? 'top' : 'bottom'} of the list\") }\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 up\n task = Task.find(params[:task_id])\n onCurrentPriority = Task.where(:user_id => current_user.id).where(\"priority = #{task.priority}\").count\n if (onCurrentPriority > 1) then\n task.priority += 1\n else\n nextTask = Task.where(:user_id => current_user.id).where(\"priority > #{task.priority}\").order(:priority).limit(1).first\n if nextTask then\n task = Task.find(params[:task_id])\n task.priority, nextTask.priority = nextTask.priority, task.priority\n nextTask.save\n end\n end\n task.save\n # Ignore errors!\n @tasks = Task.where(:user_id => current_user.id).order('priority desc')\n respond_to do |format|\n format.html { render :partial => 'tasks' }\n format.json { render json: @tasks }\n format.js { }\n end\n end",
"def sort\n @project.items.each do |item|\n if position = params[:items].index(item.id.to_s)\n item.update_attribute(:position, position + 1) unless item.position == position + 1\n end\n end\n render :nothing => true, :status => 200\n end",
"def add_to_active\n selection = @list_view.selection\n if iter = selection.selected\n selected_category = iter.parent[0]\n task_index = iter[3]\n priority = todo_data.get_priority(selected_category,task_index)\n task_text = todo_data.get_task(selected_category,task_index)\n @parent_view.add_to_tasklist(priority,selected_category,task_text)\n @list_view.model.remove(iter)\n end\n end",
"def change_priority_item(index, new_priority)\n @items[index-1].change_priority(new_priority)\n end",
"def set_task_priority\n @task_priority = TaskPriority.find(params[:id])\n end",
"def prioritize(index, position = 1)\n\t@items.insert(position-1, @items.delete_at(index.to_i-1))\n\t@items[position.to_i-1]\n\t\t\n\tend",
"def reorder\n @issue = @project.sprint_items.find(params[:issue_id])\n @issue.becomes(BacklogItem).remove_from_list\n\n @issue.remove_from_list\n\n @issue.sprint_id = @project.sprints.find(params[:id]).id\n @issue.save\n\n if @issue.insert_at(params[:position].to_i)\n render :json => :ok\n else\n render :json => { :errors => @issue.errors }, :status => :entity_unprocessable\n end\n end",
"def set_list_position(new_position, raise_exception_if_save_fails=false)\n self[position_column] = new_position\n raise_exception_if_save_fails ? save! : save\n end",
"def move_task_in_to_do(from_index, to_index)\n initial = to_do_tasks[from_index].element\n target = to_do_tasks[to_index].element\n\n move_task(initial, target)\n end",
"def increment_position\n return unless in_list?\n set_list_position(current_position + 1)\n end",
"def pending_index=(index)\n last_pending_index = @pending_index\n @pending_index = index\n redraw_item(@pending_index)\n redraw_item(last_pending_index)\n end",
"def sort\n params[:todo].each_with_index do |id, index|\n Todo.where(id: id).update_all(position: index + 1)\n end\n head :ok\n end",
"def move_above\n if @reference_task.position < @task.position\n @task.insert_at @reference_task.position\n respond_to do |format|\n format.html do\n flash[:notice] = 'Task was moved up.'\n flash[:highlight_dom_id] = dom_id(@task)\n end\n end\n end\n respond_to do |format|\n format.html do\n redirect_to params[:redirect_to] || project_tasks_path(@task.project)\n end\n end\n end",
"def update_an_item(position)\n to_do_list.at(position).update_status\n end",
"def insert_at(position = acts_as_list_top)\n insert_at_position(position)\n end",
"def update_priority\n Share.order(:priority).each.with_index(0) do |share, index|\n share.update_column :priority, index\n end\n end",
"def pending_index=(index)\r\n last_pending_index = @pending_index\r\n @pending_index = index\r\n redraw_item(@pending_index)\r\n redraw_item(last_pending_index)\r\n end",
"def reposition_queue\n task_queue = TaskQueue.where(user_id: user_id, task_type_id: task_type_id)\n if task_queue.pluck(:position).any? {|pos| pos > position}\n task_queue.where(\"position > ?\", position).each do |queue_item|\n queue_item.update(:position => (queue_item.position - 1))\n end\n end\n end",
"def position_in_list\n self[order_column]\n end",
"def edit_board_list(project, board_id, id, position)\n put(\"/projects/#{url_encode project}/boards/#{board_id}/lists/#{id}\", body: { position: position })\n end",
"def increment_position\n # return unless in_list?\n update_attribute position_column, self.send(position_column).to_i + 1\n end",
"def sortable(pos)\n @sortable[pos]\n end",
"def increment_position\n return unless in_list?\n # self_class_all_or_in_collection.where(:pos => my_position).\n adjust_position!(1)\n end",
"def move_task_in_in_progress(from_index, to_index)\n initial = in_progress_tasks[from_index].element\n target = in_progress_tasks[to_index].element\n\n move_task(initial, target)\n end",
"def index\n @tasks = @list.tasks.order(status: :asc)\n return render_success_task_index\n end",
"def index\n @task_list = TaskList.rank(:row_order).all\n\n render json: @task_list\n end",
"def down\n task = Task.find(params[:task_id])\n nextTask = Task.where(:user_id => current_user.id).where(\"priority < #{task.priority}\").order('priority desc').limit(1).first\n if nextTask then\n task.priority, nextTask.priority = nextTask.priority, task.priority\n nextTask.save\n task.save\n end\n @tasks = Task.where(:user_id => current_user.id).order('priority desc')\n respond_to do |format|\n format.html { render :partial => 'tasks' }\n format.json { render json: @tasks }\n format.js { }\n end\n end",
"def waitlist_position(order)\n @queue.position_of(order)\n end",
"def move_to_list(scope, pos = nil)\n transaction do |txn|\n self.detach # remove from current list\n self.attribute_set(model.list_options[:scope][0], scope.to_i) # set new scope\n self.save # save progress. Needed to get the positions correct.\n self.reload # get a fresh new start\n self.move(pos) unless pos.nil?\n end\n end",
"def set_task_list\n @task_list = TaskList.find(params[:id])\n end",
"def reorder_queue_items\n queue_items.each_with_index do |queue_item,index|\n queue_item.update_attributes(list_order: index + 1)\n end\n end",
"def move_task_in_completed(from_index, to_index)\n initial = completed_tasks[from_index].element\n target = completed_tasks[to_index].element\n\n move_task(initial, target)\n end",
"def move\n item = TodoItem.find(params[:id])\n todo_list = TodoList.find(params[:todo_list_id])\n column = ProjectColumn.find(params[:todo_item][:column_id], todo_list.milestone.project)\n column.add_item(item)\n\n # ReorderTodoItems.create(params)\n if should_reorder_or_reparent_item?(item, column)\n todo_list = TodoList.find(params[:todo_list_id])\n # this 'reparents' a todo item to a new todo list and reorders\n todo_list.reorder_items(ordered_todo_item_ids)\n end\n\n # store activity of our users, to get an idea of how much people are really using wallsome\n activity = TodoItemActivity.new\n activity.user_id = current_user.id\n activity.basecamp_account_id = current_account.id\n activity.save\n\n render :json => item\n rescue ActiveResource::ResourceNotFound\n head 404\n end",
"def providers_sort_save\n params[:sortable_list].each_index do |i|\n item = SmsLcrprovider.find(:first, :conditions => [\"sms_provider_id = ? AND sms_lcr_id = ?\", params[:sortable_list][i], params[:id]])\n item.priority = i\n item.save\n end\n @page_title = _('Change_Order') + \": \" + @lcr.name\n @items = @lcr.sms_providers(\"asc\")\n render :layout => false, :action => :providers_sort\n end",
"def sort\n params[:playlist_item].each_with_index do |id, index|\n PlaylistItem.update_all({position: index+1}, {id: id})\n end\n render nothing: true\n end",
"def index\n @user = current_user\n @tasks = @user.tasks.rank(:row_order)\n @label_list = Label.all\n @task = current_user.tasks.new\n @sort = nil\n if params[:task]\n selection = params.dig(:task, :keyword)\n # @tasks = Task.sort(selection)\n # @tasks = @tasks.where(user_id: current_user)\n @tasks = Task.where(user_id: current_user).order_by_key(selection)\n @sort = params[:task][:keyword]\n end\n end",
"def reorder\n if request.xhr?\n photo_set = PhotoSet.find(params[:id])\n params[:photo_list].each_with_index do |phid, idx|\n pps = photo_set.photos_photo_sets.find_or_create_by_photo_id(phid)\n pps.position = idx + 1\n pps.save\n end\n render :nothing => true\n end\n end",
"def sort\n params[:backlog_entry].each_with_index do |id, index|\n BacklogEntry.update_all({position: index+1}, {id: id})\n end\n render nothing: true\n end",
"def create\n authorize! :create_task_list, @active_project\n \n @task_list = @active_project.task_lists.build(params[:task_list])\n @task_list.created_by = @logged_user\n\n respond_to do |format|\n if @task_list.save\n flash[:notice] = 'List was successfully created.'\n format.html {\n error_status(false, :success_added_task_list)\n redirect_back_or_default(@task_list)\n }\n format.js { return index }\n format.xml { render :xml => @task_list.to_xml(:root => 'task-list'), :status => :created, :location => @task_list }\n else\n format.html { ruby_code_from_view.ruby_code_from_view do |rb_from_view|\n form_authenticity_token \n unless @active_project.nil? \n h @active_project.name \n h page_title \n h Company.owner.name \n else \n h page_title \n h Company.owner.name \n end \n stylesheet_link_tag 'project_website' \n additional_stylesheets.each do |ss| \n stylesheet_link_tag ss \n end unless additional_stylesheets.nil? \n javascript_include_tag 'application.js' \n javascript_tag \"var PROJECT_ID = #{@active_project.id}; var LOGGED_USER_ID=#{@logged_user.id};\" \n unless @active_project.is_active? \n t('project_locked_header') \n if can?(:change_status, @active_project) \n link_to t('mark_project_as_active'), open_project_path(:id => @active_project.id), :method => :put, :confirm => t('mark_project_as_active_confirmation') \n end \n end \n h @active_project.name \n if user.is_anonymous? \n t('welcome_anonymous') \n link_to(t('login'), logout_path) \n else \n t('welcome_back', :user => h(user.display_name)).html_safe \n link_to t('logout'), logout_path, :confirm => t('are_you_sure_logout') \n end \n @running_times.empty? ? 'none' : 'block' \n t('running_times', :count => @running_times.size) \n render_icon 'bullet_drop_down', '', :id => 'running_times', :class => 'PopupMenuWidgetAttachTo', :title => 'Enable javascript' \n unless user.is_anonymous? \n link_to t('account'), @logged_user \n render_icon 'bullet_drop_down', '', :id => 'account_more', :class => 'PopupMenuWidgetAttachTo', :title => 'Enable javascript' \n end \n unless projects.blank? \n link_to t('projects'), :controller => 'dashboard', :action => 'my_projects' \n render_icon 'bullet_drop_down', '', :id => 'projects_more', :class => 'PopupMenuWidgetAttachTo', :title => 'Enable javascript' \n end \n if user.is_admin \n link_to t('administration'), :controller => 'administration' \n render_icon 'bullet_drop_down', '', :id => 'administration_more', :class => 'PopupMenuWidgetAttachTo', :title => 'Enable javascript' \n end \n unless user.is_anonymous? \n t('account') \n link_to t('edit_profile'), edit_user_path(:id => user.id) \n link_to t('update_avatar'), avatar_user_path(:id => user.id) \n t('userbox_more') \n link_to t('my_projects'), :controller => 'dashboard', :action => 'my_projects' \n link_to t('my_tasks'), :controller => 'dashboard', :action => 'my_tasks' \n end \n unless projects.blank? \n t('projects') \n projects.each do |project| \n link_to h(project.name), project_path(:id => project.id) \n end \n end \n if user.is_admin \n t('administration') \n link_to t('company'), Company.owner \n link_to t('members'), companies_path \n link_to t('projects'), projects_path \n end \n listed.id \n link_to h(listed.name), listed.object_url \n link_to render_icon('stop', t('stop_time')), stop_time_path(:active_project => listed.project_id , :id => listed.id), :class => 'blank stopTime' \n \n \n unless tabs.nil? \n current_tab = self.current_tab \n tabs.each do |item| \n \"item_#{item[:id]}\" \n 'class=\"active\"'.html_safe if item[:id] == current_tab \n item[:url] \n t(item[:id]) \n end \n end \n \n unless crumbs.nil? \n crumbs.each do |crumb| \n if crumb[:url] \n crumb[:url] \n crumb[:title].is_a?(Symbol) ? t(crumb[:title]) : h(crumb[:title]) \n else \n crumb[:title].is_a?(Symbol) ? t(crumb[:title]) : h(crumb[:title]) \n end \n end \n end \n \n if Rails.configuration.search_enabled \n form_tag search_project_path(:id => @active_project.id) \n\n @search_field_default_value = t('search_box_default')\n @last_search ||= @search_field_default_value\n @search_field_attrs = {\n :onfocus => \"if (event.target.value == '#{@search_field_default_value}') event.target.value=''\",\n :onblur => \"if (event.target.value == '#{@search_field_default_value}') event.target.value=''\"\n }\n\n text_field_tag 'search_id', (h @last_search), @search_field_attrs \n t('go') \n end \n if flash[:message] \n flash[:error] ? 'error' : 'success' \n flash[:error] ? 'flash_error' : 'flash_success' \n h flash[:message] \n end \n h page_title \n if @private_object \n image_path('icons/private.gif') \n end \n @content_for_sidebar.nil? ? '' : 'class=\\'sidebar\\'' \n page_actions.each do |action| \n action[:url] \n action[:ajax] ? 'class=\"ajax_action\"' : 'class=\"action\"' \n action[:title] \n t(action[:title]) \n end \n \n form_tag task_lists_path \n error_messages_for :task_list \n t('name') \n text_field 'task_list', 'name', :id => 'taskListFormName', :class => 'long' \n t('priority') \n text_field 'task_list', 'priority', :id => 'taskListPriority', :class => 'long' \n t('description') \n text_area 'task_list', 'description', :id => 'taskListFormDescription', :class => 'short', :rows => 10, :cols => 40 \n t('milestone') \n select 'task_list', 'milestone_id', select_milestone_options(@active_project), {}, {:class => 'select_milestone', :id => 'taskListFormMilestone'} \n if @logged_user.member_of_owner? \n t('is_private_list') \n t('is_private_list_info') \n yesno_toggle 'task_list', 'is_private', :id => 'taskListFormIsPrivate', :class => 'yes_no' \n end \n t('tags') \n text_field 'task_list', 'tags', :id => 'taskListFormTags', :class => 'long' \nt('tags_info') \n \n t('add_task_list') \n unless @content_for_sidebar.nil? \n render :partial => @content_for_sidebar \n end \n if not Company.owner.homepage.nil? \n Company.owner.homepage \n Company.owner.name \n else \n Company.owner.name \n end \n product_signature \n \n\nend\n }\n \n format.xml { render :xml => @list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_task_list\n @task_list = Task::List.find(params[:id])\n end",
"def create\n @task = Task.new(task_params)\n\n respond_to do |format|\n if @task.save\n project = @task.project\n project.priority = project.priority + [@task.id]\n project.save\n format.json { render :show, status: :created, location: @task }\n else\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end",
"def move_below\n if @task.position < @reference_task.position\n @task.insert_at @reference_task.position\n respond_to do |format|\n format.html do\n flash[:notice] = 'Task was moved down.'\n flash[:highlight_dom_id] = dom_id(@task)\n end\n end\n end\n respond_to do |format|\n format.html do\n redirect_to params[:redirect_to] || project_tasks_path(@task.project)\n end\n end\n end",
"def index\n @tasks = Task.all.order(:position)\n respond_with(@tasks)\n end",
"def sort\n i = 0;\n list_orders = Hash[params[:list].to_a.map {|k| [k, i+=1]}]\n lists = Board.find(params[:board_id]).lists.order(:order)\n lists.each do |list|\n list.order = list_orders[list.id.to_s]\n list.save\n end\n render nothing: true\n end",
"def update\n begin\n @task_list = @project.task_lists.find(params[:id])\n\n respond_to do |format|\n if @task_list.update_attributes(params[:task_list])\n format.js {render 'projects/create_task_list'}\n format.html { redirect_to project_task_list_path(@project, @task_list), :notice => 'Task list was successfully updated.' }\n else\n format.js {render :create_fail}\n format.html { render :action => \"edit\" }\n end\n end\n rescue ActiveRecord::RecordNotFound\n logger.info { \"User #{current_user.email} try update a task list #{params[:id]} without permission\" }\n redirect_to project_path(@project)\n end\n end",
"def set_position(actor_id, index)\n return unless @actors.include?(actor_id)\n swap_order($game_actors[actor_id].index, [index, party_size].min)\n end",
"def index\n @tasks = Task.all(:order => \"position\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tasks }\n end\n end",
"def init_change_index_position(position)\n set_state changing_position: true, element_to_change_position: position\n end",
"def update_sortable(pos, newVal)\n sort_function = @parent.sort_function(pos)\n if sort_function\n @sortable[pos] = sort_function.call(newVal)\n else\n @sortable[pos] = newVal\n end\n end",
"def increment_positions_on_higher_items\n return unless in_list?\n acts_as_list_class.update_all(\n \"#{:position} = (#{:position} + 1)\", \"#{:position} < #{send(:position).to_i}\"\n )\n end",
"def update\n @task = current_user.lists.find(params[:list_id]).tasks.find(params[:id])\n\n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.js\n else\n render :js => \"TODO_IT.UI.show_alert('Something went wrong.')\"\n end\n end\n end",
"def check_top_position\n if current_position && !default_position? && current_position < acts_as_list_top\n self[position_column] = acts_as_list_top\n end\n end",
"def insert_in_list_at(position = 1)\n insert_at_position(position)\n end",
"def insert_in_list_at(position = 1)\n insert_at_position(position)\n end",
"def move_to_position(index, scope = {})\n insert_at(self.parent, index, scope)\n end",
"def set_tasklist\n @tasklist = Tasklist.find(params[:id])\n end",
"def index\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY CASE status\n WHEN '' THEN 1\n WHEN 'in progress' THEN 2\n WHEN 'reviewing' THEN 3\n WHEN 'done' THEN 4 END\")\n @sortType = params[:sort]\n\n if @sortType == \"title\"\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY title ASC\")\n end\n\n if @sortType == \"status\"\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY CASE status\n WHEN '' THEN 1\n WHEN 'in progress' THEN 2\n WHEN 'reviewing' THEN 3\n WHEN 'done' THEN 4 END\")\n end\n\n if @sortType == \"description\"\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY description ASC\")\n end\n\n if @sortType == \"deadline\"\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY deadline ASC\")\n end\n\n\n if @sortType == \"story_points\"\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY story_points ASC\")\n end\n\n if @sortType == \"priority\"\n @tasks = Task.find_by_sql(\"SELECT * FROM tasks ORDER BY CASE priority\n WHEN '' THEN 1\n WHEN 'high' THEN 2\n WHEN 'medium' THEN 3\n WHEN 'low' THEN 4 END\")\n end\n @project = Project.find(params[:project_id])\n @sprint = Sprint.find(params[:sprint_id])\n end",
"def set_position \n if organization.goals.reload.present?\n self.position = organization.goals.maximum(:position) + 1\n else\n self.position = 1\n end\n end",
"def set_task\n @task = Task.find(params[:id])\n if @task.list.user_id != @user.id\n redirect_to tasks_path\n end\n end",
"def accept\n task = model_from_dom_id(params[:draggable_element])\n @project.tasks.push(task) unless @project.tasks.exists?(task)\n flash[:notice] = \"Task #{task.name} successfully moved to project #{@project.name}\" unless request.xhr?\n\n respond_to do |format|\n format.html { redirect_to @project }\n format.js do\n render :update do |page|\n page.replace dom_id(task), :partial => 'tasks/task', :object => task\n page.visual_effect :highlight, dom_id(task), :duration => 1.5, :delay => 0.2\n page.visual_effect :fade, dom_id(task), :duration => 1.5, :delay => 0.2\n end\n end\n end\n end",
"def increment_position\n return unless in_list?\n # in_collection.where(:pos => my_position).\n adjust!(position_key => 1) \n save!\n end",
"def update_position\n begin\n recommendation = Recommendation.find(params[:id]) # grab the object\n recommendation.insert_at(params[:position].to_i) # update the object's order\n render :json => {:title => 'Success', :message => 'The order was updated successfuly.'}\n rescue\n logger.error $ERROR_INFO.inspect\n render :json => {:title => 'Error', :message => 'Ran into an error updating the order. Please try again.'}\n end\n end",
"def set_priority\n if params[:topic].nil?\n ReviewBid.where(participant_id: params[:id]).destroy_all\n else\n assignment_id = SignUpTopic.find(params[:topic].first).assignment.id\n @bids = ReviewBid.where(participant_id: params[:id])\n signed_up_topics = ReviewBid.where(participant_id: params[:id]).map(&:signuptopic_id)\n signed_up_topics -= params[:topic].map(&:to_i)\n signed_up_topics.each do |topic|\n ReviewBid.where(signuptopic_id: topic, participant_id: params[:id]).destroy_all\n end\n params[:topic].each_with_index do |topic_id, index|\n bid_existence = ReviewBid.where(signuptopic_id: topic_id, participant_id: params[:id])\n if bid_existence.empty?\n ReviewBid.create(priority: index + 1, signuptopic_id: topic_id, participant_id: params[:id], assignment_id: assignment_id)\n else\n ReviewBid.where(signuptopic_id: topic_id, participant_id: params[:id]).update_all(priority: index + 1)\n end\n end\n end\n redirect_to action: 'show', assignment_id: params[:assignment_id], id: params[:id]\n end",
"def set_priority\n if params[:topic].nil?\n ReviewBid.where(participant_id: params[:participant_id]).destroy_all\n else\n participant = AssignmentParticipant.find_by(id: params[:participant_id])\n assignment_id = SignUpTopic.find(params[:topic].first).assignment.id\n team_id = participant.team.try(:id)\n @bids = ReviewBid.where(participant_id: params[:participant_id])\n signed_up_topics = ReviewBid.where(participant_id: params[:participant_id]).map(&:sign_up_topic_id)\n signed_up_topics -= params[:topic].map(&:to_i)\n signed_up_topics.each do |topic|\n ReviewBid.where(sign_up_topic_id: topic, participant_id: params[:participant_id]).destroy_all\n end\n params[:topic].each_with_index do |topic_id, index|\n bid_existence = ReviewBid.where(sign_up_topic_id: topic_id, participant_id: params[:participant_id])\n if bid_existence.empty?\n ReviewBid.create(priority: index + 1,sign_up_topic_id: topic_id, participant_id: params[:participant_id],assignment_id: assignment_id)\n else\n ReviewBid.where(sign_up_topic_id: topic_id, participant_id: params[:participant_id]).update_all(priority: index + 1)\n end\n end\n end\n end",
"def create\n tasks = Task.count + 1\n @task = Task.new(params[:task])\n @task.order = tasks\n respond_to do |format|\n if @task.save\n format.html { redirect_to_index('Task was successfully created', 1) }\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 update_position\n end",
"def update_position\n end",
"def update_position\n end",
"def index\n @tasks = current_user.tasks.all.order(id: :desc)\n success_task_index\n end",
"def index\n @tasks = @list.tasks.where(\"type = ?\",\"TaskTemp\").where.not(\"estado = ?\",\"expirada\").order(:prioridad)\n end",
"def set_task\n @task = Todotasklist.find_by_id(params[:id])\n if @task\n else\n \trender json: { valid: false}, status: 404\n end\n end",
"def update_order\n update_positions params[:sorted_ids]\n render nothing: true\n end",
"def set_task_position_person\n @task_position_person = TaskPositionPerson.find(params[:id])\n end",
"def update\n @list_position.update_attributes(position: list_params['position'])\n broadcast\n end",
"def taskswap priority\n @cur_proc_id = @queue[priority].shift||@cur_proc_id\n (@queue[priority] << @cur_proc_id) if priority == 0\n @timeslice = 0\n end",
"def move(from, to)\n @tasks.insert(index(to), @tasks.delete_at(index(from)))\n end",
"def current_position\n return 1 if Task.all.empty?\n Task.maximum('position') + 1\n end",
"def move_to_top\n return unless in_list?\n insert_at_position acts_as_list_top\n end",
"def sort_index\n pos = nil\n pos ||= self.position if self.respond_to?(:position)\n [pos || 9999, self.id]\n end",
"def set_task\n @task = Task.includes(:todo).find(params[:id])\n @todo = @task.todo\n @list = @todo.list\n end",
"def process_priority_questions\n # set referring page\n @referring_url = request.referrer\n \n # get data\n @data = params[:id]\n @split_data = @data.split(\"-\")\n @category = @split_data[0]\n @priority_id = @split_data[1].to_i\n \n #check if user has already chosen any priorities\n @user_priorities = UserPriority.where(user_id: current_user.id, category: @category)\n \n if !@user_priorities.blank?\n # check if this priority is being selected or de-selected\n @this_priority = @user_priorities.find_by_priority_id(@priority_id)\n @priority_count = @user_priorities.count\n if @this_priority.blank?\n @new_count = @priority_count + 1\n # update total priorities of all other priorities\n @user_priorities.each do |priority|\n priority.update(total_priorities: @new_count)\n end\n # add this priority\n @action = \"add\"\n UserPriority.create(user_id: current_user.id, \n priority_id: @priority_id,\n priority_rank: @new_count,\n total_priorities: @new_count,\n category: @category)\n else\n @this_priority_rank = @this_priority.priority_rank\n # remove this priority\n @action = \"remove\"\n @this_priority.destroy!\n if @priority_count > 1\n @new_count = @priority_count - 1\n # update ranks of those left behind, if needed\n @user_priorities.each do |priority|\n if priority.priority_rank > @this_priority_rank\n priority.decrement!(:priority_rank)\n priority.update(total_priorities: @new_count)\n end\n end\n end # end of count check\n end\n else # this path if this is the first priority chosen\n @action = \"add\"\n UserPriority.create(user_id: current_user.id, \n priority_id: @priority_id,\n category: @category)\n end\n \n # get new list of chosen priorities\n @user_priorities = UserPriority.where(user_id: current_user.id, category: @category)\n @priority_count = @user_priorities.count\n #Rails.logger.debug(\"count: #{@priority_count.inspect}\")\n @timing = @user_priorities.order('updated_at DESC')\n @last_saved = @timing.first.updated_at\n \n respond_to do |format|\n format.js\n end\n end",
"def set_todo_item\n @todo_list.todo_items.find(:id)\n end",
"def create\n\n @question_section = QuestionSection.find(params[:question_section_id])\n @question = @question_section.questions.create!(question_params)\n @question.update_attribute(:position, 9999)\n\n @question_section.questions.order(:position).each_with_index do |question, index|\n question.position = index\n question.save!\n end\n\n redirect_to edit_question_section_path(@question_section)\n end",
"def update_position(index)\n relationships = self.group_relations\n last = relationships.count \n relationships.each do |r|\n if r.position.nil?\n r.update_attribute(:position, last -= 1)\n else\n if r.position > index\n r.update_attribute(:position, r.position - 1)\n end\n end\n end\n end",
"def index\n @tasks = Task.where(:user_id => current_user.id).order('priority desc')\n # @tasks = Task.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tasks }\n end\n end",
"def increment_positions_on_higher_items\n # return unless in_list?\n # acts_as_list_class.update_all(\"#{position_column} = (#{position_column} + 1)\", \"#{scope_condition} AND #{position_column} < #{send(position_column).to_i}\") \n acts_as_list_class.with_acts_as_list_scope(scope_condition) do\n update_all(\"#{position_column} = (#{position_column} + 1)\", \"#{position_column} < #{send(position_column).to_i}\")\n end \n end",
"def update_positions\n params[:photos_list].each_index do |i|\n item = @gallery.photos.find(params[:photos_list][i])\n item.position = i+1\n item.save\n end\n @photos = @gallery.photos.find(:all,:order=>'position')\n render :layout => false, :action => :index\n end",
"def change_task_content_of_list(id, new_content)\n \t\tpos = find_task_by_id(id)\n \t\t@task_list[pos].change_update_content(new_content) \n \t\t@task_list[pos].change_update_content_state!\n \tend",
"def create\n name, board_id = params[:name], params[:board_id]\n @list = List.new\n @list.name = name\n @list.board_id = board_id\n @list.order = List.get_max_order board_id\n @lists_size = List.get_size board_id\n respond_to do |format|\n if @lists_size < 6 && @list.save\n @lists_size += 1\n format.js { render action: 'create', status: :created, location: @list}\n else\n format.js { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def manager_list_by_priority\n \n @sort_order = get_sort_order\n @sort_order[:priority] = params[:order] == 'ASC' ? 'DESC' : 'ASC'\n flash[:sort_order] = @sort_order\n\n design_reviews = get_active_reviews\n @active_reviews = design_reviews[:active].sort_by { |dr| [dr[:review].priority.value, dr[:review].age] }\n @inactive_reviews = design_reviews[:inactive].sort_by { |dr| [dr[:review].priority.value, dr[:review].age] }\n @active_reviews.reverse! if params[:order] == 'DESC'\n @inactive_reviews.reverse! if params[:order] == 'DESC'\n\n @submissions = BoardDesignEntry.submission_count\n session[:return_to] = {:controller => 'tracker',\n :action => 'manager_list_by_priority',\n :order => params[:order]}\n render( :action => 'manager_home' )\n\n end",
"def sort\n if (defined? params[:moved] and defined? params[:test_case])\n # moved will look like 'test_case_3.0', make it '3.0' instead\n params[:moved].gsub!(/.*_(\\d+\\.\\d+)$/, '\\1')\n # find the new position for this item\n pos = params[:test_case].index(params[:moved]) + 1\n tc_id, tc_pos = params[:moved].split('.', 2)\n if (defined? pos and pos != tc_pos.to_i)\n stc = SuiteTestCase.where(:suite_id => params[:id], :test_case_id => tc_id).first\n if stc.insert_at(pos) != false\n flash[:notice] = \"Successfully saved sort order.\"\n end\n end\n end\n @suite = Suite.find(params[:id])\n # must redraw list with updated id #'s\n @current_cases = @suite.test_cases\n respond_with @suite do |format|\n format.js { render 'sort.js' }\n end\n end",
"def set_priority\n @priority = Priority.find(params[:id])\n end",
"def update(task_number, task) # Update task based on task number\n all_tasks[task_number -1] = task # Updates task\n end",
"def set_trpriority\n @trpriority = Trpriority.find(params[:id])\n end",
"def reorder\n # If it's AJAX, do our thing and move on...\n if request.xhr?\n params[\"page_list_#{params[:id]}\"].each_with_index { |id,idx| ComatosePage.update(id, :position => idx) }\n expire_cms_page ComatosePage.find(params[:id])\n render :text=>'Updated sort order', :layout=>false\n else\n @page = ComatosePage.find params[:id]\n if params.has_key? :cmd\n @target = ComatosePage.find params[:page]\n case params[:cmd]\n when 'up' then @target.move_higher\n when 'down' then @target.move_lower\n end\n redirect_to :action=>'reorder', :id=>@page\n end\n end\n end",
"def move(board,position,choice=\"X\")\n iPosition = position.to_i\n board[iPosition-1] = choice\nend",
"def create\n @task = Task.new(params[:task])\n @task.position = params[:position]\n render :json => @task.id if @task.save \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"
] |
[
"0.5924361",
"0.56312937",
"0.5601406",
"0.55601424",
"0.5548982",
"0.5534822",
"0.5512286",
"0.5488283",
"0.54663444",
"0.5423879",
"0.5382966",
"0.5339327",
"0.53325564",
"0.5332331",
"0.5320368",
"0.5319066",
"0.53031844",
"0.527709",
"0.5270131",
"0.5269593",
"0.52648896",
"0.5250389",
"0.5233597",
"0.5231653",
"0.5223253",
"0.5218492",
"0.521729",
"0.52057093",
"0.51899207",
"0.5179817",
"0.51711255",
"0.5169846",
"0.51513845",
"0.5136466",
"0.5130534",
"0.51131165",
"0.5099232",
"0.50961465",
"0.5095409",
"0.5089682",
"0.5087932",
"0.5076188",
"0.50354606",
"0.5035188",
"0.5026229",
"0.5023082",
"0.50190914",
"0.50122637",
"0.501107",
"0.5007737",
"0.50041544",
"0.5003567",
"0.4979326",
"0.4977153",
"0.4970802",
"0.49654034",
"0.49654034",
"0.4960399",
"0.49556506",
"0.49418604",
"0.49310756",
"0.49195558",
"0.49181977",
"0.4917011",
"0.49133277",
"0.48973447",
"0.4896839",
"0.48920906",
"0.48914126",
"0.48914126",
"0.48914126",
"0.48913127",
"0.4889262",
"0.48835507",
"0.48812568",
"0.48777738",
"0.48740962",
"0.48679182",
"0.48675993",
"0.48625094",
"0.486127",
"0.48588717",
"0.48539174",
"0.48499122",
"0.48497748",
"0.4848316",
"0.48432958",
"0.48318094",
"0.4827696",
"0.48184556",
"0.4817761",
"0.4808056",
"0.47991848",
"0.47895694",
"0.47844246",
"0.47835833",
"0.47834522",
"0.47544304",
"0.4752433",
"0.47504395"
] |
0.7345166
|
0
|
GET /list_items GET /list_items.xml
|
def index
@list = List.find(params[:list_id])
@list_items = @list.list_items.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @list_items }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_items\n response_xml = http_get(@client, \"#{xero_url}/Items\")\n parse_response(response_xml, {}, {:request_signature => 'GET/items'})\n end",
"def index\n @list = List.find(params[:list_id])\n @items = @list.items\n\n respond_with @items\n end",
"def items\n # Since we're parsing xml, this will raise an error\n # if the response isn't xml.\n self.response = self.class.get(\"#{record_url}/items?view=full\")\n raise_error_if(\"Error getting items from Aleph REST APIs.\") {\n (response.parsed_response[\"get_item_list\"].nil? or response.parsed_response[\"get_item_list\"][\"items\"].nil?)\n }\n [response.parsed_response[\"get_item_list\"][\"items\"][\"item\"]].flatten\n end",
"def list_items_list(page_id = current_page_id, list_id = current_list_id)\n request \"page/#{page_id}/lists/#{list_id}/items/list\"\n end",
"def get_list\n \t@items\n end",
"def index\n @items_count = Item.count\n @items = Item.find(:all, { :order => 'items.created_at DESC', :include => :user }.merge(@pagination_options))\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @items }\n format.rss { render :layout => false }\n end\n end",
"def list\n url = prefix + \"list\"\n return response(url)\n end",
"def list_items\r\n begin\r\n expand_combo\r\n get(:type => :list_item, :scope => :children, :how_many => :all)\r\n ensure\r\n collapse_combo\r\n end\r\n end",
"def list_items( args={} )\n @session.base_url = \"http://my.cl.ly\"\n \n url = \"/items\"\n args.each do |k, v|\n # probably a nicer way to do this\n if url == \"/items\"\n url << \"?#{k.to_s}=#{v.to_s}\"\n else\n url << \"&#{k.to_s}=#{v.to_s}\"\n end\n end\n resp = @session.get( url )\n \n raise AuthorizationError if resp.status == 401\n Crack::JSON.parse(resp.body)\n end",
"def path\n \"/{databaseId}/items/list/\"\n end",
"def items\n @document.xpath('//results/page/items/*')\n end",
"def list\n url = prefix + \"list\"\n return response(url)\n end",
"def show\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @list_item }\n end\n end",
"def get_items\r\n @list\r\n end",
"def index\n @action_items = ActionItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @action_items }\n end\n end",
"def index\n @list_items = @list.list_items\n end",
"def show\n authenticate\n list = List.find(params[:id])\n items = list.items\n render json: {\n items: items,\n id: list.id\n }\n end",
"def index\n @items = @project.items.ready\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @items }\n end\n end",
"def index\n @list_items = ListItem.all\n end",
"def index\n @list_items = ListItem.all\n end",
"def list(params = {})\n http_helper.send_get_request(\"#{@url_prefix}/list\", params)\n end",
"def list(params = {})\n http_helper.send_get_request(\"#{@url_prefix}/list\", params)\n end",
"def index\n @item_lists = ItemList.all\n end",
"def index\n @list_items = List.find(params[:list_id]).list_items\n\n render json: @list_items\n end",
"def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn items\n\tend",
"def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @goods_items = Goods::Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @goods_items }\n end\n end",
"def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end",
"def index\n @lists = List.find(:all)\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @lists }\n end\n end",
"def index\n @items_mobs = ItemsMob.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @items_mobs.to_xml }\n end\n end",
"def index\n @receiving_items = ReceivingItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receiving_items }\n end\n end",
"def get_list(params = {})\n http_helper.send_get_request(\"#{@url_prefix}/\", params)\n end",
"def items\n response[\"items\"]\n end",
"def index\n @items = Item.accessible_by(current_ability)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n format.xml { render xml: @items }\n end\n end",
"def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @items }\n end\n end",
"def index\n @items = @list.items.all.order(id: :desc)\n return success_item_index\n end",
"def get_items\n @items\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\r\n @items = Item.paginate(:page => params[:page])\r\n end",
"def list(params = {})\n http_helper.send_get_request(\"#{@url_prefix}\", params)\n end",
"def index\n\t\t@items = Item.all\n end",
"def show\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(params[:list_id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list_item }\n end\n end",
"def show\n @request = Request.find(params[:id])\n @items = @request.items\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def index\n @apiv1_items = Item.all.order(:name)\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.find(:all, :order => 'id ASC')\n # @items = Item.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def list\n get()\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def index\n @items = Item.paginate(:page => params[:page])\n end",
"def items\n response = @client.request :get, \"#{LISTS_PATH}/#{@id}\"\n raise(StandardError, 'unexpected response') unless response\n response['items']&.map { |i| TodoableItem.new self, i, @client }\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.eager_load(:rss).paginate(page: params[:page], :per_page => 10).order(\"date DESC\")\n end",
"def index \n\t\t@items = Item.all\n\tend",
"def index\n @stream_items = StreamItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stream_items }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def get_items\n\t\treturn @list\n\tend",
"def get_items(response, item_page)\n items = []\n response = response.to_h\n if response.key?('ItemSearchResponse') &&\n response['ItemSearchResponse'].key?('Items') &&\n response['ItemSearchResponse']['Items'].key?('Item')\n response['ItemSearchResponse']['Items']['Item'].each_with_index do |item, pos|\n items << { position: (item_page - 1) * ITEMS_PER_PAGE + pos + 1, data: item }\n end\n end\n items\n end",
"def index\n @front_page = true\n @items_count = Item.count\n @items = Item.all.paginate :page => params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @items }\n format.rss { render :layout => false }\n end\n end",
"def index\n @items = Item.all\n\n end",
"def index\n #@items = Item.all\n end",
"def list\n get('/')\n end",
"def get_listings_xml(url)\n @client.get_content(url)\n end",
"def index\n @item_options = ItemOption.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @item_options }\n end\n end",
"def index\n @thing_lists = ThingList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @thing_lists }\n end\n end",
"def index\n @items = @channel.items\n @items = @query.search(@items)\n @items = @items.order_by_published_at_desc\n @items = @items.page(params[:page]).per(10)\n\n respond_to do |format|\n format.html\n format.json { render json: @items }\n end\n end",
"def items\n @items ||= items_from_response\n end",
"def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end",
"def list\n call(:get, path)\n end",
"def index\n @league_items = LeagueItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @league_items }\n end\n end",
"def index\n @items = Item.all\n end",
"def index\n @warehouse_lists = get_warehouse_lists(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @warehouse_lists }\n end\n end"
] |
[
"0.73681515",
"0.7245629",
"0.7172651",
"0.7144363",
"0.7072838",
"0.70601827",
"0.699434",
"0.69893384",
"0.69827557",
"0.69751376",
"0.68912953",
"0.68452215",
"0.68293315",
"0.6819314",
"0.6806944",
"0.67967117",
"0.6751051",
"0.67395335",
"0.67359596",
"0.67359596",
"0.6696793",
"0.6696793",
"0.6687939",
"0.66759706",
"0.66657335",
"0.6652279",
"0.66462046",
"0.663196",
"0.66200644",
"0.66191024",
"0.6609572",
"0.6597119",
"0.65944314",
"0.6593517",
"0.6570123",
"0.655182",
"0.65373874",
"0.65303385",
"0.652135",
"0.652135",
"0.652135",
"0.652135",
"0.65189844",
"0.6509305",
"0.65076846",
"0.6501657",
"0.6480759",
"0.64771605",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.646038",
"0.644554",
"0.6436933",
"0.64238316",
"0.64078",
"0.6400706",
"0.63995475",
"0.6396382",
"0.63928264",
"0.6382981",
"0.6381947",
"0.6381947",
"0.63804096",
"0.6379318",
"0.6377685",
"0.6377486",
"0.63726014",
"0.6370543",
"0.63651884",
"0.63560265",
"0.63551146",
"0.63529366",
"0.6350777",
"0.63496524",
"0.63495207",
"0.634067",
"0.6338125",
"0.6333397"
] |
0.7516307
|
0
|
GET /list_items/1 GET /list_items/1.xml
|
def show
@list = List.find(params[:list_id])
@list_item = @list.list_items.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @list_item }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_items }\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @items = @list.items\n\n respond_with @items\n end",
"def path\n \"/{databaseId}/items/list/\"\n end",
"def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end",
"def index\n @items_count = Item.count\n @items = Item.find(:all, { :order => 'items.created_at DESC', :include => :user }.merge(@pagination_options))\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @items }\n format.rss { render :layout => false }\n end\n end",
"def index\n @action_items = ActionItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @action_items }\n end\n end",
"def show\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(params[:list_id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list_item }\n end\n end",
"def list_items_list(page_id = current_page_id, list_id = current_list_id)\n request \"page/#{page_id}/lists/#{list_id}/items/list\"\n end",
"def show\n @request = Request.find(params[:id])\n @items = @request.items\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def index\n @items = @project.items.ready\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @items }\n end\n end",
"def get_items\n response_xml = http_get(@client, \"#{xero_url}/Items\")\n parse_response(response_xml, {}, {:request_signature => 'GET/items'})\n end",
"def index\n @lists = List.find(:all)\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @lists }\n end\n end",
"def index\n @receiving_items = ReceivingItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receiving_items }\n end\n end",
"def index\n @goods_items = Goods::Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @goods_items }\n end\n end",
"def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end",
"def show\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_item = @file_list.file_list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @file_list_item }\n end\n end",
"def index\n @list_items = @list.list_items\n end",
"def show\n @mylist = Mylist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mylist }\n end\n end",
"def index\n @current_item = \"my_account\"\n \n respond_to do |format|\n format.html \n format.xml { render :xml => @accounts.to_xml }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def items\n # Since we're parsing xml, this will raise an error\n # if the response isn't xml.\n self.response = self.class.get(\"#{record_url}/items?view=full\")\n raise_error_if(\"Error getting items from Aleph REST APIs.\") {\n (response.parsed_response[\"get_item_list\"].nil? or response.parsed_response[\"get_item_list\"][\"items\"].nil?)\n }\n [response.parsed_response[\"get_item_list\"][\"items\"][\"item\"]].flatten\n end",
"def index\n @items_mobs = ItemsMob.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @items_mobs.to_xml }\n end\n end",
"def show\n @list = List.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @list }\n end\n end",
"def index\n @news_items = do_index(NewsItem, params)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @news_items }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def index\n @list_items = List.find(params[:list_id]).list_items\n\n render json: @list_items\n end",
"def index\n @list_items = ListItem.all\n end",
"def index\n @list_items = ListItem.all\n end",
"def index\n @stream_items = StreamItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stream_items }\n end\n end",
"def index\n @items = @list.items.all.order(id: :desc)\n return success_item_index\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def index\n @wishlist_items = WishlistItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @wishlist_items }\n end\n end",
"def show\n\t\t@list = List.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml\t{ render :xml => @list }\n\t\tend\n\tend",
"def show\n authenticate\n list = List.find(params[:id])\n items = list.items\n render json: {\n items: items,\n id: list.id\n }\n end",
"def index\n @front_page = true\n @items_count = Item.count\n @items = Item.all.paginate :page => params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @items }\n format.rss { render :layout => false }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html\n # show.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def index\n @items = Item.accessible_by(current_ability)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n format.xml { render xml: @items }\n end\n end",
"def index\n @item_options = ItemOption.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @item_options }\n end\n end",
"def get_list\n \t@items\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n format.xml { render xml: @item }\n end\n end",
"def index\n @league_items = LeagueItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @league_items }\n end\n end",
"def index\n @item_lists = ItemList.all\n end",
"def index\n @apiv1_items = Item.all.order(:name)\n end",
"def index\n @thing_lists = ThingList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @thing_lists }\n end\n end",
"def xml(item)\n presenter.xml(item)\n end",
"def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def items\n @document.xpath('//results/page/items/*')\n end",
"def index\n @warehouse_lists = get_warehouse_lists(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @warehouse_lists }\n end\n end",
"def index\n @news_items = NewsItem.find(:all, :order => 'updated_at desc')\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @news_items.to_xml }\n end\n end",
"def get_listings_xml(url)\n @client.get_content(url)\n end",
"def show\n @list_item = @list.list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.js\n format.xml { render :xml => @list_item }\n end\n end",
"def show\n @items_mob = ItemsMob.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @items_mob.to_xml }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def index(list_name, site_path = '', fields = [])\n url = computed_web_api_url(site_path)\n url = \"#{url}lists/GetByTitle('#{odata_escape_single_quote(list_name)}')/items\"\n url += \"?$select=#{fields.join(\",\")}\" if fields\n\n process_url( uri_escape(url), fields )\n end",
"def index\n @feedback_items = FeedbackItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feedback_items }\n end\n end",
"def index\n @expense_items = ExpenseItem.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @expense_items }\n end\n end",
"def index\n @wish_lists = WishList.find(:all, :order => 'created_at DESC').paginate :per_page => 20, :page => params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @wish_lists }\n end\n end",
"def index\n @email_lists = EmailList.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @email_lists }\n end\n end",
"def show\n @movie_list_item = MovieListItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @movie_list_item }\n end\n end",
"def list\n url = prefix + \"list\"\n return response(url)\n end",
"def index\n @todo_lists = TodoList.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @todo_lists }\n end\n end",
"def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end",
"def index\n @items = Item.eager_load(:rss).paginate(page: params[:page], :per_page => 10).order(\"date DESC\")\n end",
"def index\n @article_lists = ArticleList.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @article_lists }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @items }\n end\n end",
"def show_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def output_xml(items)\n puts \"<?xml version=\\\"1.0\\\"?><items>\"\n items.each do |item|\n puts \"<item uid=\\\"#{item[\"uid\"]}\\\" arg=\\\"#{item[\"arg\"]}\\\">\n <title>#{item[\"title\"]}</title>\n <icon>icon.png</icon>\n <subtitle>#{item[\"subtitle\"]}</subtitle>\n </item>\"\n end\n puts \"</items>\" \n end",
"def show\n respond_to do |format|\n format.html\n format.json { render json: { status: 200, item: @list } }\n end\n end",
"def index\n @product_lists = ProductList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_lists }\n end\n end",
"def index\n @help_items = HelpItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @help_items }\n end\n end",
"def index\n @priced_items = PricedItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @priced_items }\n end\n end",
"def index\n @menu_items = uhook_find_menu_items\n\n respond_to do |format|\n format.html {} # index.html.erb \n format.xml {\n render :xml => @menu_items\n }\n end\n end",
"def list_items( args={} )\n @session.base_url = \"http://my.cl.ly\"\n \n url = \"/items\"\n args.each do |k, v|\n # probably a nicer way to do this\n if url == \"/items\"\n url << \"?#{k.to_s}=#{v.to_s}\"\n else\n url << \"&#{k.to_s}=#{v.to_s}\"\n end\n end\n resp = @session.get( url )\n \n raise AuthorizationError if resp.status == 401\n Crack::JSON.parse(resp.body)\n end",
"def item(uuid)\n http.get \"/items/#{uuid}\"\n end",
"def index\r\n @items = Item.paginate(:page => params[:page])\r\n end",
"def show\n @email_list = EmailList.find(params[:id])\n @email_list_items = @email_list.email_list_items\n current_email_list_id = @email_list.id\n \n @email_list_item = EmailListItem.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @email_list }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @outlet_goods_receive_note_items = OutletGoodsReceiveNoteItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @outlet_goods_receive_note_items }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item }\n format.json { render :json => @item }\n end\n end",
"def index\n @estimate_line_items = EstimateLineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @estimate_line_items }\n end\n end",
"def index\n @items = Item.find(:all, :order => 'id ASC')\n # @items = Item.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def show\n @list_view = ListView.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @list_view }\n end\n end",
"def index\n @shopping_lists = ShoppingList.find_all_by_user_id(session[:user_id])\n\n respond_to do |format|\n format.html \n format.xml { render :xml => @shopping_lists }\n end\n end",
"def get_items\r\n @list\r\n end",
"def list_items\r\n begin\r\n expand_combo\r\n get(:type => :list_item, :scope => :children, :how_many => :all)\r\n ensure\r\n collapse_combo\r\n end\r\n end",
"def index\n\t\t@items = Item.all\n end",
"def show\n @wish_list_item = WishListItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @wish_list_item }\n end\n end",
"def new\n @list = List.find(params[:list_id])\n @item = @list.items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def get_list(params = {})\n http_helper.send_get_request(\"#{@url_prefix}/\", params)\n end",
"def new\n @mylist = Mylist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mylist }\n end\n end",
"def show\n @thing_list = ThingList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @thing_list }\n end\n end"
] |
[
"0.74913013",
"0.6927452",
"0.6771285",
"0.6749842",
"0.6674167",
"0.65780854",
"0.652523",
"0.6520168",
"0.64768356",
"0.6455133",
"0.6449316",
"0.64414245",
"0.6434415",
"0.6417664",
"0.6415853",
"0.6414747",
"0.64140445",
"0.63829",
"0.635195",
"0.63431084",
"0.63274163",
"0.63267237",
"0.6321856",
"0.6302132",
"0.6300841",
"0.6300841",
"0.62989587",
"0.6279279",
"0.6279279",
"0.62764734",
"0.627459",
"0.6254611",
"0.6254611",
"0.6254611",
"0.6254611",
"0.6254611",
"0.6254611",
"0.6228879",
"0.6222541",
"0.61994445",
"0.61975485",
"0.6196178",
"0.61851233",
"0.61844486",
"0.6184178",
"0.61713845",
"0.6168855",
"0.6159462",
"0.61526275",
"0.61479294",
"0.6146356",
"0.6146061",
"0.6142036",
"0.6135812",
"0.61284494",
"0.61208373",
"0.61048454",
"0.60915905",
"0.6082908",
"0.6082632",
"0.6052019",
"0.6041931",
"0.6034725",
"0.60259813",
"0.6025766",
"0.60226583",
"0.6014149",
"0.6012446",
"0.6010138",
"0.60024905",
"0.5999261",
"0.59981275",
"0.5994868",
"0.5992525",
"0.5988973",
"0.5988883",
"0.5981575",
"0.5976576",
"0.5972351",
"0.5969528",
"0.5962208",
"0.5958894",
"0.5955877",
"0.5955877",
"0.5955877",
"0.5955877",
"0.5944885",
"0.59381735",
"0.5927678",
"0.59247357",
"0.5916634",
"0.5916118",
"0.5914333",
"0.59100026",
"0.590979",
"0.59040046",
"0.5890516",
"0.5890458",
"0.5889852",
"0.5885763"
] |
0.71897435
|
1
|
GET /list_items/new GET /list_items/new.xml
|
def new
@list = List.find(params[:list_id])
@list_item = @list.list_items.build
@page_section = @list.page_section
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
format.js { render :partial => 'ajax_new' }
format.html # new.html.erb
format.xml { render :xml => @list_item }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @list = List.find(params[:list_id])\n @item = @list.items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.factory('local')\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new(:list_id => params[:list_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list_item }\n end\n end",
"def new\n @title = \"New item\"\n @item = ItemTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\r\n @item = Item.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @item }\r\n end\r\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n format.xml { render xml: @item }\n end\n end",
"def new\n @mylist = Mylist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mylist }\n end\n end",
"def new\n @thing_list = ThingList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing_list }\n end\n end",
"def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end",
"def new\n return error_status(true, :cannot_create_listitem) unless (ListItem.can_be_created_by(@logged_user, @list))\n \n @list_item = @list.list_items.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_item }\n end\n end",
"def new\n @action_item = ActionItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @action_item }\n end\n end",
"def new\n\t\t@list = List.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml\t{ render :xml => @list }\n\t\tend\n\tend",
"def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def new\n @clone_item_request = CloneItemRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @clone_item_request }\n end\n end",
"def new\n @list_view = ListView.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_view }\n end\n end",
"def new\n @wish_list_item = WishListItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wish_list_item }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @action_list = ActionList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @action_list }\n end\n end",
"def new\n @ordered_item = OrderedItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ordered_item }\n format.json { render :json => @ordered_item }\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 @to_do_item = ToDoItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @to_do_item }\n end\n end",
"def new\n @item = BudgetItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @receiving_item = ReceivingItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @receiving_item }\n end\n end",
"def item\n @new = New.find(params[:id])\n end",
"def new\n @miscellaneous_item = MiscellaneousItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @miscellaneous_item }\n end\n end",
"def new\r\n @lineitem = Lineitem.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @lineitem }\r\n end\r\n end",
"def new\n @list = List.new\n\n @list.list_items.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list }\n end\n end",
"def new\n @content_item = ContentItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @content_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @line_item }\n end\n end",
"def new\n @news_item = NewsItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news_item }\n end\n end",
"def new\n @news_item = NewsItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @line_item }\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 new\n @movie_list_item = MovieListItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @movie_list_item }\n end\n end",
"def new\n @item_type = ItemType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_type }\n end\n end",
"def new\n @list_record = ListRecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_record }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @item }\n end\n end",
"def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @item }\n end\n end",
"def new\n @instancia_item = InstanciaItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instancia_item }\n end\n end",
"def new\n @list_of_value = Irm::ListOfValue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_of_value }\n end\n end",
"def new\n @item = Item.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n \n end",
"def new\n @mail_item = MailItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mail_item }\n end\n end",
"def new\n @email_list = EmailList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @email_list }\n end\n end",
"def new\n @item = Item.new\n respond_to do |format|\n format.html # new.html.erb\n format.js # new.js.rjs\n format.xml { render :xml => @item }\n end\n end",
"def new\n @item_alias = ItemAlias.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_alias }\n end\n end",
"def new\n @requisicion = Requisicion.new\n @items=@requisicion.items.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @requisicion }\n end\n end",
"def new\n @inventory_item = InventoryItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @inventory_item }\n end\n end",
"def new\r\n @item_type = ItemType.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @item_type }\r\n end\r\n end",
"def new\n @nav_item = NavItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nav_item }\n end\n end",
"def new\n @shopping_list = ShoppingList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shopping_list }\n end\n end",
"def new\n @goods_item = Goods::Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @goods_item }\n end\n end",
"def new\n @list = List.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list }\n end\n end",
"def new\n @list = List.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list }\n end\n end",
"def new\n @list = List.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list }\n end\n end",
"def new\n @item = Item.new\n @items = Item.all\n @tags = Tag.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @menu_item = uhook_new_menu_item\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu_item }\n end\n end",
"def new\n @item_info = ItemInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_info }\n end\n end",
"def new\n @wish_list = WishList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wish_list }\n end\n end",
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def new\n @wishlistitem = Wishlistitem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wishlistitem }\n end\n end",
"def new\n @list_cat = ListCat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_cat }\n end\n end",
"def new\n @data_list = DataList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @data_list }\n end\n end",
"def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item}\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to lists_path, :notice => 'Item was successfully created.' }\n format.json { render :json => lists_path, :status => :created, :location => lists_path }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @question_item = QuestionItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @question_item }\n end\n end",
"def new\n @army_list = ArmyList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @army_list }\n end\n end",
"def new\n @order_list = OrderList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @order_list }\n end\n end",
"def new\n @price_list = PriceList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @price_list }\n end\n end",
"def new\n\n @checklist_item = ChecklistItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @checklist_item }\n end\n end",
"def new\n @auction_item = AuctionItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @auction_item }\n end\n end",
"def new\n @stream_item = StreamItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stream_item }\n end\n end"
] |
[
"0.752519",
"0.7446631",
"0.7367704",
"0.7348029",
"0.7348029",
"0.7348029",
"0.7348029",
"0.7348029",
"0.7348029",
"0.7348029",
"0.7348029",
"0.7333662",
"0.73181874",
"0.72891396",
"0.7268241",
"0.7250376",
"0.711803",
"0.7107238",
"0.709797",
"0.70627785",
"0.70335287",
"0.7030839",
"0.7004017",
"0.698619",
"0.69767475",
"0.69743663",
"0.69389015",
"0.69189125",
"0.69030726",
"0.69020766",
"0.6887617",
"0.6859881",
"0.6856104",
"0.68225265",
"0.68207455",
"0.6807762",
"0.68034154",
"0.6798814",
"0.6798814",
"0.67979676",
"0.67979676",
"0.6793409",
"0.6786534",
"0.6776658",
"0.6771922",
"0.67666775",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.67596424",
"0.6743567",
"0.6743567",
"0.6704394",
"0.6703828",
"0.6701904",
"0.6699354",
"0.6691945",
"0.66890675",
"0.6660148",
"0.66482604",
"0.66379917",
"0.663784",
"0.6616626",
"0.66070825",
"0.660353",
"0.6599931",
"0.6599931",
"0.6599931",
"0.65974694",
"0.6597055",
"0.6577771",
"0.65667963",
"0.65516245",
"0.6550781",
"0.6547047",
"0.6542879",
"0.6525799",
"0.65256035",
"0.6521071",
"0.65202093",
"0.6515314",
"0.65120596",
"0.65116596",
"0.6507258",
"0.65058064"
] |
0.0
|
-1
|
POST /list_items POST /list_items.xml
|
def create
@list = List.find(params[:list_id])
@list_item = @list.list_items.build(params[:list_item])
@page_section = @list.page_section
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
if @list_item.save
flash[:notice] = 'ListItem was successfully created.'
format.html { redirect_to site_section_page_url(@site_section, @page) }
format.js { render :template => 'page_sections/ajax_success' }
format.xml { render :xml => @list_item, :status => :created, :location => @list_item }
else
format.js { render :update do |page|
page.replace_html "list_item_form_container_#{@list.id}", :partial => 'ajax_new', :list_id => @list, :page_section_id => @page_section
end
}
format.html { render :action => "new" }
format.xml { render :xml => @list_item.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def create\n @item = @list.items.create(item_params)\n redirect_to @list\n end",
"def create\n\n nested = params[:list].delete(:list_items_attributes)\n\n @list = List.new( params[:list] )\n @list.user = current_user\n\n records = nested.collect do |_, fields| \n\n ListItem.new( { \"list\" => @list }.merge( fields ) ) if !item_blank?( fields )\n\n end.compact\n\n respond_to do |format|\n if @list.save && records.map( &:save ).all?\n\n format.html { redirect_to @list, notice: 'List was successfully created.' }\n format.json { render json: @list, status: :created, location: @list }\n\n else\n\n format.html { render action: \"new\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n\n end\n end\n end",
"def list_item_params\n params[:list_item]\n end",
"def create\n @item = Item.create(item_params)\n @items = List.find(item_params[:list_id]).items.order(\"id ASC\")\n @list_id = item_params[:list_id]\n end",
"def create\n list = List.find(params[:list_id])\n @list_item = list.list_items.new(list_items_params)\n @list_item.save ? json_response(@list_item) : json_response(@list_item.errors, status = :not_acceptable)\n end",
"def list_items_list(page_id = current_page_id, list_id = current_list_id)\n request \"page/#{page_id}/lists/#{list_id}/items/list\"\n end",
"def add_list_item(content,page_id = current_page_id, list_id = current_list_id)\n # POST /ws/page/#{page_id}/lists/#{list_id}/items/add\n request \"page/#{page_id}/lists/#{list_id}/items/add\", \"item\" => { \"content\" => content }\n end",
"def create\n @tags = Tag.all\n @list_item = @list.list_items.new(list_item_params)\n\n respond_to do |format|\n if @list_item.save\n format.html { redirect_to list_path(@list), notice: 'List item was successfully created.' }\n format.json { render :show, status: :created, location: @list_item }\n else\n format.html { render :new }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_items }\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @items = @list.items\n\n respond_with @items\n end",
"def create\n ListItem.transaction do\n item = Item.new(item_params)\n item.save\n\n @list_item = ListItem.new(list_item_params)\n @list_item.item_id = item.id\n @list_item.list_id = params[:list_id]\n\n\n if @list_item.save\n render json: @list_item, status: :created\n else\n render json: @list_item.errors, status: :unprocessable_entity\n end\n end\n end",
"def create_list(params={})\n @obj.post('create-list', @auth.merge(params))\n end",
"def createItemOfList\n results1 = checkUser(params[:target_account]) #userid user to give the money\n if results1.code == 200\n parameters={user_id: (@current_user[\"id\"]).to_i, description: (params[:description]), date_pay: params[:date_pay], cost: params[:cost], target_account: params[:target_account], state_pay:params[:state_pay]}\n options = {\n :body => parameters.to_json,\n :headers => {\n 'Content-Type' => 'application/json'\n }\n }\n results = HTTParty.post(\"http://192.168.99.101:4055/lists\", options)\n if results.code == 201\n head 201\n else\n render json: results.parsed_response, status: results.code\n end\n elsif results1.code == 404\n renderError(\"Not Found\", 404, \"The resource does not exist\")\n end\n end",
"def new\n @list = List.find(params[:list_id])\n @item = @list.items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def list_item_params\n params.require(:list_item).permit(:item_name, :quantity, :list_id)\n end",
"def list_item_params\n params.require(:list_item).permit(:name, :description, :status)\n end",
"def create\n @list_item = ListItem.new(list_item_params)\n\n respond_to do |format|\n if @list_item.save\n format.html { redirect_to @list_item, notice: 'List item was successfully created.' }\n format.json { render :show, status: :created, location: @list_item }\n else\n format.html { render :new }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @list = current_user.lists.find params[:list_id]\n @item = @list.items.build(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to list_items_path(@list), notice: 'Item was successfully created.' }\n #format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n #format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = @list.items.build(item_params)\n @item.user = current_user\n\n if @item.save\n return success_item_create\n else\n return error_item_save\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to lists_path, :notice => 'Item was successfully created.' }\n format.json { render :json => lists_path, :status => :created, :location => lists_path }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @list_items = List.find(params[:list_id]).list_items\n\n render json: @list_items\n end",
"def create\n @listitem = Listitem.new(listitem_params)\n\n if @todolist.listitems << @listitem\n render :show, status: :created, location: todolist_listitem_path(@todolist, @listitem)\n else\n render json: @listitem.errors, status: :unprocessable_entity\n end\nend",
"def list_params\n params.require(:list).permit(:title, \n :description, \n :list_type_id, \n :list_type,\n list_items_attributes: [:item, :id, :_destroy]\n )\n end",
"def index\n @list_items = @list.list_items\n end",
"def create\n\n @list_item = @list.list_items.create!(list_item_params)\n #@list_item = @list.list_items.create!(params[:list_item])\n\n respond_to do |format|\n if @list_item.save\n format.html { redirect_to list_path(@list), notice: 'List item was successfully created.' }\n format.json { render :show, status: :created, location: @list_item }\n else\n format.html { render :new }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list_item }\n end\n end",
"def list_item_params\n params.require(:list_item).permit(:list_id, :item_name, :description, :size, :number_wanted, :store_name, :url)\n end",
"def create\n create_params = item_params\n item = Item.new(\n name: create_params[:name], \n is_complete: false, #create_params[:is_complete], \n list_id: create_params[:list_id])\n\n item.save!\n render json: item\n end",
"def list_item_params\n params.require(:list_item).permit(:list_id, :name, :deleted_at, :deleted, :tag_id)\n end",
"def item(data, question_ids)\n xml = xml_root(\"items\")\n\n questions = question_ids.inject(XML::Node.new(\"questions\")) do |doc, id|\n question = XML::Node.new(\"question\")\n question[\"id\"] = id.to_s\n doc << question\n end\n\n arrayed(data).each do |name|\n xml.root << (XML::Node.new(\"item\") << (XML::Node.new(\"data\") << name) << questions.copy(true))\n end\n\n send_and_process('items/add', 'items/item', xml)\n end",
"def list_item_params\n params.require(:list_item).permit(:list_id, item_id)\n end",
"def make_item_list\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to(items_path) }\n format.xml { render :xml => @item, :status => :created, :location => @item }\n else\n format.html { redirect_to(items_path)}\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_todo_item(name, list_id)\n data = {\n item: {\n name: name\n }\n }\n rest(\"post\", \"lists/#{list_id}/items\", data)\n end",
"def new\n @list = List.new\n\n @list.list_items.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list }\n end\n end",
"def create\n @item_list = ItemList.new(item_list_params)\n @item_list.user_id = current_user.id\n\n respond_to do |format|\n if @item_list.save\n format.html { redirect_to @item_list, notice: 'Item list was successfully created.' }\n format.json { render :show, status: :created, location: @item_list }\n else\n format.html { render :new }\n format.json { render json: @item_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_list(name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"post\", \"lists\", data)\n end",
"def item_params\n params.require(:item).permit(:name, :tag_list, :type_list, :description)\n end",
"def set_item_list\n @item_list = ItemList.find(params[:id])\n end",
"def create\n lip = list_item_params list_type_id: params[:list_type_id]\n new_item = current_user.list_items.create(lip)\n respond_with new_item\n end",
"def index\n @list_items = ListItem.all\n end",
"def index\n @list_items = ListItem.all\n end",
"def create\n @list_item = ListItem.new(list_item_params)\n\n if @list_item.save\n redirect_to @list_item, notice: 'List item was successfully created.' \n else\n render action: 'new' \n end\n end",
"def update_list(item_name, item_list, quantity)\n add_list(item_name, item_list, quantity)\nend",
"def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end",
"def update\n @list.append_items!(params.dig(:list, :items), current_user)\n redirect_to [@project, @randomization_scheme], notice: \"Items successfully added.\"\n end",
"def create_list(name)\n path = \"lists\"\n params = { list: { name: name }}\n list = request(path, params, :post)\n list_id = list[:id]\n # output full list again\n show_list(list_id)\n end",
"def index\n @items = @list.items.all.order(id: :desc)\n return success_item_index\n end",
"def push_list(stream, *array)\n post stream, 'list' => array.flatten.map{|item| {'listItem' => item}}\n end",
"def set_post(api_key, access_token, list, list_item_id, body, opts = {})\n data, _status_code, _headers = set_post_with_http_info(api_key, access_token, list, list_item_id, body, opts)\n return data\n end",
"def get_list\n \t@items\n end",
"def index\n @item_lists = ItemList.all\n end",
"def new\n @price_list = current_company.price_lists.new\n if params[:items]\n for id in params[:items]\n item = current_company.items.find(id)\n for unit in item.units\n @price_list.entries.build(:item_id => item.id, :unit_id => unit.id, :value => unit.value)\n end\n end\n end\n #@items = current_company.items.all(:include => :units, :order => \"name\").paginate(:page => params[:page])\n #for item in @items\n # for unit in item.units\n # @price_list.entries.build(:item_id => item.id, :unit_id => unit.id, :value => 0)\n # end\n #end\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @price_list }\n end\n end",
"def create\n @list = List.create!(list_params)\n json_response(@list, :created)\n end",
"def index\n @listitems = @todolist.listitems\nend",
"def create_item_list\n @item_button_list = ButtonList.new(@viewport)\n update_item_button_list\n end",
"def new\n @item = Item.new(:list_id => params[:list_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @item }\n end\n end",
"def list_params\n params.require(:list).permit(:title, :description, :html_id, :html_classes,\n list_items_attributes: [\n :id, :type, :object_type, :object_id, :title, :subtitle, :url, :image_id, :target,\n :priority, :_destroy, :description, :html_classes,\n children_attributes: list_item_attributes\n ])\n end",
"def item_list_params\n params.require(:item_list).permit(:title, :description, :expected_cost, :image, :contact)\n end",
"def create\n @list_of_value = Irm::ListOfValue.new(params[:irm_list_of_value])\n\n respond_to do |format|\n if @list_of_value.save\n format.html { redirect_to({:action => \"index\"}, :notice => t(:successfully_created)) }\n format.xml { render :xml => @list_of_value, :status => :created, :location => @list_of_value }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @list_of_value.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @action_items = ActionItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @action_items }\n end\n end",
"def update\n item = @list.list_items.find(params[:id])\n\n if item.update_attributes(params[:list_item])\n render json: item\n else\n error(t('messages.list_item.errors.update'))\n end\n end",
"def create(name)\n Iterable.request(conf, '/lists').post(name: name)\n end",
"def create\n @item = @client.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully added.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @price_list = current_company.price_lists.new(params[:price_list])\n unless !request.xhr? && params[:item_getter].blank?\n @item = current_company.items.find_by_name(params[:item_getter])\n for unit in @item.units\n @price_list.entries.build(:item_id => @item.id, :unit_id => unit.id, :value => unit.value)\n end\n render(\"new\", :layout => false) and return\n end\n\n respond_to do |format|\n if @price_list.save\n format.html { redirect_to(@price_list, :notice => 'PriceList was successfully created.') }\n format.xml { render :xml => @price_list, :status => :created, :location => @price_list }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @price_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def list_item_params extras={}\n params.require(:list_item).merge(extras).except(:id).permit(:list_type_id, :user_id, :title, :description, :link, :onHold, :suggested)\n end",
"def createItem(title, description, date)\n new_item = List.new\n new_item.title = title\n new_item.description = description\n new_item.save\n new_item.date = date\n end",
"def create\n return error_status(true, :cannot_create_listitem) unless (ListItem.can_be_created_by(@logged_user, @list))\n \n @list_item = @list.list_items.build(params[:list_item])\n @list_item.created_by = @logged_user\n\n respond_to do |format|\n if @list_item.save\n flash[:notice] = 'ListItem was successfully created.'\n format.html { redirect_to(@list_item) }\n format.js\n format.xml { render :xml => @list_item, :status => :created, :location => page_list_list_item_path(:page_id => @page.id, :list_id => @list.id, :id => @list_item.id) }\n else\n format.html { render :action => \"new\" }\n format.js\n format.xml { render :xml => @list_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n return error_status(true, :cannot_create_listitem) unless (ListItem.can_be_created_by(@logged_user, @list))\n \n @list_item = @list.list_items.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_item }\n end\n end",
"def create(item_attrs = {})\n body = { value: item_attrs }\n Iterable.request(conf, base_path).put(body)\n end",
"def create\n @item = Item.new(params[:item])\n @item.save\n respond_with @item\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |wants|\n if @item.save\n flash[:notice] = 'Item was successfully created.'\n wants.html { redirect_to(admin_items_url) }\n wants.xml { render :xml => @item, :status => :created, :location => @item }\n else\n wants.html { render :action => \"new\" }\n wants.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @list = List.find(params[:id])\n\n nested = params[:list].delete( :list_items_attributes )\n\n new_items = []\n\n if nested then\n nested.each do |i, r|\n\n if !r.key?( \"id\" )\n\n new_items << ListItem.new( { \"list\" => @list }.merge( r ) ) if !item_blank?( r )\n\n nested.delete( i )\n\n else\n\n r[ \"_destroy\" ] = \"true\" if item_blank?( r )\n\n end\n\n end\n end\n\n respond_to do |format|\n if @list.update_attributes( params[ :list ] ) && \n @list.update_attributes( list_items_attributes: (nested || {}) ) &&\n new_items.map( &:save ).all? then\n\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { head :no_content }\n\n else\n\n format.html { render action: \"edit\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n\n end\n end\n end",
"def create\n @baintodo_item = @baintodo_list.baintodo_items.create(baintodo_item_params)\n redirect_to @baintodo_list\n end",
"def path\n \"/{databaseId}/items/list/\"\n end",
"def save_items_data\n @parsed[\"order_items\"].each do |i| \n external_code = i['item']['id']\n item = Item.find_or_create_by(external_code: external_code)\n item.order_id = @order.id\n item.external_code = i['item']['id']\n item.name = i['item']['title']\n item.price = i['unit_price']\n item.quantity = i['quantity']\n item.total = i['full_unit_price']\n @subItems = []\n item.save\n end\n end",
"def list_params\n params.require(:list).permit(:title, :category_id, :body)\n end",
"def create\n @mylist = Mylist.new(params[:mylist])\n\n respond_to do |format|\n if @mylist.save\n format.html { redirect_to(@mylist, :notice => 'Mylist was successfully created.') }\n format.xml { render :xml => @mylist, :status => :created, :location => @mylist }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mylist.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n task\n if @item.update(item_params)\n render json: @list.as_json, status: :ok\n else\n render json: {list: @item.errors, status: :unprocessable_entity}\n end\n end",
"def items\n response = @client.request :get, \"#{LISTS_PATH}/#{@id}\"\n raise(StandardError, 'unexpected response') unless response\n response['items']&.map { |i| TodoableItem.new self, i, @client }\n end",
"def list_params\n params.require(:list).permit(:title, :position)\n end",
"def list_params\n params.require(:list).permit(:title, :description)\n end",
"def item_params\n params[:item][:ingredient_list] ||= [] \n params.require(:item).permit(:name, ingredient_list: [])\n end",
"def create\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.build(params[:list_item])\n @list_item[:user_id] = current_user.id\n\n if @list_item.save\n flash[:success] = \"Item successfully added\"\n redirect_to list_path(@list)\n else\n flash[:error] = \"Item not added\"\n redirect_to list_path(@list)\n end\n end",
"def create\n @item = build_item\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to items_path, notice: 'アップロードしたでー' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item.update_attributes(item_params)\n @items = List.find(item_params[:list_id]).items.order(\"id ASC\")\n @list_id = @item.list.id\n end",
"def list_params\n params.require(:list).permit(:name, :description)\n end",
"def list_items\r\n begin\r\n expand_combo\r\n get(:type => :list_item, :scope => :children, :how_many => :all)\r\n ensure\r\n collapse_combo\r\n end\r\n end",
"def create\n @request_item = RequestItem.new(request_item_params)\n @request_item.item = Item.new(name: params[:request_item][:item][:name])\n\n if @request_item.save\n render json: @request_item \n else\n render json: @request_item.errors, status: :bad_request\n end\n end",
"def index\n self.identify_user\n @items = @user.items\n @itemlist = @items.map do |item|\n convert_to_json(item)\n end\n respond_to do |format|\n format.json { render :json => @itemlist }\n format.xml { render :xml => @items }\n format.html { render text: \"Unsupported Format\", status: 404 }\n end\n end",
"def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn items\n\tend",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def postEntityList( entity_id, headline, body)\n params = Hash.new\n params['entity_id'] = entity_id\n params['headline'] = headline\n params['body'] = body\n return doCurl(\"post\",\"/entity/list\",params)\n end",
"def test_list\n @builder.write_list('http://lancaster.myreadinglists.org/lists/4510B70F-7C50-D726-4A6C-B129F5EABB2C')\n end",
"def list_params\n params[:list]\n end",
"def items\n @document.xpath('//results/page/items/*')\n end",
"def create\n @checklist = Checklist.find(params[:checklist_item][:checklist_id])\n @checklist_item = ChecklistItem.new(params[:checklist_item])\n\n respond_to do |format|\n if @checklist_item.save\n @checklist.checklist_items << @checklist_item\n # format.html { redirect_to checklist_checklist_item_url(@checklist, @checklist_item), notice: 'Checklist item was successfully created.' }\n format.json { render json: @checklist_item, status: :created, location: @checklist_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @checklist_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list_params\n params.require(:list).permit(:name)\n end"
] |
[
"0.6939243",
"0.6640042",
"0.66219974",
"0.6580838",
"0.65639144",
"0.6539049",
"0.65368",
"0.65124077",
"0.6483423",
"0.63886154",
"0.63838345",
"0.6376204",
"0.6310107",
"0.6281453",
"0.6260847",
"0.6202426",
"0.61957246",
"0.6160829",
"0.61469996",
"0.61276853",
"0.61062163",
"0.6096744",
"0.60825324",
"0.60682726",
"0.6064691",
"0.6037205",
"0.60265666",
"0.6025661",
"0.6017809",
"0.60052764",
"0.59830254",
"0.5978421",
"0.59701383",
"0.5961538",
"0.59584093",
"0.595797",
"0.59493536",
"0.5903712",
"0.589983",
"0.58981305",
"0.58979654",
"0.5895107",
"0.5895107",
"0.5865776",
"0.58554727",
"0.58552164",
"0.58348125",
"0.581872",
"0.57979447",
"0.57823354",
"0.5765523",
"0.57612777",
"0.5761096",
"0.5749171",
"0.5742496",
"0.57386506",
"0.57289124",
"0.572197",
"0.57093227",
"0.570422",
"0.5703476",
"0.56993985",
"0.568675",
"0.56697595",
"0.5662667",
"0.56579834",
"0.5656455",
"0.565455",
"0.56526244",
"0.56496704",
"0.5645",
"0.56340957",
"0.5626022",
"0.5620579",
"0.562051",
"0.5618346",
"0.560284",
"0.5599182",
"0.55989957",
"0.55967194",
"0.5595182",
"0.55935705",
"0.55892926",
"0.5588729",
"0.55774224",
"0.55725354",
"0.556185",
"0.55402696",
"0.553427",
"0.5517288",
"0.55161554",
"0.5513983",
"0.55128586",
"0.55128586",
"0.55128586",
"0.5504671",
"0.550361",
"0.54967654",
"0.54936016",
"0.5493112",
"0.5491393"
] |
0.0
|
-1
|
PUT /list_items/1 PUT /list_items/1.xml
|
def update
@list = List.find(params[:list_id])
@list_item = @list.list_items.find(params[:id])
@page_section = @list.page_section
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
if @list_item.update_attributes(params[:list_item])
flash[:notice] = 'ListItem was successfully updated.'
format.html { redirect_to site_section_page_url(@site_section, @page) }
format.js { render :template => 'page_sections/ajax_success' }
format.xml { head :ok }
else
format.js { render :update do |page|
page.replace_html "list_item_form_container_#{@list.id}", :partial => 'ajax_new', :list_id => @list, :page_section_id => @page_section
end
}
format.html { render :action => "edit" }
format.xml { render :xml => @list_item.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n item = @list.list_items.find(params[:id])\n\n if item.update_attributes(params[:list_item])\n render json: item\n else\n error(t('messages.list_item.errors.update'))\n end\n end",
"def update\n @item.update_attributes(item_params)\n @items = List.find(item_params[:list_id]).items.order(\"id ASC\")\n @list_id = @item.list.id\n end",
"def update\n \n @list_item = ListItem.find(params[:id])\n\n if @list_item.update(list_item_params)\n head :no_content\n else\n render json: @list_item.errors, status: :unprocessable_entity\n end\n end",
"def update_list(item_name, item_list, quantity)\n add_list(item_name, item_list, quantity)\nend",
"def update\n @list = List.find(params[:id])\n\n nested = params[:list].delete( :list_items_attributes )\n\n new_items = []\n\n if nested then\n nested.each do |i, r|\n\n if !r.key?( \"id\" )\n\n new_items << ListItem.new( { \"list\" => @list }.merge( r ) ) if !item_blank?( r )\n\n nested.delete( i )\n\n else\n\n r[ \"_destroy\" ] = \"true\" if item_blank?( r )\n\n end\n\n end\n end\n\n respond_to do |format|\n if @list.update_attributes( params[ :list ] ) && \n @list.update_attributes( list_items_attributes: (nested || {}) ) &&\n new_items.map( &:save ).all? then\n\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { head :no_content }\n\n else\n\n format.html { render action: \"edit\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n\n end\n end\n end",
"def update\n \t@list = current_user.lists.find params[:list_id]\n @item = @list.items.find(params[:id])\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to list_items_path(@list), notice: 'Item was successfully updated.' }\n #format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n #format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.find(params[:id])\n\n if @list_item.update_attributes(params[:list_item])\n flash[:success] = \"List item was successfully updated.\"\n redirect_to list_path(@list) \n else\n flash[:errror] = \"Unable to update item.\"\n redirect_to edit_list_list_item_path(@list, @list_item)\n end\n end",
"def update\n task\n if @item.update(item_params)\n render json: @list.as_json, status: :ok\n else\n render json: {list: @item.errors, status: :unprocessable_entity}\n end\n end",
"def update\n\n @item = Item.find(params[:id])\n @item.update(item_params)\n\n redirect_to user_list_path(@item.list.user, @item.list)\n end",
"def update_list(id, list)\n record \"/todos/update_list/#{id}\", :list => list\n end",
"def update\n respond_to do |format|\n if @item_list.update(item_list_params)\n format.html { redirect_to @item_list, notice: 'Item list was successfully updated.' }\n format.json { render :show, status: :ok, location: @item_list }\n else\n format.html { render :edit }\n format.json { render json: @item_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to lists_path, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list_item.update(list_item_params)\n format.html { redirect_to @list, notice: 'List item was successfully updated.' }\n format.json { render :show, status: :ok, location: @list_item }\n else\n format.html { render :edit }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list_item.update(list_item_params)\n format.html { redirect_to list_path(@list), notice: 'List item was successfully updated.' }\n format.json { render :show, status: :ok, location: @list_item }\n else\n format.html { render :edit }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(list, item, qty)\n add_item(list, item, qty)\nend",
"def update\n respond_to do |format|\n if @list_item.update(list_item_params)\n format.html { redirect_to @list_item, notice: 'List item was successfully updated.' }\n format.json { render :show, status: :ok, location: @list_item }\n else\n format.html { render :edit }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n @item.update_attributes(params[:item])\n respond_with @item\n end",
"def update\n respond_to do |format|\n if @list_item.update(list_item_params)\n format.html { redirect_to @list_item, notice: 'List item was successfully updated.' }\n format.json { render json: @list_item, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to(@item)}\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item }\n format.xml { head :ok }\n else\n \n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @list = current_user.lists.find(params[:id])\n @list.update_attributes(params[:list])\n respond_with(@list, :location => my_list_url(@list))\n end",
"def update!(**args)\n @list_items = args[:list_items] if args.key?(:list_items)\n end",
"def update\n @list.append_items!(params.dig(:list, :items), current_user)\n redirect_to [@project, @randomization_scheme], notice: \"Items successfully added.\"\n end",
"def update\n\t\t@list = List.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @list.update_attributes(params[:list])\n\t\t\t\tformat.html\t{ redirect_to(root_url) }\n\t\t\t\tformat.xml\t{ head :ok }\n\t\t\telse\n\t\t\t\tformat.html\t{ render :action => \"edit\" }\n\t\t\t\tformat.xml\t{ render :xml => @list.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update_list(list_id, name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"patch\", \"lists/#{list_id}\", data)\n end",
"def set_item_list\n @item_list = ItemList.find(params[:id])\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(:action => :index) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_item\n @item = Item.find(params[:id])\n @item.update(params[:item])\n redirect \"/items/#{@item.id}\"\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(@item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(@item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(@item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @list.update_attributes list_params\n end",
"def set_list_item\n\t @list_item = ListItem.find(params[:id])\n\t end",
"def update\n @mylist = Mylist.find(params[:id])\n\n respond_to do |format|\n if @mylist.update_attributes(params[:mylist])\n format.html { redirect_to(@mylist, :notice => 'Mylist was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mylist.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if params[:new_check_list_item][:id].present?\n @check_list.check_list_items.create(check_id: params[:new_check_list_item][:id])\n end\n if params[:cli]\n params[:cli].each do |cli_array|\n cli = CheckListItem.find(cli_array[0].to_i)\n cli.position = cli_array[1].to_i\n cli.save\n end\n end\n\n respond_to do |format|\n if @check_list.update(check_list_params)\n format.html { redirect_to :back, notice: 'Check list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @check_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item ||= Item.find_by_id_or_name(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(@item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update \n respond_to do |wants|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Item was successfully updated.'\n wants.html { redirect_to(admin_items_path) }\n wants.xml { head :ok }\n else\n \n wants.html { render :action => \"edit\" }\n wants.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_list_item\n @list_item = ListItem.find(params[:id])\n end",
"def set_list_item\n @list_item = ListItem.find(params[:id])\n end",
"def set_list_item\n @list_item = ListItem.find(params[:id])\n end",
"def set_list_item\n @list_item = ListItem.find(params[:id])\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to(@item, :notice => 'Item was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to(@item, :notice => 'Item was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def updateItem(id, title, description)\n item = List.find(id)\n item.title = title\n item.description = description\n item.save\n end",
"def update\n if @list_item.update(list_item_params)\n redirect_to @list_item, notice: 'List item was successfully updated.' \n else\n render action: 'edit' \n end\n end",
"def update\n @movie_list_item = MovieListItem.find(params[:id])\n\n respond_to do |format|\n if @movie_list_item.update_attributes(params[:movie_list_item])\n format.html { redirect_to(@movie_list_item, :notice => 'Movie list item was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @movie_list_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @list_of_value = Irm::ListOfValue.find(params[:id])\n\n respond_to do |format|\n if @list_of_value.update_attributes(params[:irm_list_of_value])\n format.html { redirect_to({:action => \"index\"}, :notice => t(:successfully_updated)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @list_of_value.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item.update!(item_params)\n end",
"def update_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n if @entry_item.update_attributes(params[:entry_item])\n flash[:notice] = 'EntryItem was successfully updated.'\n #format.html { redirect_to(@entry_item) }\n format.xml { head :ok }\n else\n #format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @listitem.update(listitem_params)\n render :show, status: :ok, location: todolist_listitem_path(@todolist, @listitem)\n else\n render json: @listitem.errors, status: :unprocessable_entity\n end\nend",
"def update\n @item = @user.items.find(params[:id])\n\n @item.update(:type_list => \"\", :tag_list => \"\")\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to [@user, @item], notice: 'item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n\n\n end",
"def update!(**args)\n @item_id = args[:item_id] if args.key?(:item_id)\n @list_id = args[:list_id] if args.key?(:list_id)\n end",
"def add_to_list(list,item,quantity)\n\tupdate_item(list,item,quantity)\nend",
"def update\r\n @item = Item.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @item.update_attributes(params[:item])\r\n format.html { redirect_to(@item, :notice => 'Item Successfully updated.') }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n Rails.logger.debug params.inspect\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n respond_with(@items)\n end\n end\n end",
"def update\n respond_to do |format|\n if @apiv1_item.update(apiv1_item_params)\n format.html { redirect_to @apiv1_item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @apiv1_item }\n else\n format.html { render :edit }\n format.json { render json: @apiv1_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \tif params[:shopping_list][:other_items_attributes]\n\t \tparams[:shopping_list][:other_items_attributes].each do |k,v|\n\t \t\tif v[:shopping_item_id] == \"\" and params[:shopping_item_input][k] != \"\"\n\t \t\t\tshopping_item = ShoppingItem.create!(:name => params[:shopping_item_input][k])\n\t \t\t\tv[:shopping_item_id] = shopping_item.id\n\t \t\tend\n\t \tend\n \tend\n \t\n @shopping_list = ShoppingList.find(params[:id])\n\n respond_to do |format|\n if @shopping_list.update_attributes(params[:shopping_list])\n format.html { redirect_to @shopping_list, notice: 'Shopping list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shopping_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_items }\n end\n end",
"def update_quantity_of_item(list,item,quantity)\r\n add_item_to_list(list,item,quantity)\r\n list\r\nend",
"def update\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = \"Item has been updated\"\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { render :action => :edit }\n else\n format.json { render :text => \"Could not update item\", :status => :unprocessable_entity } #placeholder\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n format.html { render :action => :edit, :status => :unprocessable_entity }\n end\n end\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(item_attrs = {})\n body = { update: item_attrs }\n Iterable.request(conf, base_path).patch(body)\n end",
"def updating_item(list,item,quantity)\r\n\r\n adding_item(list,item, quantity)\r\n\r\nend",
"def update!(**args)\n @_context = args[:_context] if args.key?(:_context)\n @_type = args[:_type] if args.key?(:_type)\n @item_list_element = args[:item_list_element] if args.key?(:item_list_element)\n end",
"def set_apiv1_item\n @apiv1_item = Item.find(params[:id])\n end",
"def test_the_application_can_update_a_previous_item_title_on_our_to_do_list\n #Create an item to test\n #Send a PUT request to '/items/:id' that will update the item's title\n #Assert that the controller responds with a status of 200\n #Assert that the controller responds with a body of 'Item updated'\n #Assert that the item's title is the updated title and not the original title.\n end",
"def update\n @thing_list = ThingList.find(params[:id])\n\n respond_to do |format|\n if @thing_list.update_attributes(params[:thing_list])\n format.html { redirect_to(@thing_list, :notice => 'Thing list was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @thing_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[@item.class.to_s.downcase.to_sym])\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(@item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @list = List.find(params[:id])\n @show_list = true\n\n respond_to do |format|\n if @list.update_attributes(params[:list])\n format.html { render @list }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @adventure.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n item = Item.find(params[:item_id])\n\n item.name = params[:name]\n item.details = params[:details]\n item.save\n end",
"def update\n @item = @client.items.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_item(item_id)\n request_body = {\n 'name' => 'Malted Milkshake'\n }\n\n response = Unirest.put CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS,\n parameters: request_body.to_json\n\n if response.code == 200\n puts 'Successfully updated item:'\n puts JSON.pretty_generate(response.body)\n return response.body\n else\n puts 'Item update failed'\n puts response.body\n return nil\n end\nend",
"def update\n @page_title = \"Task List Update\"\n @task_list = TaskList.find(params[:id])\n\n respond_to do |format|\n if @task_list.update_attributes(params[:task_list])\n flash[:notice] = 'TaskList was successfully updated.'\n format.html { redirect_to(@task_list) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n images_arr = params[:images]\n params[:list_item].delete(:image)\n @list_item = ListItem.find(params[:id])\n @image = Image.new(images_arr)\n @list_item.images << @image\n\n respond_to do |format|\n if @list_item.update_attributes(params[:list_item])\n format.html { redirect_to user_url(current_user), notice: t('list_items.updated') }\n format.json { render :json => @list_item }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @list_item.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 @list = List.find(params[:id])\n\n respond_to do |format|\n if @list.update_attributes(params[:list])\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ordered_item = OrderedItem.find(params[:id])\n\n respond_to do |format|\n if @ordered_item.update_attributes(params[:ordered_item])\n format.html { redirect_to(@ordered_item, :notice => 'Ordered item 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 => @ordered_item.errors, :status => :unprocessable_entity }\n format.json { render :json => @ordered_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n \n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @list = List.find(params[:id])\n\n respond_to do |format|\n if @list.update_attributes(params[:list])\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @list = List.find(params[:id])\n\n respond_to do |format|\n if @list.update_attributes(params[:list])\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Artikel is succesvol ge-update.'\n format.html { redirect_to(@item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n if @api_v1_item.update(api_v1_item_params)\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end",
"def update\n \n list_attributes = params[:list] || params[:check_list]\n \n if @list.update(list_attributes)\n flash[:notice] = t(:list_saved)\n redirect_to @list\n else\n render :action => 'edit'\n end\n end",
"def set_list_item\n @list_item = ListItem.find(params[:id])\n end",
"def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'Changes and Additions Successful.' }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(_list_params)\n format.html { redirect_to @list, notice: \"List was successfully updated.\" }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(list, item_name, quantity)\n\tlist[item_name] = quantity\nend",
"def update_quantity(item, list, quantity)\n add_item(item, list, quantity)\nend",
"def set_api_v1_item\n @api_v1_item = Item.find(params[:id])\n end",
"def update_quantity(list, item, quantity)\n\tadd_to_list(list, item, quantity)\nend",
"def update\n respond_to do |format|\n if @list.update(existing_list_params)\n format.html { redirect_to my_list_path(@list), notice: 'List was successfully updated.' }\n format.json { render :show, status: :ok, location: my_list_path(@list) }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @action_list = ActionList.find(params[:id])\n\n respond_to do |format|\n if @action_list.update_attributes(params[:action_list])\n format.html { redirect_to(@action_list, :notice => 'ActionList was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @action_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @item.update(item_params)\n render json: @item, status: :ok\n else\n render json: @item.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @task_item.update(task_item_params)\n format.html { redirect_to task_list_path(@task_item.list), notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @task_item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @task_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_list(user, list, options={})\n post(\"/#{user}/lists/#{list}.json\", options)\n end",
"def update\n if @item.update_attributes(item_params)\n render json: @item, status: :ok\n else\n render_error(@item, :unprocessable_entity)\n end\n end",
"def update\n @email_list = EmailList.find(params[:id])\n\n respond_to do |format|\n if @email_list.update_attributes(params[:email_list])\n format.html { redirect_to(@email_list, :notice => 'Email list was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @email_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @list\n\n if @list.update(list_params)\n json_response(@list.decorate, :ok)\n else\n json_response(@list.errors, :unprocessable_entity)\n end\n end",
"def update_list(list_id:, name:)\n check_token\n list = Todoable::List.new(name: name)\n response = self.class.patch(\n \"/lists/#{list_id}\",\n body: list.post_body,\n headers: headers,\n format: :text\n )\n check_and_raise_errors(response)\n # This endpoint returns a plaintext body: \"<new name> updated\", so\n # while I'd like to return a List with ListItems, that would require\n # first looking up the list which isn't ideal. So we'll return true, ask\n # todoable to fix this endpoint, and make developers keep track of the\n # name change\n true\n end"
] |
[
"0.6984748",
"0.69329256",
"0.6790025",
"0.67708486",
"0.6667355",
"0.6630834",
"0.66150033",
"0.65653706",
"0.65477073",
"0.6526097",
"0.64774257",
"0.64527977",
"0.64524394",
"0.6435126",
"0.64300007",
"0.64283556",
"0.6338978",
"0.6321061",
"0.62865925",
"0.6275006",
"0.6228076",
"0.6226146",
"0.6216634",
"0.62134975",
"0.6201838",
"0.61950177",
"0.61746323",
"0.61738217",
"0.61602306",
"0.61602306",
"0.61602306",
"0.61500585",
"0.61464506",
"0.61390966",
"0.6138079",
"0.6123506",
"0.61126155",
"0.61076945",
"0.61076945",
"0.61076945",
"0.6106939",
"0.6106453",
"0.6106453",
"0.6100482",
"0.6096427",
"0.60928345",
"0.60916966",
"0.6081526",
"0.6073297",
"0.6071917",
"0.6067429",
"0.6063929",
"0.605998",
"0.60581785",
"0.60515445",
"0.60358405",
"0.6027521",
"0.6026332",
"0.60241663",
"0.60217",
"0.6003253",
"0.59874684",
"0.59864205",
"0.59842825",
"0.5982212",
"0.5980988",
"0.59803295",
"0.5980213",
"0.59697604",
"0.5969482",
"0.5958155",
"0.5951722",
"0.5951177",
"0.59510624",
"0.5949584",
"0.5934721",
"0.5933978",
"0.59331584",
"0.5930713",
"0.59297496",
"0.59297496",
"0.5927002",
"0.5926978",
"0.59218",
"0.59195894",
"0.59160423",
"0.59027135",
"0.5899648",
"0.5898749",
"0.5896227",
"0.5893939",
"0.58915126",
"0.58870715",
"0.588206",
"0.58746064",
"0.5872594",
"0.5868842",
"0.5867652",
"0.58641",
"0.5863179",
"0.58564144"
] |
0.0
|
-1
|
DELETE /list_items/1 DELETE /list_items/1.xml
|
def destroy
@list = List.find(params[:list_id])
@list_item = @list.list_items.find(params[:id])
@page_section = @list.page_section
@list_item.destroy
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
format.html { redirect_to site_section_page_url(@site_section, @page) }
format.js { render :template => 'page_sections/ajax_success' }
format.xml { head :ok }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @list_id = @item.list.id\n @item.destroy\n @items = List.find(@list_id).items.order(\"id ASC\")\n end",
"def destroy\n @list_item.destroy\n\n head :no_content\n end",
"def delete_list_item(client, uri, headers)\n # log what we are doing\n log(:info, \"Deleting Sharepoint list item at: #{uri}\")\n\n # send the delete request and return the response\n client.delete(uri, headers)\n end",
"def delete_item(list_item)\n @list.delete(list_item)\n @list\n end",
"def delete_item(list_id:, id:)\n path = \"lists/#{list_id}/items/#{id}\"\n request(method: :delete, path: path)\n end",
"def destroy\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.find(params[:id])\n @list_item.destroy\n\n if @list_item.destroy\n flash[:success] = \"Item deleted\"\n redirect_to list_path(@list)\n else\n flash[:error] = \"Item not deleted\"\n redirect_to list_path(@list)\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete_item(list,item)\n\tlist.delete(item)\nend",
"def destroy\n @mylist = Mylist.find(params[:id])\n @mylist.destroy\n\n respond_to do |format|\n format.html { redirect_to(mylists_url) }\n format.xml { head :ok }\n end\n end",
"def delete_item(list_id:, item_id:)\n api_request(method: :delete, path: \"lists/#{list_id}/items/#{item_id}\")\n end",
"def destroy\n @list_item = ListItem.find(params[:id])\n @list_item.destroy\n\n respond_to do |format|\n format.html { render :nothing => true}\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def delete_item(item)\r\n @list.delete(item)\r\n end",
"def destroy\n # @list=List.find(params[:list_id])\n @list_item=@list.list_items.find(params[:id])\n @list_item.destroy\n respond_to do |format|\n format.html { redirect_to @list, notice: 'List item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @item = Item.find(params[:id])\r\n\r\n @item.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(items_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n \t@list = current_user.lists.find params[:list_id]\n @item = @list.items.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to list_items_path(@list), notice: 'Item was successfully removed.' }\n #format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { head :ok }\n end\n end",
"def delete_item(list,item)\n list.delete(item)\nend",
"def delete_item(list,item)\n list.delete(item)\nend",
"def delete(item, list)\n\tlist.delete(item)\nend",
"def destroy\n @listitem.destroy\n head :no_content\nend",
"def delete_item(list, item)\n\tlist.delete(item)\n\tlist\nend",
"def delete(items)\n item_ids = items.collect { |item| item.id }\n args = {ids: item_ids.to_json}\n return @client.api_helper.command(args, \"item_delete\")\n end",
"def destroy\n @actionitem = Actionitem.find(params[:id])\n @actionitem.destroy\n\n respond_to do |format|\n format.html { redirect_to(actionitems_url) }\n format.xml { head :ok }\n end\n end",
"def delete_item(list, item)\n list.delete(item)\nend",
"def delete_item(item)\n @get_items.delete(item)\n end",
"def destroy\n @list_item.destroy\n redirect_to list_items_url \n end",
"def destroy\n @item = item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(budget_items_url) }\n format.xml { head :ok }\n end\n end",
"def delete_todo_item(item_id, list_id)\n rest(\"delete\", \"/lists/#{list_id}/items/#{item_id}\")\n\n return true\n end",
"def destroy\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_items_url, :notice => 'Item was deleted.') }\n format.xml { head :ok }\n end\n end",
"def destroy\n @action_item = ActionItem.find(params[:id])\n @action_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(action_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @instancia_item = InstanciaItem.find(params[:id])\n @instancia_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(instancia_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n item = @list.list_items.find(params[:id])\n\n if item.destroy\n flash[:alert] = t('messages.list_item.success.delete', name: item.name)\n else\n flash[:notice] = t('messages.list_item.errors.delete')\n end\n\n redirect_to :back\n end",
"def delete_item(list,item)\n list.delete(item)\n list\nend",
"def delete_item(list,item)\n list.delete(item)\n list\nend",
"def delete(list_id)\n Iterable.request(conf, \"/lists/#{list_id}\").delete\n end",
"def destroy\n @item.destroy\n\n respond_to do |wants|\n wants.html { redirect_to(admin_items_url) }\n wants.xml { head :ok }\n end\n end",
"def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end",
"def delete_item\n\nend",
"def del_item(list, item_to_del)\n list.delete(item_to_del)\nend",
"def delete_item(list, item)\n list.delete(item)\n list\nend",
"def delete_item(list, item)\n list.delete(item)\n list\nend",
"def delete_item(list, item)\n\tdel_list = list.delete(item)\nend",
"def destroy\n @item = @course.items.find(:first, :conditions => ['lower(name) = ?', params[:id].downcase.gsub('_', ' ')])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(course_items_url(@course)) }\n format.xml { head :ok }\n end\n end",
"def delete\n blacklight_items.each do |r|\n solr.delete_by_id r[\"id\"]\n solr.commit\n end\n end",
"def remove_item(list_items, item_name)\n list_items.delete(item_name)\nend",
"def destroy\n @list_item.destroy\n respond_to do |format|\n format.html { redirect_to list_path(@list), notice: 'List item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @action_list = ActionList.find(params[:id])\n @action_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(action_lists_url) }\n format.xml { head :ok }\n end\n end",
"def delete_item(list, item)\n del_list = list.delete(item)\nend",
"def destroy\n @item_list.destroy\n respond_to do |format|\n format.html { redirect_to item_lists_url, notice: 'Item list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_item(list, item)\n\tlist.delete(item)\n\treturn list\nend",
"def destroy\n @checklist_item = ChecklistItem.find(params[:id])\n @checklist_item.destroy\n\n respond_to do |format|\n format.html { redirect_to checklist_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list_item.destroy\n respond_to do |format|\n format.html { redirect_to list_items_url, notice: 'List item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_list(list_id)\n rest(\"delete\", \"lists/#{list_id}\")\n\n return true\n end",
"def delete_item(list,item)\n list.delete(item)\n return list\nend",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(manage_items_url, :notice => 'Item was successfully deleted.') }\n format.xml { head :ok }\n end\n end",
"def delete_list(id)\n record \"/todos/delete_list/#{id}\"\n end",
"def destroy\n @mailee_list = Mailee::List.find(params[:id])\n @mailee_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(mailee_lists_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @content_item = ContentItem.find(params[:id])\n @content_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(content_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy_rest\n @entry_item = EntryItem.find(params[:id])\n @entry_item.destroy\n\n respond_to do |format|\n #format.html { redirect_to(entry_items_url) }\n format.xml { head :ok }\n end\n end",
"def delete_item(item_id)\n response = Unirest.delete CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS\n\n if response.code == 200\n puts 'Successfully deleted item'\n return response.body\n else\n puts 'Item deletion failed'\n puts response.body\n return nil\n end\nend",
"def destroy\n @checklist = Checklist.find(params[:id])\n @checklist.destroy\n\n respond_to do |format|\n format.html { redirect_to(checklists_url) }\n format.xml { head :ok }\n end\n end",
"def deleteItems\n self.items.each do |item|\n item.delete\n end\n end",
"def destroy\n @item = @project.items.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(project_items_path(@project, :subdomain => @user.subdomain)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\t\t@list = List.find(params[:id])\n\t\t@list.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html\t{ redirect_to(root_url) }\n\t\t\tformat.xml\t{ head :ok }\n\t\tend\n\tend",
"def remove_item(id)\n return nil if self.class.mode == :sandbox\n\n query = { \"type\" => \"delete\", \"id\" => id.to_s, \"version\" => Time.now.to_i }\n doc_request query\n end",
"def remove_item(list, item_name)\r\n list.delete(item_name)\r\n list\r\nend",
"def destroy\n @movie_list_item = MovieListItem.find(params[:id])\n @movie_list_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(movie_list_items_url) }\n format.xml { head :ok }\n end\n end",
"def remove_item(list, item_name)\n list.delete(item_name)\nend",
"def destroy\r\n @lineitem = Lineitem.find(params[:id])\r\n @lineitem.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(lineitems_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :ok }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ordered_item = OrderedItem.find(params[:id])\n @ordered_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(ordered_items_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @item ||= Item.find_by_id_or_name(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def delete(item_ids = [])\n body = { itemIds: item_ids }\n Iterable.request(conf, base_path).delete(body)\n end",
"def destroyItem(id)\n item = List.find(id)\n item.destroy\n end",
"def destroy\n @request = Request.find(params[:id])\n @request_items = @request.request_items\n @request_items.each do |ri|\n ri.destroy\n end\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to(requests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n listentries = List.find(:all,:conditions => \"list_cat_id = #{params[:id]}\")\n for listentry in listentries \n listentry.destroy\n end\n @list_cat = ListCat.find(params[:id])\n @list_cat.destroy\n\n respond_to do |format|\n format.html { redirect_to(:controller => 'lists') }\n format.xml { head :ok }\n end\n end",
"def delete_item(list_name,name)\n if storage.list_exists?(list_name)\n list = List.find(list_name)\n if list.delete_item(name)\n output \"#{cyan(\"Boom!\")} #{yellow(name)} is gone forever.\"\n save\n else\n output \"#{yellow(name)} #{red(\"not found in\")} #{yellow(list_name)}\"\n end\n else\n output \"We couldn't find that list.\"\n end\n end",
"def delete\n @@all_items.delete(@id)\n end",
"def destroy\n @email_list = EmailList.find(params[:id])\n @email_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(email_lists_url) }\n format.xml { head :ok }\n end\n end",
"def delete_list(user, list)\n delete(\"/#{user}/lists/#{list}.json\")\n end",
"def destroy\n @wish_list_item = WishListItem.find(params[:id])\n @wish_list_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(wish_list_items_url) }\n format.xml { head :ok }\n end\n end",
"def delitem(list, item)\n# input: list and key\n list.delete(item)\n# steps: delete a given key item\nend",
"def destroy\n @list_view = ListView.find(params[:id])\n @list_view.destroy\n\n respond_to do |format|\n format.html { redirect_to(list_views_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @list_of_value = Irm::ListOfValue.find(params[:id])\n @list_of_value.destroy\n\n respond_to do |format|\n format.html { redirect_to(list_of_values_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n item = @item.name\n @item.deleted = true\n @item.deleted_at = Time.now\n @item.save\n\n respond_to do |format|\n format.html { redirect_to items_url, notice: \"#{item} was successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@item.destroy\n\t\thead :no_content\n\tend",
"def remove(list, item_name)\r\n\tlist.delete(item_name)\r\n\tp list\r\nend",
"def destroy\n @data_list = DataList.find(params[:id])\n @data_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(data_lists_url) }\n format.xml { head :ok }\n end\n end",
"def delete_all(xpath); end",
"def destroy\n @item = current_user.lists.items.find(item_params)\n @item.destroy\n flash[:success] = \"Item deleted\"\n redirect_to current_user\n end",
"def destroy\n @mail_item = MailItem.find(params[:id])\n @mail_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(mail_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(current_user) }\n format.xml { head :ok }\n end\n end",
"def deleted(item)\n end"
] |
[
"0.6930925",
"0.691129",
"0.6884909",
"0.68283284",
"0.68153644",
"0.67423713",
"0.6675455",
"0.6659997",
"0.66557074",
"0.6648087",
"0.6647733",
"0.6635589",
"0.6635589",
"0.6635589",
"0.6635589",
"0.6635589",
"0.6635589",
"0.66337746",
"0.66323316",
"0.6629893",
"0.66055876",
"0.66005135",
"0.65731573",
"0.65731573",
"0.6561022",
"0.6549662",
"0.6547762",
"0.6542059",
"0.65146977",
"0.65079075",
"0.6505081",
"0.6500994",
"0.649201",
"0.6477145",
"0.6461527",
"0.6450147",
"0.6447843",
"0.64421004",
"0.64399815",
"0.64399815",
"0.64276433",
"0.6425774",
"0.6424842",
"0.6423872",
"0.6420059",
"0.6416573",
"0.6416573",
"0.6416368",
"0.6412674",
"0.6404034",
"0.6400651",
"0.639535",
"0.63842434",
"0.6378834",
"0.63771164",
"0.6373479",
"0.6354521",
"0.63530076",
"0.6350903",
"0.6348297",
"0.6346524",
"0.63449293",
"0.6342576",
"0.6339844",
"0.63381004",
"0.63362384",
"0.633476",
"0.6331797",
"0.6329405",
"0.6322731",
"0.63167846",
"0.6316585",
"0.6303416",
"0.63010556",
"0.63002175",
"0.6299151",
"0.6294061",
"0.62938315",
"0.62882763",
"0.62871337",
"0.6285737",
"0.62849796",
"0.62815714",
"0.6280846",
"0.62762153",
"0.6274484",
"0.6265661",
"0.6260423",
"0.6258952",
"0.62514424",
"0.6249963",
"0.62448525",
"0.6233009",
"0.62237954",
"0.6212699",
"0.62073094",
"0.6206938",
"0.62054557",
"0.6203888",
"0.6201139",
"0.61901987"
] |
0.0
|
-1
|
GET /comments/1 GET /comments/1.json
|
def show
#@comment = Comment.find(params[:id])
redirect_to "/home/index"
#respond_to do |format|
#format.html # show.html.erb
#format.json { render json: @comment }
#end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n @article = Article.find(params[:id])\n @comments = @article.comments\n\n respond_to do |format|\n format.html \n format.json { render json: @comments, status: :ok }\n end\n end",
"def show\n comment = Comment.find(params[:id])\n render json: comment, status: 200\n end",
"def comments; rest_query(:comment); end",
"def comments\n render json: @post.comments\n end",
"def show\n @comment = Comment.find(params[:id])\n render json:@comment\n end",
"def show\n user = User.find_by({token: env['HTTP_TOKEN']})\n render json: user.comments.find(params[:id])\n end",
"def show\n # comment = Comment.find_comment\n render json: @comment\n end",
"def show\n comment = Comment.find_by(id: params[:id])\n render json: comment\n end",
"def show\n @comment = @commentable.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n comment = Comment.find(params[:id])\n render json: comment, status: :ok\n end",
"def show\n @comments = @post.comments\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def index\n @comments = @commentable.comments\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def index\n comments = @project.comments\n render json: comments\n end",
"def index\n @post = Post.find_by_id(params[:post_id])\n if @post.nil?\n return render json: { error: \"Post not found\" }, status: :not_found\n end\n render json: @post.comments,status: 200\n end",
"def show\n @comment1 = Comment1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment1 }\n end\n end",
"def index\n @comments = DiscussionComment.all\n render json: @comments\n end",
"def get_comment(comment_id)\n get(\"comments/#{comment_id}\")\n end",
"def index\n @comments = Comment.all\n render json: @comments\n end",
"def index\n if params[:comment_id].nil?\n render json: {\n comments: @card.comments.paginate(page: params[:page], per_page: 3)\n }, statues: :ok\n else\n @comment = Comment.find(params[:comment_id])\n render json: {\n comment: @comment,\n replaies: @comment.replaies.paginate(page: params[:page], per_page: 3)\n }, statues: :ok\n end\n end",
"def list\n comments = Comment.where(post: @post)\n render json: comments, status: 200\n end",
"def show\n @comment = @posting.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def index\n #@comments = Comment.all\n comments = @blog.comments\n render json: comments, status: :ok\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 render json: comment\n end",
"def show\n render json: @comment\n end",
"def GetComments id,params = {}\n\n params = params.merge(path: \"tickets/#{id}/comments.json\")\n APICall(params)\n\n end",
"def index\n comments = @post.comments\n render json: { comments: comments }\n #loop through comments and find first and last name by user_id\n #User.find....etc\n end",
"def show\n @comment = Comment.find(params[:id])\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def get_comment\n @comment = Comment.find(params[:id])\n end",
"def all_comments\n render :json => User.find(params[:user_id]).comments\n end",
"def comment\n Comment.find(params[:id])\n end",
"def show\n @comment = Comment.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n \tend\n end",
"def index\n @comments = Comment.where('user_id = ?', current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def comments_for(url)\n get_data(\"comments/show/#{FORMAT}?url=#{url}\")\n end",
"def comments(options={})\n parse_comments(request(singular(id) + \"comments\", options))\n end",
"def index\n @comments = Comment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def index\n @comments = Comment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def index\n @comments = Comment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def show\n render json: { comment: @comment, replaies: @comment.replaies }, status: :ok\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n end\n end",
"def index\n logger.info(\"comments got index! #{params}\");\n @comments = Comment.find_by_post_id(params[:post_id])\n respond_with @comments\n end",
"def details(id, params = {})\n wrike.execute(:get, api_url(\"comments/#{id}\"), params)\n end",
"def comments\n Birdman::ApiPaginatedCollection.new(\"movies/#{id}/comments\")\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 @comments = Recipe.find(params[:recipe_id]).comments.all\n @comment = Recipe.find(params[:recipe_id]).comments.find(params[:id]) \n if @comment \n respond_to do |f|\n f.html {render :index}\n f.json {render json: @comment}\n end\n else\n @comments\n respond_to do |f|\n f.html {render :index}\n f.json {render json: @comments}\n end\n end\n end",
"def show\n @comments = @servidor.comments.order(\"id DESC\").page(params[:page]).per(3)\n end",
"def index\n @post = Post.find(params[:post_id])\n @comments = @post.comments\n\n render json: @comments, include: ['user']\n end",
"def comment(options)\n get(\"/content/items/#{options.delete(:item)}/comments/#{options[:id]}\",options)\n end",
"def show\n @comment = @song.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find_by_permalink(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def index\n @comments = @entry.comments\n respond_with(@comments)\n end",
"def index\n @comments = @post.comments.order(created_at: :desc)\n render json: @comments, status: :ok\n\n 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 render json: @comment, status: :ok\n\n end",
"def show\n @new_comment = Comment.build_from(@post, \"\")\n\n render json: @post, status: 200\n\n\n end",
"def show\n recipe = Recipe.find_by_id(params[:id])\n\n respond_to do |format|\n if recipe\n @comments = []\n comments = recipe.comments\n for comment in comments\n comment_user = comment.user\n @comments << { :user => comment_user, :profile_picture => comment_user.profile_picture.url, :comment => comment }\n end\n\n format.json { render :json => @comments }\n else\n format.json { render :status => 404, :json => { :message => \"No such Recipe\"}}\n end\n end\n end",
"def index\n @comments = @complaint.comments\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @comments }\n format.js\n end\n end",
"def index\n comments = list.comments.desc(:created_at)\n comments = comments[5, (comments.length-1)]\n\n render json: comments\n end",
"def show\n @comments = Comment.where(post_id: params[:id])\n end",
"def gist_comments(id)\n get \"/gists/#{id}/comments\"\n end",
"def show\n logger.info(\"comments got show! #{params}\");\n @comments = Comment.find_by_post_id(params[:post_id])\n respond_with @comments\n end",
"def index\n event = Event.find(params[:event_id])\n render json: event.comments, status: :ok\n end",
"def comments\n expose Challenge.comments(@oauth_token, params[:challenge_id].strip)\n end",
"def show\n if @comment.nil?\n render json: {error: \"Not Found\"}, status: :not_found\n else\n render json: @comment, status: :ok\n end\n end",
"def get_comments(user_name)\n uri = create_api_uri(@@base_uri, user_name, 'getComments')\n return get(uri)\n end",
"def index\n @comments = Comment.order(\"created_at DESC\")\n render json: @comments, status: :ok\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 view_comment\n @comment = Comment.find(params[:id])\n end",
"def show\n @comment_relationship = CommentRelationship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment_relationship }\n end\n end",
"def index\n @comments = @commentable.comments\n end",
"def index\n # @post = Post.find(params[:post_id])\n @comments = @post.comments\n end",
"def show\n @comment = @complaint.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n format.js\n end\n end",
"def show\n @messages_comment = MessagesComment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @messages_comment }\n end\n end",
"def getComment(response)\r\n\t\t\t\r\n\t\t\t\tjsonObject = JSON.parse response\r\n\t\t\t\t\r\n\t\t\t\tcomments = jsonObject[\"comments\"]\r\n\t\t\t\t\t\r\n\t\t\t\treturn jsonToComment(comments[0])\r\n\t\t\t\r\n\t\t\tend"
] |
[
"0.8280257",
"0.74416476",
"0.74416476",
"0.7434451",
"0.7404793",
"0.7303314",
"0.7282542",
"0.72574276",
"0.72542727",
"0.72470427",
"0.7242218",
"0.7219159",
"0.7217871",
"0.72176784",
"0.71734184",
"0.7157483",
"0.7156849",
"0.71178067",
"0.7117778",
"0.71012414",
"0.70996296",
"0.709326",
"0.7075605",
"0.70607615",
"0.70469993",
"0.7041377",
"0.7026612",
"0.70096487",
"0.6991003",
"0.6973729",
"0.696011",
"0.6952527",
"0.69522464",
"0.6913443",
"0.691221",
"0.69052315",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68968195",
"0.68965167",
"0.6881779",
"0.68767893",
"0.686565",
"0.686565",
"0.686565",
"0.6864471",
"0.6860159",
"0.6860159",
"0.6860159",
"0.6856828",
"0.6856264",
"0.68498874",
"0.68280095",
"0.68225616",
"0.680551",
"0.6802573",
"0.6793266",
"0.67866015",
"0.67826325",
"0.67652863",
"0.6764235",
"0.6757986",
"0.6744526",
"0.67398757",
"0.6724224",
"0.67201436",
"0.67125",
"0.6704979",
"0.6696969",
"0.6691325",
"0.66872007",
"0.66822386",
"0.6681735",
"0.6668344",
"0.6667345",
"0.66317564",
"0.6625409",
"0.6619273",
"0.66192627",
"0.66190165",
"0.66184336",
"0.661762",
"0.6614873"
] |
0.0
|
-1
|
GET /comments/new GET /comments/new.json
|
def new
#@comment = Comment.new
redirect_to "/home/index"
#respond_to do |format|
#format.html # new.html.erb
#format.json { render json: @comment }
#end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @comment = @commentable.comments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = @posting.comments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @comment }\n end\n end",
"def new\n load_data\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = @parent.comments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n if params[:recipe] != nil\n @recipe = Recipe.find(params[:recipe].to_i)\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment_node = CommentNode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @comment_node }\n end\n end",
"def new\n @comment = Comment.new :task_id => params[:task_id], :user_id => current_user.id\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = @song.comments.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @post = Post.where(id: params[:post_id]).first\n @comment = @post.comments.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment_relationship = CommentRelationship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment_relationship }\n end\n end",
"def new\n unless current_user.try(:admin?)\n redirect_to \"/\"\n end\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new(options_for_commentable)\n respond_to do |format|\n format.html { render layout: false } # new.html.erb\n format.json { render json: @users }\n end\n end",
"def new\n @bug_comment = BugComment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bug_comment }\n end\n end",
"def show\n @new_comment = Comment.build_from(@post, \"\")\n\n render json: @post, status: 200\n\n\n end",
"def new\n @messages_comment = MessagesComment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @messages_comment }\n end\n end",
"def new\n comment = Comment.new(comment_params)\n render_ajax locals: {comment: comment}\n end",
"def new\n @comment = Comment.new\n @meta[:title] = 'New comment'\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = @story.comments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @story_comment = StoryComment.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @story_comment }\n end\n end",
"def new\n @talk_comment = TalkComment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @talk_comment }\n end\n end",
"def new\n @user = User.find(params[:user_id])\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n# @task = Task.find(params[:task_id])\n# @task.comments.new(params[:comment]) \n @comment = Comment.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n return false unless authorize(permissions = [\"create_comment\"])\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @project_comment = ProjectComment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @project_comment }\n end\n end",
"def new\n @comment = Comment.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @dish_comment = @dish.dish_comments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dish_comment }\n end\n end",
"def new\n @comment1 = Comment1.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment1 }\n end\n end",
"def new\n @comment = Comment.new\n session[:postid] = params[:postid]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new(recipe_id: params[:recipe_id])\n render :_ajax_new, layout: false\n end",
"def new\n @comment = @complaint.comments.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @comment }\n format.js\n end\n end",
"def new\n @comment = Comment.new(:parent_id => params[:parent_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.js\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n @task_id = params[:task_id]\n if(@task_id)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n else\n redirect_to projects_path, notice: \"can't create independent comments\"\n end\n end",
"def new\n @comment_vote = CommentVote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment_vote }\n end\n end",
"def new\n @comment_vote = CommentVote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment_vote }\n end\n end",
"def new\n @comment_vote = CommentVote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment_vote }\n end\n end",
"def new\n @restaurant_comment = @restaurant.restaurant_comments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restaurant_comment }\n end\n end",
"def new\n @comments_course_post = CommentsCoursePost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comments_course_post }\n end\n end",
"def new\n @casualcomment = Casualcomment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @casualcomment }\n end\n end",
"def new\n @goal_comment = GoalComment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal_comment }\n end\n end",
"def new\n @comment = current_user.comments.build # crea comentario vacío asociado a current_user\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @imgcomment = Imgcomment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @imgcomment }\n end\n end",
"def new\n respond_with @comment\n end",
"def new\n @comment = @network.comments.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @page_title = \"New Comment\"\n @comment = current_recipe.comments.build\n @btnText = \"Add Comment\"\n @obj = @comment\n respond_to do |f|\n f.html {render 'shared/form'}\n f.js\n end\n end",
"def new\t\n\t @comment = Comment.new\t\t\n\tend",
"def new\n @note = Note.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @notes }\n end\n end",
"def new_comment\n if user_signed_in?\n @comment = Comment.create!(:comment => params[:comment])\n @comment.idea_id = params[:idea_id]\n \n if params[:parent_id] && params[:parent_id] != 0\n @comment.parent_id = params[:parent_id]\n end\n \n @comment.user_id = current_user.id\n @comment.save\n \n respond_to do |format|\n format.json { render :json => @comment, :status => :created }\n end\n end\n end",
"def new\n @new_review = NewReview.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_review }\n end\n end",
"def new\r\n @comment = @commentable.comments.new\r\n end",
"def new\n @comment = Comment.new\n end",
"def new\n @comment = Comment.new\n end",
"def new\n @comment = Comment.new\n\t\t\n\t\t#@name = params[:name] #make a variable visible in views, have to use instance variable\n\t\t@blog_id = params[:blog_id] #instance variable of blog_id for passing param into URL\n\t\tRails.logger.info \"BLOG_ID = #{@blog_id}\" #Logging the ID to the Command Line for debugging\n\t\t\n\t\t@blog = Blog.find(@blog_id) #accessing blog id that's passed through query string variable to get the row where ID = the id passed\n\t\t#Used to add the name of the blog to the <h3> as a title to identify which blog users are writing the comment for\n\t\t\n\t\t#Could also do this to be DRY: @blog = Blog.find(params[:blog_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = @commentable.comments.new\n end",
"def new\n @post = Post.find(params[:post_id])\n @comment = @post.comments.new\n end",
"def new\n @comment = @task.comments.new(user_id: current_user.id)\n respond_to do |format|\n format.js\n end\n end",
"def new\n @note = Note.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @note }\n end\n end",
"def new\n @note = Note.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @note }\n end\n end",
"def new\n @note = Note.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @note }\n end\n end",
"def new\n @note = Note.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @note }\n end\n end",
"def new\n @comment = @parent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n\n @comment = Comment.new\n @reply_to = nil\n\n # if we're replying to something\n if params.key?('reply_to')\n begin\n # grab comment\n @reply_to = Comment.find(params[:reply_to])\n @comment.reply_to_id = @reply_to.id\n\n # add comment text to the current comment\n @comment.comment = '> '+@reply_to.comment.gsub(/^>(.*?)\\n/m, '').strip.gsub(/\\n\\n+/, \"\\n\\n\").gsub(/\\n/, \"\\n> \")\n rescue\n end\n end\n\n unless cookies[:comment_details].nil?\n begin\n data = JSON.parse(cookies[:comment_details])\n @comment.name = data[\"name\"] unless data[\"name\"].nil?\n @comment.email = data[\"email\"] unless data[\"email\"].nil?\n @comment.website = data[\"website\"] unless data[\"website\"].nil?\n @comment.save_deets = true\n rescue\n end\n end\n\n end",
"def new\n @comment = @commentable.comments.build(:user => current_user, :email => current_user.email)\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def create\n @new_comment = post.comments.new(comment_params)\n @new_comment.user = current_user\n\n respond_to do |format|\n if @new_comment.save\n format.html { redirect_to post, notice: I18n.t('controllers.comments.created') }\n format.json { render :show, status: :created, location: post }\n else\n format.html { redirect_to post, alert: I18n.t('controllers.comments.error') }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @comment = Comment.new(:parent_id => params[:parent_id])\n\n respond_to do |format|\n format.html do\n render :layout => false if params[:no_layout]\n end\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n if (params[:post_id] != nil)\n\t\t@comment.ppost_id = params[:post_id]\n\tend\n\tif ( params[:comment_id] != nil) \n\t\t@comment.ppost_id = Comment.find(params[:comment_id]).ppost_id\n\t\t@comment.pc_id = params[:comment_id]\n\tend\n\t\n respond_to do |format|\n\t\tif (current_user == nil)\n\t\t\tformat.html { redirect_to :login, notice: 'Please login to comment.' }\n\t\tend\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @discussion = Discussion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @discussion }\n end\n end",
"def new\n @discussion = Discussion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @discussion }\n end\n end",
"def new\n @discussion = Discussion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @discussion }\n end\n end",
"def new\r\n\t\t@comment = Comment.new(:parent_id => params[:comment_id])\r\n\tend",
"def new\n\n @comment = Comment.new\n @comment.commit_sha = session[:patch_id]\n @comment.block = params[:block]\n @comment.line = params[:line]\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.js { render \"new.html\", :layout => false }\n wants.xml { render :xml => @comment }\n end\n\n end",
"def new\n @note = Note.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @note }\n end\n end",
"def new\n @meetup_comment = MeetupComment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meetup_comment }\n end\n end"
] |
[
"0.8087922",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8074817",
"0.8012823",
"0.80119",
"0.80119",
"0.80058974",
"0.76914775",
"0.7650126",
"0.7645689",
"0.75123835",
"0.7483091",
"0.74653053",
"0.7458038",
"0.74061126",
"0.73712575",
"0.73598677",
"0.73400784",
"0.73377717",
"0.733695",
"0.7295392",
"0.72909766",
"0.7278397",
"0.7277434",
"0.7275747",
"0.72713387",
"0.7265118",
"0.7264603",
"0.7262278",
"0.72545534",
"0.72545534",
"0.72545534",
"0.72545534",
"0.72545534",
"0.72545534",
"0.72545534",
"0.72545534",
"0.72545534",
"0.72545534",
"0.72545534",
"0.72545534",
"0.7252999",
"0.72281593",
"0.7224553",
"0.722202",
"0.7131717",
"0.71229154",
"0.7116237",
"0.7104078",
"0.70988613",
"0.70988613",
"0.70988613",
"0.70629424",
"0.7062751",
"0.7051253",
"0.7024414",
"0.7015513",
"0.6977369",
"0.69721615",
"0.69404465",
"0.6934263",
"0.6870035",
"0.68635696",
"0.6862236",
"0.6844619",
"0.6827822",
"0.68272024",
"0.68272024",
"0.6823653",
"0.68037224",
"0.68013984",
"0.6796586",
"0.6789437",
"0.6789437",
"0.6789437",
"0.6789437",
"0.6786654",
"0.67824596",
"0.6757238",
"0.67548734",
"0.6754191",
"0.6740768",
"0.67235976",
"0.67235976",
"0.67235976",
"0.6712509",
"0.670543",
"0.6700444",
"0.668996"
] |
0.71943396
|
56
|
POST /comments POST /comments.json
|
def create
@comment = Comment.new(params[:comment])
@comment.user_id = current_user.id
@comment.modifier = current_user.id
respond_to do |format|
if @comment.save
#redis保存评论数
ask_answers_comments_count @comment.answer.ask_id
@one_comment = OneComment.new(@comment)
@answer_id = @comment.answer_id
@state = "OK"
answer_id = @answer_id.to_s
$redis.zincrby("answer_comments_count", 1, answer_id)
format.js
else
@state = "Error"
format.js
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @comment = @post.comments.new(comment_params)\n if @comment.save\n render json: @comment, status: :created\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n\n end",
"def comment options={}\n client.post(\"/#{id}/comments\", options)\n end",
"def create\n post = Post.find(params[:post_id])\n @comment = post.comments.new(comment_params)\n if @comment.save\n render json: {\n data: @comment\n }\n else\n render json: {\n errors: @comment.errors\n }\n end\n end",
"def create\n puts params.to_json\n @post = Post.find(params[:comment][:post_id])\n @comment = @post.comments.build(comment_params)\n if @comment.save\n redirect_to root_path\n end\n end",
"def create\n comment = Comment.new(comment_params)\n\n post = Post.find(params[:comment][:post_id])\n post.data[\"comments\"] = post.data[\"comments\"] + 1\n\n if comment.save && post.save\n render json: {\n status: \"success\",\n data: {\n comment: comment.as_json(include: {\n user: {\n only: [:id, :name, :avatar]\n }\n }),\n comments: post.data[\"comments\"]\n }\n }, status: :ok\n else\n render json: comment.errors, status: 404\n end\n end",
"def create\n @comment = Comment.new(params[:comment])\n @comment.save\n respond_with(@post, @comment)\n end",
"def create\n json_create_and_sanitize(comment_params, Comment)\n end",
"def create\n comment = Comment.new(create_params)\n comment.post = @post\n if comment.save\n render json: comment, status: 200\n else\n render json: comment.errors, status: 403\n end\n\n end",
"def create\n # get the post\n @post = Post.find_by_id(params[:post_id])\n if @post.nil?\n return render json: { error: \"Post not found\" }, status: :not_found\n end\n # create post to comment\n @comment = @post.comments.create(body: params[:body])\n # associate comment before save(comment cannot be saved without user_id)\n @comment.user = @current_user\n # save comment\n if @comment.save\n render json: @comment, status: :ok\n else\n render json: { errors: { status: \"400\",\n title: \"Bad request\",\n details: @comment.errors\n }\n }, status: :bad_request\n end\n end",
"def create\n @new_comment = post.comments.new(comment_params)\n @new_comment.user = current_user\n\n respond_to do |format|\n if @new_comment.save\n format.html { redirect_to post, notice: I18n.t('controllers.comments.created') }\n format.json { render :show, status: :created, location: post }\n else\n format.html { redirect_to post, alert: I18n.t('controllers.comments.error') }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new({user_id: params[:user_id], announcement_id: params[:announcement_id], description: params[:description]})\n @comment.save\n render json:@comment\n end",
"def create\n @comment = @noticia.comments.create(comment_params)\n\n if @comment.save\n render json: @comment, status: :created\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def create\n #if @user && @user.posts.include(@post)\n @comment = @post.comments.create!(comment_params)\n json_response(@comment, :created)\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.json { render :show, status: :created, location: @comment }\n else\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = current_user.comments.new(comment_params)\n @comment.user_id = current_user.id\n if @comment.save\n render json: @comment\n else\n render :json => @comment.errors\n end\n end",
"def create\n comment = @project.comments.build(comment_params)\n\n if comment.save\n render json: comment \n else\n render json: { message: 'Error: Failed to add comment.'}\n end\n end",
"def create\n @comment = @user.comments.build(@json['comment'])\n update_values :@comment, @json['comment']\n end",
"def create\n @post = Post.where(id: params[:post_id]).first\n @comment = @post.comments.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @post, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def comments\n render json: @post.comments\n end",
"def create\n @blogpost = Blogpost.find(params[:blogpost_id])\n\n @comment = @blogpost.comments.create(comment_params)\n render json: @comment\n end",
"def create\n @comment = Comment.new(comment_params)\n respond_to do |format|\n if @comment.save\n format.json {\n render json: {status:0, msg:\"success\"} \n }\n else\n \tformat.json { \n render json: {status:-1, msg:\"failed\"} \n }\n end\n end\n end",
"def create\n @radio = Radio.find(params[:radio_id])\n comment = @radio.comments.create({:body => params[:comment], :user_id => current_user.id});\n respond_to do |format|\n format.json { render :json => to_commentDTO(comment), :status => :ok }\n end\n end",
"def create\n @comment = Comment.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to comments_url, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n session = UserSession.find_by_authentication_token(params[:authentication_token])\n user = session.user\n \n respond_to do |format|\n if user\n @comment = Comment.new(:user_id => user.id, :recipe_id => params[:recipe_id], :text => params[:text])\n \n if @comment.save\n recipe = Recipe.find_by_id([params[:recipe_id]])\n\n @comments = recipe.fetch_comments\n format.json { render :json => { :comments => @comments, :message => \"success\"} }\n else\n format.json { render :status => 500, :json => { :message => \"There was an error uploading your comment.\" }}\n end\n else\n format.json { render :json => { :message => \"Invalid authentication token\"}} \n end\n end\n end",
"def create\n @comment = Comment.new(post_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to root_path, notice: 'Post was successfully created.' }\n format.json { render root_path, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.build(params[:comment])\n respond_to do |format|\n if @comment.save\n format.json { render :json => @comment }\n else\n format.json { render :json => @comment.errors, :status => :unprocessable_entity}\n end\n end\n #respond_with(@post,@post.comments.create(params[:comment]))\n end",
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def create\n \tnew_comment = params.require(:comment).permit(:body)\n \tpost = Post.find(params[:post_id])\n \tcomment = post.comments.create(new_comment)\n\n \tredirect_to post_comment_path(post, comment)\n end",
"def create\n @comment = @secret.comments.build(comment_params)\n @comment.user_id = current_user.id.to_s\n if @comment.save\n comment = CommentModel.new(@comment, current_user)\n render json: comment\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n @comment.user_id = @current_user.json_hash[:id]\n @comment.dinner_id = params[:id]\n if @comment.valid?\n @comment.save\n render json: @comment.comment_info\n else\n puts @comment.errors.messages.inspect\n render status: :bad_request, json: {\n errors: @comment.errors.messages\n }\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n @comment.user = current_user\n if @comment.save\n render json: @comment\n # redirect_to recipe_path(@comment.recipe.id, @comment)\n else\n render \"recipes/show\"\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.create(content: params[:content])\n current_user.comments << @comment\n current_user.save\n\n idea = Idea.find(params[:ideaId])\n idea.comments << @comment\n idea.comments.order(\"created_at DESC\")\n idea.save\n respond_to do |format|\n format.json {render json: @comment}\n end\n end",
"def create\n @comment = Comment.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to admin_comments_url, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = current_user.comments.build(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to \"/posts/#{@comment.post_id}\" }\n format.json { render :show, status: :created, location: @comment }\n else\n errors = @comment.errors.full_messages.join('! ')\n format.html { redirect_to \"/posts/#{@comment.post_id}\", alert: \"Comment was failly created!\\n#{errors}!\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n\n\n end",
"def create\n @comment = @parent.comments.new(params[:comment])\n @comment.user_id = session[:user_id]\n\n respond_to do |format|\n if @comment.save\n @comment.update_post\n format.html { redirect_to post_path(@comment.post), notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n post_comment(@comment)\n format.html { redirect_to @comment.article, notice: 'Comment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @comment }\n else\n format.html { render action: 'new' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(\n name: params[:name],\n content: params[:content],\n post: Post.find(params[:post_id])\n )\n # @comment = Comment.new(comment_params)\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment.post, notice: \"comment was created.\" }\n else\n puts @comment.errors\n format.html { redirect_to post_path(params[:post_id]) }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #@comment = Comment.new(comment_params)\n @comment = @blog.comments.new(comment_params)\n \n if @comment.save\n render json: @comment, status: :created\n else\n render json: {\n error: @comment.errors.full_messages\n }, status: :unprocessable_entity\n end\n end",
"def create\n @comment = @post.comments.build(comment_params)\n @comment.user_id = current_user.id\n @comment.post_id = @post.id\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @post, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_comments\n end",
"def create_comments\n end",
"def create_comments\n end",
"def create\n @comment = Comment.new(comment_params)\n @post = Post.find(@comment.post_id)\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @post, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\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 @comment = Comment.new\n @comment.content = params[:content]\n @comment.post_id = params[:post_id]\n @comment.user_id = current_user.id\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to root_path, notice: \"Comment was successfully created.\" }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { redirect_to root_path, notice: \"Por favor añada contenido a su comentario.\" }\n end\n end\n end",
"def create\n comment = Comment.new(params[:comment])\n @entry.comments << comment if comment.valid?\n respond_with(comment, location: redirect_to_index)\n end",
"def create\n\n \t\t\t@comment = Comment.new comment_params\n\n @comment.user_id = current_user.id\n\n \t\t\tif @comment.save\n\n \t\t\t\trender json: @comment,status: :created\n\n \t\t\telse\n\n \t\t\t\trender json: {error: true,errors: @comment.errors},status: :unprocessable_entity\n\n \t\t\tend\n\n \t\tend",
"def show\n @new_comment = Comment.build_from(@post, \"\")\n\n render json: @post, status: 200\n\n\n end",
"def create\n if params.present?\n Comment.create(name: params[:author], description: params[:text], rating: params[:rating])\n end\n render json: {success: \"Sucessfully Commented\"}\n end",
"def create_comment\n unless user_signed_in?\n render status: 403, json: { message: 'Please sign in to add a comment.' }\n end\n\n comment_params = params.permit(:content, :id)\n new_comment = Comment.create!(\n content: comment_params.require(:content),\n post_id: comment_params.require(:id),\n user_id: current_user.id\n )\n render status: :created, json: new_comment\n end",
"def create\n @comment = Comment.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment.generic_item, :notice => t('notice.successfully_created') }\n format.json { render :json => @comment, :status => :created, :location => @comment }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\r\n\t\t#create new comment\r\n\t\t@comment = Comment.new(comment_params)\r\n\t\tif @comment.save\r\n\t\t\t#if save success send js handles the rest\r\n\t\t\t@post = @comment.post\r\n\t\t\trespond_to :js\r\n\t\telse\r\n\t\t\t# if fails alert user\r\n\t\t\tflash[:alert] = \"Something went wrong\"\r\n\t\tend\r\n\tend",
"def create\n @comment = Comment.new(params[:comment])\n @posts = Post.find_all_by_id(@comment.post_id)\n @comment.user_id = session[:user_logged_in]\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @posts, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(params[:comment]) #has a hash called comment, passes initial values\n\n respond_to do |format|\n if @comment.save # Goes in here and saves it to the DB\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n :authenticate_user!\n @comment = Comment.create!(comment_params)\n respond_with @comment\n end",
"def create\n @comment = current_user.comments.build(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = @repository.comments.new(params.require(:comment).permit(:body))\n @comment.author = current_user\n authorize @comment\n\n if @comment.save\n respond_with(@comment)\n else\n respond_with @comment.errors, status: :unprocessable_entity\n end\n end",
"def create\n @comment = @idea.comments.build(comment_params)\n @comment.user = current_user\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @idea, notice: 'Your comment has been recorded' }\n format.json { render action: 'show', status: :created, comment: @comment }\n else\n format.html { render action: 'new' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def comment_params\n if request.format.json?\n return params.permit(:post_id, :body)\n end\n params.require(:comment).permit(:user_id, :post_id, :body)\n end",
"def create_comment(comment)\n post_params = {\n :body => comment.post_json,\n :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'})\n }\n\n response = Logan::Client.post \"/projects/#{@project_id}/todos/#{@id}/comments.json\", post_params\n Logan::Comment.new response\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.create(params[:comment])\n @comment.researcher = logged_in_researcher\n\n if @comment.save\n respond_to do |format|\n format.html { redirect_to post_path(@post), :notice => \"Comment was successfully added.\" }\n format.xml { render :xml => @comment, :status => :created, :location => @comment}\n format.json { render :json=> @comment, :status => :created, :location => @comment}\n end\n else\n respond_to do |format|\n format.html { redirect_to post_path(@post), :alert => \"Failed to add comment: #{@comment.errors.full_messages.join(', ')}\" }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n format.json { render :json=> @comment.errors, :status => :unprocessable_entity }\n end \n end\n end",
"def create\n @comment = @question.comments.create(comment_params)\n redirect_to question_path(@question)\n end",
"def post_comment(comment, poi=\"4f4f4c27d4374e800100001d\")\n uri = URI.parse(\"http://mashweb.fokus.fraunhofer.de:3008/api/comment\")\n response = Net::HTTP.post_form(uri, {\n :title => 'Autocomment',\n :body => comment\n })\n end",
"def create\n @comment = Comment.new(params[:comment])\n\t\t@comment.user_id = session[:userid]\n @comment.save\n\t\trespond_with @comment, :location => @comment.post\n end",
"def create\n @comment = @issue.comments.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @issue_path, notice: 'Comment is succesfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@comment = Comment.new()\n\t\t@comment.comment = params[:comment] \n\t\t@comment.user = current_user\n\t\t@comment.save\n\t\t\n\t\t@resource_comment = ResourceComment.new()\n\t\t@resource_comment.resource_path = params[:path]\n\t\t@resource_comment.comment_id = @comment.id\n\t\t@resource_comment.save\n\t\tif(@resource_comment)\n\t\t\trespond_with(@comment)\n\t\telse\n\t\t\trender json: {error: \"something went wrong while creating resource comment\"}\n\t\tend\n end",
"def create\n comment = Comment.new(params[:comment])\n @articles_comments_service.create_comment(comment)\n end",
"def create\n @user = User.find(params[:user_id])\n @comment = @user.comments.build(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to user_path(@user.id), notice: 'Your comment has been submitted' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment_node = CommentNode.new(params[:comment_node])\n\n respond_to do |format|\n if @comment_node.save\n format.html { redirect_to @comment_node, :notice => 'Comment node was successfully created.' }\n format.json { render :json => @comment_node, :status => :created, :location => @comment_node }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @comment_node.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = current_user.comments.new(comment_params)\n @comment.post_id = params['post_id']\n # @comment.parent_id = params[:parent_id]\n\n respond_to do |format|\n if @comment.save\n flash[:notice] = t('comment.create_success_mesg')\n @post = Post.find(params['post_id'])\n @all_comments = @post.comments.paginate(page: params[:page])\n format.html\n format.json { render :show, status: :created, location: @comment }\n format.js\n else\n flash[:notice] = t('comment.create_unsuccessful_msg')\n format.html\n format.json {\n render json: @comment.errors, status: :unprocessable_entity\n }\n format.js \n end\n end\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.create(comment_params)\n redirect_to post_path(@post)\n end",
"def post_comment(request)\n data, _status_code, _headers = post_comment_with_http_info(request)\n request_token if _status_code == 401\n data\n end",
"def comment #create comment\n comment = Comment.new\n if comment.create_comment(params[:body], params[:video_id])#calling create_comment method of Comment model\n respond_with do |format|\n format.json {render :json => {:success => true, :message => \"comment successfully posted\"}}\n end\n else\n respond_with do |format|\n format.json {render :json => {:success => false}}\n end\n end\n end",
"def index\n post = Post.find(params[:post_id])\n comments = post.comments.order(updated_at: :desc)\n @comment = Comment.new\n\n @comments = comments.map do |comment|\n {\n content: comment.content,\n created_at: comment.created_at.strftime('%Y-%m-%d %H:%M:%S')\n }\n end\n\n render json: {\n data: {\n comments: @comments,\n new_comment: @comment,\n }\n }\n end",
"def new_comment(name, discussion_id)\n response = self.class.post(\n @@base_uri + @@comments_uri,\n body: {\"comment\":{\"body\":name,\"discussion_id\":discussion_id,\"document_ids\":[]}}.to_json,\n headers: @headers\n )\n return response\n end",
"def create\n @comment = Comment.new :body => params[:comment][:body],\n :issue => false\n @comment.polycomment_type = params[:polycomment_type]\n @comment.polycomment_id = params[:polycomment_id]\n @comment.user_id = current_user.id \n if @comment.save\n #flash[:notice] = 'Your comment was posted!'\n redirect_to :back\n else\n flash[:alert] = 'Something went wrong, try reposting your comment.'\n end\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.create!(comment_params)\n\n redirect_to post_path(@post)\n end",
"def create\n @comment = Comment.new(comment_params)\n @comment.save\n end",
"def create\n @comment = @post.comments.build(params[:comment])\n \n respond_to do |format|\n if @comment.save\n flash[:notice] = 'Post was successfully created.'\n format.html { redirect_to(posts_url) }\n format.xml { render :xml => @comment, :status => :created, :location => @comment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n user = User.find_by({token: env['HTTP_TOKEN']})\n comment = user.comments.find(params[:id])\n comment.update(comment_params)\n render json: comment\n end",
"def comments\n @article = Article.find(params[:id])\n @comments = @article.comments\n\n respond_to do |format|\n format.html \n format.json { render json: @comments, status: :ok }\n end\n end",
"def add\n @comment = Comment.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n # format.html { redirect_to comments_url, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @task_comment = Task::Comment.new(task_comment_params)\n\n respond_to do |format|\n if @task_comment.save\n format.html { redirect_to @task_comment, notice: \"Comment was successfully created.\" }\n format.json { render :show, status: :created, location: @task_comment }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @task_comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.new(comment_params)\n @comment.user_id = current_user.id\n @comment.save\n\n respond_to do |format|\n format.js\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment.article, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @article.comments << Comment.new(comment_params)\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to article_show_path(@article), notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @article }\n else\n format.html { render :new }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end",
"def comment_creation_params\n params.require(:comment).permit(:cardset_id, :card_id, :user_id, :user_name, :posttime, :body, :status)\n end",
"def create\n \t# collects nested attributes, for post & comment, from params\n new_post = params.require(:post).permit(:body, :link, comments_attributes: [:body])\n\n \tpost = Post.create(new_post)\n \tredirect_to post_path(post.id)\n end",
"def create\n @commentable = find_commentable\n @comment = @commentable.comments.build(params[:comment]) do |comment|\n comment.access = current_access\n end\n if @comment.save\n flash.now[:notice] = t('comment.added')\n Rails.logger.info @comment.inspect\n @counter = @commentable.comments.count\n respond_with @comment\n else\n Rails.logger.info @comment.errors.messages\n flash.now[:error] = t('comment.added.error')\n end\n end",
"def new\n @comment = @commentable.comments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def create_comment\n @user = User.find(params[:user_id])\n @message = Message.find(params[:message_id])\n @comment = @message.comments.create(params.permit(:content))\n @comment.user = @user\n @comment.user_name = @user.id\n @comment.user_avatar = @user.id\n\n if @comment.save\n response = { \"code\" => 1, \"msg\" => \"Comment Created Successfully\" }\n else\n response = { \"code\" => 0, \"msg\" => \"Comment Can't be created\" }\n end\n\n render json: response\n end",
"def create \n @comment = @post.comments.new(params[:comment])\n @comment.user_id = current_user.id\n respond_to do |format|\n if @comment.save\n format.js { \n flash[:notice] = 'Comment was successfully created.' \n }\n else\n format.js { \n flash[:error] = @comment.errors.full_messages.join('<br/>')\n }\n end\n end\n @comments = @post.comments.created_at_order\n end",
"def add_new_comment\n\t# Get the object that you want to comment\n\tcommentable = Post.find(params[:id])\n\n\t# Create a comment with the user submitted content\n\tcomment = Comment.new(comment_params)\n\t# Add the comment\n\tcommentable.comments << comment\n\t@comments = commentable.comments\n respond_to do |format|\n\t format.html { redirect_to root_path }\n\t format.js\n\tend\n end",
"def create\n @post = Post.find params[:id]\n @comment = @post.comments.create comment_params\n @comment.user_id = current_user.id\n\n if @comment.save\n redirect_to \"/post/\" + params[:id]\n else\n flash[:danger] = \"No success\"\n redirect_to \"/\"\n end\n end",
"def create\n @comment = @parent.comments.build(comment_params_with_user)\n authorize @comment\n\n if @comment.save\n CommentCreatedMailJob.perform_later(@comment)\n render json: @comment, serializer: CommentSerializer, status: :created\n else\n render_error :unprocessable_entity, @comment.errors\n end\n end",
"def comment_params\n params.require(:comment).permit(:body, :request_id)\n end",
"def create\n @comment = @secret.comments.build(comment_params)\n @comment.user_id = @user.id\n respond_to do |format|\n if @comment.save\n format.html { redirect_to [@user, @secret], notice: 'Secret was successfully created.' }\n format.json { render action: 'show', status: :created, location: @comment }\n else\n format.html { render action: 'new' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @submission = Submission.find(params[:submission_id])\n @scomment = @submission.comments.build(comment_params)\n if @scomment.save\n render json: @scomment.as_json(except: [:updated_at]), status: :created\n else\n render json: @scomment.errors, status: :unprocessable_entity\n end\n #@comment.user = current_user\n\n #respond_to do |format|\n # if comment_params[:title].present? && comment_params[:body].present?\n # if @comment.save\n # format.html { redirect_to @submission, notice: 'Comment was successfully created.' }\n # #format.json { render :show, status: :created, location: @comment }\n # else\n # format.html { render :new }\n # #format.json { render json: @comment.errors, status: :unprocessable_entity }\n # end\n # else\n # format.html { redirect_to @submission, notice: 'Debe llenar los campos.' }\n # end\n #end\n end"
] |
[
"0.75120175",
"0.74212646",
"0.7374645",
"0.72364116",
"0.7205224",
"0.7086658",
"0.7069151",
"0.70549524",
"0.7049054",
"0.6989455",
"0.69825",
"0.69657713",
"0.69578165",
"0.6910411",
"0.6909373",
"0.68731725",
"0.6871654",
"0.6822542",
"0.6810818",
"0.6787486",
"0.6785412",
"0.6761798",
"0.67223775",
"0.6717274",
"0.6712879",
"0.6703357",
"0.66780496",
"0.66693354",
"0.6666063",
"0.66510963",
"0.6646797",
"0.66438144",
"0.66438144",
"0.66438144",
"0.66438144",
"0.6618947",
"0.66069686",
"0.6589945",
"0.6582926",
"0.6580036",
"0.6575621",
"0.65625244",
"0.6551164",
"0.65488863",
"0.65488863",
"0.65488863",
"0.65371865",
"0.6536091",
"0.6533879",
"0.6513311",
"0.64948153",
"0.64924634",
"0.6489975",
"0.64784837",
"0.6471345",
"0.64571255",
"0.64314175",
"0.6424426",
"0.641567",
"0.6397403",
"0.63957936",
"0.63860476",
"0.63849616",
"0.6383141",
"0.63804007",
"0.6373539",
"0.63700426",
"0.6368417",
"0.6364637",
"0.6360786",
"0.6327905",
"0.63212544",
"0.6320553",
"0.6298183",
"0.629413",
"0.629149",
"0.62839085",
"0.6282247",
"0.6277586",
"0.6272559",
"0.62677294",
"0.62629545",
"0.6259366",
"0.62515587",
"0.6248281",
"0.6246175",
"0.6245974",
"0.62448645",
"0.6240034",
"0.62330633",
"0.6232268",
"0.62317383",
"0.6227576",
"0.62232935",
"0.62225336",
"0.62210953",
"0.62100106",
"0.62075067",
"0.62066275",
"0.61986846",
"0.61980444"
] |
0.0
|
-1
|
PUT /comments/1 PUT /comments/1.json
|
def update
redirect_to "/home/index"
#@comment = Comment.find(params[:id])
#respond_to do |format|
#if @comment.update_attributes(params[:comment])
#format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }
#format.json { head :ok }
#else
#format.html { render action: "edit" }
#format.json { render json: @comment.errors, status: :unprocessable_entity }
#end
#end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n user = User.find_by({token: env['HTTP_TOKEN']})\n comment = user.comments.find(params[:id])\n comment.update(comment_params)\n render json: comment\n end",
"def update\n @comment = Comment.find(params[:comment_id])\n @comment.update(comment_params)\n render json: @comment\n end",
"def update\n json_update_and_sanitize(comment, comment_params, Comment)\n end",
"def update\n @comment = Comment.find(params[:id])\n authorize @comment\n if @comment.update(comment_params)\n render 'api/v1/comments/show', status: :success\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def comments_put(resource, comment)\n merged_options = options.merge({ resource: resource, comment: comment })\n response = RestClient.post endpoint(\"/comments/put\"), merged_options\n parse_response(response)\n end",
"def update\n comment = Comment.find(params[:id])\n if comment.update(params_comment)\n render json: comment, status: 200\n else\n render json: comment.errors, status: 422\n end\n\n end",
"def update\n @comment = Comment.find(params[:id])\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.json { render :json => @comment }\n else\n format.json { render :json => @comment.errors, :status => :unprocessable_entity}\n end\n end\n #respond_with(@post,@post.comments.update(params[:id],params[:comment]))\n end",
"def update\n @comment = Comment.find(params[:id])\n @comment.user_id = params[:user_id]\n @comment.announcement_id = params[:announcement_id]\n @comment.description = params[:description]\n @comment.save\n render json:@comment\n end",
"def update\n if @comment.update(comment_params)\n render json: @comment, status: :ok\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def update\n\n if @comment.update(comment_params)\n render json: @comment, status: :ok\n else\n render json: @comment.errors, status: :unprocessable_entity\n\n end\n\n\n end",
"def update\n @comment = Comment.find(params[:id])\n if @comment.update(comment_params)\n render json: {status: \"success\", data: {comment: @comment}}, status: :ok\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @comment.update_attributes(comment_params)\n render json: @comment, status: :ok\n else\n render json: {error: \"Not found\"}, status: :not_found\n end\n end",
"def update\n if @comment.update(comment_params)\n render json: @comment, serializer: CommentSerializer\n else\n render_error :unprocessable_entity, @comment.errors\n end\n end",
"def update\n # @comment = Comment.find(params[:id])\n end",
"def update\n if @comment.update(comment_params)\n head :no_content\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @comment.update(comment_params)\n head :no_content\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def update\n authorize [:api, :v1, @requesting_object]\n ticket = ServiceTicket.where(\n client_key: params['avatar_key'],\n id: params['id']\n ).first\n if params['comment_text']\n ticket.comments << Comment.new(author: params['avatar_name'],\n text: params['comment_text'])\n end\n ticket.update(status: params['status']) if params['status']\n render json: { message: 'OK' }, status: :ok\n end",
"def update\n if @comment.update(comment_params)\n render json: {status: 'Comment was successfully updated.'}, status: :201\n else\n render json: { message: \"Error. Error. Please try again.\"}, status: 400\n end\n end",
"def update\n @comment.update(comment_params)\n end",
"def update\n @comment1 = Comment1.find(params[:id])\n\n respond_to do |format|\n if @comment1.update_attributes(params[:comment1])\n format.html { redirect_to @comment1, notice: 'Comment1 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.xml { head :ok }\n format.json { head :ok } \n else\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity } \n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, :notice => 'Comment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, :notice => 'Comment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, :notice => 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, :notice => 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_comment\n @comment = Comment.find(params[:id])\n @comment.update(params[:comment])\n redirect \"/comments/#{@comment.id}\"\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to project_sprint_user_story_comments_path, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: t(\"actions.updated\", model: t(\"activerecord.models.#{controller_name.singularize.gsub(\" \", \"\")}\"))}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = current_user.comments.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to post_path(@comment.post), notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def comment options={}\n client.post(\"/#{id}/comments\", options)\n end",
"def update\n respond_to do |format|\n if @comment1.update(comment1_params)\n format.html { redirect_to @comment1, notice: 'Comment1 was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment1 }\n else\n format.html { render :edit }\n format.json { render json: @comment1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment.update_attributes(params[:comment])\n respond_with(@comment, location: redirect_to_index)\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :json => {:comment => @comment, :status => 200} }\n else\n format.html { render :edit }\n format.json { render :json => {:comment => @comment, :status => 400 } }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n @posts = Post.find_by_id(@comment.post_id)\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @posts, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #if @user && @user.posts.include(@post)\n @comment.update(comment_params)\n json_response(@comment)\n end",
"def update\n\n if @comment.update(comment_params)\n\n render json: @comment,status: :ok\n\n else\n\n render json: {error: true,errors: @comment.errors},status: :unprocessable_entity\n\n end\n\n \t\tend",
"def update\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment.generic_item, :notice => t('notice.successfully_updated') }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to post_comment_path(@post, @comment), notice: \"Comment was successfully updated.\" }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to post_path(@comment.post, :anchor => \"comment_#{@comment.id}\"), :notice => t(\"messages.comments.updated\") }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment.blog}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = find_by_id(Comment)\n @comment.update(comment_params)\n redirect_to recipe_path(@comment.recipe)\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, \tºlocation: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to admin_comments_url, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t respond_to do |format|\n\t if @comment.update(comment_params)\n\t format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n\t format.json { head :no_content }\n\t else\n\t format.html { render action: 'comment' }\n\t format.json { render json: @comment.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to @comment, notice: 'Note was successfully updated.' }\n format.js { head :ok }\n else\n format.html { render action: \"edit\" }\n format.js { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = @task.comments.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n flash[:notice] = 'Comment was successfully updated.'\n format.html { redirect_to(sprint_task_comments_path(@sprint,@task)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = @item.comments.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n flash[:notice] = 'Comment was successfully updated.'\n format.html { redirect_to(@comment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @issue_path, notice: 'Comment is sucesfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to [@section, @commentable, :comments], notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Zmodyfikowano komentarz.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n flash[:notice] = 'Comment was successfully updated.'\n format.html { redirect_to(@story) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = @posting.comments.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n #@comment.create_activity :update, owner: current_user\n format.html { redirect_to postings_path, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n flash[:notice] = 'Comment was successfully updated.'\n format.html { redirect_to(@comment) }\n format.xml { head :ok }\n else\n @meta[:title] = \"Comment from #{@comment.author}\"\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment.snippet, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render @comment.snippet }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #respond_to do |format|\n if @comment.update(comment_params)\n render json: @comment.as_json(except: [:updated_at]), status: :ok\n else\n # format.html { render :edit }\n render json: @comment.errors, status: :unprocessable_entity\n # end\n end\n end",
"def update\n @post = Post.find(params[:post_id])\n @comment = @post.comments.find(params[:id])\n\n if @comment.update(params[:comment].permit(:comment))\n redirect_to post_path(@post)\n else\n render 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comentario actualizado.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_comment(resource_id, comment_id, params)\n http.put(\"#{comment_endpoint(resource_id)}/#{comment_id}\", body: params) do |response|\n Rexpense::Entities::Comment.new response.parsed_body\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_back(fallback_location: root_path, notice: t('comment.update_msg')) }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json {\n render json: @comment.errors, status: :unprocessable_entity\n }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment.submission }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_answer_comment.update(api_v1_answer_comment_params)\n format.html { redirect_to @api_v1_answer_comment, notice: 'Answer comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_answer_comment }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_answer_comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n isadmin\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @comment = @complaint.comments.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to([@comment.complaint, @comment], :notice => 'Su comentario ha sido actualizado.') }\n format.json { head :ok }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment.article, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment.article, notice: 'Comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.74237627",
"0.72877294",
"0.72015166",
"0.7041067",
"0.7038625",
"0.7016224",
"0.6951647",
"0.6932251",
"0.69247323",
"0.6889922",
"0.68619525",
"0.6827522",
"0.6823996",
"0.6765764",
"0.6764756",
"0.6764756",
"0.67415977",
"0.66934323",
"0.6693032",
"0.6677461",
"0.6649507",
"0.6623392",
"0.6623392",
"0.6609735",
"0.6609735",
"0.65928644",
"0.65762234",
"0.6562501",
"0.6562501",
"0.6560088",
"0.6560088",
"0.6560088",
"0.6560088",
"0.6560088",
"0.6560088",
"0.6560088",
"0.6560088",
"0.6560088",
"0.65353036",
"0.6533433",
"0.6531289",
"0.6517575",
"0.65069056",
"0.64982224",
"0.6491061",
"0.64736736",
"0.6460897",
"0.64558625",
"0.6455012",
"0.6450096",
"0.64500415",
"0.64356965",
"0.643534",
"0.6426143",
"0.641963",
"0.64188325",
"0.64188325",
"0.64188325",
"0.6389441",
"0.63861364",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.6384093",
"0.63761556",
"0.6365952",
"0.6363289",
"0.6332271",
"0.63140357",
"0.6311476",
"0.6311201",
"0.63054734",
"0.62997425",
"0.62980807",
"0.62977076",
"0.62966603",
"0.62901646",
"0.62890315",
"0.62845",
"0.62798125",
"0.62697786",
"0.6260463",
"0.62579685",
"0.6257267",
"0.6247514",
"0.62445134",
"0.62445134"
] |
0.62886804
|
91
|
DELETE /comments/1 DELETE /comments/1.json
|
def destroy
redirect_to "/home/index"
#@comment = Comment.find(params[:id])
#respond_to do |format|
#format.html { redirect_to comments_url }
#format.json { head :ok }
#end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @comment.destroy\n render json: @comment, status: :ok\n\n end",
"def destroy\n @comment1 = Comment1.find(params[:id])\n @comment1.destroy\n\n respond_to do |format|\n format.html { redirect_to comment1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = @commentable.comments.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n render json:@comment\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n \n respond_to do |format|\n format.xml { head :ok }\n format.json { head :ok } \n end\n end",
"def destroy\n @comment.destroy\n head :no_content\n end",
"def destroy\n @comment.destroy\n head :no_content\n end",
"def destroy\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def delete_comments\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @comment.destroy!\n head :no_content\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:comment_id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def delete_comment(id)\n record \"/msg/delete_comment/#{id}\"\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to project_sprint_user_story_comments_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to post_path(@comment.post) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to post_url(@comment.post_id) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment1.destroy\n respond_to do |format|\n format.html { redirect_to comment1s_url, notice: 'Comment1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n if @comment.nil?\n render json: {error: \"Not found\"}, status: :not_found\n else\n @comment.destroy\n render json: @comment, status: :ok\n\n end\n end",
"def destroy\n comment = Comment.find(params[:id])\n if current_user.id == comment.user_id\n post = comment.post\n post.data['comments'] = post.data['comments'] - 1\n if comment.destroy && post.save\n render json: {status: \"success\", data: {id: Integer(params[:id]), comments: post.data['comments']}}, status: :ok\n else\n render json: {status: \"failure\", data: nil}, status: 404\n end\n\n else\n render json: {status: \"failure\", data: nil}, status: 404\n end\n end",
"def destroy\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to :back, :notice => t('successfully_deleted')}\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url, notice: 'Comentario eliminado.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n comment = Comment.find(params[:id])\n if comment.destroy\n render json: {destroyed: true}\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { head :ok }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.destroy(params[:id])\n end",
"def destroy\n @comment = Comment.destroy(params[:id])\n end",
"def destroy\n if @commentable.comments.find(params[:id]).destroy\n render json: { success: true }\n end\n end",
"def destroy\n @dish_comment = @dish.dish_comments.find(params[:id])\n @dish_comment.destroy\n\n respond_to do |format|\n format.html { redirect_to dish_comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n puts \"Inside destroy. Comment id is \"+params[:id].to_s\n #puts \"Post id is \"+params[:postid].to_s\n @comment = Comment.find(params[:id])\n @comment.destroy\n @posts = Post.find_by_id(params[:postid])\n\n respond_to do |format|\n format.html { redirect_to @posts }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n respond_with(@post, @comment)\n end",
"def destroy\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(post_url(@post), :notice => \"Comment was removed\") }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to user_secret_comments_path(@user, @secret) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_path }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @visit_comment.destroy\n respond_to do |format|\n format.html { redirect_to visit_comments_url, notice: 'Comentario eliminado con exito' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to post_comments_url, notice: \"Comment was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n if @comment.destroy\n\n render json: {comment: {id: params[:id].to_i}},status: :ok\n\n else\n\n render json: {error: true,errors: @comment.errors},status: :unprocessable_entity\n\n end\n\n \t\tend",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n\t\trespond_with @comment, :location => @comment.post\n end",
"def destroy\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to_commentable(@comment, false) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to \"index\", notice: 'Comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url, notice: 'Usunięto komentarz.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = @repository.comments.find(params[:id])\n authorize @comment\n @comment.destroy\n respond_with @comment\n end",
"def destroy\n @story_comment = StoryComment.find(params[:id])\n @story_comment.destroy\n\n respond_to do |format|\n format.html { redirect_to story_comments_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url, notice: 'Comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comment_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n unless @comment.present?\n @comment.destroy\n end\n\n respond_to do |format|\n format.html { redirect_to admin_comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(\"/\") }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comments = Comment.where(question_id: @question.id)\n @comments.each do |comment|\n comment.destroy\n end\n @question.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_comments_url) }\n format.xml { head :ok }\n end\n end",
"def delete_comment1\n params[:comment].each { |key, value|\n comment=Comment.find(key)\n if !comment.nil?\n k comment.destroy\n end\n }\n redirect_to requirements_path\n end",
"def destroy\n @comment14.destroy\n respond_to do |format|\n format.html { redirect_to comment14s_url, notice: 'Comment14 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_with(@comment, location: redirect_to_index)\n end",
"def destroy\n @comment = @posting.comments.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n #@comment.create_activity :destroy, owner: current_user\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to post_path(@comment.post), notice: 'Comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { render :nothing => true }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url, notice: 'Comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url, notice: 'Comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url, notice: 'Comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url, notice: 'Comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url, notice: 'Comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.75611866",
"0.74358994",
"0.73740494",
"0.73681736",
"0.7359092",
"0.7355231",
"0.7294599",
"0.7294599",
"0.727844",
"0.7270565",
"0.72603524",
"0.72603524",
"0.72603524",
"0.72558737",
"0.72558737",
"0.72558737",
"0.7241665",
"0.7240772",
"0.7240202",
"0.7240202",
"0.7240202",
"0.7240202",
"0.7240202",
"0.7240202",
"0.7240202",
"0.7240202",
"0.7240202",
"0.7240202",
"0.7240202",
"0.7240202",
"0.7240202",
"0.7240202",
"0.7240202",
"0.72330916",
"0.71895593",
"0.71842074",
"0.7148797",
"0.7145958",
"0.71336055",
"0.7118882",
"0.7109058",
"0.7107792",
"0.7096745",
"0.70846456",
"0.7066005",
"0.706142",
"0.70578074",
"0.7055439",
"0.7055439",
"0.7045216",
"0.70448714",
"0.70214885",
"0.69965047",
"0.699612",
"0.6995898",
"0.69942296",
"0.6987752",
"0.69874734",
"0.69862664",
"0.69862664",
"0.69862664",
"0.69862664",
"0.69862664",
"0.69862664",
"0.69862664",
"0.69862664",
"0.69862664",
"0.69862664",
"0.69862664",
"0.69862664",
"0.69862664",
"0.69837487",
"0.69778985",
"0.69695616",
"0.6967985",
"0.6963756",
"0.6957364",
"0.69565195",
"0.6949777",
"0.6944117",
"0.69377595",
"0.69340885",
"0.69339085",
"0.6932644",
"0.69324696",
"0.69287264",
"0.69269526",
"0.6926282",
"0.6912814",
"0.6906828",
"0.69039416",
"0.6896876",
"0.6896408",
"0.68823725",
"0.68808764",
"0.6877498",
"0.6877498",
"0.6877498",
"0.6877498",
"0.6877498"
] |
0.69425315
|
80
|
TODO: caching (like etags and stuff)
|
def getRoutes
# [["MTA NYCT_B65", "B65", "Downtown Brooklyn - Crown Heights", "via Bergen St & Dean St"]...]
url = "http://bustime.mta.info/api/where/routes-for-agency/MTA%20NYCT.xml?key=#{APIKEY}"
xml_str = Net::HTTP.get URI(url)
xml = Nokogiri::XML(xml_str)
xml.css("response data list route").to_a.map{|rte| [rte.css('id').text, rte.css('shortName').text, rte.css('longName').text, rte.css('description').text]}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def cache_tags\n self[:tag_s] = self.tags.collect{|tag| tag.pattern}.reject{|p| p.starts_with?('wait') }.sort.join(' ')\n end",
"def cache_tags\n self[:tag_s] = self.tags.collect{|tag| tag.pattern}.reject{|p| p.starts_with?('wait') }.sort.join(' ')\n end",
"def extract_tags!\n @tagmap = {}\n data.gsub!(/(.?)\\[\\[(.+?)\\]\\]([^\\[]?)/m) do\n if $1 == \"'\" && $3 != \"'\"\n \"[[#{$2}]]#{$3}\"\n elsif $2.include?('][')\n if $2[0..4] == 'file:'\n pre = $1\n post = $3\n parts = $2.split('][')\n parts[0][0..4] = \"\"\n link = \"#{parts[1]}|#{parts[0].sub(/\\.org/,'')}\"\n id = Digest::SHA1.hexdigest(link)\n @tagmap[id] = link\n \"#{pre}#{id}#{post}\"\n else\n $&\n end\n else\n id = Digest::SHA1.hexdigest($2)\n @tagmap[id] = $2\n \"#{$1}#{id}#{$3}\"\n end\n end\n nil\n end",
"def complete_tags\n\n end",
"def tags=(_arg0); end",
"def etags\n (@env['HTTP_IF_NONE_MATCH'] || '').split(/\\s*,\\s*/)\n end",
"def fragment(tags); end",
"def parse(tags); end",
"def weak_etag?; end",
"def tags\n return @tags_cache if (@tags_cache ||= nil)\n \n global_tags, tag_types = {}, {}\n \n f = nil\n # For each current .hgtags file in our history (including multi-heads), read in\n # the tags\n hg_tags_nodes.each do |rev, node, file_node|\n # get the file\n f = (f && f.file(file_node.file_node)) || self.versioned_file(\".hgtags\", :file_id => file_node.file_node)\n # read the tags, as global, because they're versioned.\n read_tags(f.data.split(\"\\n\"), f, \"global\", global_tags, tag_types)\n end\n \n # Now do locally stored tags, that aren't committed/versioned\n begin\n # get the local file, stored in .hg/\n data = @hg_opener.read(\"localtags\")\n # Read the tags as local, because they are not versioned\n read_tags(data.split_newlines, \"local_tags\", \"local\", global_tags, tag_types)\n rescue Errno::ENOENT\n # do nothing. most people don't have this file.\n end\n # Save our tags for use later. Use ivars.\n @tags_cache, @tags_type_cache = {}, {}\n \n # Go through the global tags to store them in the cache\n global_tags.each do |k, nh|\n # update the cache\n @tags_cache[k] = nh.first unless nh.first == NULL_ID\n @tags_type_cache[k] = tag_types[k]\n end\n \n # tip = special tag\n @tags_cache[\"tip\"] = self.changelog.tip\n \n # return our tags\n @tags_cache\n end",
"def tags; end",
"def tags; end",
"def tags; end",
"def tags; end",
"def tags; end",
"def tagged?; end",
"def download_tags\n\n end",
"def tags() ; info[:tags] ; end",
"def tags() ; info[:tags] ; end",
"def see_tag(text); end",
"def log_tags; end",
"def log_tags; end",
"def log_tags; end",
"def tags() []; end",
"def gettag()\n omnifocus.tags.get.each do |tagg|\n\t tagg.tags.get.each do |t|\n\t\t\t if t.name.get == \"Today\" \n\t\t\t\t return t\n\t\t\t end\n\t\t end \n\n end\n\n end",
"def tagline; end",
"def parse_context; end",
"def parse_context; end",
"def test_tag_assignment\n assert_equal 2, @twitter_reporter.reports.create(:body => 'my #machine is #good').tags.size\n # assert_equal 7, @twitter_reporter.reports.create(:body => 'many #challenges here, #bad').score\n goodreport = @twitter_reporter.reports.create(:body => 'no problems #good overall, #wait12')\n goodreport.reload\n assert_equal 2, goodreport.tags.size\n epreport = @twitter_reporter.reports.create(:body => 'being #challenges here #EPOH l:cincinnati oh')\n epreport.reload\n assert_equal 2, epreport.tags.size\n # FIXM - figure out how to get EPXX back into the tag_list, all we have is the pattern here\n #assert epreport.tag_list.split(Tag::TAG_SEPARATOR).include?('EPOH'), \"has tag_list: #{epreport.tag_list}\"\n end",
"def extractTags()\n line = @lines[@currentLine]\n re = /\\[([^\\[]+)\\]/m\n while line =~ re\n @currentBlock.addTag($~[1])\n line = line.sub(re, '')\n end\n end",
"def collect_tags_indeed(text_to_scan, offer_object)\n puts \"Mining tags from posting\"\n tags = Tag.all.map(&:name)\n tags.each do |tag|\n offer_object[:tags] << tag if text_to_scan.include?(tag)\n end\n end",
"def cache_tag_list\n set_cached_tag_list\n save\n end",
"def since_tag(text); end",
"def deli_tags(uri, id)\n begin\n md5 = Digest::MD5.hexdigest(uri)\n target = \"http://badges.del.icio.us/feeds/json/url/data?hash=#{md5}\"\n json = open(target).read\n deli = JSON.load(json)[0]\n tags = \"\"\n if deli['top_tags'].class == Hash then\n all_tags = deli['top_tags'].sort_by {|k,v| v}.reverse.map{|i|i[0]}\n if all_tags.size > 8 then\n all_tags = all_tags.first(8) << '...'\n end\n tags = '(' << all_tags.join(', ') << ')'\n end\n if deli['total_posts'].to_i > 0 then\n response = \"#{id}: (deli) #{deli['total_posts']} links, tagged #{tags}\"\n $q_meta.enq response\n end\n rescue\n puts \"problem fetching deli for #{uri}\"\n end\nend",
"def extract_tags(data)\n data.gsub!(/(.?)\\[\\[(.+?)\\]\\]([^\\[]?)/m) do\n if $1 == \"'\" && $3 != \"'\"\n \"[[#{$2}]]#{$3}\"\n elsif $2.include?('][')\n if $2[0..4] == 'file:'\n pre = $1\n post = $3\n parts = $2.split('][')\n parts[0][0..4] = \"\"\n link = \"#{parts[1]}|#{parts[0].sub(/\\.org/,'')}\"\n id = Digest::SHA1.hexdigest(link)\n @tagmap[id] = link\n \"#{pre}#{id}#{post}\"\n else\n $&\n end\n else\n id = Digest::SHA1.hexdigest($2)\n @tagmap[id] = $2\n \"#{$1}#{id}#{$3}\"\n end\n end\n data\n end",
"def tags(host)\n tags = []\n # POP\n case host\n when /^[^.]+\\.dv\\./\n tags << \"dev\"\n when /^[^.]+\\.tt\\./\n tags << \"test\"\n else\n tags << \"new\"\n end\n tags\nend",
"def tag; end",
"def tag; end",
"def log_tags=(_arg0); end",
"def log_tags=(_arg0); end",
"def log_tags=(_arg0); end",
"def processTags(files)\n files.each do |file|\n count = 0\n File::readlines(file).each do |line|\n count+=1\n\n # function sym (\n line.gsub(/function ([\\w_$]+)([\\s]*)\\(/) {|match|\n puts $1 << \"\\t\" << file << \"\\t\" << '/' << match << '/' << ';\"'\n match\n }\n\n # obj.prototype.sym =\n line.gsub(/([\\w_$]+)\\.prototype\\.([\\w_$]+)([\\s]*)=/) {|match|\n puts $2 << \"\\t\" << file << \"\\t\" << '/' << match << '/' << ';\"'\n match\n }\n\n # this.sym = [new] [Ff]unction\n line.gsub(/this\\.([\\w_$]+)([\\s]*)=([\\s]*)(new[\\s])*[Ff]unction/) {|match|\n puts $1 << \"\\t\" << file << \"\\t\" << '/' << match << '/' << ';\"'\n match\n }\n\n # goog.namespace.sym =\n line.gsub(/goog\\.([\\w_$]+)\\.([\\w_$]+)([\\s]*)=/) {|match|\n puts $2 << \"\\t\" << file << \"\\t\" << '/' << match << '/' << ';\"'\n match\n }\n\n # sym : [new] [Ff]unction\n line.gsub(/([\\w_$]+)([\\s]*):([\\s]*)(new[\\s])*[Ff]unction[\\W]/) {|match|\n puts $1 << \"\\t\" << file << \"\\t\" << '/' << match << '/' << ';\"'\n match\n }\n end\n end\n return\nend",
"def retrieve_tags\n # noop\n end",
"def tag_pruning tags\n pruned_tags = []\n chunks = tags.in_groups_of( (tags.count/20).to_i )\n # binding.pry\n\n chunks.each_with_index do |chunk, i|\n # binding.pry\n if chunk.first.first.ascii_only?\n tag_nodes = InstaHelper.get_tag_media_nodes(chunk.first.first)\n puts \"=========== #{tag_nodes.count} @ #{i} ================\"\n unless (DateTime.now - DateTime.strptime(tag_nodes.first[\"node\"][\"taken_at_timestamp\"].to_s,'%s')).to_i > 30\n puts \"<<<<<<<<<<<<<<< Added #{i}th tag >>>>>>>>>>>>>>>>>>\"\n pruned_tags.push chunk\n end\n end\n end\n pruned_tags.flatten.in_groups_of(2)\n end",
"def strong_etag?; end",
"def load_tags\n return if request.fullpath.match(/^\\/(\\S+)preview/)\n \n load = Rails.cache.read('tags')\n if load.nil?\n load = blog_models.map { |resource|\n resource.tag_counts_on(:tags).all\n }.flatten.uniq.sort { |a,b| \n a.name.upcase <=> b.name.upcase\n }\n Rails.cache.write('tags', load)\n end\n @tags = load\n end",
"def transitive_tags; end",
"def find_tags\n @find_tags = true\n end",
"def etfs\n\n end",
"def tag(tag); end",
"def tag(tag); end",
"def tag(string); end",
"def scan_tags\n self.content.scan(/#\\w+/).uniq\n end",
"def get_hash_tags\n self.text.gsub(/#(([a-z_\\-]+[0-9_\\-]*[a-z0-9_\\-]+)|([0-9_\\-]+[a-z_\\-]+[a-z0-9_\\-]+))/).to_a\n #self.text.gsub(/#(\\w+)/).to_a\n end",
"def todo_tag(text); end",
"def tag_list; []; end",
"def get_all_tags\n taglist = %x[vorbiscomment -l #{@file.shellescape}].split(\"\\n\")\n tags = {}\n taglist.each do |line|\n key,value = line.split(\"=\")\n tags[key] = value\n end\n return tags\n end",
"def fetch_tags (arg, regex=/\\A[v]\\d+[.]\\d+\\z/)\n clean_tags = []\n tag(arg).split(\"\\n\").each { |vtag|\n clean_tags.push(vtag) if vtag.match(regex) }\n # contains tags that conform to format : discuss\n return clean_tags unless clean_tags.length < 1\n raise ImqsGitError, \"no tags were found that matches the regex : #{regex.to_s}\"\n end",
"def parse_tag_heads(lines, filename)\n file_tags = {}\n # Each line is of the format:\n # [char * 40, node ID] [tag]\n # 0123456789012345678901234567890123456789 crazymerge\n lines.each_with_index do |line, count|\n # skip if we have no text to parse\n next if line.nil? || line.empty?\n \n # split once, so we could theoretically have spaces in tag names\n node, tag = line.split(\" \", 2)\n # make sure we parsed the tag entry alright\n unless node && tag\n UI::warn \"Can't parse entry, filename #{filename} line #{count}\"\n next\n end\n \n # convert out of file-stored format\n bin_node, tag = node.unhexlify, tag.strip\n \n # Is it in our repo? if not, skip to the next tag.\n unless self.changelog.node_map[bin_node]\n UI::warn \"Tag #{tag} refers to unknown node\"\n next\n end\n \n # have we already seen this tag?\n if file_tags[tag]\n # pull out the old data\n heads = file_tags[tag][1] << file_tags[tag][0]\n else\n heads = []\n end\n # update our tag list\n file_tags[tag] = [bin_node, heads]\n end\n file_tags\n end",
"def auto_tag!\n tags = self.body.scan(/(?<=#)\\S+/).map{ |ts| J::Tag.find_or_create_by(name: ts) }\n self.tags = tags\n end",
"def transitive_tags=(_arg0); end",
"def taggable_topical_events_cache_digest\n @taggable_topical_events_cache_digest ||= calculate_digest(TopicalEvent.order(:id), \"topical-events\")\n end",
"def get_tags() tag_ids.inject([]) { |l, tag_id| l << get_tag_from_id(tag_id) } end",
"def store\n @by_cache.each{|cache, tags| cache[:tags] = tags }\n end",
"def est_ts_load_notetags\n matches = Scope_Regex.match(self.note)\n if matches\n @scope = matches[1].to_i\n end\n end",
"def load_notetags\n super\n self.note.split(/[\\r\\n]+/).each { |line|\n case line\n when /<itype_id:\\s*(\\d+)\\s*>/i\n @itype_id = $1.to_i\n when /<synthesis_level:\\s*(\\d*)\\s*>/i\n @synthesis_level = $1.to_i\n when /<synthesis_material:\\s*(\\d*)\\s*,\\s*(\\d*)\\s*,\\s*(\\d*)\\s*>/i\n @synthesis_materials.push(RPG::Material.new($1.to_i, $2.to_i, $3.to_i))\n end\n }\n end",
"def parsed; end",
"def parsed; end",
"def load_notetags\n super\n init_custom_fields\n self.note.split(/[\\r\\n]+/).each { |line|\n case line\n when /<default title:\\s*(\\d*)\\s*>/i\n @default_title_id = $1.to_i\n when /<titles:[ ](\\d+(?:\\s*,\\s*\\d+)*)>/i\n $1.scan(/\\d+/).each { |num| \n @titles.push(num.to_i) if num.to_i > 0 \n }\n when /<icon_index:\\s*(\\d*)\\s*>/i\n @icon_index = $1.to_i\n when /<max_level:\\s*(\\d*)\\s*>/i\n @max_level = $1.to_i\n end\n }\n end",
"def extract_tags\n extract_hashtags(content) do |tag|\n extracted_tag = Tag.find_or_create_by(name: tag.downcase)\n self.tags << extracted_tag unless tags.include? extracted_tag\n end\n end",
"def get_tags( file , ofile, format )\n File.open( file ) do |f|\n File.open( ofile, 'w' ) do |of|\n while line = f.gets\n #begin\n batch, id, hash, url =* line.split(/\\s+/)\n puts \"#{id}, #{hash}, #{url}\"\n api_url = \"curl https://lifidea:1275dkjy@api.del.icio.us/v1/posts/suggest?url=#{url}\"\n puts api_url\n content = `#{api_url}`#Net::HTTP.get(URI.parse(api_url))\n of.puts \"#{hash}\\t#{content.size}\\t#{url}\"\n #Dir.mkdir(format) if !File.exist?(format)\n File.open( \"tags/#{hash}.#{format}\",'w'){|of2|of2.puts content}\n #rescue Exception => e\n # puts \"Error in [#{line}]\",e\n #end\n sleep(1)\n end\n end\n end\nend",
"def get_tags\n\ttags = Set.new\n\t@site.articles.each do |post|\n\t\tif(post[:tags].nil?) \n\t\t\tpost[:tags] = Array.new\n\t\t\tpost[:tags] << \"(none)\"\n\t\t\ttags << \"(none)\"\n\t\telse\n\t\t\tpost[:tags].each do |tag|\n\t\t\t\ttags << tag\n\t\t\tend\n\t\tend\n\tend\n\ttags.to_a\nend",
"def private; end",
"def make_tags(item)\n\ttags_for(item, { :base_url => @site.config()[:base_url] + \"/tags/\" })\nend",
"def tag(name); end",
"def update_cached_tag_lists\n cache_tag_list if tag_list != cached_tag_list\n cache_topic_list if topic_list != cached_topic_list\n cache_user_tag_list if user_tag_list != cached_user_tag_list\n cache_owned_tag_list if owned_tag_list != cached_owned_tag_list\n end",
"def parse_init\n @tg_end = [] #momorize tag end from regex function\n @doc_src = []\n @doc_out = []\n @tg_hot = {} \n merge_tags @mrg ? @mrg : @ext\n next_tag_init\n end",
"def build_list\n\t\ttags = []\n\t\ttags << get_initial_commit\n\t\ttags += `git tag --sort v:refname`.split(\"\\n\").map { |s| s.rstrip }\n\t\ttags << \"HEAD\" if @include_head\n\t\ttags.reverse\n\tend",
"def unfiltered_content; end",
"def unfiltered_content; end",
"def unfiltered_content; end",
"def process_sentance(blob)\n # strip out enclosures\n blob = blob.gsub(/\\\\/,'')\n # test for quotes\n # if quotes, these words are important (flag them)\n test = blob.match(/[\"'](.*)['\"]/)\n if test && test.size > 1\n @words = test[1..test.size].join(\" \")\n #test.each{|word|\n # @words << word\n #}\n #blob = blob.gsub(@words,'')\n blob = blob.gsub(/([\"'])/,'')\n end\n unless @words.nil?\n # break up and add to @local_important\n tmp = @words.split(\" \")\n tmp.each{|word|\n @local_important << word.downcase unless @local_important.include? word\n }\n end\n #puts blob\n the_pieces = blob.split(\" \")\n parse_words(the_pieces)\n \n # try to sort words\n words = grab_important_words\n puts words.inspect\n \n puts \"Derived Tags: #{words.join(' ')}\"\n \n end",
"def author_tag(text); end",
"def set_extra_stuff\n @templates = Template.all\n @tags = tags_for('Common')\n end",
"def tags ( what=\"all\" )\n\t send( what )\n\t r = Array.new\n\t each { |l| r << l.chomp.split[0] }\n\t r\n\tend",
"def on_etag(name)\n \"v = #{compile!(name)}; ctx._eval_etag(@output_buffer, v); \"\n end",
"def process(tweet)\n puts tweet\n hash_to_dict(tweet).each do |tag|\n if tag[0] == \"loc\"\n tag[1] = parse_location(tag[1])\n end\n p tag\n end\nend",
"def fragment(tags = T.unsafe(nil)); end",
"def fragment(tags = T.unsafe(nil)); end",
"def our_tags\n tag_map.tap do |t|\n t.each_pair { |k, v| t[k] = tags.fetch(v, nil) }\n end\n end",
"def process_tags(article_id)\n p = Article.find(article_id)\n p.tag_list.each do |tag|\n t = Tag.find_or_create_by_content(tag)\n t.articles << p\n t.save\n\n p.content = p.content.gsub(\"#\" + tag) {\"<a href='\" + Rails.application.routes.url_helpers.tag_path(tag) + \"'>#\"+tag+\"</a>\"}\n p.save\n end\n end",
"def parse_by_feednormalizer(feed_text)\n feed_data = FeedNormalizer::FeedNormalizer.parse feed_text\n feed_data.entries.map do|e|\n metadata = {:author => e.author} if e.author\n {:did=>(e.id || e.urls.join(\" \")), :title=>e.title,:content=>e.content,:basetime=>e.date_published, \n :metadata=>metadata, :uri=>e.urls.join(\" \"), :tag_list=>e.categories.join(\",\")}\n end\n end",
"def return_tag(text); end",
"def abstract_tag(text); end",
"def tag_content\n return @tag_content\n end",
"def load_notetags_specdef\r\r\n @unblockable = false\r\r\n @block_adjust = 0 \r\r\n @thac0 = 0\r\r\n @armor_class = 0\r\r\n @is_normal_attack = false\r\r\n notetagged_items = false\r\r\n \r\r\n self.note.split(/[\\r\\n]+/).each { |line|\r\r\n case line\r\r\n when MOTO::REGEXP::BASEITEM::UNBLOCKABLE\r\r\n @unblockable = true\r\r\n when MOTO::REGEXP::BASEITEM::BLOCK_ADJUST_SET\r\r\n $data_notetagged_items.push(self)\r\r\n @block_adjust_set = $1.to_i\r\r\n p sprintf(\"[Attack Block]:%s's normal block attack: %d\",self.name,self.block_adjust_set)\r\r\n when MOTO::REGEXP::BASEITEM::IS_NORMAL_ATTACK\r\r\n @is_normal_attack = true\r\r\n when MOTO::REGEXP::BASEITEM::IS_MISSILE\r\r\n @is_missile = true\r\r\n p sprintf(\"[Attack Block]:%s is missile attack\",self.name)\r\r\n when MOTO::REGEXP::BASEITEM::MISSILE_BLOCK_RATE\r\r\n $data_notetagged_items.push(self)\r\r\n @missile_block_rate = $1.to_i\r\r\n p sprintf(\"[Attack Block]:%s missile block rate: %d\",self.name,self.missile_block_rate)\r\r\n when MOTO::REGEXP::BASEITEM::THAC0\r\r\n $data_notetagged_items.push(self)\r\r\n @thac0 = $1.to_i\r\r\n p sprintf(\"[Attack Block]:%s THAC adjust: %d\",self.name,self.thac0)\r\r\n when MOTO::REGEXP::BASEITEM::ARMOR_CLASS\r\r\n $data_notetagged_items.push(self)\r\r\n @armor_class = $1.to_i\r\r\n p sprintf(\"[Attack Block]:%s AC adjust: %d\",self.name,self.armor_class)\r\r\n \r\r\n end\r\r\n } # self.note.split\r\r\n end",
"def assign_tags\n if self.text\n self.tag_s = self.text.scan(/\\s+\\#\\S+/).join(' ')\n save\n end\n true\n end",
"def preprocess___tags data\n\t\tname = 'general' \n\t\ttags_alaise = [:tag, :type]\n\t\ttags_alaise.each do | item |\n\t\t\tname = data.delete(item) if data.include?(item)\n\t\tend\n\t\tif DB[:_tags].filter(:name => name).empty?\n\t\t\tDB[:_tags].insert(:name => name) \n\t\tend\n\t\tdata[:tid] = DB[:_tags].filter(:name => name).get(:tid)\n\t\tdata\n\tend",
"def get_updated_tag_list\n if is_filtered?\n @tags = Tag.filtered_hacker_tags(session[:filter], current_user.id)\n else\n @tags = Tag.current_hacker_tags(current_user.id)\n end\n end",
"def convert_ref_tags; end",
"def test_get_hits_for_tag\n hits = CachedResource.get_hits_for_tag(\"good\", @paul)\n assert_equal 1, hits.length\n assert_equal \"http://resource/3/both\", hits[0]['uri']\n hits = CachedResource.get_hits_for_tag(\"bad\", nil)\n assert_equal 0, hits.length\n hits = CachedResource.get_hits_for_tag(\"bad\", @paul)\n assert_equal 0, hits.length\n hits = CachedResource.get_hits_for_tag(\"daves_tag\", @paul)\n assert_equal 0, hits.length\n hits = CachedResource.get_hits_for_tag(\"daves_tag\", @dave)\n assert_equal 1, hits.length\n assert_equal \"http://resource/2/dave\", hits[0]['uri']\n hits = CachedResource.get_hits_for_tag(\"good\", nil)\n end"
] |
[
"0.63389456",
"0.63389456",
"0.60042936",
"0.59716046",
"0.5962481",
"0.5948608",
"0.5901294",
"0.58995426",
"0.57903916",
"0.5781116",
"0.57682556",
"0.57682556",
"0.57682556",
"0.57682556",
"0.57682556",
"0.5755753",
"0.5748969",
"0.5739459",
"0.5739459",
"0.57206833",
"0.5711442",
"0.5711442",
"0.5711442",
"0.5664013",
"0.5657619",
"0.56127876",
"0.5594983",
"0.5594983",
"0.55929667",
"0.5570836",
"0.5543131",
"0.5524802",
"0.55231285",
"0.55068505",
"0.5495461",
"0.5474539",
"0.5461267",
"0.5461267",
"0.54566073",
"0.54566073",
"0.54566073",
"0.5451952",
"0.543075",
"0.54258966",
"0.5418544",
"0.5414742",
"0.5401785",
"0.540143",
"0.53715116",
"0.5351384",
"0.5351384",
"0.5340274",
"0.5336623",
"0.53254294",
"0.53247535",
"0.5323864",
"0.53230196",
"0.5320358",
"0.53193074",
"0.5314775",
"0.52973497",
"0.5273508",
"0.52593356",
"0.5259224",
"0.52579045",
"0.5250562",
"0.5246614",
"0.5246614",
"0.52071136",
"0.52015036",
"0.51963955",
"0.5194576",
"0.5188512",
"0.51836556",
"0.5182915",
"0.5180644",
"0.5176582",
"0.5173397",
"0.51729894",
"0.51729894",
"0.51729894",
"0.5170369",
"0.51586086",
"0.51388294",
"0.5135839",
"0.5123918",
"0.51151025",
"0.51042217",
"0.51042217",
"0.5094545",
"0.5089311",
"0.5086871",
"0.5078892",
"0.5076018",
"0.5075048",
"0.5069702",
"0.50651807",
"0.50646025",
"0.50615275",
"0.5055631",
"0.5051199"
] |
0.0
|
-1
|
Argument: integer, number Side effects: None Return value: Boolean. true if argument is prime, false otherwise. Edge cases: prime?(1) prime?(2) Algorithm: number <= argument 1) is_prime = true 2) for all integers between 2 and (number 1): |index| check whether number is divisible by index if it is, then: is_prime = false break out of the iteration 3) return is_prime
|
def prime?(number)
return false if number == 1
2.upto(number - 1) do |index|
return false if number % index == 0
end
true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def PrimeNumber?(number)\n return false if number<2 || number%2 ==0\n (3..number-1).select(&:odd?).each do |i|\n return false if number%i == 0\n end\n true\nend",
"def prime?(number)\n if number > 1 \n number_range = (2..number-1).to_a\n number_range.detect{ |test_number| number % test_number == 0} ? false : true\n else\n false\n end\nend",
"def prime?(number)\n (2...number).each do |x|\n return false if (number % x).zero?\n end\n true\n end",
"def prime?(number)\n if number >= 2\n (2..number - 1).all? do |x|\n number % x != 0\n end\n else\n return false\n end\nend",
"def is_prime?(number)\n return true if number == 2\n 2.upto(number/2) do |x|\n return false if number%x == 0\n end\n return true\nend",
"def is_prime?(number)\n if number <= 1\n # only numbers > 1 can be prime.\n return false\n end\n\n idx = 2\n while idx < number\n if (number % idx) == 0\n return false\n end\n\n idx += 1\n end\n\n return true\nend",
"def is_prime?(number)\n if number <= 1\n # only numbers > 1 can be prime.\n return false\n end\n\n idx = 2\n while idx < number\n if (number % idx) == 0\n return false\n end\n\n idx += 1\n end\n\n return true\nend",
"def is_prime?(number)\r\n if number <= 1\r\n # only numbers > 1 can be prime.\r\n return false\r\n end\r\n\r\n idx = 2\r\n while idx < number\r\n if (number % idx) == 0\r\n return false\r\n end\r\n\r\n idx += 1\r\n end\r\n\r\n return true\r\nend",
"def prime?(number)\n\nreturn false if number < 2\n\n (2...number).each do |x|\n return false if number % x == 0\n end\nreturn true\n\nend",
"def is_prime?(number)\n (2...number).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\n \nend",
"def prime?(number)\n return false if 2 > number\n (2...number).each { |i| return false if number % i == 0 }\n true\nend",
"def prime?(number)\n if number > 1\n (2..number-1).each {|n| return false if number <= 1 || number % n == 0}\n return true\n else\n false\n end\nend",
"def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend",
"def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend",
"def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend",
"def is_prime? (number)\n return false if number < 1\n 2.upto(Math.sqrt(number)) do |x|\n return false if number % x == 0\n end \n true\nend",
"def prime?(number)\n if number == 0 or number == 1\n return false\n end\n i = 2\n while i < number\n if number % i == 0\n return false\n end\n i += 1\n end\n return true\nend",
"def prime?(num)\n if num == 2\n true\n elsif num > 1 && num % num == 0 && num % 1 == 0 && !(2 .. (num - 1)).to_a.any?{|number| num % number == 0}\n true\n else\n false\n end\nend",
"def prime?(number)\n if number < 2\n return false\n else\n (2..number-1).each do |n|\n if number % n == 0\n return false\n end\n end\n true\nend\nend",
"def is_prime(number)\n if number == 1\n return true\n end\n 2.upto(number) do |x|\n if (number % x == 0) && (number != x)\n return false\n end\n end\n return true\nend",
"def prime? (number)\n if number == 2\n return true\n elsif number < 2\n return false\n else\n for num in 2..Math.sqrt(number)\n if number % num == 0\n return false\n else\n return true\n end\n end\n end\nend",
"def prime?(number)\n (2..(number-1)).each do |possible_factor|\n return false if number % possible_factor == 0\n end\n true\nend",
"def is_prime?(number)\n\n if (number > 1) && (number % 2 != 0) && (number % 3 != 0) && (number % (number-1) != 0) || (number == 2) || (number == 3)\n return true\n else\n return false\n end\nend",
"def is_prime?(number)\n return false if number < 2\n \n (2..number - 1).each do |n|\n return false if number % n == 0\n end\n\n true\nend",
"def is_prime?(number)\n for i in 2..(number-1)\n if (number % i) == 0\n return false\n break\n end\n end\n true\nend",
"def is_prime?(number)\n factors = (2...(number))\n if number == 2 || number == 3\n return true\n elsif number == 0 || number == 1\n return false\n elsif factors.any? {|factor| number % factor == 0 }\n return false\n else return true\n end\nend",
"def is_prime?(number)\n (2..(number-1)).each do |divisor| # this is a range (2..number -1)\n return false if number % divisor == 0\n end\n true # code intentionally, return true, otherwise it would return a truthy value anyway but that's not the point\nend",
"def is_prime?(number)\n return false if number < 2\n (2...number).to_a.none?{ |integer| number % integer == 0 }\nend",
"def is_prime?(number)\n remainders = (2...number).map { |d| number % d}\n !remainders.include?(0) && number > 1\nend",
"def is_prime?(number)\n (2...number).each do |factor|\n if number % factor == 0\n return false\n end\n end\n return true\nend",
"def prime?(number)\n return false if number < 2\n (2..number - 1).each do |x|\n if (number % x) == 0\n return false\n end\n end\n true\nend",
"def is_prime?(number)\n if number < 1\n return false\n end\n divisor = 2\n while number % divisor != 0\n divisor += 1\n if number == divisor\n return true \n end\n end\n return false\n end",
"def prime?(i)\n if i <= 1\n false\n else\n #(range_of_numbers[i] / 1) == range_of_numbers[i] || 1\n range_of_numbers = (2...i).to_a\n range_of_numbers.all? {|number| i % number != 0}\n end\nend",
"def is_prime?(number)\r\n (2...number).each do |n|\r\n return false if number % n == 0\r\n end\r\n true\r\nend",
"def prime?(num)\n return false if num == 1\n return true if num == 2\n (2...num).each do |divisor|\n return false if num % divisor == 0\n end\n true\nend",
"def prime?(number) #11\n start = 2\n if number > 1\n range = (start..number-1).to_a #[2, 3, 4, 5, 6, 7, 8, 9, 10]\n range.none? do |num_to_test|\n number % num_to_test == 0\n end\n else\n false\n end\nend",
"def is_prime?(num)\n return false if num == 1\n return true if num == 2 \n (2..Math.sqrt(num)+1).each do |x|\n return false if num%x == 0\n end\n true\nend",
"def prime?(value)\n if value <= 1 || value == 0# || #value == 1\n return false\n elsif\n (2..value - 1).each do |i|\n if value % i == 0\n return false\n end\n end\n end\n true # <= need explanation\nend",
"def prime?(number)\n a = []\n n = (2...number).to_a\n if number == 1 || number == 0 || number.negative?\n false\n else\n n.collect {|x| a << number % x}\n if a.include?(0)\n false\n else\n true\n end\n end\n # (2...number).to_a.each {|x| (number/x).integer? ? false : true}\nend",
"def is_prime?(integer)\n return false if integer == 1\n (2...integer).to_a.all? {|num| integer % num != 0}\nend",
"def is_prime?(number)\n return false if number <= 1\n prime = true\n (2..number - 1).each do |n|\n prime = false if number % n == 0\n end\n prime\nend",
"def prime?(num)\n return false if num == 1\n return true if num == 2 or num == 3 or num == 5 or num == 7\n return false if num % 2 == 0 or num % 3 == 0 or num % 5 == 0 or num % 7 == 0\n (11..Math.sqrt(num).ceil).each do |i| \n return false if num % i == 0\n end\n true \nend",
"def is_prime?(number)\n idx = 2\n if number < 2\n return false\n end\n\n while idx <= number**0.5\n return false if number%idx == 0\n idx+=1\n end\n return true\nend",
"def prime?(number)\n if number <= 1\n return false\n end\n (2..Math.sqrt(number)).each do |n|\n if number%n == 0\n return false\n end\n end\n return true\nend",
"def is_prime?(number)\n if number < 1\n return false\n elsif number <= 3\n return true\n elsif number % 2 == 0 || number % 3 == 0 \n return false\n elsif number != 5 && number % 5 == 0\n return false\n elsif number != 7 && number % 7 == 0\n return false\n elsif number != 9 && number % 9 == 0\n return false\n elsif number != 11 && number % 11 == 0\n return false\n else \n return true\n end\nend",
"def prime?(number)\n if (number>1 && number.is_a?(Fixnum)) #floats/doubles like 2.35 wont work here\n #if it qualifies as a prime candidate let's set up counter variables \n \n # iterationCounter = 1 #I mean, is there anything NOT divisible by 1? localize\n myArray = (2..number).to_a #make the range an array to cycle through!\n\n for counter in myArray do\n mod = number%counter\n #puts \"#{number} % #{counter} is #{mod}.\" #just for testing purposes\n if mod == 0 \n if counter == number \n puts \"number is Prime!\"\n return true\n # expected\n else \n puts \"#{number} is not prime. It is divisible by #{counter}.\"\n return false\n end\n end\n end\n else\n puts \"That is not a valid value!\"\n return false\n end\nend",
"def is_prime?(num)\n if !is_integer?(num)\n return false\n elsif num <= 1\n return false\n else\n (2..(num-1)).each do |el|\n if num % el == 0\n return false\n end\n end\n end\n return true\nend",
"def prime?(number)\n (2...number).none? { |n| number % n == 0 }\nend",
"def is_prime?(number)\n i = number - 1\n until i < 2\n if number % i == 0\n return false\n end\n i -= 1\n end\n return true\nend",
"def is_prime?(number)\n result = true\n\n # 2 is the only even prime number\n if number == 2\n result = true\n elsif number < 2 or number % 2 == 0\n result = false\n else\n # if there aren't any multiples of n before the square root\n # of n, there aren't any at all.\n root = Math.sqrt(number).ceil\n (3..root).each do |i|\n if number % i == 0\n result = false\n break\n end\n end\n end\n return result\nend",
"def prime?(num)\n return false if num == 1\n (2...num).each do |number|\n return false if num % number == 0\n end\n return true\nend",
"def is_prime?(num)\n return 2 if num == 2\n (2...num).each do |n|\n return false if num % n == 0\n end\n true\nend",
"def is_prime?(number)\n if number <= 1\n return false\n end\n\n i = 2\n while i < number\n if (number % i) == 0\n return false\n end\n i += 1\n end\n return true\nend",
"def is_prime?(number)\n return false if number < 2\n\n #Start at 2, since anything lower isn't prime\n idx = 2\n\n #Anything above has a conjugatae divisor less than sqrt number.\n while idx < number**0.5\n\n if number%idx==0\n return false\n end\n\n #After 2, only check odd numbers for primeness\n if idx%2==0\n idx += 1\n else\n idx += 2\n end\n end\n\n return true\nend",
"def prime?(num)\n if num < 3\n num.even? ? true : false\n else\n for i in 2...num\n return false if num % i == 0\n end\n true\n end\nend",
"def prime?(integer)\n return false if integer < 2 || (integer.even? && integer != 2)\n\n n = Math.sqrt(integer).floor\n (2..n).none? { |x| (integer % x).zero? }\nend",
"def is_prime (number)\n if [1,2,3,5,7,11].include?(number)\n return TRUE\n end\n if number % 2 == 0 and number != 2\n # p \"not prime, divisible by 2\"\n return FALSE\n elsif number % 3 == 0 and number != 3\n # p \"not prime, divisible by 3\"\n return FALSE\n elsif number % 5 == 0 and number != 5\n # p \"not prime, divisible by 5\"\n return FALSE\n elsif number % 7 == 0 and number != 7\n # p \"not prime, divisible by 7\"\n return FALSE\n else\n divisor = 2\n # from one to the square root of a number is all the numbers it could be divided by\n # because after the square root you're repeating yourself.\n while divisor <= (Math.sqrt(number)).ceil\n # while divisor is less than the square root of the ( smallest integer greater than the number )\n if number % divisor == 0 and number != divisor\n return FALSE\n elsif (Math.sqrt(number)).ceil == divisor\n # if the divisor is equal to the square root of the ( smallest integer greater than the number )\n return TRUE\n else\n # increment the divisor\n divisor = divisor + 1\n end\n end\n end\nend",
"def prime number\n return true if number==2\n max = Math.sqrt number\n for i in 2..max\n return false if number%i==0\n end\n return true\nend",
"def prime?(number)\n if number <= 1\n return false\n\n\n elsif number.between?(2,3)\n return true\n\n\n elsif number % 2 == 0 || number % 3 == 0\n return false\n end\n\ni = 5\nwhile i*i <= number\n if number % i ==0 || number % (i+2) ==0\n false\n end\n i+=2\nend\n\ntrue\nend",
"def prime?(num)\n if 0 == num or 1 == num\n return false\n else\n return (2..Math.sqrt(num)).all? { |x| num % x != 0}\n end\nend",
"def prime?(num)\n Math.sqrt(num).to_i.downto(2).each { |i| return false if (num % i).zero? }\n true\nend",
"def prime?(number)\n is_prime = true\n is_prime = false if number <= 1\n for divisor in (2...number)\n if (number%divisor) == 0\n is_prime = false\n break\n end\n end\n is_prime\nend",
"def prime?(int)\n if int < 0 || int == 0 || int == 1 \n return false \n\n else\n (2...int).to_a.all? {|num| int % num != 0}\n\n end\nend",
"def is_prime?(num)\n if !num.is_a?(Integer) || ( num.class == Float && !num.nan? && num == num.floor ) || num <= 1\n false\n else\n (2...num).each do |i|\n if num % i == 0\n return false\n end\n end\n true\n end\nend",
"def prime?(int)\n return false if int <= 1\n (2..Math.sqrt(int)).none? { |i| (int % i).zero? }\nend",
"def prime?(num)\n return true if num == 2\n (2...num).each { |x| return false if num % x == 0 }\n true\nend",
"def prime?(arg)\nreturn false if arg <= 1\nreturn true if arg == 2\n result = true\n (3..arg).to_a.each_with_index{|num, idx|result = false if arg % (idx+1) == 0 && (idx+1) != 1}\n result\nend",
"def is_prime?(num)\n return false if num <= 1\n\n (2...num).each do |fact|\n return false if num % fact == 0\n end\n\n true\nend",
"def prime?(num)\n divis_array = (2...num)\n if num < 2 \n false\n # num == 2 elsif \n # true \n else \n divis_array.each do |prime_test|\n if num % prime_test == 0 \n return false\n end\n end\n true # true after prime test has completly run\n end\nend",
"def prime?(number)\n\tx = Math.sqrt(number).ceil\n\tfor num in 2..x\n\t\tif number % num == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend",
"def prime?(n)\n if n <= 1\n return false\n elsif n <= 3\n return true\n else (2..n/2).none? do |x|\n n % x == 0\n end\n end\nend",
"def is_prime?(number)\n if number <= 1 || number == 4 #4 is a special case because the Math.sqrt(4) will fail from start of while loop\n # only numbers > 1 can be prime.\n return false\n end\n\n index = 2 #this should have been 3 to make the is_prime? optional, but the program fails\n sqrt = Math.sqrt(number)\n while (index <= sqrt)\n \n if (number % index) == 0\n return false\n end\n\n index += 1 #this should have been 2 to make the is_prime? optional, but the program fails\n end\n\n return true\nend",
"def is_prime?(num)\n return true if num == 1\n (2...num).all? {|i| (num % i) != 0}\nend",
"def is_prime?(num)\n (2..num-1).each do |x|\n return false if num % x == 0\n end\n true\nend",
"def is_prime?(num)\n (2...num).each do |el|\n return false if num % el == 0\n end\n true\nend",
"def is_prime?(num)\n # Write your code here\n # (1..num).select { |element| num % element == 0 }.length == 2 ? true : false\n\n return false if num < 2\n\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n return true\nend",
"def is_prime number\n\ti = 1\n\tnot_prime = 0\n\tloop do\n\t\tbreak if i == number / 2\n\t\tif number % i == 0\n\t\t\tnot_prime = 1\n\t\tend\n\t\tbreak if not_prime == 1\n\t\ti = i + 1\n\tend\n\tnot_prime\nend",
"def is_prime?(num)\n (2...num).none? { |div| num % div == 0 }\nend",
"def prime?(integer)\n denominators = (2..integer - 1).to_a \n if integer < 2\n false \n else \n !(denominators.any? do |denominator| \n integer % denominator == 0\n end)\n end\nend",
"def is_prime?(num)\n (2..num/2).none?{|el| num % el == 0}\nend",
"def prime?(number)\n # binding.pry\n return false if number < 2\n (2..number - 1 ).each do|num|\n if (number % num) == 0\n return false\n end\n end\n true\nend",
"def is_prime?(num)\n (2..(num - 1)).each do |divisor|\n return false if num % divisor == 0\n end\n\n true\nend",
"def is_prime?(num)\n (2..num / 2).each do |n|\n return false if num % n == 0\n end\n true\nend",
"def prime?(num) \n return false if !num.integer? #integer is # that is not a fraction\n return false if num < 2\n return true if num == 2\n (2..num-1).each {|int| return false if num % int == 0}\n true\nend",
"def is_prime?(num)\n (2..(num/2)).each { |divisor| return false if num % divisor == 0 }\n true\nend",
"def is_prime?(num)\n for i in (2...num/2)\n if num % i == 0\n return false\n end\n end\n return true\nend",
"def prime?(num)\n return false if num < 2\n (2..num - 1).each { |div| return false if num % div == 0 }\n true\nend",
"def prime(next_number, primes)\n primes.each do |prime|\n return false if next_number % prime == 0\n end\n return true\nend",
"def prime?(num)\n if num < 2\n return false\n elsif num == 2\n return true\n end\n\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n true\nend",
"def prime?(num)\n return true if num < 3\n\n (2...num).each do |i|\n return false if num % i == 0\n end\n true\nend",
"def is_prime?(num)\n 2.upto(num / 2) do |n|\n return false if num % n == 0\n end\n true\nend",
"def prime_checker(number)\n (2..number - 1).each do |divisor|\n if number % divisor == 0\n return false\n end\n end\n true\nend",
"def prime?(num)\n if num < 2\n return false\n end\n\n (2...num).each do |divisor|\n if num % divisor == 0\n return false\n end\n end\n\n return true\nend",
"def is_prime?(num)\n if num < 2\n return false\n end\n\n idx = 2\n while idx < num\n if num % idx == 0\n return false\n end\n idx += 1\n end\n true\nend",
"def is_prime?(num)\n (2...num).each do |i|\n if num % i == 0\n return false\n end\n end\n num > 2\nend",
"def is_prime?(num)\n (2...num).each {|el| return false if num % el == 0}\n true\nend",
"def is_prime?(number)\n \n if number == 2 then return true end\n if number%2 == 0 then return false end\n if number == 3 then return true end\n if number%3 == 0 then return false end\n \n square_root= Math.sqrt(number).to_i # .to_i is not necessary, but it doesn't hurt (9<9.5 is true)\n \n divisor= 5\n while divisor <= square_root\n \n if number%divisor == 0 then return false end\n \n divisor+= 2\n if number%divisor == 0 then return false end\n \n divisor+= 4\n end\n # note the sequence of divisors, 5,7,11,13,17,19,23,25,29,31... <- these are the set of numbers not divisible by either 2 or 3 or both\n \n return true\nend",
"def is_prime?(num)\n return false if num <2\n return (2..num/2).none? {|i| num%i==0}\nend",
"def is_prime?(num)\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n true\nend",
"def is_prime?(num)\n\n return false if num<2\n\n (2...num).none? {|factor| num%factor == 0}\n\nend"
] |
[
"0.85317254",
"0.84911567",
"0.84838957",
"0.8461209",
"0.841997",
"0.84190595",
"0.84190595",
"0.8414049",
"0.8408009",
"0.8393138",
"0.8391178",
"0.8381351",
"0.8378008",
"0.8378008",
"0.8378008",
"0.83719385",
"0.8366088",
"0.836071",
"0.8359709",
"0.8347902",
"0.8341994",
"0.8333626",
"0.83318686",
"0.83312386",
"0.8325811",
"0.832493",
"0.8323186",
"0.8320827",
"0.8317281",
"0.83051264",
"0.83022535",
"0.82977545",
"0.8293258",
"0.82779855",
"0.82643145",
"0.8260432",
"0.8238843",
"0.82333827",
"0.8229386",
"0.82172704",
"0.82139957",
"0.82100266",
"0.82092357",
"0.82053536",
"0.8200158",
"0.8198654",
"0.8198352",
"0.8198016",
"0.81978923",
"0.8194019",
"0.8192878",
"0.8184286",
"0.81819016",
"0.8180561",
"0.8179248",
"0.8176919",
"0.8169946",
"0.8165732",
"0.8164568",
"0.81467885",
"0.81421125",
"0.8141448",
"0.8141002",
"0.81378984",
"0.8137244",
"0.8128052",
"0.8127801",
"0.8127291",
"0.8124911",
"0.8122759",
"0.8119932",
"0.8119639",
"0.81180286",
"0.81152886",
"0.81129926",
"0.8112148",
"0.81111044",
"0.81092525",
"0.8106651",
"0.8105444",
"0.81032604",
"0.8103163",
"0.81016415",
"0.810121",
"0.8099571",
"0.80991364",
"0.8097013",
"0.8094885",
"0.8093564",
"0.80884063",
"0.8087455",
"0.8086051",
"0.8078915",
"0.8078004",
"0.8075973",
"0.80733675",
"0.80730516",
"0.80726147",
"0.80678713",
"0.80674887"
] |
0.8473722
|
3
|
Each subarray will have strings which are anagrams of each other Time Complexity: O(n) if you pretend line 12 is a simple mathematically based hashing function, probably O (n n log n) as for each string you have to sort the string to get a key for the hash. Space Complexity: O(n) worst case is one string to one key, which is linearly dependent on the number of strings in the input array for an array of N strings, the has will at minimum expand to hold N elements, and at most 2 N elements assume all anagrams are unique
|
def grouped_anagrams(strings)
string_hash = {}
strings.each do |string|
key = string.split("").sort.join # probably an O(n log n) operation, I couldn't find an integer based hashing function i liked
string_hash[key] ||= [] # trying this thing out
string_hash[key] << string
end
return string_hash.values # also probably an O(n) operation
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def group_anagrams(arr)\n hash = Hash.new { |h, k| h[k] = [] }\n arr.each do |str|\n hash[str.chars.sort] << str\n end\n\n hash.values.map(&:sort)\nend",
"def anagrams(array_of_words)\n ana_hash = Hash.new { |hash, key| hash[key] = [] }\n array_of_words.each { |word| ana_hash[word.split(\"\").sort.join] << word }\n ana_hash.map { |key, list| list }.select { |list| list.size > 1 }\nend",
"def grouped_anagrams(strings)\n hash = {}\n acc = 0\n return_array = []\n strings.each do |str|\n if !(hash[str.split(//).sort!.join().hash])\n hash[str.split(//).sort!.join().hash] = acc\n return_array[acc] = [str]\n acc += 1\n else\n return_array[hash[str.split(//).sort!.join().hash]] << str\n end\n end\n return return_array\nend",
"def grouped_anagrams(strings)\n hash_map = {}\n \n strings.each do |str| #n\n chars = str.chars #k length of string\n sorted = chars.sort # k log(k)\n hash_map[sorted] ? hash_map[sorted].push(str) : hash_map[sorted] = [].push(str)\n end\n \n return hash_map.values\nend",
"def anagrams(string, array)\nend",
"def grouped_anagrams(strings)\n\n string_hash = {}\n\n strings.each do |string|\n \n temp = string.chars.sort.join\n if string_hash.has_key?(temp)\n string_hash[temp] << string\n else\n string_hash[temp] = Array.new()\n string_hash[temp] << string\n end\n \n end\n return string_hash.values\n\nend",
"def grouped_anagrams(strings)\n hash_ana = {}\n outerArray = []\n\n # The way I identify they are anagrams is using bytes to get the ASCII value of each char sum them,\n # Then we know all the characters have the same letter on it.\n strings.each do |string|\n if hash_ana[string.bytes.sum]\n hash_ana[string.bytes.sum].push(string)\n else\n hash_ana[string.bytes.sum] = [string]\n end\n end\n\n hash_ana.each do |key|\n outerArray << key[1]\n end\n\n return outerArray\nend",
"def grouped_anagrams(strings)\n\n new_hash = Hash.new()\n\n strings.each do |word|\n # calculate the hash key\n key_word = word.downcase.chars.sort.join\n\n if new_hash[key_word] == nil\n new_hash[key_word] = []\n end\n array_value = new_hash[key_word]\n\n length = array_value.length\n array_value[length] = word\n end\n\n return new_hash.values\nend",
"def grouped_anagrams(strings)\n # create an anagrams hash of arrays\n anagrams = {}\n # for each string, split the characters and sort them\n # join the characers, and test the hash keys\n # if the key already exists add it to the array of that key\n # if not create one\n strings.each do |word| \n sorted_word = word.split(//).sort.join\n if anagrams[sorted_word]\n anagrams[sorted_word] << word\n else\n anagrams[sorted_word] = [word]\n end\n end\n \n # return the arrays\n anagrams.values\nend",
"def grouped_anagrams(strings)\n hash = {}\n\n strings.each do |string|\n sorted_string_array = string.split(\"\").sort\n\n if hash[sorted_string_array]\n hash[sorted_string_array] << string\n else\n hash[sorted_string_array] = [string]\n end\n end\n\n answer = []\n\n hash.each do |key, value|\n answer.push(value)\n end\n\n return answer\nend",
"def grouped_anagrams(strings)\n return [] if strings.length == 0\n\n result = []\n hash = {}\n count = 0\n\n strings.each do |string|\n sorted_string = string.chars.sort.join\n\n if hash[sorted_string] \n result[hash[sorted_string]].push(string)\n else\n hash[sorted_string] = count\n result.push([string])\n count += 1\n end\n end\n\n return result\nend",
"def grouped_anagrams_version2(strings)\n # edge cases\n return [] if strings.empty?\n return [[strings[0]]] if strings.size == 1\n # new array has the same number of elements as the input array\n # each inner array has 25 elements, by the number of letter in the English alphabet\n anagrams_storage = {}\n strings.each do |word|\n letters = Array.new(26, 0)\n word.chars.each do |char|\n # get an Integer ordinal of a letter\n letters[char.ord - 97] += 1\n end\n\n # we freeze the array as a key because it's recommended not to have mutable data structures as keys\n letters = letters.freeze\n # check if there is a hash equal to this newly created one.\n # checks key-value pairs, not their order\n if !anagrams_storage[letters]\n anagrams_storage[letters] = Array.new\n anagrams_storage[letters] << word\n else\n anagrams_storage[letters] << word\n end\n end\n # as a result we have \n # { [1,0,0,0...all 26 elements] => [\"tan\", \"nat\", \"ant\"] }\n return anagrams_storage.values\nend",
"def grouped_anagrams(strings)\n hash = {}\n strings.each do | i |\n key = i.chars.sort.join\n if hash[key] != nil \n hash[key] << i\n else \n hash[key] = [i]\n end\n end\n return hash.values\n\nend",
"def grouped_anagrams(strings) \n h = {}\n return [] if strings.nil? || strings.empty? || !strings.is_a?(Array)\n strings.each do |str| \n key = str.chars.sort.join\n if h.include?(key)\n h[key] << str\n else\n h[key] = [str]\n end \n end\n return h.values\nend",
"def combine_anagrams(words)\r\n big_array = Array.new\r\n hash = Hash.new(0)\r\n words.each do |w| \r\n array = Array.new\r\n array = w.downcase.split(//)\r\n if hash.has_key?(array.sort) \r\n hash[array.sort]=hash[array.sort].push(w)\r\n else\r\n hash[array.sort]=Array.[](w)\r\n end\r\n end\r\n hash.each { |key,value| big_array.push(value) }\r\n big_array\r\nend",
"def anagram_hash(input)\n list = {} # empty hash\n input.each do |word| # iterates over each word in the array\n add_word = word.chars.sort.join # sorts the anagrams\n list[add_word] ||= []\n list[add_word] << word\n end\n # list of all anagrams and words\n list.values\nend",
"def grouped_anagrams(strings)\n return [] if strings.empty?\n\n #create empty hash\n hash = {}\n strings.each do |word|\n alphabet = word.chars.sort.join\n if !hash[alphabet]\n hash[alphabet]\n else\n hash[alphabet] = [word]\n end\n end\nend",
"def grouped_anagrams(strings)\n return [] if strings.empty?\n\n anagram_hash = Hash.new()\n strings.each do |string|\n word_array = string.split(\"\").sort\n if anagram_hash.include?(word_array)\n anagram_hash[word_array] << string\n else\n anagram_hash[word_array] = [string]\n end\n end\n\n result = []\n anagram_hash.each do |key, value|\n result << value\n end\n return result\n\nend",
"def group_anagrams(strs)\n hash = {}\n \n strs.each do |s|\n sorted = s.split('').sort().join()\n if !hash[sorted]\n hash[sorted] = [s]\n else\n hash[sorted].push(s)\n end\n end\n\n hash.values\nend",
"def grouped_anagrams(strings)\n hash = Hash.new\n strings.each do |element|\n key = element.chars.sort.join()\n groupedAnagrams = hash[key]\n if groupedAnagrams == nil\n hash[key] = []\n groupedAnagrams = hash[key]\n end\n groupedAnagrams << element\n end\n return hash.values\nend",
"def grouped_anagrams(strings)\n results = []\n return results if strings.empty?\n\n hash_map = {}\n set_no = 1 \n\n strings.each do |word|\n letters = word.split('').sort!\n\n if hash_map.empty?\n hash_map[set_no] = letters\n set_no += 1\n elsif !hash_map.has_value?(letters)\n hash_map[set_no] = letters\n set_no += 1\n end \n end \n\n results = []\n\n hash_map.keys.each do |sub_arr|\n sub_arr = []\n results << sub_arr\n end \n\n strings.each do |word|\n letters = word.split('').sort!\n\n if hash_map.has_value?(letters)\n sub_group = hash_map.key(letters)\n results[sub_group-1] << word\n end \n end \n\n results.each do |list|\n list.sort!\n end \nend",
"def grouped_anagrams(strings)\n return [] if strings.empty?\n hash = {}\n\n strings.each do |string|\n alphabetized = string.chars.sort.join\n\n if hash[alphabetized]\n hash[alphabetized] << string\n else\n hash[alphabetized] = [string]\n end\n end\n return hash.values\nend",
"def group_anagrams(strs)\n result = Hash.new{|h,k| h[k] = []}\n strs.each do |str|\n hash = Hash.new(0)\n str.each_char do |char|\n hash[char] +=1\n end\n result[hash] << str\n end\n return result.values\nend",
"def combine_anagrams(words)\n hash = {}\n words.each do |str|\n sorted = str.chars.sort { |a, b| a.casecmp(b) } .join\n down = sorted.downcase\n if (hash[down]== nil)\n hash[down] = Array.new\n end\n arr = hash[down]\n arr[arr.length] = str\n hash[down] = arr\n# puts \"[sorted] is \\\"\" + sorted + \",\\\" and hash[sorted] is \" + hash[sorted].inspect\n arr = nil\n end\n hash.values\nend",
"def anagrams(array)\n copy_array = array.dup\n result_array = []\n iteration_idx = 0\n until copy_array.empty?\n \n word = copy_array.pop\n next if word.nil?\n \n result_array << []\n result_array[iteration_idx] << word\n copy_array.each do |sub_word|\n next if sub_word.nil?\n if are_anagrams?(sub_word, word)\n result_array[iteration_idx] << sub_word\n idx = copy_array.index(sub_word)\n copy_array[idx] = nil\n end\n end\n \n iteration_idx += 1\n end\n \n result_array\nend",
"def grouped_anagrams(strings)\n if strings.length == 0\n return []\n end\n\n anagram_hash = {}\n\n strings.each do |string|\n sorted_letters = string.split(\"\").sort.join\n if anagram_hash[sorted_letters]\n anagram_hash[sorted_letters] << string\n else\n anagram_hash[sorted_letters] = [string]\n end\n end\n return anagram_hash.values\nend",
"def my_anagram(type_array) \n #Create Hash container\n storage_hash = {} \n #Take given array argument and opperate on each element.\n #Anagrams are words that can be spelled using the same letters. Order inmaterial. \n\n #Split text into Array / Sort String.split(\"\") Array using Array.sort. / String.join \n #Iterate over array input\n\n type_array.each do |word|\n word_sorted = word.split(\"\").sort.join\n #Check to see if word sorted is already in container (storage_array)\n if storage_hash.has_key?(word_sorted)\n storage_hash[word_sorted].push(word)\n else\n #add the new unique storage key\n storage_hash[word_sorted] = [word]\n end\n end\n #Iterate threw your storage and print results\n storage_hash.each do |key, value|\n puts \"---#{key}----\"\n p value\n end\nend",
"def grouped_anagrams(strings)\n return [] if strings.empty?\n\n hash_groups = []\n anagrams_grouped = []\n\n strings.each do |string|\n string_hash = {}\n\n # count freq of characters in string through hash\n string.each_char do |char|\n if string_hash[char]\n string_hash[char] += 1\n else\n string_hash[char] = 1\n end\n end\n\n # if no hash_groups exist, add new string hash to hash group and add string to anagrams list\n if hash_groups.empty?\n hash_groups << string_hash\n anagrams_grouped << [string]\n \n # otherwise, test string hash against all previous hashes, if match, add to existing anagram group, if unique, add hash group, create new anagram group\n else\n unique = true\n hash_groups.each_with_index do |hash, index|\n if hash == string_hash\n unique = false\n anagrams_grouped[index] << string\n end\n end\n\n if unique\n hash_groups << string_hash\n anagrams_grouped << [string]\n end\n end\n end\n\n return anagrams_grouped\nend",
"def grouped_anagrams(strings)\n return [] if strings.length == 0\n \n hash = {}\n strings.each do |word|\n sorted_word = word.split(\"\").sort\n if hash[sorted_word]\n hash[sorted_word] << word\n end\n end\n final_anagrams = []\n hash.each do |k, v|\n anagrams << v\n end\n return final_anagrams\nend",
"def grouped_anagrams(strings)\n\n hash = {}\n\n # take each word in 'strings' array ...\n strings.each do |word|\n # ... and split it into letters, alphabetize those letters, and join them back together: this produces a standardized string for words that are anagrams of each other ('ate', 'eat' => 'aet')\n letters = word.split(//).sort().join()\n \n # if the standardized string isn't already in the hash, add it as the key and an empty array as the value\n if hash[letters].nil?\n hash[letters] = []\n end\n\n # push the word to the array for the associated standardized string\n hash[letters] << word\n\n end\n\n # return the values (array of words that are anagrams) for each standardized string\n return hash.values\n\nend",
"def grouped_anagrams(strings)\n res = []\n return res if strings.empty?\n hash = {}\n strings.each do |word|\n key = word.split(\"\").sort.join\n if hash[key]\n hash[key] << word\n else\n hash[key] == [word]\n end\n end\n hash.each do |k, v|\n res << v \n end\n return res\nend",
"def grouped_anagrams(strings)\n # edge cases\n return [] if strings.empty?\n return [[strings[0]]] if strings.size == 1\n # a hash is going to have hashes with letters as a key, and array of words\n # containing those letters as values\n anagrams_storage = {}\n strings.each do |word|\n # create a hash with letters as keys and a number of times it appears in that word as values\n letters = {}\n word.chars.each do |char|\n if letters[char]\n letters[char] += 1\n else\n letters[char] = 1\n end\n end\n # we freeze the hash as a key because it's recommended not to have mutable data structures as keys\n letters = letters.freeze\n # check if there is a hash equal to this newly created one.\n # checks key-value pairs, not their order\n if !anagrams_storage[letters]\n anagrams_storage[letters] = Array.new\n anagrams_storage[letters] << word\n else\n anagrams_storage[letters] << word\n end\n end\n # as a result we have \n # { {\"t\"=>1,\"a\"=>1,\"n\"=>1} => [\"tan\", \"nat\", \"ant\"], \"b\"=>1,\"a\"=>1,\"t\"=>1} => [\"bat\"] }\n return anagrams_storage.values\nend",
"def grouped_anagrams(strings)\n anagram_hash = Hash.new\n\n strings.each do |word|\n sorted_string = word.chars.sort.join\n\n #Check if key exists with the sorted string already\n #In case of yes, add the word to the array value of the key \n if anagram_hash[sorted_string]\n anagram_hash[sorted_string] += [word] \n\n #If not, set it as a new key/value pair in the hash\n else \n anagram_hash[sorted_string] = [word]\n end \n end \n return anagram_hash.valuesend\n\n# This method will return the k most common elements\n# in the case of a tie it will select the first occuring element.\n# Time Complexity: O(n)\n# Space Complexity: O(n)\ndef top_k_frequent_elements(list, k)\n result = []\n\n hash = Hash.new\n \n list.each do |letter|\n if hash[letter]\n hash[letter] += 1\n else \n hash[letter] = 1\n end \n end \n\n k.times do \n max = nil\n hash.each do |num, value|\n\n if value && (max.nil? || value > max)\n max = num \n end \n end \n\n if max \n hash[max] = nil \n result << max \n end \n end \n return result end\n\n\n# This method will return the true if the table is still\n# a valid sudoku table.\n# Each element can either be a \".\", or a digit 1-9\n# The same digit cannot appear twice or more in the same \n# row, column or 3x3 subgrid\n# Time Complexity: ?\n# Space Complexity: ?\ndef valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def anagrams(array, string)\n dictionary = dictionary_hash(array)\n anagrams = []\n letters = string.chars.sort.join\n if dictionary.has_key?(letters)\n anagrams = dictionary[letters]\n end\n if anagrams.empty?\n \"No anagrams were found for #{string}\"\n else\n anagrams.each do |word|\n puts word\n end\n end\nend",
"def combine_anagrams(wordArray)\n \n \n sortedCharsHash = Hash.new\n groupedArray = Array.new\n n = 0\n \n wordArray.each do |word|\n \n #if freq hash not in freq hash array, put in there and add to grouped array\n #if freq hash in freq hash array, iterate through items until match and put in there\n \n sortedChars = word.downcase.split(//).sort.join\n if sortedCharsHash[sortedChars]\n groupedArray[sortedCharsHash[sortedChars].to_i] << word\n else\n sortedCharsHash[sortedChars] = n\n n = n +1\n groupedArray << [word]\n end\n end\n \n return groupedArray\n \n \nend",
"def combine_anagrams(strings)\n lettercombinations = strings.map{|string| string.downcase.count_regex(/\\w/)}\n lettercombinationsunique = lettercombinations.uniq\n lettercombinationsindex = lettercombinations.map{|lettercombination| lettercombinationsunique.index(lettercombination)}\n newarray = lettercombinationsunique.map{[]}#pitfall, new will make the same copy of the array throughout\n strings.each_index{|i| newarray[lettercombinationsindex[i]].push(strings[i])}\n newarray\nend",
"def funWithAnagrams(word_arr)\n # Write your code here\n visited = {}\n\n word_arr.each_with_index do |word,idx|\n if visited[word.split(\"\").sort.join(\"\")]\n word_arr[idx] = \"\"\n else\n visited[word.split(\"\").sort.join(\"\")] = 1\n end\n end\n\n word_arr.delete(\"\")\n word_arr.sort\nend",
"def grouped_anagrams(strings)\n string_hashmap = {}\n strings.each do |string|\n if string_hashmap[grouped_anagrams_helper(string)]\n string_hashmap[grouped_anagrams_helper(string)] << string\n else\n string_hashmap[grouped_anagrams_helper(string)] = []\n string_hashmap[grouped_anagrams_helper(string)] << string\n end\n end\n return string_hashmap.values\nend",
"def combine_anagrams(words)\r\n\th = Hash.new\r\n\twords.each do |a_word|\r\n\t\tkey = a_word.downcase.chars.sort.join\r\n\t\tputs key\r\n\t\tputs \"-------\"\r\n\t\tif h[key] == nil\r\n\t\t\th[key] = Array.new\r\n\t\tend\r\n\t\th[key].push(a_word)\r\n\tend\r\n\t\r\n\tr_a=Array.new\r\n\t\r\n\th.each do |key, list|\r\n\tr_a.push(list)\r\n\tend\r\n\treturn r_a\r\nend",
"def combine_anagrams(words)\n anagrams = Hash.new()\n words.each do |word|\n letters = word.downcase.gsub(/[^a-z]/, \"\").split(\"\").sort.join\n anagrams[letters] = Array.new unless anagrams.include?(letters)\n anagrams[letters] << word\n end\n anagrams.values\nend",
"def combine_anagrams(words)\n #h=Hash.new(0)\n output = Array.new\n words.map{|word| word.chars.sort.join }.uniq.each {|anagram|\n w = words.partition { |word| word.chars.sort.join==anagram}\n# puts \"w : \" + w.to_s\n output += [w[0]]\n# puts \"output : \" + output.to_s\n }\n return output\nend",
"def grouped_anagrams(strings)\n return [] if strings.empty?\n anagram_hash = {}\n \n strings.each do |word|\n letters = word.split(\"\").sort.join(\"\")\n if anagram_hash[letters].nil?\n anagram_hash[letters] = [word]\n else\n anagram_hash[letters] << word\n end\n end\n return anagram_hash.values\nend",
"def grouped_anagrams(strings)\n word_hash = {}\n\n strings.each do |word|\n char_hash = {}\n\n word.each_char do |char|\n if char_hash[char] \n char_hash[char] += 1\n else\n char_hash[char] = 1\n end\n end\n\n if word_hash[char_hash]\n word_hash[char_hash] << word\n else\n word_hash[char_hash] = [word]\n end\n end\n\n return word_hash.values\nend",
"def grouped_anagrams(strings)\n return [] if strings == []\n anagrams = {}\n\n strings.each_with_index do |string, i|\n sorted_string = string.split(\"\").sort.join(\"\").downcase\n if anagrams[sorted_string]\n anagrams[sorted_string] << string\n else\n anagrams[sorted_string] = [string]\n end\n end\n\n return anagrams.values\nend",
"def anagrams_of(string)\n return [string[0]] if string.length == 1\n\n collection = []\n\n substring_anagrams = anagrams_of(string[1, string.length - 1])\n\n substring_anagrams.each do |substring_anagram|\n (0..substring_anagram.length).each do |index|\n copy = String.new(substring_anagram)\n collection << copy.insert(index, string[0])\n end\n end\n collection\nend",
"def grouped_anagrams(strings)\n strings = {}\n\n strings.each do |string|\n # https://stackoverflow.com/questions/9464065/how-to-sort-a-strings-characters-alphabetically\n alphabetized_string = string.chars.sort.join\n if strings[alphabetized_string]\n strings[alphabetized_string] << [string]\n else\n strings[alphabetized_string] = [string]\n end\n end\n\n return strings.values\nend",
"def combine_anagrams(words)\n result = Hash.new\n words.each do |word|\n sw = word.downcase.split(//).sort\n if !result.has_key?(sw)\n result[sw] = Array.new\n end\n result[sw] << word\n end\n result.values\nend",
"def anagrams_for(word, array)\n #Pasar la palabra a minuscula para que sea igual\n word.downcase!\n #Arreglo vacio para meter los que sean anagramas\n arr = []\n #Separar la palabra en su forma canonica\n cano = word.chars.sort\n #iterar dentro de cada palabra del array\n array.each do |dicc|\n #crear una variable donde pase la palabra del array a su forma canonica\n word_cano = dicc.chars.sort\n #si la palabra es igual a la palabra del array\n #Ya las 2 en su forma canonica\n if cano == word_cano\n #mete la palabra a el array\n arr << dicc\n #De lo contrario deja el array igual\n else\n arr\n end\n end\n #Regresar el array lleno si habia palabras\n #o vacio si no las encontro\n arr\nend",
"def grouped_anagrams(strings)\n sorted_words = {}\n anagrams = []\n\n strings.each do |word|\n word_sorted = word.chars.sort.join\n if !sorted_words.keys.include?(word_sorted)\n # In the hashmap, the sorted word will point to the index in the outer array that the anagram should be placed.\n index = sorted_words.length\n sorted_words[word_sorted] = index\n anagrams[index] = [word]\n else\n # Add anagram to correct group.\n anagrams[sorted_words[word_sorted]].push(word)\n end\n end\n\n return anagrams\nend",
"def anagrams_for(word, array)\n p array.select {|w| canonical(word) == canonical(w)}\nend",
"def grouped_anagrams(strings)\n result = []\n return result if strings.empty?\n\n anagrams = {}\n strings.each do |string|\n sorted_string = string.split(\"\").sort.join(\"\")\n anagrams[sorted_string] ? anagrams[sorted_string] << string : anagrams[sorted_string] = [string]\n end\n\n return anagrams.values\nend",
"def grouped_anagrams(strings)\n hash = {}\n\n strings.each do |word|\n letter_grouping = word.split('').sort().join()\n\n if !hash[letter_grouping]\n hash[letter_grouping] = []\n end \n \n hash[letter_grouping] << word\n end \n\n return hash.values\nend",
"def anagrams(string, array)\n string_anagram = string.chars\n \n array.select! do |word|\n word.chars.all? do |letter|\n word.chars.count(letter) == string_anagram.count(letter)\n end\n end\n array\nend",
"def combine_anagrams(words)\r\n buckets = Hash.new([])\r\n words.each do | item |\r\n key = item.downcase.chars.sort.join\r\n\r\n if buckets.has_key?(key)\r\n buckets[key] << item\r\n else\r\n buckets[key] = [item]\r\n end\r\n end\r\n\r\n output = Array.new;\r\n buckets.each do | key, value |\r\n output << value\r\n end\r\n return output\r\nend",
"def combine_anagrams(words)\n#\n\n hash = {}\n words.each{ |word| \n key = word.downcase.split(//).sort\n hash[key] = (hash[key] || []) + [word]\n }\n ans = []\n hash.map{ |k, v|\n ans += v\n }\n ans\nend",
"def grouped_anagrams(strings)\n return [] if strings.empty?\n numbered_letters = {}\n ('a'..'z').each_with_index { |l, i| numbered_letters[l] = i}\n\n possible_anagrams = {}\n\n strings.each do |string|\n value = 0\n string.each_char do |char|\n value += numbered_letters[char]\n end\n if possible_anagrams[value]\n possible_anagrams[value] << string \n else\n possible_anagrams[value] = [string]\n end\n end\n\n return possible_anagrams.values\nend",
"def combine_anagrams(words)\n\th = Hash.new{|hash, key| hash[key] = Array.new;}\n\twords.each do |word| h[word.downcase.split(//).sort.join] << word end\n\th.values \nend",
"def anagram(words)\n words_hash = {}\n\n words_hash = words.each_with_object(Hash.new []) do |word, hash|\n hash[word.chars.sort] += [word]\n end\n\n words_array = words_hash.flatten\n final_hash = []\n\n words_array.each_index do |index|\n final_hash << words_array[index] if index.odd?\n end\n\n return final_hash\nend",
"def grouped_anagrams(strings)\n grouped = {}\n strings.each do |e|\n current_sorted = e.split(\"\").sort.join(\"\") \n if !grouped[\"#{current_sorted}\"]\n grouped[\"#{current_sorted}\"] = [e]\n else\n grouped[\"#{current_sorted}\"] << e\n end \n end \n return grouped.values\nend",
"def combine_anagrams(words)\r\n\r\n h=Hash.new([])\r\n words.map {|w| key=w.downcase.split('').sort.join; h[key]+=[w]}\r\n h.values\r\n \r\nend",
"def combine_anagrams(words)\r\n # <YOUR CODE HERE>\r\n # create a hash to store the anagrams and return arrays of the hash\r\n h = Hash.new \r\n words.each {|x|\r\n key = x.downcase.split(//).sort.join\r\n if h.has_key? key then\r\n a = h[key]\r\n h[key] = a.push(x)\r\n else\r\n h[key]= [x]\r\n end\r\n }\r\n return_array = Array.new\r\n # TODO Figure out how to build an array of arrays\r\n h.each_key {|x| return_array.push (h[x])}\r\n return return_array\r\nend",
"def grouped_anagrams(strings)\n words = {} \n \n until strings.empty? \n i = 0 \n word_to_compare = strings[0] # \"eat\" => \"tan\" => \"bat\"\n words[word_to_compare] = []\n # [\"eat\", \"tea\", \"ate\"]\n # [\"tan\", \"nat\"]\n # [\"bat\"]\n\n while i < strings.length \n if permutation(word_to_compare, strings[i])\n words[word_to_compare].push(strings[i])\n strings.delete_at(i) \n i -= 1\n end\n i += 1 # 0 => 0\n end\n end\n\n return words.values\nend",
"def anagrams_for(word, array)\n array.find_all {|element| are_anagrams?(word, element)}\nend",
"def grouped_anagrams(strings)\n return strings if strings.empty?\n \n anagrams = {}\n # for each word, if the sum is in the hash\n strings.each do |word|\n if anagrams[word.sum].nil?\n anagrams[word.sum] = [word]\n else\n anagrams[word.sum] << word\n end\n end\n \n return anagrams.values\nend",
"def all_anagrams(string)\n return [string] if string.length <= 1\n\n options = all_anagrams(string[1..-1])\n\n result = []\n\n options.each do |sub|\n string.length.times do |i|\n result << sub[0...i] + string[0] + sub[i..-1]\n end\n end\n\n result\nend",
"def combine_anagrams(words)\r\n hash = Hash.new\r\n words.each{|w|\r\n key = w.downcase.chars.sort * \"\"\r\n if hash.has_key?(key)\n hash[key] += [w]\n else\n hash[key] = [w]\n end}\r\n return hash.values\r\nend",
"def combine_anagrams(words)\n\thashes = Hash.new(0)\n\twords.each do |x|\n\t\talpha_word = x.downcase.chars.sort.join\n\n\t\tif hashes[alpha_word] == 0\n\t\t\thashes[alpha_word] = [x]\n\t\telse\n\t\t\thashes[alpha_word] = hashes[alpha_word] << x\n\t\tend\n\tend\n\toutArray = Array.new\n\thashes.each do |key, value|\n\t\toutArray << value\n\tend\n\t\n\treturn outArray\nend",
"def anagrams(str1, str2)\n \nend",
"def combine_anagrams(words)\r\n cage = Hash.new()\r\n words.each do |word|\r\n sorted_word = word.split('').sort.join\r\n if cage.has_key?(sorted_word)\r\n cage.store(sorted_word, cage.fetch(sorted_word).push(word))\r\n else\r\n cage.store(sorted_word, Array.new(1,word))\r\n end\r\n end\r\n return cage.values\r\nend",
"def combine_anagrams(words)\n return [] if words.nil?\n return [] if words.length == 0\n\n h = Hash[]\n words.each {|x|\n s = x.strip.downcase.chars.sort.join\n if !h.has_key?(s)\n h[s] = [x]\n else\n h[s].push(x)\n end\n }\n h.values\nend",
"def combine_anagrams(words)\r\n hash = Hash.new([])\r\n anagrams = []\r\n words.each do |word|\r\n keyword = word.downcase.chars.sort.join\r\n hash[keyword] += [word]\r\n end\r\n hash.each_value do |words|\r\n anagrams += [words]\r\n end\r\n return anagrams\r\nend",
"def grouped_anagrams(strings)\n return [] if strings.empty?\n\n result = {}\n groups = []\n\n strings.each do |word|\n key = word.split(\"\").sort.join\n if result.has_key?(key)\n result[key] << word\n else\n result[key] = [word]\n end\n end\n\n result.each do |k, v|\n groups << v\n end\n\n return groups\nend",
"def combine_anagrams(words)\n anagrams = Hash.new([])\n for i in 0..(words.length - 1)\n anagram_found = false\n if (i == 0)\n anagrams[words[i]] = []\n end\n for j in 0..(i-1)\n# puts \"Comparing #{words[i]} and #{words[j]}\"\n anagram1 = merge_sort(words[i].downcase)\n anagram2 = merge_sort(words[j].downcase)\n# puts \"#{anagram1} #{anagram2}\"\n if (merge_sort(words[i].downcase) == merge_sort(words[j].downcase))\n# puts \"#{words[i]} and #{words[j]} are the same anagram.\"\n anagrams[words[j]] << words[i]\n anagram_found = true\n #puts \"anagrams: #{anagrams.to_s}\"\n break\n end\n end\n anagrams[words[i]] = [] unless (anagram_found)\n end\n\n # Convert hash to an array.\n anagrams_arr = hash_to_array(anagrams)\n return anagrams_arr\n #return anagrams\nend",
"def find_anagrams(target_word, array_of_words)\n array_of_anagrams = []\n\n array_of_words.each do |member|\n if member.split(//).sort == target_word.split(//).sort\n array_of_anagrams.push(member)\n else\n next\n end\n end\n array_of_anagrams\nend",
"def combine_anagrams(words)\n @results = []\n word_bins = words.group_by { |word| word.length }\n word_bins.values.map { |sublist| \n sublist = sublist.zip(sublist)\n sublist.map { |wordpairs| wordpairs[0] = wordpairs[0].downcase.chars.sort.join }\n # collect unique keys for this sublist:\n keys = sublist.collect { |list| list[0] }.uniq\n # print \"keys: \", keys, \"\\n\"\n keys.each do |key| \n anagrams = sublist.collect { |list| list[0] == key ? list[1] : nil }\n anagrams.compact!\n @results << anagrams\n # print \"anagrams= \", anagrams, \"\\n\"\n end\n # print sublist.length, \": \", sublist, \"\\n\\n\" \n }\n # print \"final results: \", @results, \"\\n\"\n @results\nend",
"def combine_anagrams_method2(words)\n\ttemp1 = Array.new\n\ttemp1 = words.clone\t# making a deep copy of the input \n\tanagram = Array.new\t\n\ti = 0\n\twhile i < temp1.length\t\t\t\n\t\tcount = 0 # count the number of anagrams of a particular string say \"cars\"\n\t\tfor j in i+1..(temp1.length - 1)\n\t\t\tif temp1[i].downcase.chars.sort.join == temp1[j].downcase.chars.sort.join \n\t\t\t\tcount = count + 1\n\t\t\t\ttemp1[j],temp1[i+count] = temp1[i+count],temp1[j] # get all the anagrams to one place by swapping\n\t\t\tend\n\t\tend\n\t\tanagram.push([temp1[i..i+count]]) # pushing the array of anagrams into anagram array say [\"cars\", \"racs\", \"scar\"]\n\t\ti = i + count + 1\n\tend\n\t# printing each group\n\tfor i in 0..anagram.length-1\n\t\tprint \"anagram[\" + i.to_s + \"]: \" \n\t\tputs anagram[i]\n\tend\t\nend",
"def combine_anagrams(words)\r\n words.sort!{|a, b| a.length <=> b.length}\r\n letters = words.map{|w| w.downcase.split(//).sort}\r\n outp = Array.new \r\n prev_a = []\r\n for w in words\r\n if letters[words.index(w)] == prev_a\r\n outp[outp.length - 1].push(w)\r\n else\r\n outp.push([w])\r\n prev_a = letters[words.index(w)]\r\n end\r\n end\r\n return outp\r\nend",
"def combine_anagrams(words)\n h = Hash.new()\n\n words.each do |word|\n lowercase_word = word.downcase\n sorted_lowercase_word = lowercase_word.chars.sort.join\n\n similar_words = h[sorted_lowercase_word]\n if not similar_words\n similar_words = []\n end\n similar_words << word\n h[sorted_lowercase_word] = similar_words\n\n end\n\n output = []\n h.each_value { |value| output << value }\n return output\nend",
"def combine_anagrams(words)\n outp = Hash.new;\n words.each{|w| idx = w.downcase.chars.to_a.sort.join; if outp[idx] == nil then outp[idx] = Array.new; end; outp[idx].push(w); };\n return outp.values ;\nend",
"def combine_anagrams(words)\n output_array = Array.new(0) #create a new output array\n words.each do |firstword| \n\ttemp_array = [] #create a temp array \n words.each do |nextword|\n\t\tif (nextword.downcase.split(//).sort == firstword.downcase.split(//).sort) #compare if two words are anagrams\n\t\t\ttemp_array.push(nextword) #if so, push nextword to array\n\t\tend\n end\n output_array.push(temp_array) #push word to output array, then move up\n end\n \n return output_array.uniq #output array\nend",
"def combine_anagrams(words)\n Array anagrams = []\n words.each {|x|\n flag = false\n anagrams.collect {|y|\n if x.downcase.chars.to_a.sort == y[0].downcase.chars.to_a.sort then\n y << x\n flag = true\n break\n end\n }\n unless flag; anagrams << [x] end \n }\n anagrams\nend",
"def combine_anagrams(words)\n result = Array.new\n words.each do |i|\n anagrams = Array.new\n sorted = i.downcase.chars.sort.join\n words.each do |j|\n if j.downcase.chars.sort.join == sorted\n anagrams << j\n end\n end\n result << anagrams\n end\n return result.uniq\nend",
"def combine_anagrams(words)\n hash = Hash.new\n words.each {|w|\n if(hash[w.downcase.split(\"\").sort().join] == nil)\n hash[w.downcase.split(\"\").sort().join] = [] \n end\n hash[w.downcase.split(\"\").sort().join] << w\n }\n rList = []\n hash.each_value{|v|\n rList << v\n }\n return rList\n\nend",
"def combine_anagrams(words)\r\n\tanagrams = words.group_by { |word| word.chars.sort }.values\t\r\nend",
"def combine_anagrams(words) \r\n anagrams = words.inject(Hash.new()) do |r, word|\r\n key = word.downcase.chars.sort.join\r\n r[key] ||=[]\r\n r[key] << word\r\n r\r\n end\r\n anagrams.values\r\nend",
"def combine_anagrams(words)\n\n ouArr = Array.new\n\n words.each do |w|\n\n ouIt = Array.new [w]\n\n words.each do |w2|\n if w.downcase.chars.sort == w2.downcase.chars.sort && !ouIt.include?(w2)\n ouIt.push(w2)\n end\n end\n ouIt.sort!\n\n if !ouArr.include?(ouIt)\n ouArr.push(ouIt)\n end\n end\n ouArr\nend",
"def grouped_anagrams(strings)\n result = {}\n strings.each do |word|\n letter_occurrence = {}\n word.each_char do |char|\n if letter_occurrence[char] \n letter_occurrence[char] += 1\n else\n letter_occurrence[char] = 1\n end\n end\n \n if result[letter_occurrence]\n result[letter_occurrence] << word\n else\n result[letter_occurrence] = [word]\n end\n end\n return result.values\nend",
"def combine_anagrams(words)\n hash = {}\n anagrams = []\n\n words.each { |w| \n sorted = w.downcase.each_char.sort.join \n\n if (hash.has_key?(sorted))\n hash[sorted].push w\n else\n hash[sorted] = Array.new.push(w)\n end\n }\n\n hash.each_value { |v|\n anagrams.push v\n }\n\n return anagrams\nend",
"def combine_anagrams(list)\n hash_to_anagrams = Hash.new { |h,k| h[k] = Array.new }\n list.each { |word| hash_to_anagrams[hash_for(word)] << word }\n hash_to_anagrams.keys.map { |key| hash_to_anagrams[key] }\nend",
"def combine_anagrams(words)\n words_hash = Hash.new{ |hash, key| hash[key] = [] }\n words.each { |word| word_key = word.downcase.chars.sort.join; words_hash[word_key] = words_hash[word_key] << word; }\n words_list = Array.new()\n words_hash.keys.each { |key| words_list << words_hash[key] }\n return words_list\nend",
"def combine_anagrams(words)\n anagram_group = Hash.new([])\n words.each {|word| anagram_group[word.downcase.split(//).sort.join] += [word]}\n return anagram_group.values\nend",
"def combine_anagrams(words)\n output = []\n if words.length == 0\n return output\n end\n words.each do |item|\n s_string = item.downcase.chars.sort.join.to_s\n temp_arry = []\n words.each do |scan|\n if s_string == scan.downcase.chars.sort.join.to_s\n temp_arry << scan\n end\n end\n if output.include?(temp_arry)\n #do nothing\n else\n output << temp_arry\n end\n end\n return output\nend",
"def anagrams(str)\n return [str] if str.length < 2\n result = []\n first = str[0]\n prev_perms = anagrams(str[1..-1])\n prev_perms.each do |perm|\n (0...perm.length).each do |i|\n result << perm[0...i] + first + perm[i..-1]\n end\n end\n result\nend",
"def fifth_anagram?(word1, word2) # O(n)\n \n p \"Running fifth_anagram...\" \n\n start = Time.now\n \n hash1 = Hash.new(0)\n # hash2 = Hash.new(0)\n\n word1.each_char {|char| hash1[char] += 1}\n word2.each_char {|char| hash1[char] += 1}\n\n hash1.values.all? {|v| v.even?}\n\n\n # puts \"Took #{Time.now - start} seconds\"\n\n \nend",
"def combine_anagrams(words)\r\n words.group_by{|w| w.downcase.chars.sort.to_s}.values\r\nend",
"def grouped_anagrams(strings)\n \n inventory = {}\n # key = alphabetically sorted word\n # value = array of original word(s), where each can be sorted into the key.\n # example: \"bat\" from strings[] would show up in inventory as \"abt\" => [\"bat\"]\n # and later if \"tab\" is found in strings[], inventory would now include \"abt\" => [\"bat\", \"tab\"]\n \n strings.each do |word|\n # source for line below: https://solidfoundationwebdev.com/blog/posts/how-to-sort-a-string-alphabetically-in-ruby\n sortedWord = word.chars.sort_by(&:downcase).join\n \n if inventory[sortedWord]\n inventory[sortedWord] << word \n else\n inventory[sortedWord] = [word]\n end\n end\n \n output = []\n inventory.each do |key, value|\n output << value\n end\n \n return output\nend",
"def anagram(words)\r\n result = words.group_by { |word| word.chars.sort.join }\r\n result.each {|k, v| p v unless v.size == 1}\r\nend",
"def combine_anagrams(words)\n words_uniq = words.map{ |w| w.downcase.split(//).sort.join }.uniq\n words_uniq.map{ |wu| words.select{ |w| w.downcase.split(//).sort.join == wu }}\nend",
"def combine_anagrams(words)\n word_list = Hash.new{|h, k| h[k] = []}\n \n words.each do |word|\n sorted = word.downcase.chars.sort.join\n # if not (word_list.include? sorted and word_list[sorted].include?(word))\n word_list[sorted] << word\n # end\n end\n \n word_list.map { |key,value| value }\nend",
"def match(array) #takes in an array of possible anagrams\n anagrams = []\n \n # iterate over array of words\n array.each do |word|\n # compare each word of array to OG word \n # determine if word is anagram\n if word.chars.sort == @word.chars.sort\n anagrams << word\n end\n end\n anagrams #return all matches/ empty array if no matches exist\n end"
] |
[
"0.79885423",
"0.7935334",
"0.7923127",
"0.7874945",
"0.7807073",
"0.7719393",
"0.7689198",
"0.76115584",
"0.7574334",
"0.7565763",
"0.755894",
"0.755675",
"0.7552811",
"0.7519341",
"0.7513236",
"0.7502722",
"0.74964917",
"0.7465122",
"0.7446689",
"0.744336",
"0.74047935",
"0.73909664",
"0.7387006",
"0.73642534",
"0.73566306",
"0.7355286",
"0.7349181",
"0.73351204",
"0.7317035",
"0.7313244",
"0.72968835",
"0.7296778",
"0.72748005",
"0.7258515",
"0.7195688",
"0.7193937",
"0.7180721",
"0.7174978",
"0.7167048",
"0.7162752",
"0.7160697",
"0.715986",
"0.7158888",
"0.7153064",
"0.7146395",
"0.71295065",
"0.7121907",
"0.71203923",
"0.7117566",
"0.71096057",
"0.7092916",
"0.7065739",
"0.70636153",
"0.7047675",
"0.70346695",
"0.70346665",
"0.70325714",
"0.7022972",
"0.6999767",
"0.6986143",
"0.6977838",
"0.6966687",
"0.6955292",
"0.69545084",
"0.694545",
"0.69410545",
"0.69382674",
"0.6931155",
"0.6924887",
"0.6906462",
"0.69061756",
"0.6903469",
"0.690331",
"0.6899398",
"0.6894199",
"0.68931925",
"0.68835723",
"0.687756",
"0.6867916",
"0.68584037",
"0.6848277",
"0.683859",
"0.68272805",
"0.68265915",
"0.68255347",
"0.68229383",
"0.6819892",
"0.6817505",
"0.6804754",
"0.6802612",
"0.6797965",
"0.6789616",
"0.67872936",
"0.67705375",
"0.67664146",
"0.6754857",
"0.67530334",
"0.6747463",
"0.67434174",
"0.67319715"
] |
0.7949817
|
1
|
This method will return the k most common elements in the case of a tie it will select the first occuring element. Time Complexity: O(n) First runs through length of list, then all elements in list via list param, then all hash objects in hash, then another array with size of list sequentially, which adds up to O(3n) or just O(n) Space Complexity: O(n) Two arrays and one hash is created whose size depend on the number of elements in the list. No nesting, stays O(n)
|
def top_k_frequent_elements(list, k)
return [] if list.empty?
# list tracking quantities
total_ele = list.length # O(n) operation
return list if total_ele == 1
top_k = Array.new(total_ele + 1){[]} # plus one for better tracking
count_hash = {}
# get frequencies of each element, O(n)
list.each do |e|
count_hash[e] ||= 1
count_hash[e] += 1
end
# use a non-nested O(n) operation to sort
# frequencies in top_k
count_hash.each do |k,v|
top_k[v] << k
end
return_arr = []
# sort array in order now
until total_ele == 0
if(!top_k[total_ele].empty?)
return_arr += top_k[total_ele]
end
total_ele -= 1
end
return return_arr[0...k]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def top_k_frequent_elements(list, k)\n\n return [] if list.empty?\n \n # create a hash that has each element as key and number of occurrences as value: [1, 1, 1, 2, 2, 3] => {1=>3, 2=>2, 3=>1}\n hash = {}\n list.each do |element|\n if hash[element].nil?\n hash[element] = 1\n else \n hash[element] += 1\n end\n end\n \n # get the keys associated with k max values. There is almost certainly a better way to do this \n max_arrays = hash.max_by(k) {|key, value| value} # this returns k hash pairs as arrays: {1=>3, 2=>2, 3=>1}, k = 2 => [[1, 3], [2, 2]]\n\n # return the first element from each array\n max_keys = []\n max_arrays.each do |array|\n if k == 1\n # \"will work for an array when k is 1 and several elements appear 1 time\" situation: return the first key with value of 1 in the element counts hash\n max_keys << hash.min[0]\n else\n max_keys << array[0]\n end\n end\n\n return max_keys\n\nend",
"def top_k_frequent_elements(list, k)\n result = []\n\n hash = Hash.new\n \n list.each do |letter|\n if hash[letter]\n hash[letter] += 1\n else \n hash[letter] = 1\n end \n end \n\n k.times do \n max = nil\n hash.each do |num, value|\n\n if value && (max.nil? || value > max)\n max = num \n end \n end \n\n if max \n hash[max] = nil \n result << max \n end \n end \n return result end",
"def top_k_frequent_elements(list, k)\n return list if list.empty? || list.size == 2\n\n elements = []\n hash = {}\n\n list.each do |elem|\n if hash[elem]\n hash[elem] += 1\n else\n hash[elem] = 1\n end\n end\n\n k.times do\n max_key = hash.key(hash.values.max)\n elements << max_key\n hash.delete(max_key)\n end\n return elements\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n hash = {}\n\n list.each do |element|\n if hash[element]\n hash[element] += 1\n else\n hash[element] = 1\n end\n end\n\n answer = []\n answer_length = 0\n\n highest_freq = hash.values.max\n\n while answer_length < k\n hash.each do |element, count|\n if count == highest_freq\n answer << element\n answer_length += 1\n end\n\n break if answer_length == k\n end\n\n highest_freq -= 1\n end\n\n return answer\nend",
"def top_k_frequent_elements(list, k)\n result_arr = []\n return result_arr if list.length == 0\n\n frequency_hash = {}\n\n list.each do |element|\n if frequency_hash[element]\n frequency_hash[element] += 1\n else\n frequency_hash[element] = 1\n end\n end\n\n k.times do\n top_element = nil\n top_frequency = 0 \n\n frequency_hash.each do |element, frequency|\n top_frequency = frequency && top_element = element if frequency > top_frequency\n end\n\n result_arr << top_element\n frequency_hash[top_element] = 0\n end\n\n return result_arr\nend",
"def top_k_frequent_elements(list, k)\n h = {}\n solution = []\n return solution if list.nil? || list.empty? || !list.is_a?(Array)\n list.each do |element|\n if h.include?(element)\n h[element] += 1\n else\n h[element] = 1\n end\n end\n k.times do\n top = nil\n h.each do |element,value| \n if value && (top.nil? || value > top)\n top = element\n end\n end \n if top \n h[top] = nil\n solution << top\n end\n end \n return solution\nend",
"def top_k_frequent_elements(list, k)\n res = []\n return res if list.empty?\n hash = {}\n list.each do |num|\n if hash[num]\n hash[num] += 1\n else\n hash[num] = 1\n end\n end\n \n k.times do \n max = nil\n hash.each do |num, v|\n if v && (max.nil? || v > max)\n max = num \n end\n end\n if max\n hash[max] = nil\n res << max\n end\n end\n \n return res\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n count_hash = Hash.new(0)\n result = []\n\n list.each do |element|\n count_hash[element] += 1\n end\n\n max_array = count_hash.sort_by { |k, v| -v }\n\n (0...k).each do |i|\n result << max_array[i][0]\n end\n\n return result\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n return list if list.length == 1\n\n element_count = Hash.new()\n\n list.each do |element|\n if element_count[element]\n element_count[element] += 1\n else\n element_count[element] = 1\n end\n end\n\n result = []\n\n k.times do |i|\n count = 0\n frequent_element = nil\n element_count.each do |element, frequency|\n if frequency > count\n count = frequency\n frequent_element = element\n end\n end\n result << frequent_element\n element_count[frequent_element] = 0 if frequent_element\n end\n\n return result\n\nend",
"def top_k_frequent_elements(list, k)\n hash = {}\n \n list.each do |value|\n if hash[value]\n hash[value] += 1\n else\n hash[value] = 1\n end\n end\n \n top_elements = Array.new(k)\n return top_elements = hash.sort_by{ |key, value| value } \nend",
"def top_k_frequent_elements(list, k)\n return list if list.empty? || list.length == k\n count = {}\n \n list.each do |num|\n count[num] ? count[num] += 1 : count[num] = 1\n end\n \n sorted = count.sort_by { |k, v| -v }\n \n most_frequent = Array.new(k)\n k.times { |i| most_frequent[i] = sorted[i][0] } \n \n return most_frequent\nend",
"def top_k_frequent_elements(list, k)\n return [] if list == []\n\n frequency = {}\n list.each do |element|\n if frequency[element]\n frequency[element] += 1\n else\n frequency[element] = 1\n end\n end\n\n k_frequent_elements = []\n\n k.times do |i|\n max_freq = 0\n max_freq_element = nil\n frequency.each do |element, freq|\n if freq > max_freq\n max_freq = freq\n max_freq_element = element\n end\n end\n k_frequent_elements << max_freq_element\n frequency[max_freq_element] = 0 if max_freq_element\n end\n\n return k_frequent_elements\nend",
"def top_k_frequent_elements(list, k)\n # load a hash table which has elements & their frequency \n element_frequency = {}\n array = []\n return array if list.length == 0\n\n list.each do |val|\n if !(element_frequency[val])\n element_frequency[val] = 1\n else\n element_frequency[val] += 1\n end\n end\n\n values = element_frequency.values.sort!\n inverted_hash = element_frequency.invert\n \n k.times do |i|\n array << inverted_hash[values[i]]\n end\n\n return array \nend",
"def top_k_frequent_elements(list, k)\n k_freq = []\n return k_freq if list.empty?\n \n hash_map = Hash.new\n\n list.each do |element| \n hash_map[element] ? hash_map[element] += 1 : hash_map[element] = 1\n end\n \n vals = hash_map.values \n max_vals = vals.max(k) \n \n max_vals.each do |val| \n key = hash_map.key(val)\n k_freq << key\n hash_map.delete(key)\n end\n return k_freq\nend",
"def top_k_frequent_elements(list, k)\n return [] if list == []\n hash = Hash.new(0)\n counter = 0;\n list.each do |value|\n hash[value] = [] if hash[value].nil?\n hash[value]+=1\n end\n \n if k > hash.size()\n raise ArgumentError, \"Not Enough Values to Display\"\n end\n \n solution = hash.max(k){ |a, b| b<=>a} \n p solution\n numbers = []\n solution.each do |array|\n numbers << array[0]\n end\n return numbers\nend",
"def top_k_frequent_elements(list, k)\n return nil if !list\n # intialze an empty hash\n ## iterate throught the list\n #chechk if the key is in the hash,\n # if key is in the hash ++ value\n # otherwise add key and value as 1 since it's first occurance\n # now the key(uniqe) and value(how many time the int_value) happend is in the hash,\n # my_hash.sort_by { |_, value| value }.each { |key, value| puts key } (iterate throught the hash, (hash.each {|key, value|}) )\n # before pushing the key into the initalized array, check to see if the length is less than k\n # if\n hash = Hash.new\n list.each do |int_value|\n if hash.key?(int_value)\n hash[key] = +1\n else\n hash[key] = 1\n end\n end\n kth_frequent_elements = []\n counter = 0 \n pervisou_value = 0\n hash.sort_by { |k, v| -v }.each do |key, value|\n if counter < k\n kth_frequent_elements << key\n if pervisou_value != value\n pervisou_value = value\n counter += 1\n end\n # end\n # if kth_frequent_elements.length < k\n # kth_frequent_elements << key\n else\n break\n end\n end\n return kth_frequent_elements\nend",
"def top_k_frequent_elements(list, k)\n element_occurrence = {}\n list.each do |element|\n if element_occurrence[element]\n element_occurrence[element] += 1\n else\n element_occurrence[element] = 1\n end\n end\n \n sorted_pairs = element_occurrence.sort_by {|key, value| -value }\n output = []\n k.times do |index|\n return output if sorted_pairs[index].nil?\n output << sorted_pairs[index].first\n end\n return output\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n frequency_count = Hash.new(0)\n list.each do |num|\n frequency_count[num] += 1\n end\n\n top_k = frequency_count.to_a.sort_by { |e| e[1] }\n\n if k == 1\n top_k.first(k).map { |e| e[0] }\n else\n top_k.last(k).map { |e| e[0] }\n end\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n frequency = {}\n list.each do |i|\n frequency[i] ? (frequency[i] += 1) : (frequency[i] = 1)\n end\n\n nums = []\n unique = list.uniq\n max = frequency.values.max\n\n until max == 0 || nums.length == k\n unique.each do |i|\n break if nums.length == k\n if frequency[i] == max\n nums << i\n end\n end\n max -= 1\n end\n\n return nums\nend",
"def top_k_frequent_elements(list, k)\n return [] if k == 0\n\n frequency = {}\n list.each do |element|\n frequency[element] ? frequency[element] += 1 : frequency[element] = 1\n end\n\n return frequency.keys[0...k]\nend",
"def top_k_frequent_elements(list, k)\n results = []\n\n return list if list.length == k\n return results if list.length == 0 \n\n list = list.sort.uniq\n\n i = 0\n k.times do \n results << list[i]\n i += 1\n end \n return results\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n counts_hash = {}\n\n list.each do |number|\n if !counts_hash[number]\n counts_hash[number] = 1 \n else\n counts_hash[number] = counts_hash[number] + 1\n end\n end\n\n length_to_num_hash = {}\n\n counts_hash.keys.each do |number|\n if !length_to_num_hash[counts_hash[number]]\n length_to_num_hash[counts_hash[number]] = []\n end\n length_to_num_hash[counts_hash[number]] << number\n end\n\n result_length = k\n result = []\n most_freq_num = length_to_num_hash.keys.max\n\n while result_length > 0 && most_freq_num != nil && most_freq_num >= 0\n if length_to_num_hash[most_freq_num]\n length_to_num_hash[most_freq_num].each do |num|\n result << num\n result_length -= 1\n break if result_length <= 0\n end\n end\n most_freq_num -= 1\n end\n\n return result\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n \n element_count = {}\n \n list.each do |element|\n if element_count[element].nil?\n element_count[element] = 1\n else\n element_count[element] += 1\n end\n end\n \n sorted_elements = element_count.sort_by(&:first)\n \n i = 0\n max_nums = []\n k.times do\n max_nums << sorted_elements[i][0]\n i += 1\n end\n \n return max_nums\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty? || k == 0\n\n item_with_freq = []\n item_freq = {}\n\n # make hash with freq of each element\n list.each do |item|\n if item_freq[item]\n item_freq[item] += 1\n else\n item_freq[item] = 1\n end\n end\n\n # turn hash into array and sort by freq\n item_with_freq = item_freq.to_a\n item_with_freq.sort_by { |item| item[1] }\n\n # iterate through sorted array k times and pull out top items\n top_items = []\n k.times do |i|\n top_items << item_with_freq[i][0]\n end\n\n return top_items\nend",
"def top_k_frequent_elements(list, k)\n # list = [1,1,1,2,2,3]\n # k = 2\n return [] if list == []\n\n counter = {}\n\n list.each do |value|\n if counter[value]\n counter[value] += 1\n else\n counter[value] = 1\n end\n end\n\n puts counter\n\n ordered = counter.sort_by{ |key, value| value } \n\n k_most = []\n\n k.times do |i|\n k_most << ordered[-i]\n end\n\n return k_most\nend",
"def top_k_frequent_elements(list, k)\n \n return [] if list.empty?\n ranked_hash = {}\n ranked = []\n\n list.each do |element|\n if ranked_hash.has_key?(element)\n ranked_hash[element] += 1\n else\n ranked_hash[element] = 1\n end\n end\n\n sorted = ranked_hash.sort_by { | k, v | -v }\n\n k.times do \n max = sorted.shift\n ranked << max[0]\n k -= 1\n end\n\n return ranked \n\nend",
"def top_k_frequent_elements(list, k)\n if list.length == 0 \n return []\n end \n nums = {}\n list.each do |num|\n if !nums[num]\n nums[num] = 1\n else\n nums[num] += 1\n end\n end \n\n sorted = nums.sort_by {|k, v| -v}\n top_k = []\n k.times do |k|\n top_k << sorted[k][0]\n end \n return top_k\nend",
"def top_k_frequent_elements(list, k)\n # build hashmap\n num_hash = {}\n list.each do |num|\n if num_hash[num]\n num_hash[num] += 1\n else\n num_hash[num] = 1\n end\n end\n\n # convert hashmap to array\n array_num_hash = num_hash.to_a\n\n # sort by occurences\n sorted_array_num_hash = array_num_hash.sort_by {|num| -num[1]}\n\n # sorted elements only\n sorted_numbers = sorted_array_num_hash.map{|num| num[0]}\n\n # slice sorted array by k elements\n return sorted_numbers.slice(0, k)\nend",
"def top_k_frequent_elements(list, k)\n counter_hash = {}\n list.each do |value|\n if counter_hash[value].nil?\n counter_hash[value] = 1\n else\n counter_hash[value] += 1\n end\n end \n \n values_sort = counter_hash.sort_by {|key, value| -value}\n k_values = values_sort.slice(0..(k-1))\n final_values = []\n k_values.each do |value|\n final_values << value[0]\n end\n \n return final_values\nend",
"def top_k_frequent_elements_version2(list, k)\n # edge cases\n return list if list.empty? || list.size == 1\n\n occurances_counter = {}\n list.each do |digit|\n if occurances_counter[digit]\n occurances_counter[digit] += 1\n else\n occurances_counter[digit] = 1\n end\n end\n # occurances_counter looks like this for input [1,1,2,2,2]: {1=>2, 2=>3}\n # create an array out of this hash, sort it by values and return keys of k elements\n sorted_occurances = occurances_counter.to_a.sort_by{ |pair| pair[1]}\n number_pairs = sorted_occurances.slice(sorted_occurances.length - k, k)\n result = number_pairs.map do |pair|\n pair[0]\n end\n return result\nend",
"def top_k_frequent_elements(list, k)\n return list if list.empty?\n\n num_frequency = {}\n\n list.each do |num|\n num_frequency[num] ? num_frequency[num] += 1 : num_frequency[num] = 1\n end\n\n top_frequent_nums = []\n\n k.times do\n max_frequency = 0\n max_frequent_num = nil\n\n num_frequency.each do |key, value|\n if value > max_frequency\n max_frequency = value\n max_frequent_num = key\n end\n end\n\n top_frequent_nums << max_frequent_num\n num_frequency[max_frequent_num] = 0\n end\n\n return top_frequent_nums\nend",
"def top_k_frequent_elements(list, k)\n # edge cases\n return list if list.empty? || list.size == 1\n\n occurances_counter = {}\n list.each do |digit|\n if occurances_counter[digit]\n occurances_counter[digit] += 1\n else\n occurances_counter[digit] = 1\n end\n end\n # occurances_counter looks like this for input [1,1,2,2,2]: {1=>2, 2=>3}\n\n # create an array with the input number of elements + 1\n # at indexes equal to occurance number I will store an array of occured digits\n # +1 to have the last index available, e.g. [1,1,1] => [nil, nil, nil, (here at index 3 will be digit 1)]\n sorted_occurances = Array.new(list.size + 1)\n occurances_counter.each do |digit, counter|\n if !sorted_occurances[counter]\n sorted_occurances[counter] = Array.new\n sorted_occurances[counter] << digit\n else\n sorted_occurances[counter] << digit\n end\n end\n # sorted_occurances array for input c will be like: [nil, nil, [1,3], [2], nil, nil]\n # reverse to keep the needed order of inner arrays elements, then flatten and get rid of nil elements\n sorted_occurances = sorted_occurances.reverse.flatten.select { |element| !element.nil? }\n # the result is: [2,3,1] where 1 is least frequent, 2 is most frequent in the input array\n # the last step is to slice the k number of elements\n result = sorted_occurances.slice(0, k)\n return result\nend",
"def top_k_frequent_elements(list, k)\n # create a counter hash for the numbers\n counter = {}\n # go through the list of numbers\n # test the hash keys, if it is not there, add it with a number 1 value\n # otherwise increment the value by 1\n list.each do |num|\n if !counter[num]\n counter[num] = 1\n else\n counter[num] += 1\n end\n end\n\n # list.each do |element|\n # counts[element] ||= 0\n # counts[element] += 1\n # end\n\n # find the K max counts\n highest_counts = counter.values.max(k)\n # return the values of those keys\n most_frequent = []\n highest_counts.each do |n|\n most_frequent << counter.key(n)\n counter.delete(counter.key(n))\n end\n return most_frequent\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_b(nums, k)\n nums\n .inject(Hash.new(0)) { |h, n| h[n] += 1; h }\n .sort_by { |_, v| -v }\n .first(k)\n .map(&:first)\nend",
"def find_most_frequent_integer(arr)\n #1. Create hash variable with default 0 value.\n hashld = Hash.new 0\n \n #2. Loop through each array element, count them, and insert the final key/value combo into the hashld hash.\n arr.each do |ele|\n \t hashld[ele] += 1\n end\n \n #3. Hold max count in variable.\n maxd = hashld.values.max\n \n #4. Create new hash containing keys with more than 1 count.\n fnlhsh = (hashld.select {|key,value| value == maxd})\n \n #5. Return array if size == 1, else return nil. \n if fnlhsh.size == 1\n final_val = fnlhsh.keys.join.to_i\n else \n final_val = nil\n end\n \n return final_val\nend",
"def frequent_itemsets\n k = 2\n l = [nil, large_one_itemsets]\n\n # Transform itemsets into a mapping of tid to {Itemset}\n tid_itemsets = database.map do |tid, items|\n [tid, items.map do |item|\n l[k - 1].find { |itemset| itemset.items[0] == item }\n end.compact.to_set]\n end\n\n until l[k - 1].empty?\n cks = gen(l[k - 1])\n kth_tid_itemsets = Hamster::Hash[{}]\n\n tid_itemsets.each do |tid, set_of_itemsets|\n # Find candidate itemsets in ck contained in the transaction\n cts = set_of_itemsets.flat_map do |ck_1|\n ck_1.extensions.select do |ck|\n ck.generators.subset?(set_of_itemsets)\n end\n end.to_set\n\n # Register the support for each transaction candidate\n cts.each { |ct| ct.support += 1 }\n\n # Update the transaction candidate list for the next k value\n kth_tid_itemsets = kth_tid_itemsets.merge(tid => cts) unless cts.empty?\n end\n\n l[k] = cks.select { |candidate| candidate.support >= min_support }\n tid_itemsets = kth_tid_itemsets.map do |tid, cts|\n [tid, cts.select { |c| l[k].include?(c) }.to_set]\n end\n\n k += 1\n end\n\n l.flatten.compact.map(&:to_h)\n end",
"def most_common_value(a)\n a.group_by do |e|\n e\n end.values.max_by(&:size).first\nend",
"def most_common_number(array)\n #var\n numbers_and_count = Hash.new 0\n \n array.each do |num|\n \tnumbers_and_count[num] += 1\n end\n #var\n most = numbers_and_count.sort_by { |key, value| value }.reverse\n \n top = Hash[*most.first]\n top.select { |k,v| p k }\n\nend",
"def k_most_visited input, k\n \n hotels_to_visits = Hash.new\n \n input.each do |user|\n user.each do |hotel_id|\n hotels_to_visits[hotel_id] = (hotels_to_visits[hotel_id] || 0) + 1\n end\n end\n \n sorted_hotels_and_visits = hotels_to_visits.to_a.sort { |a,b| a[1] < b[1] }\n \n return sorted_hotels_and_visits[0..k]\n \nend",
"def grouped_anagrams(strings)\n anagram_hash = Hash.new\n\n strings.each do |word|\n sorted_string = word.chars.sort.join\n\n #Check if key exists with the sorted string already\n #In case of yes, add the word to the array value of the key \n if anagram_hash[sorted_string]\n anagram_hash[sorted_string] += [word] \n\n #If not, set it as a new key/value pair in the hash\n else \n anagram_hash[sorted_string] = [word]\n end \n end \n return anagram_hash.valuesend\n\n# This method will return the k most common elements\n# in the case of a tie it will select the first occuring element.\n# Time Complexity: O(n)\n# Space Complexity: O(n)\ndef top_k_frequent_elements(list, k)\n result = []\n\n hash = Hash.new\n \n list.each do |letter|\n if hash[letter]\n hash[letter] += 1\n else \n hash[letter] = 1\n end \n end \n\n k.times do \n max = nil\n hash.each do |num, value|\n\n if value && (max.nil? || value > max)\n max = num \n end \n end \n\n if max \n hash[max] = nil \n result << max \n end \n end \n return result end\n\n\n# This method will return the true if the table is still\n# a valid sudoku table.\n# Each element can either be a \".\", or a digit 1-9\n# The same digit cannot appear twice or more in the same \n# row, column or 3x3 subgrid\n# Time Complexity: ?\n# Space Complexity: ?\ndef valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def k_largest_elements(array, k)\nend",
"def mode(list)\n my_hash = {}\n list.each do |item| \n if my_hash[item]\n my_hash[item] += 1\n else\n my_hash[item] = 1\n end\n end\n max_count = my_hash.values.max\n my_hash.select { |key, value| value == max_count }.keys\nend",
"def find_most_frequent_integer(arr)\n collect = Hash.new 0\n \n arr.each do |int|\n collect[int] += 1\n end\n \n if collect.select {|k,v| v == collect.values.max}.count > 1\n nil\n else\n collect.key(collect.values.max)\n end\nend",
"def k_largest_elements(array, k)\n heap = BinaryMinHeap.new { |a,b| b <=> a }\n result = []\n array.each do |el|\n heap.push(el)\n if heap.count > array.length - k\n result << heap.extract\n end\n end\n\n result\nend",
"def find_most_frequent_integer(arr)\n highest_value = Hash.new(0)\n store_integer = Array.new\n arr.each do |x|\n highest_value[x] += 1\n end\n highest_value.each do |key,value|\n if value == highest_value.values.max \n store_integer.push(key) #need to put the highest value somewhere, so an array it will have to be! This was the hardest step for me. I could figure out how to return the key from the above step, but that wasn't helpful since one couldn't directly compare the keys (but putting them in an array worked.)\n end\n end \n if store_integer.length == 0 or store_integer.length >= 2 #This will return nil if there is no most frequent integer (like in the case of an empty hash), or if there are several of the most frequent integer amount\n return nil\n else\n return store_integer[0] \n end \n \nend",
"def find_key(cipher)\n (0..2).map do |offset|\n # Create a sublist starting at the given offset, taking every 3rd element\n elems = cipher.values_at(*(offset..cipher.length).step(3))\n # Find the most common item\n item = elems.group_by { |x| x }.values.max_by { |vs| vs.size }.first\n # We assume it's an int representing the ord of the space character\n item ^ \" \".ord\n end\nend",
"def find_most_frequent_integer(arr)\n #use a Hash to keep track of the number of duplicates\n new_hash = Hash.new(0)\n #iterate through each element in the array\n arr.each do |element|\n #add all elements to the new_hash and add one to the key's value if there's a duplicate\n new_hash[element] += 1\n end\n #make sure that the Array passed in contained something\n if new_hash.empty?\n return nil\n end\n #create empty array to add the key(s) with the \"highest value\" value(s)\n comparison_array = []\n #iterate through each key and value in new_hash\n new_hash.each do |x, y|\n #compare each value to the \"max\" value of the hash\n if y == new_hash.values.max\n #add any keys that match the \"highest value\" value in the \n #hash to the new array\n comparison_array.push(x)\n end\n end\n #check if more than one key was added to the new array\n if comparison_array.count > 1\n #if the array contains more than one element then there was more than one\n #repeated integer\n return nil\n else\n #if the array contains only one element then that element is the most\n #frequent integer\n return comparison_array[0]\n end\nend",
"def majority_element_3(nums)\n majority = nums.size / 3\n result = []\n counts = nums.inject({}) { |acc, n| \n acc[n] ||= 0\n acc[n] += 1\n if acc[n] > majority && !result.include?(n)\n result << n\n end\n \n acc\n }\n \n return result\nend",
"def find_most_frequent_integer(arr)\n most = []\n freq = Hash.new(0)\n arr.each do |i|\n freq[i] += 1\n end\n freq.each do |k,v|\n if v == freq.values.max\n most.push(k)\n end\n end\n if most.count > 1\n nil\n else return most[0]\n end\nend",
"def mode(array)\n instance = Hash.new(0)\n array.each do |item|\n instance[item] += 1\n end\n most_frequent = instance.values.max\n p instance.collect { |k, v| k if v == most_frequent }.compact\nend",
"def find_most_frequent_integer(arr)\n count_hash = arr.each_with_object (Hash.new(0)) { |element, counts| counts[element] += 1 }\n count_hash.each { |key, value| return key if value == count_hash.values.max }\nend",
"def find_most_frequent_integer(arr)\n new_array=[]\n final_array=[]\n if arr.uniq.length==0\n return nil\n else\n array_to_use=arr.uniq\n array_to_use.each do |x| \n new_array << [arr.count(x), x]\n final_array=new_array.sort\n end\n end\n count_array=[]\n final_array.each do |x|\n count_array << x.reverse\n end\n just_count_array=[]\n count_array.each do |x|\n just_count_array << x.pop\n end\n z=just_count_array[-1]\n res=just_count_array[0..-2].include?(z)\n if res==false\n return final_array[-1][1]\n end\nend",
"def find_unique_elements(arr)\n freq = Hash.new #hash to count integers in using key as integer and value as count\n answer = Array.new #array to store the answer to be returned in\n\n \n arr.each {|a| #loop through every element in array \n if freq[a] != nil #check to see if hash value exists\n freq[a] = freq[a] + 1 #add 1 to the hash value\n else \n freq[a] = 1 #create the hash value\n end\n }\n\n\n freq.each {|key, value| #loop through all key and value combinations in hash\n if value == 1 #If the value is 1 it is unique so add it to the answer array to be returned\n answer << key\n end\n } \n return answer\n\nend",
"def find_most_frequent_integer(arr)\n empty = {}\n max = {}\n num = nil\n \n i = 0 \n while i < arr.length\n if empty.has_key?(arr[i]) == true\n empty[arr[i]] += 1\n else\n empty[arr[i]] = 1\n end\n i+=1\n end\n \n empty.each do |key,value|\n if value == empty.values.max\n max[key] = value\n num = key\n end\n end\n \n max.length > 1 ? nil : num\n \nend",
"def numberOfPairs(a,k)\n count = 0\n find_arr(a,k).each do |pair|\n if uniq(pair,k)\n count += 1\n end\n end\n return count\nend",
"def mode(items)\n keys = items.uniq\n occurences = Hash.new\n\n keys.each do |element|\n occurences[element] = items.count { |item| item == element }\n end\n\n count = 0\n mode = []\n occurences.each do |key, value|\n if value > count\n mode[0], count = key, value\n end\n end\n\n occurences.each do |key, value|\n if value == count && !mode.include?(key)\n mode << key\n end\n end\n\n mode\nend",
"def mode(array)\n count = Hash.new 0\n array.each do |n|\n count[n] += 1\n end\n\n frequency = count.values.max\n \n x = []\n count.each do |k, v|\n if frequency == v \n x.push k\n end\n end\n x\nend",
"def find_most_frequent_integer(arr)\n counts = Hash.new(0)\n\n arr.each do |int|\n counts[int] += 1\n end\n\n freq = counts.values\n # returns array of frequencies [2,1]\n\n if freq.uniq! == false && freq.uniq.length > 1\n freq.max\n counts.key(freq.max)\n else\n nil\n end\n\n \nend",
"def most_common(arr) #sort array first\n arr.sort!\n most_common = 0\n most_common_count = 0\n type_count = 0\n prev = 0\n\n arr.each do |type|\n if prev == type\n type_count += 1\n else\n prev = type\n type_count = 1\n end\n\n if type_count > most_common_count\n most_common = type\n most_common_count = type_count\n end\n end\n\n most_common\nend",
"def mode(arr)\n\th = {}\n\tarr.each do |x| \n\t\th [x] = arr.count(x)\n\tend\n\tarr = h.values.sort\n highest_count = arr.last\n h.select {|k,v| v == highest_count}.keys\nend",
"def most_frequent(nums)\n hash = {}\n max_occurence = 0\n\n nums.each do |num|\n if !hash.has_key?(num.to_s)\n hash[num.to_s] = 1\n else\n hash[num.to_s] += 1\n if max_occurence < hash[num.to_s] \n max_occurence = hash[num.to_s]\n end\n end\n end\n\n hash.select { |key, value| value == max_occurence }\n .map { |key, value| key.to_i} \nend",
"def duplicates(array)\n frequency = Hash.new(0)\n array.each do |element|\n frequency[element] += 1\n end\n frequency.each do |k, v|\n return k if v > 1\n end\nend",
"def mode (list)\n\tmodes = []\n\tmost_numbers = 0\n\tcounts = Hash.new 0\n\tlist.each do |number|\n\t\tlist.count(number)\n\t\tif most_numbers < list.count(number)\n\t\t\tmost_numbers = list.count(number)\n\t\tend\n\tend\n\tlist.each do |number|\n\t\tlist.count(number)\n\t\tif list.count(number) == most_numbers\n\t\t\tmodes.push(number)\n\t\tend\n\tend\n\tmodes = modes.uniq\n\treturn modes\nend",
"def most_frequent_bigram(str)\n new_array =[]\n new_arr = []\n hash = {}\n hash = Hash.new {|k, v| hash[k] = 0}\n new_str = str.split(\"\")\n (0...new_str.length).each do |i0|\n (i0...new_str.length).each do |iz|\n pair = new_str[i0..iz]\n new_array << pair\n end\n end\n\n new_array.each do |combined|\n if combined.length == 2\n new_arr << combined \n end\n end\n \n new_arr.each do |pairs| \n hash[pairs] += 1\n end\n \n hash.each {|k, v| return k.join(\"\") if v == hash.values.max}\n\n \nend",
"def common_characters(arr)\n target_count = arr.count\n\n hash = Hash.new(0)\n (0...target_count).each do |i|\n arr[i].split('').each do |letter|\n hash[letter] += 1\n end\n end\n\n result = []\n hash.each do |k, v|\n while v >= target_count\n if v >= target_count\n result << k\n v -= target_count\n end\n end\n end\n\n result\nend",
"def k_largest_elements2(array, k) \n result = BinaryMinHeap.new\n k.times do\n result.push(array.pop)\n end\n until array.empty?\n result.push(array.pop)\n result.extract\n end\n result.store\nend",
"def appears_most_times(array)\n hash = {}\n max = 0\n key_max = array[0]\n array.each do |num|\n if hash[num].nil?\n hash[num] = 1\n else\n hash[num] += 1\n end\n if hash[num] > max\n max = hash[num]\n key_max = num\n end\n end\n key_max\nend",
"def majority_element(nums)\n majority_1 = nil\n majority_2 = nil\n count_1 = 0\n count_2 = 0\n nums.each { |x|\n if count_1 == 0 || x == majority_1\n count_1 += 1\n majority_1 = x\n elsif count_2 == 0 || x == majority_2\n count_2 += 1\n majority_2 = x\n else\n count_1 -= 1\n count_2 -= 1\n end\n }\n\n result = []\n if nums.count{ |x| x == majority_1 } > nums.size / 3\n result << majority_1 unless majority_1.nil?\n end\n if majority_1 != majority_2 && nums.count{ |x| x == majority_2 } > nums.size / 3\n result << majority_2 unless majority_2.nil?\n end\n\n result\nend",
"def mode(array)\n\thash = Hash.new(0)\n \t\tarray.each do |i|\n \t\thash[i] += 1\n \tend\n\tfinal_array = []\n \tn = 0\n \tfrequent_value = hash.values[0]\n \twhile n < hash.length\n\t\tif frequent_value < hash.values[n]\n \t\tfrequent_value = hash.values[n]\n \tend\n \tn += 1\n \tend\n \thash.each do |key, val|\n \tif val == frequent_value\n \t\tfinal_array.push(key)\n \tend\n \tend\n \tp final_array\nend",
"def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend",
"def merge_k_lists(lists)\n lists.reduce { |acc, x|\n merge(acc, x)\n }\nend",
"def merge_k_lists(lists)\n lists.reduce { |acc, x|\n merge(acc, x)\n }\nend",
"def compute_element_occurrence(values)\n uniq_elements = Hash.new(0)\n values.map { |x| uniq_elements[x] += 1 }\n uniq_elements\nend",
"def mode(array)\n freq = Hash.new(0)\n\n array.each do |i|\n freq[i] += 1\n end\n\n temp = Array.new\n largest = 0\n\n freq.each do |k, v|\n if(v > largest)\n temp.clear\n temp.push(k)\n largest = v\n elsif(v == largest)\n temp.push(k)\n end\n end\n\n return temp\nend",
"def majority_element(nums)\n counter_hash = Hash.new(0)\n\n nums.each do |num|\n counter_hash[num] += 1\n end\n\n counter_hash.find { |k,v| v == counter_hash.values.max }.first\nend",
"def mode(array)\n frequency = Hash.new\n array.each do |x|\n array.count(x)\n frequency[x] = array.count(x)\n end\n\n most_frequent = Array.new\n max = frequency.max_by { |x, y| y}\n min = frequency.min_by { |x, y| y}\n if min == max\n frequency.each do |x,y| \n most_frequent = most_frequent.push(x)\n end\n else\n most_frequent[0] = max[0]\n end\n return most_frequent\nend",
"def frequent_elements_with_ties(spectrum, m)\n # Given an array of masses in the spectrum figure out the most 'm' frequent masses\n # including the ties\n\n freq_h = {}\n spectrum.each do |m|\n if freq_h[m]\n freq_h[m] += 1\n else\n freq_h[m] = 1\n end\n end\n\n freq_sorted_h = Hash[freq_h.sort_by{|k,v| v}.reverse]\n\n return_arr = freq_sorted_h.keys.slice(0, m)\n\n # puts freq_sorted_h\n\n (m..(freq_sorted_h.keys.length-1)).each do |i|\n if (freq_sorted_h.values[m-1] == freq_sorted_h.values[i])\n return_arr << freq_sorted_h.keys[i]\n elsif (freq_sorted_h.values[m-1] > freq_sorted_h.values[i])\n break\n end\n end\n # puts return_arr.to_s\n return return_arr\n end",
"def count_occurrences(list)\n keys = list.uniq\n count = keys.map{ |key| list.count(key) }\n keys.each_index{ |indx| puts \"#{keys[indx]} => #{count[indx]}\"}\nend",
"def most_common(string)\n # binding.pry\n arr = string.downcase.gsub(/[^a-z0-9\\s]/i, '').split(\" \")\n arr = arr.map { |x| x.downcase }\n words_hash = arr.group_by { |x| x }\n final_arr = []\n words_hash.each do |k,v|\n #binding.pry\n if v.length > 1\n final_arr << k\n end\n end\n p final_arr\nend",
"def returnK(list, k)\n count = list.count\n target = count - k\n list.each_with_index do |link, j|\n if j == target\n return link\n end\n end\nend",
"def mode(array)\n\tfrequency = Hash.new\n\n\tfor i in array\n\t\tfrequency[i] = array.count(i)\n\tend\n\n\tmost_frequent_key = frequency.values.max\n\tmode_list = []\n\n\tfor key, value in frequency\n\t\tif value == most_frequent_key\n\t\t\tmode_list << key\n\t\tend\n\tend\n\treturn mode_list\nend",
"def pairs(k, arr)\n ha = {}\n pairs = Set.new\n count = 0\n arr.to_set.each do |element|\n ha[element] = 1\n end\n arr.to_set.each do |element|\n sum = (k + element)\n if ha.key? sum\n count += 1\n end\n end\n count\nend",
"def my_uniq(arr)\n hashed = arr.map {|value| [value, arr.count(value)]}.flatten\n return Hash[*hashed].keys\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend",
"def mode (array)\n hash = Hash.new (0)\n array.each { |item|\n hash[item] += 1}\n hash\n\n frequency = hash.values.max\n new_array = []\n\n hash.each { |key, value|\n if frequency == value\n new_array.push(key)\n end}\n new_array\nend",
"def mode(arr)\n count = Hash.new(0)\n arr.each { |value| count[value] += 1 }\n count = count.sort_by { |key, value| value }\n count.reverse!\n high = count[0][1]\n count.select! { |key, value| value == high } \n result = count.collect(&:first)\n result.sort!\nend",
"def get_most_common_words(limit, words_hash)\n pq = PQueue.new(words_hash.to_a) { |a, b| a[1] > b[1] }\n\n ret = Array.new\n limit.times do\n ret.push pq.pop\n end\n\n return ret\n end",
"def majority_class_in_list(list, classes)\n sizes = classes.map{|c| list.count{|i| i == c}}\n Hash[classes.zip sizes].keep_if{|k,v| v == sizes.max}.keys.sample\n end",
"def mode(array)\n hash = Hash.new {|hash,key| hash[key] =0}\n array.each do |item|\n hash[item] = array.count(item)\n end\n array2 = []\n hash.each do |k, v|\n if v == hash.values.max\n array2 << k\n end\n end\n array2\nend",
"def mode(array)\n freq_hash = Hash.new(0)\n #hash_array = Hash[array.map{|x| [x,0]}]\n array.each do |arg|\n freq_hash[arg] += 1\n end\n freq_hash\n new_array = Array.new\n\n freq_hash.each do |key,value|\n if value == freq_hash.values.max\n new_array.push(key)\n end\n end\n new_array\nend",
"def mode(list)\n mode = 0\n biggesttime = 1\n list.size.times do |i|\n times = 0\n list.size.times do |n|\n if list[i] == list[n]\n times = times + 1\n end\n if times > biggesttime\n biggesttime = times\n mode = list[i]\n end\n end\n end\n if biggesttime <= 1\n return list\n else \n return mode\n end\nend",
"def mode(array)\n container = []\n final = []\n h = Hash.new(0)\n array.each {|object| h[object] += 1}\n h.each do |key, value|\n container << value\n end \n highest = container.max\n h.each do |key, value| \n if value == highest\n final << key\n end\n end\n final\nend",
"def find_unique_elements(arr)\n collect = Hash.new 0\n \n arr.each do |elt|\n collect[elt] += 1\n end\n\n unique_hash = Hash(collect.select {|k,v| v == 1})\n \n unique_hash.keys\nend",
"def hash_letter_freq( array )\n\n i = 0 # keeps track of outter loop\n hash = Hash.new()\n\n while( array.length > i )\n\n count = 1\n\n i2 = 1 + i # keeps track of inner while loop\n\n while( array.length > i2 ) # this will never check the last element of the array - otherwise have i2 check itself by doing i2 = i\n\n # puts(\"i #{i} | i2 #{i2}\") -- check if iteration is made right\n\n if( array[i] == array[i2] )\n count += 1\n end\n\n i2 += 1\n end # inner - while\n\n # alternative cond: hash.has_key?(\"#{array[i]}\") http://ruby-doc.org/core-1.9.3/Hash.html#method-i-has_key-3F\n if( hash[\"#{array[i]}\"] == nil ) # checks if key exists\n hash[\"#{array[i]}\"] = count\n end\n\n # for the last element in the array -- skipped by i2\n if( i2 == array.length )\n if( hash[\"#{array[i]}\"] == nil )\n hash[\"#{array[i]}\"] = 1\n end\n end\n\n\n i += 1\n end # while -outter\n\n # puts( hash )\n return hash\n\nend",
"def mode(array)\n mode_machine = Hash.new(0)\n array.each do |element|\n mode_machine[element] += 1\n end\n highest_count = 0\n mode_container = []\n mode_machine.each do |element, count|\n mode_container << element if count == highest_count\n if count > highest_count\n mode_container = []\n mode_container << element\n highest_count = count\n end\n end\n mode_container\nend"
] |
[
"0.8200631",
"0.8159024",
"0.8084402",
"0.7990214",
"0.7959866",
"0.7956065",
"0.7918516",
"0.79163265",
"0.79089487",
"0.7906697",
"0.7893889",
"0.7865139",
"0.78523624",
"0.78516424",
"0.7837732",
"0.7833812",
"0.78095806",
"0.7793178",
"0.77845746",
"0.777552",
"0.7762357",
"0.7750747",
"0.7732159",
"0.7730831",
"0.77202964",
"0.7664846",
"0.76640713",
"0.7654754",
"0.7649733",
"0.7641336",
"0.76280934",
"0.7524288",
"0.750538",
"0.7347996",
"0.7347996",
"0.7347996",
"0.7347996",
"0.7347296",
"0.6659754",
"0.62135005",
"0.6206165",
"0.61709756",
"0.6145178",
"0.6131552",
"0.61041445",
"0.6013763",
"0.5981355",
"0.5976194",
"0.5924322",
"0.5917485",
"0.5916917",
"0.587173",
"0.586596",
"0.5850977",
"0.5833079",
"0.5803269",
"0.5761458",
"0.5748674",
"0.57417077",
"0.5722136",
"0.56907076",
"0.5670651",
"0.563716",
"0.56323326",
"0.5625374",
"0.5613979",
"0.5576349",
"0.556819",
"0.55539936",
"0.5553909",
"0.5544533",
"0.55415314",
"0.5540442",
"0.55362374",
"0.5533887",
"0.55231094",
"0.55231094",
"0.5520802",
"0.5519358",
"0.5513458",
"0.55087876",
"0.5507684",
"0.5502597",
"0.5499975",
"0.549489",
"0.54930824",
"0.54837734",
"0.5478172",
"0.5444214",
"0.542798",
"0.54211634",
"0.54196817",
"0.54185605",
"0.53995764",
"0.53917205",
"0.5389955",
"0.53857416",
"0.5373592",
"0.5373164",
"0.5363759"
] |
0.77806693
|
19
|
This method will return the true if the table is still a valid sudoku table. Each element can either be a ".", or a digit 19 The same digit cannot appear twice or more in the same row, column or 3x3 subgrid Time Complexity: I want to say this is O(1) since the number of elements in a 3x3 grid you have to check is always the same, and any lookups and inserts are O(1) since I'm not only storing everything in a hash, but I'm mapping the keys to another hash. Space Complexity: I also think if we are always using a 3x3 grid and inserting into a hash, this should technically be O(1) since all of the hashes will only expand to the number of elements in a 3x3 grid, which doesn't change, or would only increase by a constant.
|
def valid_sudoku(table)
sudoku_box_hash = { [0, 0] => {}, [0, 1] => {}, [0, 2] => {},
[1, 0] => {}, [1, 1] => {}, [1, 2] => {},
[2, 0] => {}, [2, 1] => {}, [2, 2] => {}}
sudoku_row_hash = { 1 => {}, 2 => {}, 3 => {},
4 => {}, 5 => {}, 6 => {},
7 => {}, 8 => {}, 9 => {}}
sudoku_col_hash = { 1 => {}, 2 => {}, 3 => {},
4 => {}, 5 => {}, 6 => {},
7 => {}, 8 => {}, 9 => {}}
sudoku_diagonal_hash = {1 => {}, 9 => {}}
table.each_with_index do |arr, i|
arr.each_with_index do |ele, j|
next if ele == "."
# check and add diagonals
if i == j
return false if sudoku_diagonal_hash[1].include?(ele)
sudoku_diagonal_hash[1][ele] = 1
elsif i + j + 1 == 9 || i == 4 && j == 4
return false if sudoku_diagonal_hash[9].include?(ele)
sudoku_diagonal_hash[9][ele] = 1
end
# check these hashes for all elements
return false if sudoku_row_hash[i + 1].include?(ele)
return false if sudoku_col_hash[j + 1].include?(ele)
return false if sudoku_box_hash[[i / 3, j / 3]].include?(ele)
# can add if no return
sudoku_row_hash[i + 1][ele] = 1
sudoku_col_hash[j + 1][ele] = 1
sudoku_box_hash[[i / 3, j / 3]][ele] = 1 # based off calculating indices of ecah sudoku box
end
end
return true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def valid_sudoku(table)\n # edge cases\n return false if table.nil? || table.size != 9 || table[0].size != 9\n # 3 new storages will count number of occurances of each element for columns, rows and sub-boxes\n rows = Array.new(9)\n i = 0\n while i < rows.size\n rows[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=>0,\"5\"=>0,\"6\"=>0,\"7\"=>0,\"8\"=>0,\"9\"=>0}\n i += 1\n end\n\n columns = Array.new(9)\n i = 0\n while i < columns.size\n columns[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=>0,\"5\"=>0,\"6\"=>0,\"7\"=>0,\"8\"=>0,\"9\"=>0}\n i += 1\n end\n\n sub_boxes = Array.new(9)\n i = 0\n while i < sub_boxes.size\n sub_boxes[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=>0,\"5\"=>0,\"6\"=>0,\"7\"=>0,\"8\"=>0,\"9\"=>0}\n i += 1\n end\n\n # loop through the input table to populate the above created storages with occurance numbers\n i = 0 # i is a row counter\n while i < table.size\n j = 0 # j is a column counter\n while j < table.size\n if table[i][j] != \".\"\n rows[i][table[i][j]] += 1\n columns[j][table[i][j]] += 1\n # find a number of a box/hash by calculating (i/3)*3 + (j/3)\n # e.g. for the element at indexes 1,2 the box will be: (1/3)*3 + (2/3) = 0, first box\n sub_boxes[(i/3)*3 + (j/3)][table[i][j]] += 1\n end\n j += 1\n end\n i += 1\n end\n # check if any of table elements occured more than 1 time within a row, a column or a sub-box\n rows.each do |hash|\n return false if hash.any? { |key, value| value > 1}\n end\n columns.each do |hash|\n return false if hash.any? { |key, value| value > 1}\n end\n sub_boxes.each_with_index do |hash, i|\n return false if hash.any? { |key, value| value > 1}\n end\n\n return true\nend",
"def valid_sudoku(table)\n store = {\n rows: {},\n cols: {},\n square: {},\n }\n # First loop it represents the first row we are checking\n # Second loop it represents the column.\n\n (0...9).each do |i|\n (0...9).each do |j|\n box = table[i][j]\n if !store[:rows][i] && box != \".\"\n store[:rows][i] = []\n store[:rows][i].push(box)\n elsif box != \".\" && !store[:rows][i].include?(box)\n store[:rows][i].push(box)\n elsif store[:rows][i] && store[:rows][i].include?(box)\n return false\n end\n\n if !store[:cols][j] && box != \".\"\n store[:cols][j] = []\n store[:cols][j].push(box)\n elsif box != \".\" && !store[:cols][j].include?(box)\n store[:cols][j].push(box)\n elsif store[:cols][j] && store[:cols][j].include?(box)\n return false\n end\n\n # Converting to float and the ceil to round up always.\n squareRowId = ((i + 1).to_f / 3).ceil\n squareColId = ((j + 1).to_f / 3).ceil\n # The squeare id is gonna be like\n # 1-1 , 1-2, 1-3\n # 2-1 , 2-2, 2-3\n # 3-1 , 3-2, 3-3\n\n squareId = \"#{squareRowId}-#{squareColId}\"\n\n # Here insted of checking rows and colums I will be checking the numbers inside of this\n # Squeare ids.\n if !store[:square][squareId] && box != \".\"\n store[:square][squareId] = []\n store[:square][squareId].push(box)\n elsif box != \".\" && !store[:square][squareId].include?(box)\n store[:square][squareId].push(box)\n elsif store[:square][squareId] && store[:square][squareId].include?(box)\n return false\n end\n end\n end\n return true\nend",
"def valid_sudoku(table)\n subgrids = {}\n\n # return false if any element is repeated in a row\n table.each do |row|\n row_count = {}\n row.each do |element|\n if row_count[element]\n return false unless element == \".\"\n else\n row_count[element] = 1\n end\n end\n end\n\n # return false if any element is repeated in a column\n columns = {\n 0 => {},\n 1 => {},\n 2 => {},\n 3 => {},\n 4 => {},\n 5 => {},\n 6 => {},\n 7 => {},\n 8 => {},\n }\n table.each do |row|\n row.each_with_index do |element, index|\n if columns[index][element]\n return false unless element == \".\"\n else\n columns[index][element] = 1\n end\n end\n end\n\n first_subgrid = {}\n second_subgrid = {}\n third_subgrid = {}\n\n table[0..2].each do |row|\n row[0..2].each do |element|\n if first_subgrid[element]\n return false unless element == \".\"\n else\n first_subgrid[element] = 1\n end\n end\n\n row[3..5].each do |element|\n if second_subgrid[element]\n return false unless element == \".\"\n else\n second_subgrid[element] = 1\n end\n end\n\n row[6..8].each do |element|\n if third_subgrid[element]\n return false unless element == \".\"\n else\n third_subgrid[element] = 1\n end\n end\n end\n\n first_subgrid = {}\n second_subgrid = {}\n third_subgrid = {}\n\n table[3..5].each do |row|\n row[0..2].each do |element|\n if first_subgrid[element]\n return false unless element == \".\"\n else\n first_subgrid[element] = 1\n end\n end\n\n row[3..5].each do |element|\n if second_subgrid[element]\n return false unless element == \".\"\n else\n second_subgrid[element] = 1\n end\n end\n\n row[6..8].each do |element|\n if third_subgrid[element]\n return false unless element == \".\"\n else\n third_subgrid[element] = 1\n end\n end\n end\n\n first_subgrid = {}\n second_subgrid = {}\n third_subgrid = {}\n\n table[6..8].each do |row|\n row[0..2].each do |element|\n if first_subgrid[element]\n return false unless element == \".\"\n else\n first_subgrid[element] = 1\n end\n end\n\n row[3..5].each do |element|\n if second_subgrid[element]\n return false unless element == \".\"\n else\n second_subgrid[element] = 1\n end\n end\n\n row[6..8].each do |element|\n if third_subgrid[element]\n return false unless element == \".\"\n else\n third_subgrid[element] = 1\n end\n end\n end\n\n return true\nend",
"def valid_sudoku(table)\n numbers = {}\n\n # iterate through each row and confirm valid\n row = 0\n while row < table.length\n table[row].each do |value|\n return false if !check_value(numbers, value)\n end\n\n numbers = {}\n row += 1\n end\n\n # iterate through each column and confirm valid\n numbers = {}\n col = 0\n while col < table[0].length\n (0..8).each do |x|\n value = table[x][col]\n\n return false if !check_value(numbers, value)\n end\n\n numbers = {}\n col += 1\n end\n\n # create list of each sub-box's upper left corner\n corners = []\n (0..2).each do |row|\n (0..2).each do |col|\n corners << [row * 3, col * 3]\n end\n end\n\n # iterate through the list of corners to see if each value is unique within the sub-box\n numbers = {}\n index = 0\n while index < corners.length\n (0..2).each do |x|\n (0..2).each do |y|\n x_point = corners[index][0] + x\n y_point = corners[index][1] + y\n value = table[x_point][y_point]\n\n return false if !check_value(numbers, value)\n end\n end\n\n numbers = {}\n index += 1\n end\n\n return true\nend",
"def valid_sudoku(table)\n table.each do |row|\n row_map = {}\n row.each do |elem|\n if elem != '.'\n if row_map[elem] \n return false\n else\n row_map[elem] = 1\n end\n end\n end\n end\n \n i = 0\n 9.times do\n column_map = {}\n table.each do |row|\n col = row[i]\n if col != '.'\n if column_map[col] \n return false\n else\n column_map[col] = 1\n end\n end\n\n end\n k += 1\n end\n \n i = 0\n k = 0\n 9.times do\n box_map = {}\n while i < i + 3\n while k < k + 3\n \n end\n end \n end\n \n return true\nend",
"def valid_sudoku(table)\n row_list = {}\n col_list = {}\n\n i = 0\n while i < table.length \n j = 0\n\n while j < table[i].length\n \n row_num = table[i][j]\n col_num = table[j][i]\n\n row_list = update_sub_grid(row_list, row_num)\n return false if !row_list\n\n col_list = update_sub_grid(col_list, col_num)\n return false if !col_list\n\n j += 1\n end\n\n\n row_list = {}\n col_list = {}\n \n i += 1\n end\n\n\n starting_points = [\n [0, 0],\n [0, 3],\n [0, 6],\n [3, 0],\n [3, 3],\n [3, 6],\n [6, 0],\n [6, 3],\n [6, 6]\n ]\n\n starting_points.each do |row_start, col_start|\n return false if !valid_sub_grid(table, row_start, col_start)\n end \n\n return true\nend",
"def sudoku_valid? grid\n \n # grid has first index for row, 2nd index for column\n \n # Check every row\n grid.each do |row|\n seen = Set.new\n (0..9).each do |row_value|\n if !seen.add?(row_value)\n return false\n end\n end\n end\n \n # Check every column\n grid.each do |row|\n seen = Set.new\n row.each do |col_value|\n if !seen.add?(col_value)\n return false\n end\n end\n end\n \n # Check every 3x3\n [0,3,6].each do |offset|\n [0,3,6].each do |offset2|\n to_check = get3by3 grid, offset, offset2\n seen = Set.new\n to_check.each do |value|\n if !seen.add?(value)\n return false\n end\n end\n end\n end\n \n \n return true\nend",
"def valid_sudoku(table)\n l = table.length\n # row, time l * l\n table.each do |row|\n return false if !sudoku_helper(row)\n end\n \n # column, time l * 2l\n l.times do |i|\n column = []\n l.times do |j|\n column << table[j][i]\n end\n return false if !sudoku_helper(column)\n end\n \n # area, time l * 2l\n x = Integer.sqrt(l)\n m = n = 0\n x.times do\n x.times do \n area = []\n x.times do |i|\n area += table[n + i][m...(m+x)]\n end\n return false if !sudoku_helper(area)\n m += x\n end\n n += x\n m = 0\n end\n return true\nend",
"def sudoku2(grid)\n \n i = 0\n \n while i < grid.length\n hash = Hash.new(0)\n j = 0\n\n while j < grid[0].length\n hash[grid[i][j]] += 1\n return false if hash[grid[i][j]] > 1 && grid[i][j] != '.'\n j += 1\n end\n i += 1\n end\n\n i = 0\n\n while i < grid[0].length\n hash = Hash.new(0)\n j = 0\n\n while j < grid.length\n hash[grid[j][i]] += 1\n return false if hash[grid[j][i]] > 1 && grid[j][i] != '.'\n j += 1\n end\n i += 1\n end\n\n true && grid_builder(grid)\nend",
"def valid_sudoku(table)\n\n return true if in_row?(table) && in_column?(table) && in_box?(table)\n\n return false\n\nend",
"def valid?\n 0.upto(8) { |row| return false if @rows[row].uniq! }\n 0.upto(8) { |column| return false if @columns[column].uniq! } \n 0.upto(8) { |box| return false if @boxes[box].uniq! }\n\n return true\n end",
"def is_valid_sudoku(board)\n transposed_board = board.transpose\n board.each_with_index do |row, r_index|\n row.each_with_index do |cell, c_index|\n # check row\n # check column\n if !check_row(row, cell, c_index) || !check_row(transposed_board[c_index], cell, r_index)\n p \"False at: #{cell}, #{r_index}, #{c_index}\"\n return false\n end\n end\n end\n return true\nend",
"def valid_sudoku(table)\n \nend",
"def consistent?\n ret = true\n # Check every row first\n @board.each_row do |row|\n row_numbers = Set.new\n row.each do |cell|\n n = cell.number\n if n and row_numbers.include? n\n ret = false\n end\n row_numbers << n\n end\n end\n # Check every column\n @board.each_column do |col|\n col_numbers = Set.new\n col.each do |cell|\n n = cell.number\n if n and col_numbers.include? n\n ret = false\n end\n col_numbers << n\n end\n end\n # Check every region\n @board.each_region do |reg|\n reg_numbers = Set.new\n reg.each do |cell|\n n = cell.number\n if n and reg_numbers.include? n\n ret = false\n end\n reg_numbers << n\n end\n end\n return ret\n end",
"def valid\n for i in 0..(@n-1)\n for j in 0..(@m-1)\n return false if @maze_table[2*j+1][2*i+1] == \"1\"\n walls = 0\n walls += 1 if @maze_table[2*j][2*i+1] == \"1\"\n walls += 1 if @maze_table[2*j+2][2*i+1] == \"1\"\n walls += 1 if @maze_table[2*j+1][2*i+2] == \"1\"\n walls += 1 if @maze_table[2*j+1][2*i] == \"1\"\n return false if walls < 1 || walls > 3\n end\n end\n for i in 0..(@maze_table.size-1)\n return false if @maze_table[i][0] == \"0\" || @maze_table[i][2*@n] == \"0\"\n end\n for i in 0..(@maze_table[0].size-1)\n return false if @maze_table[0][i] == \"0\" || @maze_table[2*@m][i] == \"0\"\n end\n return true\n end",
"def check_sudoku(grid)\n return (check_rows(grid) and check_cols(grid) and check_squares(grid))\nend",
"def validSolution(board)\n return false if board.flatten.size != 81\n return false if board.flatten.any? { |el| el.class != Fixnum }\n return false if board.size != 9\n board.each do |row|\n return false if row.any? { |el| el < 1 || el > 9 }\n return false if row.uniq.size != 9\n end\n (0..8).each do |col|\n this_col = []\n (0..8).each do |el|\n this_col << board[el][col]\n end\n return false if this_col.uniq.size != 9\n end\n [-1, 2, 5].each do |xoffset|\n [-1, 2, 5].each do |yoffset|\n this_square = []\n (1..3).each do |x|\n (1..3).each do |y|\n this_square << board[x + xoffset][y + yoffset]\n end\n end\n return false if this_square.uniq.size != 9\n end\n end\n true\nend",
"def valid?\n # Valid puzzle has 9 rows.\n unless @puzzle.size == 9\n raise RuntimeError, \"Sudoku puzzle must have 9 rows.\"\n end\n\n # Valid puzzle has 9 columns of 9 cells.\n each_row do |row|\n unless row.size == 9\n raise RuntimeError, \"Each row in the Sudoku puzzle must have 9 cells.\"\n end\n end\n\n # Valid puzzle has valid cells.\n each do |cell|\n cell.valid?\n end\n\n #TODO: Find out if there are conflicts in row, column or nonet.\n\n # If we get this far without error, the puzzle is valid.\n return true\n end",
"def row_checker(puzzle_digit_location_hash)\n for i in 0...ROW_LENGTH\n current_row = row_selector(i, puzzle_digit_location_hash)\n current_row_digits = digit_selector(current_row)\n current_row_digits.size == current_row_digits.uniq.size ? solution_okay = true : solution_okay = false\n break if solution_okay == false\n end\n solution_okay\n end",
"def solved?\n cols = @grid.transpose\n return false unless (0..8).all? {|i| check_cols(i) && check_row(i)}\n (0..2).each do |horiz| \n (0..2).each {|vert| return false unless check_square(horiz,vert)}\n end\n true\n end",
"def valid_sudoku(table)\n # seen_set = Set.new()\n # for i in \nend",
"def validateBoard()\n #cycle through all lines in the file\n row = 0\n for row in 0..8\n # @gameboard index\n index = 0\n # array temp is used to store number appearing in the same row\n temp = Array.new\n # temp array index\n i = 0\n while index<@DIMENSION\n if (1..9).member? @gameboard[row * @DIMENSION + index]\n if temp.include? @gameboard[row * @DIMENSION + index]\n return false\n else\n temp[i] = @gameboard[row * @DIMENSION + index]\n i += 1\n end\n end\n index += 1\n end\n end\n #cycle through all columns in the file\n column = 0\n for column in 0..8\n # @gameboard index\n index = 0\n # array temp is used to store number appearing in the same row\n temp = Array.new\n # temp array index\n i = 0\n while index<@DIMENSION\n if (1..9).member? @gameboard[column + index * @DIMENSION]\n if temp.include? @gameboard[column+ index * @DIMENSION]\n return false\n else\n temp[i] = @gameboard[column+ index * @DIMENSION]\n i += 1\n end\n end\n index += 1\n end\n end\n #cycle through all @DEIMENSION squares in the file\n startIndex = 0\n rowBase = 0\n columnBase = 0\n for rowBase in 0..2\n startIndex = rowBase * 3 * @DIMENSION\n for columnBase in 0..2\n # array temp is used to store number appearing in the same row\n temp = Array.new\n # temp array index\n i = 0\n #find the real index in @gameboard\n l = 0\n for l in 0..2\n m = 0\n for m in 0..2\n index = startIndex + m * @DIMENSION + l\n if (1..9).member? @gameboard[index]\n if temp.include? @gameboard[index]\n return false\n else\n temp[i] = @gameboard[index]\n i += 1\n end\n end\n end\n end\n startIndex += 3\n end\n end\n return true\nend",
"def in_column?(table)\n\n table.length.times do |col|\n column_hash = Hash.new()\n\n table.length.times do |i|\n\n if column_hash[table[i][col]]\n return false\n end\n if table[i][col] != '.'\n column_hash[table[i][col]] = 1\n end\n end\n end\n end",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid_sudoku(table)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def valid?\n 1.upto(puzzle.size) { |index| return false unless valid_row?(index - 1) && valid_column?(index - 1) }\n sections.all? { |section| valid_section?(section) }\n end",
"def valid_rows?\n valid = true\n row = 0\n while (row < @board.length && valid)\n valid = false if !unique_arr?(@board[row])\n row += 1\n end\n valid\n end",
"def checkSubgrid(row, col, num)\n\t\tx = (row / 3) * 3\n\t\ty = (col / 3) * 3\n\n\t\tbox = @sudokuBoard[x][y..(y+2)] + @sudokuBoard[x+1][y..(y+2)] + @sudokuBoard[x+2][y..(y+2)]\n\t\tdisjointSet = box - [num]\n\t\tif disjointSet.length == 9 then\n\t\t\t# Safe to add num to the row.\n\t\t\treturn true\n\t\telse\n\t\t\t# Unsafe to add num to the row, since it already existed there.\n\t\t\treturn false\n\t\tend\n\t\t\n\t\n\t\n\t\n\tend",
"def internal_check?(row, col)\n\n values = [@rows[row], @cols[col], @blks[find_block(row,col)]] #Values related to the section\n \n #Check for a missing value\n #------------------------------- \n values = values.flatten.uniq.join.gsub(\"0\",\"\")\n values = \"123456789\".tr(values,\"\")\n if values.length == 1\n @rows[row][col] = values.to_s\n adjust_values\n return true\n else\n return false\n end\n end",
"def validate(section)\n \n #Rows, Columns or Blocks\n #--------------------------------------------------\n section.each do |i|\n check = i.sort.join.squeeze(\"0\")\n if check.length > check.split(\"\").uniq.length\n\tputs \"***************************************************\"\n\tputs \"Failed Validation, Values did not meet sudoku rules\"\n\tputs \"***************************************************\"\n\treturn false\n end\n end \n \n #Return true if all validations passed\n #--------------------------------------------------\n return true\n end",
"def solved?(board)\n board.all? { |row| row.flatten.length == 9 && row.sort == [1,2,3,4,5,6,7,8,9] }\nend",
"def check?(ptr)\n ptr_x, ptr_y = x_y(ptr)\n\n # Keep track of what we've seen\n row = {}\n col = {}\n sec = {}\n\n @board.each_with_index do |value, i|\n next if value == 0\n\n x, y = x_y(i)\n\n if y == ptr_y\n return false if row[value]\n\n row[value] = true\n end\n\n if x == ptr_x\n return false if col[value]\n\n col[value] = true\n end\n\n # Check the cells in the sector\n if x / 3 == ptr_x / 3 && y / 3 == ptr_y / 3\n return false if sec[value]\n\n sec[value] = true\n end\n end\n\n # These checks aren't *theoretically* necessary, given the algorithm,\n # but nice to have as a sanity check.\n if row.length == 9\n return false unless row.keys.inject(:+) == 45\n end\n\n if col.length == 9\n return false unless col.keys.inject(:+) == 45\n end\n\n true\n end",
"def legal?\n [rows, columns, boxes].all? do |group|\n group.all? { |_, n| n.uniq == n }\n end\n end",
"def is_safe(grid, row, column, number)\n $count += 1\n return !exist_in_row(grid, row, number) && !exist_in_column(grid, column, number) && !exists_in_box(grid, row - (row % 3), column - (column % 3), number)\nend",
"def board_solved?\r\n # Check that all the cells are filled with values\r\n #\r\n (0 .. 8).each do |row|\r\n (0 .. 8).each do |col|\r\n return false unless board[row][col] > 0\r\n end\r\n end\r\n \r\n # Check column constraints\r\n #\r\n @board.each do |column|\r\n return false unless column.uniq.size == 9\r\n end\r\n \r\n # Check row constraints\r\n #\r\n @board.transpose.each do |column|\r\n return false unless column.uniq.size == 9\r\n end\r\n \r\n # Check box constraints\r\n #\r\n (0 .. 2).each do |box_x|\r\n (0 .. 2).each do |box_y|\r\n box_vals = []\r\n \r\n (0 .. 2).each do |i|\r\n (0 .. 2).each do |j|\r\n box_vals << @board[3 * box_x + i][3 * box_y + j]\r\n end\r\n end\r\n \r\n return false unless box_vals.uniq.size == 9\r\n end\r\n end\r\n \r\n true\r\n end",
"def valid?\n expected = {}\n\n count = 0\n self.each_unsafe do |k,v|\n return false if @data[k][2] != v\n count += 1\n end\n count == @data.count\n end",
"def valid?\n cells.find_all(&:filled?).compact.length == 1\n end",
"def valid?\n tally = Hash.new(0)\n tally[:xxx] = 1\n \n 5.times do |u|\n 5.times do |h|\n if !@solution[h][u].nil?\n tally[@solution[h][u]] += 1\n end\n end\n return true if tally.values.max < 2\n end\n puts \"invalid: #{tally.inspect}\"\n puts self.to_s\n return false\n end",
"def b_check sym \n\t\t#check rows\n\t\ti=0\n\t\twhile i<@arr.length\n\t\t\tgame_finished=true\n\t\t\tj=0\n\t\t\twhile j<@arr.length\n\t\t\t\tif @arr[i][j]!=sym\n\t\t\t\t\tgame_finished=false\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t\tj=j+1\n\t\t\tend\n\t\t\tif game_finished\n\t\t\t\treturn game_finished\n\t\t\tend\n\t\t\ti=i+1\n\t\tend\n\t\t# check colmns\n\t\ti=0\n\t\twhile i<@arr.length\n\t\t\tgame_finished=true\n\t\t\tj=0\n\t\t\twhile j<@arr.length\n\t\t\t\tif @arr[j][i]!=sym\n\t\t\t\t\tgame_finished=false\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t\tj=j+1\n\t\t\tend\n\t\t\tif game_finished\n\t\t\t\treturn game_finished\n\t\t\tend\n\t\t\ti=i+1\n\t\tend\n\t\t#check diagonals\n\t\ti=0\n\t\tgame_finished=true\n\t\tj=@arr.length-1\n\t\twhile i<@arr.length\n\t\t\tif @arr[i][j]!=sym\n\t\t\t\tgame_finished=false\n\t\t\t\tbreak\n\t\t\tend\n\t\t\ti=i+1\n\t\t\tj=j-1\n\t\tend\n\t\tif game_finished\n\t\t\treturn game_finished\n\t\tend\n\n\t\ti=0\n\t\tgame_finished=true\n\t\tj=0\n\t\twhile i<@arr.length\n\t\t\tif @arr[i][j]!=sym\n\t\t\t\tgame_finished=false\n\t\t\t\tbreak\n\t\t\tend\n\t\t\ti=i+1\n\t\t\tj=j+1\n\t\tend\n\t\tif game_finished\n\t\t\treturn game_finished\n\t\tend\n\t\treturn false\n\tend",
"def all_valid\n # Check the vertical\n @size.times { |i|\n if !valid_column(i)\n return false\n end\n }\n\n # Check the diagonal\n @size.times { |i|\n if !valid_diagonal(true, true, i)\n return false\n end\n if !valid_diagonal(true, false, i)\n return false\n end\n if !valid_diagonal(false, true, i)\n return false\n end\n if !valid_diagonal(false, false, i)\n return false\n end\n }\n\n # Check the horizontal\n @size.times { |i|\n if !valid_row(i)\n return false\n end\n }\n\n return true\n end",
"def valid?(board_array)\n board_array.each { |row| return false if row.length != row.uniq.length }\n return true\nend",
"def valid_column(column)\n bits = 0\n\n @size.times { |i|\n if @state[(@size *i) + column]\n bits += 1\n if bits > 1\n return false\n end\n end\n }\n\n return true\n end",
"def verify?(game_hash)\n\tflat_board = hash_to_flat(game_hash)\n\treturn row_checker(flat_board) && column_checker(flat_board) && square_checker(flat_board)\nend",
"def external_check?(row,col)\n \n #Get values available in this block\n #------------------------------------------------------------------\n values = [@rows[row], @cols[col], @blks[find_block(row,col)]] #Values related to the section\n values = values.flatten.uniq.join.gsub(\"0\",\"\")\n values = \"123456789\".tr(values,\"\")\n \n section = []\n \n #Check row\n #Get values available in the other blocks in the current row\n #---------------------------------------------------------------------------------------------------\n 9.times do |i|\n if @rows[row][i] == \"0\"\n\tsection << internal_check(row,i) unless col==i\n end\n end\n \n section = section.join.split(\"\").sort.uniq.join.gsub(\"0\",\"\")\n values_row = values.tr(section,\"\")\n \n if values_row.length == 1\n @rows[row][col] = values_row.to_s\n adjust_values\n return true\n else\n return false\n end \n #Check column\n #Get values available in the other blocks in the current column\n #---------------------------------------------------------------------------------------------------\n 9.times do |i|\n if @rows[row][i] == \"0\"\n\tsection << internal_check(i,col) unless row==i\n end\n end\n \n section = section.join.split(\"\").sort.uniq.join.gsub(\"0\",\"\")\n \n values_col = values.tr(section,\"\")\n if values_col.length == 1\n @rows[row][col] = values_col.to_s\n adjust_values\n return true\n else\n return false\n end \n \n #Check block\n #Get values available in the other blocks in the current block\n #---------------------------------------------------------------------------------------------------\n blk = find_block(row,col)\n case blk\n when 0\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r-1,c-1) unless r=row and c=col\n\tend\n end\n when 1\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r-1,c+2) unless r=row and c=col\n\tend\n end\n when 2\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r-1,c+5) unless r=row and c=col\n\tend\n end\n when 3\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r+2,c-1) unless r=row and c=col\n\tend\n end\n when 4\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r+2,c+2) unless r=row and c=col\n\tend\n end\n when 5\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r+2,c+5) unless r=row and c=col\n\tend\n end\n when 6\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r+5,c-1) unless r=row and c=col\n\tend\n end\n when 7\n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r+5,c+2) unless r=row and c=col\n\tend\n end\n else \n 3.times do |r|\n\t3.times do |c|\n\t section << internal_check(r+5,c+5) unless r=row and c=col\n\tend\n end\n end \n \n @blks[blk].each do |i|\n if @rows[row][i] == \"0\"\n\tsection << internal_check(row,i) unless col==i\n end\n end\n \n section = section.join.split(\"\").sort.uniq.join.gsub(\"0\",\"\")\n \n values_block = values.tr(section,\"\") \n if values_block.length == 1\n @rows[row][col] = values_block.to_s\n adjust_values\n return true\n else\n return false\n end \n end",
"def validate\n\n entireSet = Set.new([1, 2, 3, 4, 5, 6, 7, 8, 9])\n\n @rows = []\n 9.times { @rows.push(entireSet.dup) }\n\n @cols = []\n 9.times { @cols.push(entireSet.dup) }\n\n @box = []\n 3.times do\n subrow = []\n 3.times { subrow.push(entireSet.dup) }\n @box.push(subrow)\n end\n\n (0..8).each do |i|\n (0..8).each do |j|\n v = @grid[i,j]\n if v > 0\n raise \"dup number in row #{i} : #{v}\" unless @rows[i].delete?(v)\n raise \"dup number in column #{j} : #{v}\" unless @cols[j].delete?(v)\n raise \"dup number in box #{i/3}-#{j/3} : #{v}\" unless @box[i/3][j/3].delete?(v)\n end\n end\n end\n\n @poss = []\n @poss_grid = []\n (0..8).each do |i|\n poss_row = []\n (0..8).each do |j|\n if @grid[i,j] == 0 then\n p = Poss.new(i, j, @rows[i], @cols[j], @box[i/3][j/3])\n @poss.push(p)\n poss_row.push(p.to_a)\n else\n poss_row.push([])\n end\n end\n @poss_grid.push(poss_row)\n end\n @poss.sort! { |x, y| x.length <=> y.length }\n\n end",
"def row_checker(flat_board_array)\n first_row_indexes = [0,1,2,3,4,5,6,7,8]\n current_row = 0\n until current_row >= 9\n indexes = first_row_indexes.map { |index| index + current_row * 9}\n hash_of_vals = {}\n indexes.each do |index|\n if hash_of_vals[flat_board_array[index]] && flat_board_array[index] != 0\n return false\n else \n hash_of_vals[flat_board_array[index]] = 1\n end\n end\n current_row += 1\n end\n \n return true\nend",
"def sudoku_clauses\n res = []\n\n #ensure each cell contains a digit\n (1..9).each do |i|\n (1..9).each do |j|\n #must contains at least one of 9 digits\n res << (1..9).map {|d| variable(i, j, d) }\n\n (1..9).each do |d|\n ((d+1)..9).each do |dp|\n #can not contain two digits at once\n res << [-variable(i, j, d), -variable(i, j, dp)]\n end\n end\n end\n end\n\n #ensure each rows and columns contain distinct values\n (1..9).each do |i|\n res += valid( (1..9).map{|j| [i, j]} )\n res += valid( (1..9).map{|j| [j, i]} )\n end\n\n #ensure 3x3 sub-grids regions have distinct values\n [1, 4, 7].each do |i|\n [1, 4, 7].each do |j|\n res += valid((0..8).map{|k| [i + k%3, j+k / 3]})\n end\n end\n\n res\n end",
"def is_valid_cell?(cell)\n if cell.nil?\n return false\n end\n\n if cell.col < 0 || cell.row < 0\n return false\n end\n\n if cell.row < @maze.size && cell.col < @maze[0].size\n return true\n end\n\n false\n end",
"def valid_table(table_array)\n\n valid_set = Array[]\n for card1 in 0...table_array.length\n for card2 in 0...table_array.length\n if(card1 == card2) #skip if same card\n next\n end\n\n for card3 in 0...table_array.length\n\n if card2 == card3 or card1 == card3 #skip if same card\n next\n end\n\n if is_a_set?([table_array[card1], table_array[card2], table_array[card3]])\n #found valid set\n valid_set[0] = card1\n valid_set[1] = card2\n valid_set[2] = card3\n break\n end\n\n end\n end\n end\n\n return valid_set\nend",
"def solved?\n # Return whether the total passed in is equal to the total for a valid house.\n def is_valid_house_total?(total)\n return total == 45\n end\n\n # Return the total of adding up all the cells in this house.\n def house_total(house)\n return house.inject(0) {|sum, cell| sum + cell.to_i }\n end\n\n ## Check whether all the houses in the puzzle have valid totals.\n ##\n\n each_row do |row|\n return false unless is_valid_house_total?(house_total(row))\n end\n\n each_column do |column|\n return false unless is_valid_house_total?(house_total(column))\n end\n\n each_nonet do |nonet|\n return false unless is_valid_house_total?(house_total(nonet))\n end\n end",
"def valid?\n 81.times do |i|\n return false if @board[i] == 0\n return false unless check?(i)\n end\n\n true\n end",
"def loadFromFile(fileName)\n inFile = File.new(fileName, \"r\")\n index = 0\n\n # Iterate over the lines from the file.\n inFile.each_line do |line|\n # line is a string containing one line from the file.\n\n ### The code to process the line goes here. ###\n\t\tvals = line.split\n\t\t# The collect block will iterate over each item in vals (strings)\n\t\t# and perform the function (convert to int) returning the set as a new array.\n\t\t@sudokuBoard[index] = vals.collect { |x| x.to_i }\n index = index + 1\n end\n\t\n\t\n\t# Returns whether a number can be placed in this column\n\t#\n\t# @param col A number representing the board column\n\t# @param num A number we're checking\n\t# @return Returns true if the number is valid in the column, false otherwise\n\tdef checkCol(col, num)\n\t\t0.upto(BOARD_SIZE-1){\n\t\t|row| \n\t\tif num == @sudokuBoard[row][col] then\n\t\t\treturn false\n\t\tend\n\t\t}\n\t\treturn true\n\n\tend\n\t# Returns whether a number can be placed in this row\n\t#\n\t# @param row A number representing the board row\n\t# @param num A number we're checking\n\t# @return Returns true if the number is valid in the row, false otherwise\n\tdef checkRow(row, num)\n\t\tdisjointSet = @sudokuBoard[row] - [num]\n\t\tif disjointSet.length == 9 then\n\t\t\t# Safe to add sum to the row.\n\t\t\treturn true\n\t\telse\n\t\t\t# Unsafe to add sum to the row, since it already existed there.\n\t\t\treturn false\n\t\tend\n\t\t\n\tend\n\t\n\t# Returns whether a number can be placed in this subgrid\n\t#\n\t# @param row A number representing the board row\n\t# @param col A number representing the board column\n\t# @param num A number we're checking\n\t# @return Returns true if the number is valid in the subgrid, false otherwise\n\tdef checkSubgrid(row, col, num)\n\t\tx = (row / 3) * 3\n\t\ty = (col / 3) * 3\n\n\t\tbox = @sudokuBoard[x][y..(y+2)] + @sudokuBoard[x+1][y..(y+2)] + @sudokuBoard[x+2][y..(y+2)]\n\t\tdisjointSet = box - [num]\n\t\tif disjointSet.length == 9 then\n\t\t\t# Safe to add num to the row.\n\t\t\treturn true\n\t\telse\n\t\t\t# Unsafe to add num to the row, since it already existed there.\n\t\t\treturn false\n\t\tend\n\t\t\n\t\n\t\n\t\n\tend\n\t\n\t# Returns whether a number can be placed per sudoku rules\n\t#\n\t# @param row A number representing the board row\n\t# @param col A number representing the board column\n\t# @param num A number we're checking\n\t# @return Returns true if the number is valid in this postion, false otherwise\n\tdef check(row, col, num)\n\t\treturn checkCol(col,num) && checkRow(row,num) && checkSubgrid(row,col,num)\n\t\n\tend\n\t\n\t# A recursive backtracking function to solve sudoku boards \n\t#\n\t# @param row A number representing the board row\n\t# @param col A number representing the board column\n\t# @return Returns true if the board is solved, false otherwise\n\tdef solve(row, col)\n\tif row == 9 then\n\t\treturn true\n\tend\n\t\n\tif col == 9 then\n\t\treturn solve(row +1, 0)\n\tend\n\t\n\tif @sudokuBoard[row][col] != 0 then\n\t\treturn solve(row, col +1)\n\tend\n\t\n\t1.upto(9) {\n\t|num|\n\t\n\tif check(row,col,num) then\n\t\t@sudokuBoard[row][col] = num\n\t\tif solve(row, col+1) then\n\t\t\treturn true\n\t\tend\n\tend\n\t}\n\t\n\t@sudokuBoard[row][col] = 0\n\treturn false\n\t\n\t\n\tend\n\t\t\n\n inFile.close\nend",
"def check_rows(piece, arr)\n arr.each do |row|\n row.each_cons(4).each do |combination|\n return true if combination.all? { |a| a == piece }\n end\n end\n false\n end",
"def check_row\n @num_row.times do |row|\n consecutive = 0\n curr_tile = @board[row][0]\n @num_col.times do |col|\n if curr_tile == @board[row][col]\n next unless @board[row][col] #skip over empty tiles before the first non-empty\n consecutive += 1\n return true if consecutive == 4\n else\n curr_tile = @board[row][col]\n consecutive = 1\n end\n end\n end\n false\n end",
"def all_cells_cleared?\n cell_count = 0\n (0..row_count).each do |row|\n (0..column_count).each do |column|\n if cell_cleared?(row, column) || contains_mine?(row, column)\n cell_count += 1\n end\n end\n end\n\n (row_count * column_count) == cell_count\n end",
"def validate_position(board, row, col, number)\n position_row = row\n position_col = col\n # Checks the row to ensure there's no duplicate while also checking the column to ensure there's no duplicate.\n for val in 0...9 do\n if board[val][position_col] == number || board[position_row][val] == number\n return false\n end\n end\n\n # Defining the boundaries of the block that the given position falls into...\n block_row_min = position_row / 3 * 3 # Abusing integer division to get the lower bound for the rows.\n block_row_max = block_row_min + 3 # Max is just 3 higher than that.\n block_col_min = position_col / 3 * 3 # Abusing integer division to get the lower bound for the columns.\n block_col_max = block_col_min + 3 # Max is just 3 higher than that.\n\n # Checks that the given position is valid, given the dimensions calculated above...\n for row in block_row_min...block_row_max do\n for col in block_col_min...block_col_max do # Simple double for-loop with an if statement.\n if board[row][col] == number\n return false\n end\n end\n end\n return true\n end",
"def spans_all_rows?(cells_list)\n cells_list.inject([]) {|rows, (_, r)| rows << r }.uniq.size == @board.size\n end",
"def all_cells_cleared?\n count = 0\n (0..row_count).each do |row|\n (0..column_count).each do |column|\n if cell_cleared?(row, column) || contains_mine?(row, column)\n count += 1\n end\n end\n end\n if count == row_count*column_count\n true\n else\n false\n end\n end",
"def has_tied(new_board)\n new_board.each_with_index do |row,i|\n row.each_with_index do |col,j|\n return false if new_board[i][j] == '-'\n end\n end\n true\nend",
"def diccionario_valido?(dic)\n # Verifica que cada una de las llaves sea un simbolo, ademas que sea\n # un simbolo valido \n dic.each_key do |jugada|\n if not jugada.instance_of?(Symbol) or not $simbolos_posibles.member?(jugada)\n return false\n end\n end \n\n # Que la probabilidad sea un numero mayor o igual que 1 \n dic.each_value do |probabilidad|\n if probabilidad < 1\n return false \n end\n end\n\n return true \n end",
"def group_valid?(sym)\n unless [ :row, :column, :block].include?(sym)\n raise ArgumentError.new(\"group_valid can only be called :row, :column or :block\")\n end\n grouped_syms = self.squares.group_by(&sym).values\n sum_truths = []\n grouped_syms.each do |group|\n values = group.map{|square| square.value}\n good_sum = values.sum == (0..self.size).sum\n no_dupes = values.uniq == values\n sum_truths.push(good_sum && no_dupes)\n end\n\n sum_truths.all?\n end",
"def exists_in_box(grid, start_row, start_column, number)\n row = 0\n column = 0\n while row < 3\n column = 0\n while column < 3\n return true if grid[row + start_row][column + start_column] == number\n column += 1\n end\n row += 1\n end\n return false\nend",
"def all_cells_cleared?\n count_num_of_cells_cleared = @cleared_field.select{|key, value| value == true}.size\n total_cell_count = @column_count * @row_count\n cell_clear_check = total_cell_count - @mine_count == count_num_of_cells_cleared\n return true if !any_mines_detonated? && cell_clear_check\n false\n\n end",
"def valid_row(row)\n row_begin = @size * (row)\n bits = 0\n\n @size.times { |i|\n if @state[row_begin + i]\n bits += 1\n if bits > 1\n return false\n end\n end\n }\n\n return true\n end",
"def valid?\n return false if @first_row_index.nil?\n return false if @first_cell_index.nil?\n return false if @last_row_index.nil?\n return false if @last_cell_index.nil?\n return false if @allow_splitting.nil?\n true\n end",
"def valid?\n !!free_cell_index\n end",
"def contains_duplicate(nums)\n hash_table = {}\n (0..nums.length).each do |i|\n if hash_table.include? nums[i]\n return true\n else\n hash_table[nums[i]] = 1\n end\n end\n return false\nend",
"def all_cells_cleared?\n row_count.times do |row|\n column_count.times do |col|\n if !contains_mine?(row, col)\n return false unless cell_cleared?(row, col)\n end\n end\n end\n true\n end",
"def solved?(board_array)\n return valid?(board_array) && valid?(transpose_arrays(board_array)) && valid?(create_grid(board_array))\nend",
"def check_number(element, row, col, grid)\n grid_row = (row / 3) * 3\n grid_column = (col / 3) *3\n for i in 0..8 do\n if ((grid[row][i] == element) || (grid[i][col] == element) ||(grid[grid_row + ( i % 3 )][grid_column + (i / 3)] == element))\n return 0\n end\n end\n grid[row][col] = element\n return 1\nend",
"def all_cells_cleared?\n x = 0\n @field.each do |row|\n y = 0\n row.each do |col|\n if !contains_mine?(x, y)\n if @field[x][y].cleared == false\n return false\n end\n end\n y += 1\n end\n x += 1\n end\n true\n end",
"def check_if_all_combos_tried(row, col, forward)\n \n if @board_indicator[row][col] == 0 && @board[row][col] == 9 && row == @row_of_first_empty_square && col == @col_of_first_empty_square\n return true\n else\n return false\n end\n # if all initial holes are filled with'9', all combos were tried\n # all_combos_tried = true\n # (0..8).each do |k|\n # (0..8).each do |j|\n # if @board_indicator[k][j] == 0 && @board[k][j] < 9\n # all_combos_tried = false\n # #break\n # end\n # end\n # end\n # puts all_combos_tried\n # all_combos_tried\n end",
"def check_map(map)\n\t\tways = Array2D.new(@width, @height, -1)\n\t\t@width.times do |x|\n\t\t\t@height.times do |y|\n\t\t\t\tpoint = Point.new(x, y)\n\t\t\t\tways[point] = 0 if ! map[point]\n\t\t\tend\n\t\tend\n\t\tways[@center] = 1\n\n\t\tnew_cells = true\n\t\tstep = 2\n\t\twhile new_cells\n\t\t\tnew_cells = false\n\t\t\t@width.times do |x|\n\t\t\t\t@height.times do |y|\n\t\t\t\t\tpoint = Point.new(x, y)\n\t\t\t\t\tif map[point]\n\t\t\t\t\t\tways[point] = -1\n\t\t\t\t\telsif ways[point] == 0\n\t\t\t\t\t\tif ways[point.up] == step - 1\n\t\t\t\t\t\t\tways[point] = step\n\t\t\t\t\t\t\tnew_cells = true\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif ways[point.down] == step - 1\n\t\t\t\t\t\t\tways[point] = step\n\t\t\t\t\t\t\tnew_cells = true\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif ways[point.left] == step - 1\n\t\t\t\t\t\t\tways[point] = step\n\t\t\t\t\t\t\tnew_cells = true\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif ways[point.right] == step - 1\n\t\t\t\t\t\t\tways[point] = step\n\t\t\t\t\t\t\tnew_cells = true\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\tstep += 1\n\t\tend\n\n\t\t@width.times do |x|\n\t\t\t@height.times do |y|\n\t\t\t\tpoint = Point.new(x, y)\n\t\t\t\treturn false if ways[point] == 0\n\t\t\tend\n\t\tend\n\t\ttrue\n\tend",
"def check_victory(number)\n\t\t3.times do |i|\n\t\t\tif @board[i][0] == board[i][1] && board[i][1] == board[i][2] && @board[i][0] != 0\n\t\t\t\treturn true\n\t\t\telsif @board[0][i] == board[1][i] && board[1][i] == board[2][i] && @board[0][i] != 0\n\t\t\t\treturn true\n\t\t\tend\n\t\tend\n\t\tif @board[2][0] == board[1][1] && board[1][1] == board[0][2] && @board[0][2] != 0\n\t\t\treturn true\n\t\telsif @board[0][0] == board[1][1] && board[1][1] == board[2][2] && @board[2][2] != 0\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def full?(cells = @cells)\n cells.all?{|taken| taken == \"X\" || taken == \"O\"}\n end",
"def valid?\n (0..@dimension - 1).each do |i|\n return false unless valid_enum(row_elems(i))\n return false unless valid_enum(col_elems(i))\n return false unless valid_enum(block(i))\n end\n true\n end",
"def validation(board, xblks, yblks)\n # row in valid\n\n \tfor x in 0..board.length-1\n \t\tcol = Array.new\n \t\trow = Array.new(board[x]) #need new array not modify board via reference\n\t\tblock = Array.new(board.length) {Array.new}\n \t\tfor y in 0..board.length-1\n if (board[y][x] != 0)\n\n \t\t\t\tcol.concat([board[y][x]])\n\t\t\tend\n\n\t\t\tputs [y, x]\n \t\t\tputs \"\"\n\t\t\tif (board[x][y] != 0)\n \t\t\t\tblk = (x/xblks).floor + yblks * (y/yblks).floor\n\t\t\t\tblock[blk-1].concat([board[x][y]])\n\t\t\tend\n \t \tend\n\t\trow.delete(0)\n\n \t\tif (col.uniq! != nil or row.uniq! != nil)\n\n\n\t\t\treturn false\n\t\tend\n\n\n \tend\n\n for each in block\n\t\tif each.uniq! != nil\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\n end",
"def exist_in_row(grid, row, number)\n column = 0\n while column < N\n return true if grid[row][column] == number\n column += 1\n end\n return false\nend",
"def all_cells_cleared?\n @board.each do |row|\n row.each do |cell|\n if !cell.has_bomb && !cell.is_open\n return false\n end\n end\n end\n true\n end"
] |
[
"0.8122185",
"0.8087225",
"0.80445236",
"0.8037947",
"0.8000477",
"0.7858658",
"0.7618002",
"0.751144",
"0.74835074",
"0.71662134",
"0.6996734",
"0.6786182",
"0.6760026",
"0.6748393",
"0.6654424",
"0.6517259",
"0.6499932",
"0.64429265",
"0.6407294",
"0.64067",
"0.6398252",
"0.6390865",
"0.6371766",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.63572407",
"0.6357056",
"0.63429517",
"0.630666",
"0.63021815",
"0.62841386",
"0.62489855",
"0.62467116",
"0.6222188",
"0.6221981",
"0.6161494",
"0.6123273",
"0.61118466",
"0.6105223",
"0.60827684",
"0.6077889",
"0.6074044",
"0.6058878",
"0.60470814",
"0.6022397",
"0.60174227",
"0.59935963",
"0.5986497",
"0.597131",
"0.5966008",
"0.5950312",
"0.5949963",
"0.5949566",
"0.59278077",
"0.59191275",
"0.5902707",
"0.5888962",
"0.5878945",
"0.58730197",
"0.5872764",
"0.5850406",
"0.58479863",
"0.58266705",
"0.582003",
"0.5806006",
"0.5791575",
"0.5788781",
"0.5771245",
"0.5755445",
"0.57428575",
"0.5737651",
"0.5731008",
"0.5720931",
"0.5717993",
"0.5716408",
"0.57045865",
"0.56744725",
"0.56741506",
"0.56435007",
"0.5643146"
] |
0.8228795
|
0
|
GET /sales GET /sales.json
|
def index
@sales = Sale
.where("EXTRACT(MONTH FROM transaction_date)=EXTRACT(MONTH FROM CURRENT_DATE) AND EXTRACT(YEAR FROM transaction_date)=EXTRACT(YEAR FROM CURRENT_DATE)")
.order(:created_at).reverse_order
.pagination(params[:page])
@customers = Customer.order(:name)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sales }
format.js
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @sales = Sale.all\n\n render json: @sales\n end",
"def index\n @sales = @saleService.all_to_json().as_json;\n end",
"def show\n render json: @invoice, methods: [:sales]\n end",
"def show\n render json: @sale\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def sales\n FarMar::Sale.get_by(\"vendor\", id)\n end",
"def index\n @pre_sales = PreSale.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pre_sales }\n end\n end",
"def index\n @sells = Sell.all\n\n render json: @sells\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale }\n end\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale }\n end\n end",
"def getDate\n @sales = Sale.where(\"date = ?\", params[:date])\n render json: @sales\n end",
"def sales(options = {})\n options[:product_id] = epages_id(options[:product_id]) if options[:product_id]\n perform_get_with_object('/sales', format_dates_options(options), Epages::SalesSummary)\n end",
"def sales\n Sale.find_all_by_vendor_id(@id)\n end",
"def show\n @sales_datum = SalesDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_datum }\n end\n end",
"def salesApi\n require 'uri'\n require 'net/http'\n require 'json'\n\n #Arrays for each category\n \n @frequency = Hash.new(0)\n\n url = URI(\"https://api.salesloft.com/v2/people.json\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n\n request = Net::HTTP::Get.new(url)\n request[\"Authorization\"] = 'Bearer ' + ENV[\"API_KEY\"]\n\n response = http.request(request)\n \n @body = JSON.parse(response.body)['data']\n return @body\n end",
"def index\n @sales_productivities = SalesProductivity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sales_productivities }\n end\n end",
"def index\n @sale_orders = current_company.sale_orders.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sale_orders }\n end\n end",
"def index\n @salespeople = Salesperson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @salespeople }\n end\n end",
"def index\n @product_sales = ProductSale.all\n end",
"def index\n @sales = Sale.paginate(:page => params[:page], :per_page => 10)\n end",
"def index\n @sales_ads = SalesAd.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sales_ads }\n end\n end",
"def show\n @sales_productivity = SalesProductivity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_productivity }\n end\n end",
"def show\n @sale_day_total = SaleDayTotal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale_day_total }\n end\n end",
"def index\n @sales_items = SalesItem.all\n end",
"def index\n page = params[:page].to_i\n limit = params[:limit].to_i\n offset = (page - 1) * limit\n\n results = Sale.joins(:product, :status, :sale_lead)\n .order(time: :desc)\n .select(\n 'sales.id',\n 'sales.customer',\n 'sales.demand',\n 'sales.connection',\n 'sales.email',\n 'sales.phone',\n 'sales.time',\n 'statuses.name AS status_name',\n 'products.name AS product_name',\n 'sale_leads.name AS sale_lead_name',\n ).limit(limit).offset(offset)\n\n count = results.length\n\n (statuses, products, sale_leads) = [Status, Product, SaleLead].map(&:names)\n\n render json: {\n items: results,\n statusOptions: statuses,\n productOptions: products,\n leadOptions: sale_leads,\n total: count,\n }, status: :ok\n end",
"def show\n @sales_order = SalesOrder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_order }\n end\n end",
"def alltime_sales(type, product_ids=[], options={})\n accept_types = %w{products products+countries countries countries+products}\n raise ArgumentError, \"Type must be one of TYPE: #{accept_types}\" unless accept_types.include?(type)\n product_ids = [product_ids] unless product_ids.is_a?(Array)\n\n options.merge!({:basic_auth => @auth, :products => product_ids.join(\";\")})\n url = \"/reports/sales/#{type}\"\n self.class.get(url, options)\n end",
"def show\n @sales_term = SalesTerm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_term }\n end\n end",
"def index\n @gross_revenue = Sale.sum(:sale_total)\n @sales = Sale.order('created_at desc').page params[:page]\n end",
"def sales\n end",
"def index\n @sales_products = SalesProduct.all\n end",
"def index\n @sales = Sale.where(env: nil, user_id: current_user.id)\n end",
"def get_sale\n sales.first\n end",
"def index\n @sales_entries = SalesEntry.all\n end",
"def index\n events = Event.where(team: current_team)\n @sales = Sale.where(event: events)\n end",
"def show\n @sales_ad = SalesAd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_ad }\n end\n end",
"def index\n @origin_sales = OriginSale.paginate(:page => params[:page], :per_page => 10)\n end",
"def sales_invoice(id)\n get \"sales_invoices/#{id}\"\n end",
"def index\n render json: Seller.all\n end",
"def show\n render json: @sell\n end",
"def sales(type, start_date, end_date, product_ids, options={})\n raise ArgumentError, \"Type must be one of TYPE: #{TYPE.values.join(\", \")}\" unless TYPE.values.index(type)\n raise ArgumentError, \"Type must be one of DATASOURCE: #{DATASOURCE.values.join(\", \")}\" if (options[:data_source] && !DATASOURCE.values.index(options[:data_source]))\n\n product_ids = [product_ids] unless product_ids.is_a?(Array)\n options.merge!({:basic_auth => @auth, :product_ids => product_ids.join(\";\")})\n url = \"/sales/#{type}/#{start_date}/#{end_date}/\" \n self.class.get(url, options)\n end",
"def index\n @business_sales = BusinessSale.all\n end",
"def sale_get(api_key, opts = {})\n data, _status_code, _headers = sale_get_with_http_info(api_key, opts)\n return data\n end",
"def sale_get_sales_with_http_info(site_id, version, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SaleApi.sale_get_sales ...'\n end\n # verify the required parameter 'site_id' is set\n if @api_client.config.client_side_validation && site_id.nil?\n fail ArgumentError, \"Missing the required parameter 'site_id' when calling SaleApi.sale_get_sales\"\n end\n # verify the required parameter 'version' is set\n if @api_client.config.client_side_validation && version.nil?\n fail ArgumentError, \"Missing the required parameter 'version' when calling SaleApi.sale_get_sales\"\n end\n # resource path\n local_var_path = '/public/v{version}/sale/sales'.sub('{' + 'version' + '}', version.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', 'text/json', 'application/xml', 'text/xml', 'multipart/form-data'])\n header_params[:'siteId'] = site_id\n header_params[:'authorization'] = opts[:'authorization'] if !opts[:'authorization'].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(: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 => 'GetSalesResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SaleApi#sale_get_sales\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def sale_get_with_http_info(api_key, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SaleApi.sale_get ...\"\n end\n # verify the required parameter 'api_key' is set\n if @api_client.config.client_side_validation && api_key.nil?\n fail ArgumentError, \"Missing the required parameter 'api_key' when calling SaleApi.sale_get\"\n end\n # resource path\n local_var_path = \"/api/Sale\"\n\n # query parameters\n query_params = {}\n query_params[:'saleId'] = opts[:'sale_id'] if !opts[:'sale_id'].nil?\n query_params[:'maxRecords'] = opts[:'max_records'] if !opts[:'max_records'].nil?\n query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?\n query_params[:'to'] = opts[:'to'] if !opts[:'to'].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', 'application/xml', 'text/xml'])\n header_params[:'ApiKey'] = api_key\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<SwiftPOSVenue>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SaleApi#sale_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def sale\n ret = nil\n if @json_body.include?('sale_id')\n ret = @mc2p.sale('id' => @json_body['sale_id'])\n ret.retrieve\n end\n ret\n end",
"def index\n @shop_special_offers_transactions = Shop::SpecialOffersTransaction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shop_special_offers_transactions }\n end\n end",
"def index\n @shop = Shop.find(1)\n render :json => @shop\n return\n end",
"def get_sale_all_using_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SupportApi.get_sale_all_using_get ...'\n end\n # resource path\n local_var_path = '/sales'\n\n # query parameters\n query_params = {}\n query_params[:'ascending'] = opts[:'ascending'] if !opts[:'ascending'].nil?\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\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 => 'PageSale')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SupportApi#get_sale_all_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @revenue = Revenue.find(params[:id])\n\n render json: @revenue\n end",
"def index\n all=Sale.where(active:true)\n ventas= resumen all \n\n render json:ventas\n end",
"def index\n @items = @sale.items\n end",
"def index\n @expenses = find_expenses.all\n render json: @expenses\n end",
"def index\n @purchases = Purchase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @purchases }\n end\n end",
"def index\n @purchases = Purchase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @purchases }\n end\n end",
"def show\n @pre_sale = PreSale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pre_sale }\n end\n end",
"def index\n @sales_channels = SalesChannel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @sales_channels }\n end\n end",
"def index\n @msales = Msale.all \n end",
"def show\n @sales_code = SalesCode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_code }\n end\n end",
"def show\n @sales_team = SalesTeam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_team }\n end\n end",
"def index\n \n @sales_types = SalesType.find_all_by_company_id(current_user.company_id)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sales_types }\n end\n \n end",
"def sales\n return array_of_instances(FarMar::Sale.all, \"product_id\", product_id)\n end",
"def index\n @accesory_sales = AccesorySale.all\n end",
"def get_sale_using_get_with_http_info(sales_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SupportApi.get_sale_using_get ...'\n end\n # verify the required parameter 'sales_id' is set\n if @api_client.config.client_side_validation && sales_id.nil?\n fail ArgumentError, \"Missing the required parameter 'sales_id' when calling SupportApi.get_sale_using_get\"\n end\n # resource path\n local_var_path = '/sales/{sales_id}'.sub('{' + 'sales_id' + '}', sales_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(['*/*'])\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 => 'Sale')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SupportApi#get_sale_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @salesperson = Salesperson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @salesperson }\n end\n end",
"def index\n @cal_month_sales = CalMonthSale.paginate(page: params[:page])\n end",
"def index\n @sales_orders = SalesOrder.all\n end",
"def show\n @product_sold = ProductSold.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_sold }\n end\n end",
"def index\n @salespeople = Salesperson.all\n end",
"def sales\n FarMar::Sale.all.find_all { |sale| sale.product_id == id }\n end",
"def index\n @sales_sellers = Sales::Seller.all\n end",
"def sales\n FarMar::Sale.all.find_all { |sale| sale.product_id == @id }\n end",
"def get_sale\n @ventad = Sale.find(params[:sale_id])\n end",
"def show\n @d_sale_item = DSaleItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @d_sale_item }\n end\n end",
"def index\n @taxes = Tax.all\n\n render json: @taxes\n end",
"def index\n @totals = {subtotal: 0, iva: 0, retencion: 0, other_concepts: 0, total: 0 }\n @title = t('view.sale_invoices.index_title', month: @monthly_movement.month, year: @monthly_movement.year)\n if params[:firm].present?\n @sale_invoices = @monthly_movement.sale_invoices.where('firms.nombre LIKE ?', \"%#{params[:firm]}%\")\n else\n @sale_invoices = @monthly_movement.sale_invoices\n end\n\n @sale_invoices = @sale_invoices.includes(:firm).order('date asc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sale_invoices }\n end\n end",
"def region_sales(start_date, end_date, options={})\n options.merge!({:basic_auth => @auth})\n url = \"/sales/regions/#{start_date}/#{end_date}\" \n self.class.get(url, options)\n end",
"def index\n \tcustomers = Customer.all\n \trender json: customers\n \tend",
"def index\n @requested_sales_documents = RequestedSalesDocument.all\n end",
"def index\n @per_page = 5\n @sales = Sale.paginate(per_page: @per_page, page: params[:page])\n end",
"def index\n @sales_channel = SalesChannel.find(params[:sales_channel_id])\n @sales_channel_apis = @sales_channel.apis\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @sales_channel_apis }\n end\n end",
"def sales\n FarMar::Sale.all.find_all {|instance| instance.product_id == id}\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def index\n @stores = Store.all\n render json: @stores\n end",
"def index\n @title = t('view.sellers.index_title')\n @sellers = Seller.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sellers }\n end\n end",
"def index\n @supermarkets = Supermarket.all\n respond_to do |format|\n format.json { render json: @supermarkets, status: :ok } \n end \n end",
"def show\n @sell = Sell.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sell }\n end\n end",
"def sales(ven_id)\n FarMar::Sale.all.find_all { |sale_item| sale_item.vendor_id == ven_id }\n end",
"def index\r\n @sales_orders = @customer.sales_orders\r\n end",
"def index\n @point_of_sales = PointOfSale.all\n end",
"def index\n @purchases = Purchase.where(user_id: get_current_user.id.to_i)\n\n render json: @purchases\n end",
"def index\n @shops = Shop.all\n @search = Shop.search(params[:q])\n @shops = @search.result.page(params[:page]).per(30)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shops }\n end\n\n end"
] |
[
"0.8167744",
"0.81421864",
"0.7505555",
"0.734486",
"0.7266149",
"0.7266149",
"0.7266149",
"0.7266149",
"0.7266149",
"0.7266149",
"0.7266149",
"0.72475237",
"0.72210985",
"0.7124364",
"0.70870465",
"0.70870465",
"0.70577073",
"0.7030278",
"0.7018311",
"0.7000222",
"0.695755",
"0.6913336",
"0.69009894",
"0.6893327",
"0.68326914",
"0.68264455",
"0.6824798",
"0.67539334",
"0.67476624",
"0.67344403",
"0.66926336",
"0.66874474",
"0.6669207",
"0.6660905",
"0.664095",
"0.6622472",
"0.66127956",
"0.66123605",
"0.65953815",
"0.65807784",
"0.6574215",
"0.6568011",
"0.65150636",
"0.65019417",
"0.64999413",
"0.6492696",
"0.64781034",
"0.6438235",
"0.64363533",
"0.6425327",
"0.63947934",
"0.6390681",
"0.6389564",
"0.63786036",
"0.63757765",
"0.63530433",
"0.6351176",
"0.6349149",
"0.6329553",
"0.6321324",
"0.6321324",
"0.6317992",
"0.63138777",
"0.631296",
"0.63128906",
"0.63075155",
"0.6305501",
"0.6300866",
"0.62991124",
"0.6292738",
"0.6287233",
"0.62834585",
"0.6283388",
"0.6271291",
"0.62600857",
"0.6259189",
"0.62528294",
"0.6250087",
"0.6247792",
"0.6239319",
"0.6235117",
"0.6227909",
"0.6225621",
"0.622369",
"0.6220835",
"0.62130433",
"0.62080926",
"0.6184317",
"0.6175794",
"0.6175794",
"0.6175794",
"0.6168391",
"0.6158758",
"0.61509687",
"0.6145044",
"0.61399096",
"0.61338013",
"0.6131609",
"0.6131464",
"0.6109602"
] |
0.6918693
|
21
|
GET /sales/1 GET /sales/1.json
|
def show
@sale = Sale.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @sale }
format.pdf do
pdf = SaleIndividualPdf.new(@sale.id, view_context, ApplicationController.helpers.get_company_identity)
send_data pdf.render, filename: "#{I18n.t 'sale.sales_invoice'} #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}.pdf",
type: "application/pdf", :disposition => "inline"
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @sales = Sale.all\n\n render json: @sales\n end",
"def index\n @sales = @saleService.all_to_json().as_json;\n end",
"def show\n render json: @invoice, methods: [:sales]\n end",
"def show\n render json: @sale\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale }\n end\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale }\n end\n end",
"def show\n @sales_datum = SalesDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_datum }\n end\n end",
"def index\n @pre_sales = PreSale.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pre_sales }\n end\n end",
"def getDate\n @sales = Sale.where(\"date = ?\", params[:date])\n render json: @sales\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def show\n @sales_productivity = SalesProductivity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_productivity }\n end\n end",
"def sales\n FarMar::Sale.get_by(\"vendor\", id)\n end",
"def index\n @sells = Sell.all\n\n render json: @sells\n end",
"def show\n @sales_order = SalesOrder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_order }\n end\n end",
"def get_sale\n sales.first\n end",
"def index\n @sales_productivities = SalesProductivity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sales_productivities }\n end\n end",
"def show\n @sale_day_total = SaleDayTotal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale_day_total }\n end\n end",
"def index\n @sales = Sale\n .where(\"EXTRACT(MONTH FROM transaction_date)=EXTRACT(MONTH FROM CURRENT_DATE) AND EXTRACT(YEAR FROM transaction_date)=EXTRACT(YEAR FROM CURRENT_DATE)\")\n .order(:created_at).reverse_order\n .pagination(params[:page])\n\n @customers = Customer.order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sales }\n format.js\n end\n end",
"def index\n @sale_orders = current_company.sale_orders.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sale_orders }\n end\n end",
"def sales\n Sale.find_all_by_vendor_id(@id)\n end",
"def index\n @salespeople = Salesperson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @salespeople }\n end\n end",
"def show\n @sales_term = SalesTerm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_term }\n end\n end",
"def show\n @sales_ad = SalesAd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_ad }\n end\n end",
"def index\n @sales_items = SalesItem.all\n end",
"def index\n @sales = Sale.paginate(:page => params[:page], :per_page => 10)\n end",
"def index\n @product_sales = ProductSale.all\n end",
"def sales_invoice(id)\n get \"sales_invoices/#{id}\"\n end",
"def index\n @shop = Shop.find(1)\n render :json => @shop\n return\n end",
"def index\n @sales_ads = SalesAd.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sales_ads }\n end\n end",
"def show\n @pre_sale = PreSale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pre_sale }\n end\n end",
"def show\n @sales_code = SalesCode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_code }\n end\n end",
"def show\n @d_sale_item = DSaleItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @d_sale_item }\n end\n end",
"def index\n page = params[:page].to_i\n limit = params[:limit].to_i\n offset = (page - 1) * limit\n\n results = Sale.joins(:product, :status, :sale_lead)\n .order(time: :desc)\n .select(\n 'sales.id',\n 'sales.customer',\n 'sales.demand',\n 'sales.connection',\n 'sales.email',\n 'sales.phone',\n 'sales.time',\n 'statuses.name AS status_name',\n 'products.name AS product_name',\n 'sale_leads.name AS sale_lead_name',\n ).limit(limit).offset(offset)\n\n count = results.length\n\n (statuses, products, sale_leads) = [Status, Product, SaleLead].map(&:names)\n\n render json: {\n items: results,\n statusOptions: statuses,\n productOptions: products,\n leadOptions: sale_leads,\n total: count,\n }, status: :ok\n end",
"def salesApi\n require 'uri'\n require 'net/http'\n require 'json'\n\n #Arrays for each category\n \n @frequency = Hash.new(0)\n\n url = URI(\"https://api.salesloft.com/v2/people.json\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n\n request = Net::HTTP::Get.new(url)\n request[\"Authorization\"] = 'Bearer ' + ENV[\"API_KEY\"]\n\n response = http.request(request)\n \n @body = JSON.parse(response.body)['data']\n return @body\n end",
"def show\n @revenue = Revenue.find(params[:id])\n\n render json: @revenue\n end",
"def show\n @salesperson = Salesperson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @salesperson }\n end\n end",
"def sales(options = {})\n options[:product_id] = epages_id(options[:product_id]) if options[:product_id]\n perform_get_with_object('/sales', format_dates_options(options), Epages::SalesSummary)\n end",
"def index\n @sales_products = SalesProduct.all\n end",
"def index\n @sales_entries = SalesEntry.all\n end",
"def alltime_sales(type, product_ids=[], options={})\n accept_types = %w{products products+countries countries countries+products}\n raise ArgumentError, \"Type must be one of TYPE: #{accept_types}\" unless accept_types.include?(type)\n product_ids = [product_ids] unless product_ids.is_a?(Array)\n\n options.merge!({:basic_auth => @auth, :products => product_ids.join(\";\")})\n url = \"/reports/sales/#{type}\"\n self.class.get(url, options)\n end",
"def index\n @sales = Sale.where(env: nil, user_id: current_user.id)\n end",
"def index\n @purchases = Purchase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @purchases }\n end\n end",
"def index\n @purchases = Purchase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @purchases }\n end\n end",
"def show\n @title = t('view.sale_invoices.show_title')\n @sale_invoice = SaleInvoice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sale_invoice }\n end\n end",
"def show\n @product_sold = ProductSold.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_sold }\n end\n end",
"def show\n render json: @sell\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def index\n @api_v1_stores = Store.all\n json_response(@api_v1_stores)\n end",
"def get_sale\n @ventad = Sale.find(params[:sale_id])\n end",
"def show\n @sales_team = SalesTeam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_team }\n end\n end",
"def index\n render json: Seller.all\n end",
"def sale\n ret = nil\n if @json_body.include?('sale_id')\n ret = @mc2p.sale('id' => @json_body['sale_id'])\n ret.retrieve\n end\n ret\n end",
"def index\n @shop_special_offers_transactions = Shop::SpecialOffersTransaction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shop_special_offers_transactions }\n end\n end",
"def show\n @supermarket = Supermarket.find(params[:id])\n respond_to do |format|\n format.json { render json: @supermarket, status: :ok } \n end \n end",
"def index\n @items = @sale.items\n end",
"def sales\n end",
"def index\n @origin_sales = OriginSale.paginate(:page => params[:page], :per_page => 10)\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sale }\n end\n end",
"def show\n @sale = Sale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sale }\n end\n end",
"def sale_get_sales_with_http_info(site_id, version, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SaleApi.sale_get_sales ...'\n end\n # verify the required parameter 'site_id' is set\n if @api_client.config.client_side_validation && site_id.nil?\n fail ArgumentError, \"Missing the required parameter 'site_id' when calling SaleApi.sale_get_sales\"\n end\n # verify the required parameter 'version' is set\n if @api_client.config.client_side_validation && version.nil?\n fail ArgumentError, \"Missing the required parameter 'version' when calling SaleApi.sale_get_sales\"\n end\n # resource path\n local_var_path = '/public/v{version}/sale/sales'.sub('{' + 'version' + '}', version.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', 'text/json', 'application/xml', 'text/xml', 'multipart/form-data'])\n header_params[:'siteId'] = site_id\n header_params[:'authorization'] = opts[:'authorization'] if !opts[:'authorization'].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(: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 => 'GetSalesResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SaleApi#sale_get_sales\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @sell = Sell.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sell }\n end\n end",
"def index\n @supermarkets = Supermarket.all\n respond_to do |format|\n format.json { render json: @supermarkets, status: :ok } \n end \n end",
"def index\n all=Sale.where(active:true)\n ventas= resumen all \n\n render json:ventas\n end",
"def index\n \tcustomers = Customer.all\n \trender json: customers\n \tend",
"def show\n @sales_rep = SalesRep.find(params[:id])\n # @follow_up = FollowUp.new\n # @meeting = Meeting.new\n # @client = Client.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_rep }\n end\n end",
"def index\n @business_sales = BusinessSale.all\n end",
"def show\n @shop_purchase = Shop::Purchase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_purchase }\n end\n end",
"def index\n @gross_revenue = Sale.sum(:sale_total)\n @sales = Sale.order('created_at desc').page params[:page]\n end",
"def index\n events = Event.where(team: current_team)\n @sales = Sale.where(event: events)\n end",
"def sale_get_with_http_info(api_key, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SaleApi.sale_get ...\"\n end\n # verify the required parameter 'api_key' is set\n if @api_client.config.client_side_validation && api_key.nil?\n fail ArgumentError, \"Missing the required parameter 'api_key' when calling SaleApi.sale_get\"\n end\n # resource path\n local_var_path = \"/api/Sale\"\n\n # query parameters\n query_params = {}\n query_params[:'saleId'] = opts[:'sale_id'] if !opts[:'sale_id'].nil?\n query_params[:'maxRecords'] = opts[:'max_records'] if !opts[:'max_records'].nil?\n query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?\n query_params[:'to'] = opts[:'to'] if !opts[:'to'].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', 'application/xml', 'text/xml'])\n header_params[:'ApiKey'] = api_key\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<SwiftPOSVenue>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SaleApi#sale_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n\n @sales_type = SalesType.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sales_type }\n end\n \n end",
"def index\n \n @sales_types = SalesType.find_all_by_company_id(current_user.company_id)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sales_types }\n end\n \n end",
"def search\n render json: Consultation.first(10)\n end",
"def index\n @sales_channels = SalesChannel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @sales_channels }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n @store_cust_group = CustomerGroup.find_by_name(\"Bakul/Toko\")\n @workshop_cust_group = CustomerGroup.find_by_name(\"Bengkel/Montir\")\n\n @sale_histories = SaleDetail.where(:product_id => @product.id).order(:updated_at).reverse_order.limit(10)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def index\n @purchases = Purchase.where(user_id: get_current_user.id.to_i)\n\n render json: @purchases\n end",
"def new\n @sales_datum = SalesDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sales_datum }\n end\n end",
"def sales(type, start_date, end_date, product_ids, options={})\n raise ArgumentError, \"Type must be one of TYPE: #{TYPE.values.join(\", \")}\" unless TYPE.values.index(type)\n raise ArgumentError, \"Type must be one of DATASOURCE: #{DATASOURCE.values.join(\", \")}\" if (options[:data_source] && !DATASOURCE.values.index(options[:data_source]))\n\n product_ids = [product_ids] unless product_ids.is_a?(Array)\n options.merge!({:basic_auth => @auth, :product_ids => product_ids.join(\";\")})\n url = \"/sales/#{type}/#{start_date}/#{end_date}/\" \n self.class.get(url, options)\n end",
"def show\n @sales_channel = SalesChannel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @sales_channel }\n end\n end",
"def show\n render json: @shop\n end",
"def show\n @shop_special_offers_transaction = Shop::SpecialOffersTransaction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_special_offers_transaction }\n end\n end",
"def index\n @totals = {subtotal: 0, iva: 0, retencion: 0, other_concepts: 0, total: 0 }\n @title = t('view.sale_invoices.index_title', month: @monthly_movement.month, year: @monthly_movement.year)\n if params[:firm].present?\n @sale_invoices = @monthly_movement.sale_invoices.where('firms.nombre LIKE ?', \"%#{params[:firm]}%\")\n else\n @sale_invoices = @monthly_movement.sale_invoices\n end\n\n @sale_invoices = @sale_invoices.includes(:firm).order('date asc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sale_invoices }\n end\n end",
"def set_sale\n @sale = Sale.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n render json: {\n success: false,\n msg: 'Sale not found',\n }\n end",
"def show\n @shop = Shop.find(params[:id])\n @rates = @shop.rates.page(params[:page])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop }\n end\n end",
"def show\n @customer = Customer.includes(:invoices).find(params[:id].split(\",\"))\n\n render json: @customer\n end",
"def get_sale_using_get_with_http_info(sales_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SupportApi.get_sale_using_get ...'\n end\n # verify the required parameter 'sales_id' is set\n if @api_client.config.client_side_validation && sales_id.nil?\n fail ArgumentError, \"Missing the required parameter 'sales_id' when calling SupportApi.get_sale_using_get\"\n end\n # resource path\n local_var_path = '/sales/{sales_id}'.sub('{' + 'sales_id' + '}', sales_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(['*/*'])\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 => 'Sale')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SupportApi#get_sale_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @expenses = find_expenses.all\n render json: @expenses\n end",
"def index\n @title = t('view.sellers.index_title')\n @sellers = Seller.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sellers }\n end\n end",
"def index\n @sales_orders = SalesOrder.all\n end",
"def index\n @taxes = Tax.all\n\n render json: @taxes\n end",
"def index\n @sales_channel = SalesChannel.find(params[:sales_channel_id])\n @sales_channel_apis = @sales_channel.apis\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @sales_channel_apis }\n end\n end",
"def company_intel\n company_id = params[:company_id]\n start_date = params[:start_date]\n end_date = params[:end_date]\n\n @intel = ItemPurchase.get_market_share(company_id, start_date, end_date)\n\n respond_to do |format|\n format.json\n end\n \n \n \n \n end",
"def index\n @q = params[:q]\n @q ||= \"\"\n @shops = Shop.search(@q).records\n\n\n respond_to do |format|\n format.html { render action: 'index' }\n format.json { render json: @shops, each_serializer: ShopListSerializer }\n end\n end"
] |
[
"0.7998383",
"0.7861703",
"0.7389379",
"0.73709834",
"0.7334243",
"0.7334243",
"0.7176787",
"0.71458316",
"0.70973235",
"0.7082648",
"0.7082648",
"0.7082648",
"0.7082648",
"0.7082648",
"0.7082648",
"0.7082648",
"0.69916207",
"0.6967121",
"0.69211215",
"0.6917201",
"0.68852955",
"0.68627864",
"0.68614846",
"0.684126",
"0.6829409",
"0.6811886",
"0.6756003",
"0.6741986",
"0.66638607",
"0.66609436",
"0.6649946",
"0.6640834",
"0.66350037",
"0.66237766",
"0.66232485",
"0.66066897",
"0.6585307",
"0.65599674",
"0.6557844",
"0.6547887",
"0.65392077",
"0.6532667",
"0.6486112",
"0.6475114",
"0.6457674",
"0.64546293",
"0.64502126",
"0.6445383",
"0.6445383",
"0.6441187",
"0.64328414",
"0.64299536",
"0.6422058",
"0.6422058",
"0.6422058",
"0.63979375",
"0.63962644",
"0.63890636",
"0.63752866",
"0.6363796",
"0.63619775",
"0.6359116",
"0.6357406",
"0.6342716",
"0.6306146",
"0.6297158",
"0.6297158",
"0.62803364",
"0.6271404",
"0.62692565",
"0.625842",
"0.6256768",
"0.62562364",
"0.624607",
"0.6243419",
"0.6239498",
"0.6228966",
"0.6228327",
"0.62179464",
"0.62156516",
"0.6212055",
"0.6210789",
"0.62048227",
"0.6204227",
"0.6202537",
"0.6199515",
"0.61929506",
"0.61919236",
"0.619029",
"0.61899114",
"0.6188623",
"0.6187588",
"0.6163713",
"0.615955",
"0.61560315",
"0.6154152",
"0.6141537",
"0.6141223",
"0.61357063",
"0.6125556",
"0.61242115"
] |
0.0
|
-1
|
GET /sales/new GET /sales/new.json
|
def new
@sale = Sale.new
respond_to do |format|
format.html
format.js
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sales_datum = SalesDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sales_datum }\n end\n end",
"def new\n @sales_code = SalesCode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sales_code }\n end\n end",
"def new\n @sale_day_total = SaleDayTotal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale_day_total }\n end\n end",
"def new\n @pre_sale = PreSale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pre_sale }\n end\n end",
"def new\n print params\n @product_sold = ProductSold.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_sold }\n end\n end",
"def new\n @sales_term = SalesTerm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sales_term }\n end\n end",
"def new\n @sell = Sell.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sell }\n end\n end",
"def new\n @sales_rep = SalesRep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sales_rep }\n format.js\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n\n if @sale.save\n render json: @sale, status: :created, location: @sale\n else\n render json: @sale.errors, status: :unprocessable_entity\n end\n end",
"def new\n @sales_ad = SalesAd.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sales_ad }\n end\n end",
"def new\n @sales_team = SalesTeam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sales_team }\n end\n end",
"def new\n @d_sale_item = DSaleItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @d_sale_item }\n end\n end",
"def create\n @sale = Sale.new(params[:sale])\n\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render json: @sale, status: :created, location: @sale }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(params[:sale])\n\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render json: @sale, status: :created, location: @sale }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(params[:sale])\n\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render json: @sale, status: :created, location: @sale }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @newspage = Newspage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newspage }\n end\n end",
"def new\n @invoice = Invoice.new\n @stores = Store.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invoice }\n end\n end",
"def new\n @total_stock = TotalStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @total_stock }\n end\n end",
"def new\n @enterprise = Enterprise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enterprise }\n end\n end",
"def new\n session[:current] = 'menu_admin'\n @salesperson = Salesperson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @salesperson }\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sale }\n else\n format.html { render action: 'new' }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @order = Order.new\n @order.sales.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @purchase = Purchase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchase }\n end\n end",
"def new\n @purchase = Purchase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchase }\n end\n end",
"def new\n @purchase = Purchase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchase }\n end\n end",
"def new\n @sales_channel = SalesChannel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @sales_channel }\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @purchased_stock = PurchasedStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchased_stock }\n end\n end",
"def new\n @purchased_stock = PurchasedStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchased_stock }\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sale = Sale.new(sale_params)\n respond_to do |format|\n if @sale.save\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render :show, status: :created, location: @sale }\n else\n format.html { render :new }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @shop_purchase = Shop::Purchase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop_purchase }\n end\n end",
"def new\n @store = Store.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @store }\n end\n end",
"def new\n @store = Store.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @store }\n end\n end",
"def new\n @store = Store.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @store }\n end\n end",
"def new\n @store = Store.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @store }\n end\n end",
"def new\n @store = Store.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @store }\n end\n end",
"def new\n @shop_transaction = Shop::Transaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop_transaction }\n end\n end",
"def new\n @shop = Shop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop }\n end\n end",
"def new\n @shop = Shop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop }\n end\n end",
"def new\n @shop = Shop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop }\n end\n end",
"def new\n @cust = Cust.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cust }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end",
"def new\n @title = t('view.sellers.new_title')\n @seller = Seller.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seller }\n end\n end",
"def new\n @sp500_stock = Sp500Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sp500_stock }\n end\n end",
"def new\n @shop_special_offers_transaction = Shop::SpecialOffersTransaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop_special_offers_transaction }\n end\n end",
"def create\n instance = Sale.new(sale_params)\n\n if instance.save\n render json: { msg: instance }, status: :created\n else\n render json: { msg: instance.errors }, status: :unprocessable_entity\n end\n end",
"def new\n @stock_transaction = StockTransaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock_transaction }\n end\n end",
"def new\n @product = Product.new\n\n render json: @product\n end",
"def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sprint }\n end\n end",
"def new\n \n @sales_type = SalesType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @outgoing_type }\n end\n \n end",
"def new\n @detail = Detail.new\n @products = Product.all\n @product_types = ProductType.all\n @customers = Customer.all\n if session[:created_sale] == nil and !@customers.empty?\n @sale = Sale.new\n @sale.date = Time.now\n @sale.save\n session[:sale_id] = @sale.id\n session[:created_sale] = \"true\"\n end\n @details = Detail.where(:sale_id => session[:sale_id])\n \n\n respond_to do |format|\n if @customers.empty?\n format.html { redirect_to customers_path, notice: \"Debe crear un cliente para realizar una venta\" }\n else\n format.html # new.html.erb\n format.json { render json: @detail }\n end\n end\n end",
"def new\n @service = Service.new\n @vendors = Vendor.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @service }\n end\n end",
"def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end",
"def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end",
"def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end",
"def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end",
"def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end",
"def new\n @vessel = Vessel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vessel }\n end\n end",
"def new\n @shop_ose = ShopOse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop_ose }\n end\n end",
"def new\n @company = Company.new(:name => 'default')\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @company }\n end\n end",
"def new\n @transaction = Transaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transaction }\n end\n end",
"def new\n @transaction = Transaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transaction }\n end\n end",
"def new\n @transaction = Transaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transaction }\n end\n end",
"def new\n @magento_product = MagentoProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @magento_product }\n end\n end",
"def new\n fetch_data\n @payment = Payment.new(:payment_date => Date.today)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @payment }\n end\n end",
"def new\n @get = Get.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @get }\n end\n end",
"def new\n @stable = Stable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stable }\n end\n end",
"def new\n @substrate = Substrate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @substrate }\n end\n end",
"def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def new\n @transaction = Transaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @transaction }\n end\n end",
"def new\n @salesperson = Salesperson.new\n prepFormVariables\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @salesperson }\n end\n end",
"def new\n @distributor = Distributor.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distributor }\n end\n end",
"def new\n @store = Store.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @store }\n end\n end",
"def new\n # Create new news\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end",
"def new\n @mostsmalltrapeffectinventory = Mostsmalltrapeffectinventory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mostsmalltrapeffectinventory }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end",
"def new\n @spdatum = Spdatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spdatum }\n end\n end",
"def new\n @sale_representative = SaleRepresentative.new\n @contact = Contact.find_all_by_company_id(current_user.company_id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sale_representative }\n end\n end",
"def new\n @feedstock = Feedstock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feedstock }\n end\n end",
"def new\n @seller = Seller.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seller }\n end\n end",
"def new\n @supplier = Supplier.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @supplier }\n end\n end",
"def new\n\t\t\t\t @store = Store.new\n\n\t\t\t\t respond_to do |format|\n\t\t\t\t format.html # new.html.erb\n\t\t\t\t format.json { render json: @store }\n\t\t\t\t end\n\t\t\t\t end"
] |
[
"0.8026322",
"0.8026322",
"0.8026322",
"0.7617632",
"0.7348117",
"0.7332829",
"0.7321252",
"0.7276389",
"0.7250406",
"0.7248883",
"0.71988344",
"0.7197199",
"0.7196902",
"0.71611774",
"0.7089569",
"0.70761955",
"0.70761955",
"0.70761955",
"0.7022161",
"0.7003506",
"0.6946766",
"0.6946676",
"0.6936588",
"0.6932434",
"0.6908981",
"0.6893153",
"0.6893153",
"0.6893153",
"0.6858623",
"0.68365294",
"0.68362886",
"0.68362886",
"0.6835383",
"0.6835383",
"0.68274605",
"0.68165654",
"0.68165654",
"0.68165654",
"0.68165654",
"0.68165654",
"0.68156874",
"0.6812046",
"0.6812046",
"0.6812046",
"0.6802524",
"0.6798278",
"0.6798278",
"0.6798278",
"0.6798278",
"0.6798278",
"0.6798278",
"0.67924356",
"0.6791925",
"0.6783703",
"0.6780091",
"0.67791736",
"0.67577964",
"0.675469",
"0.6753119",
"0.6745658",
"0.67443156",
"0.673025",
"0.673025",
"0.673025",
"0.673025",
"0.673025",
"0.6728632",
"0.6716365",
"0.671286",
"0.67105067",
"0.67105067",
"0.67105067",
"0.6707403",
"0.67021567",
"0.670204",
"0.66994226",
"0.66985714",
"0.6696921",
"0.6682176",
"0.6678705",
"0.6674774",
"0.66655004",
"0.6664514",
"0.6664359",
"0.6650851",
"0.6650851",
"0.6650851",
"0.6650851",
"0.6650851",
"0.6650851",
"0.6650851",
"0.6650851",
"0.6650851",
"0.6650851",
"0.6650494",
"0.66493225",
"0.6647636",
"0.66446245",
"0.6643185",
"0.6642401"
] |
0.7193064
|
13
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.