query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
sequencelengths
19
19
metadata
dict
Returns the bottom position number in the list. bottom_position_in_list => 2
def bottom_position_in_list(except = nil) item = bottom_item(except) item ? item.send(:position) : 0 end
[ "def bottom_position_in_list(except = nil)\n item = bottom_item(except)\n item ? item.position : 0\n end", "def bottom_position_in_list(except = nil)\n item = bottom_item(except)\n item ? item.send(position_column) : 0\n end", "def assume_bottom_position\n set_list_position(bottom_position_in_list(self).to_i + 1)\n end", "def add_to_list_bottom\n self[position_column] = bottom_position_in_list.to_i + 1\n end", "def assume_bottom_position\n pos = bottom_position_in_list(self).to_i + 1 \n set_my_position(pos)\n end", "def assume_bottom_position\n update_position( bottom_position_in_list(self).to_i+1 )\n end", "def bottom\n return @bottom\n end", "def bottom_queue_position_in_queue(except = nil)\n item = bottom_item_in_queue(except)\n item ? item.send(queue_position_column) : 0\n end", "def getBottomBound()\n return @board_start_y + @board_height\n end", "def bottom(column)\n index = column.last(12).index(0)\n if index == 0\n return nil\n end\n return index\n end", "def find_bottom_of_map\n\t\t\tfind_max_of_map \"y\", \"height\"\n\t\tend", "def last?\n return false unless in_list?\n bottom_pos = bottom_position_in_list\n my_position == bottom_pos\n end", "def move_to_bottom\n return unless in_list?\n decrement_positions_on_lower_items\n assume_bottom_position\n end", "def move_to_bottom\n return unless in_list?\n\n decrement_positions_on_lower_items\n assume_bottom_position \n end", "def absolute_bottom\n @y - height\n end", "def bottom\n self[-1]\n end", "def getBottomSize ()\n bottom_size = 0\n (bottom_size = @bottom.getSize()) if (@bottom)\n return bottom_size\n end", "def last_position(list_name = nil)\n item = last_item(list_name)\n item.nil? ? 0 : item.send(evaluate_sortable_options(list_name)[:column])\n end", "def move_to_bottom\n return unless in_list?\n\n decrement_positions_on_lower_items\n assume_bottom_position\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Use equivalentxml to determine equivalence
def equivalent_nokogiri(other) if defined?(::EquivalentXml) EquivalentXml.equivalent?(object, other.object) else equivalent_rexml(other) end end
[ "def equivalent_nodes(node_1, node_2)\n EquivalentXml.equivalent?(node_1,\n node_2,\n element_order: false,\n normalize_whitespace: true,\n ignore_attr_values: ['version', 'xmlns', 'xmlns:xsi', 'schemaLocation'])\n end", "def equivalent_rexml(other)\n begin\n require 'active_support'\n require 'active_support/core_ext'\n rescue LoadError\n # string equivalence\n end\n\n if Hash.respond_to?(:from_xml)\n Hash.from_xml(\"<root>#{self}</root>\") == Hash.from_xml(\"<root>#{other}</root>\")\n else\n # Poor mans equivalent\n value == other.value\n end\n end", "def assert_equivalent_xml(expected, actual)\n expected_xml = Nokogiri::XML(\"<test-xml>\\n#{expected}\\n</test-xml>\")\n actual_xml = Nokogiri::XML(\"<test-xml>\\n#{actual}\\n</test-xml>\")\n ignored_attributes = %w(style data-disable-with)\n\n equivalent = EquivalentXml.equivalent?(expected_xml, actual_xml, {\n ignore_attr_values: ignored_attributes\n }) do |a, b, result|\n if result === false && b.is_a?(Nokogiri::XML::Element)\n if b.attr('name') == 'utf8'\n # Handle wrapped utf8 hidden field for Rails 4.2+\n result = EquivalentXml.equivalent?(a.child, b)\n end\n if b.delete('data-disable-with')\n # Remove data-disable-with for Rails 5+\n # Workaround because ignoring in EquivalentXml doesn't work\n result = EquivalentXml.equivalent?(a, b)\n end\n if a.attr('type') == 'datetime' && b.attr('type') == 'datetime-local'\n a.delete('type')\n b.delete('type')\n # Handle new datetime type for Rails 5+\n result = EquivalentXml.equivalent?(a, b)\n end\n end\n result\n end\n\n assert equivalent, lambda {\n # using a lambda because diffing is expensive\n Diffy::Diff.new(\n sort_attributes(expected_xml.root),\n sort_attributes(actual_xml.root)\n ).to_s(:color)\n }\n end", "def assert_xml_equal(expected, actual)\n expected_xml = Nokogiri::XML(\"<test-xml>\\n#{expected}\\n</test-xml>\", &:noblanks)\n actual_xml = Nokogiri::XML(\"<test-xml>\\n#{actual}\\n</test-xml>\", &:noblanks)\n\n equivalent = EquivalentXml.equivalent?(expected_xml, actual_xml)\n assert equivalent, -> {\n # using a lambda because diffing is expensive\n Diffy::Diff.new(\n sort_attributes(expected_xml.root).to_xml(indent: 2),\n sort_attributes(actual_xml.root).to_xml(indent: 2)\n ).to_s\n }\n end", "def ns_semantic_equivalent_xml?(noko_a, noko_b)\n noko_a = noko_a.root if noko_a.kind_of?(Nokogiri::XML::Document)\n noko_b = noko_b.root if noko_b.kind_of?(Nokogiri::XML::Document)\n\n noko_a.name == noko_b.name &&\n noko_a.namespace&.prefix == noko_b.namespace&.prefix &&\n noko_a.namespace&.href == noko_b.namespace&.href &&\n noko_a.attributes == noko_b.attributes &&\n noko_a.children.length == noko_b.children.length &&\n noko_a.children.each_with_index.all? do |a_child, index|\n ns_semantic_equivalent_xml?(a_child, noko_b.children[index])\n end\n end", "def xml_should_be_same(expected, actual)\n expected = Hpricot(expected)\n actual = Hpricot(actual)\n \n blame = \"\\n\\n#################### expected\\n#{expected.to_html}\\n\\n\" \"#################### actual:\\n#{actual.to_html}\\n\\n\" \n (xml_cmp(expected, actual)).should.blaming(blame).equal true\nend", "def xml_compare a, b\n a = REXML::Document.new(a.to_s)\n b = REXML::Document.new(b.to_s)\n\n normalized = Class.new(REXML::Formatters::Pretty) do\n def write_text(node, output)\n super(node.to_s.strip, output)\n end\n end\n\n normalized.new(indentation=0,ie_hack=false).write(node=a, a_normalized='')\n normalized.new(indentation=0,ie_hack=false).write(node=b, b_normalized='')\n\n a_normalized == b_normalized\n end", "def xml_should_eql(actual, expected)\n same = xml_cmp(actual, expected)\n actual.should.== expected unless same \nend", "def xml_cmp a, b\n a = REXML::Document.new(a.to_s)\n b = REXML::Document.new(b.to_s)\n\n normalized = Class.new(REXML::Formatters::Pretty) do\n def write_text(node, output)\n super(node.to_s.strip, output)\n end\n end\n\n normalized.new(indentation=0,ie_hack=false).write(node=a, a_normalized='')\n normalized.new(indentation=0,ie_hack=false).write(node=b, b_normalized='')\n\n a_normalized == b_normalized\n end", "def == other\n return false if other.class != self.class \n return false if @__xmlele - other.__xmlele == []\n return false if @__xmlattr != other.__xmlattr\n return true\n end", "def equivalent(sim)\r\n sim.equivalence_id == self.equivalence_id\r\n end", "def ==(other)\n if other.class == self.class\n xml.to_s == other.xml.to_s\n else\n super\n end\n end", "def on_eq(ast_node, context)\n left = process(ast_node.children[0], context)\n right = process(ast_node.children[1], context)\n\n if left.is_a?(XML::NodeSet)\n left = first_node_text(left)\n end\n\n if right.is_a?(XML::NodeSet)\n right = first_node_text(right)\n end\n\n if left.is_a?(Numeric) and !right.is_a?(Numeric)\n right = to_float(right)\n end\n\n if left.is_a?(String) and !right.is_a?(String)\n right = to_string(right)\n end\n\n return left == right\n end", "def compare_xml_method current, expect\n @compareTable.compare_table(current, expect)\n end", "def equivalent?(other)\n Equivalence.new.call(self, other)\n end", "def test_match\n # two nodes with same name\n node1 = XML::Node.new( 'nexml' )\n node2 = XML::Node.new( 'nexml' )\n\n # same attributes\n node1.attributes = { :version => '0.9', :generator => 'bioruby' }\n node2.attributes = { :generator => 'bioruby', :version => '0.9' }\n\n # childe nodes for node1\n child11 = XML::Node.new( 'otus' )\n child12 = XML::Node.new( 'otus' )\n child11.attributes = { :id => 'taxa1', :label => 'Taxa 1' }\n child12.attributes = { :id => 'taxa2', :label => 'Taxa 2' }\n\n # childe nodes for node2\n child21 = XML::Node.new( 'otus' )\n child22 = XML::Node.new( 'otus' )\n child21.attributes = { :id => 'taxa1', :label => 'Taxa 1' }\n child22.attributes = { :id => 'taxa2', :label => 'Taxa 2' }\n\n # same children\n node1 << child11\n node1 << child12\n node2 << child22\n node2 << child21\n\n assert match?( node1, node2 )\n end", "def compare_nodes(a, b) # :doc:\n c = clean_hash(xml_node_to_hash(a))\n d = clean_hash(xml_node_to_hash(b))\n c == d\n end", "def equivalent_edges?(e, f)\n e.raw_data == f.raw_data\n end", "def test_renormalize\n a = \"<foo></foo>\"\n b = \"<foo></foo><bar></bar>\"\n \n assert_equal(\"<foo/>\", XML.renormalize(a), \"XML#renormalize should work\")\n assert_equal(\"<foo/>\", XML.renormalize_sequence(a), \"XML#renormalize_sequence should work\")\n assert_equal(\"<foo/><bar/>\", XML.renormalize_sequence(b), \"XML#renormalize_sequence should work\")\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Simple equivalence test for REXML
def equivalent_rexml(other) begin require 'active_support' require 'active_support/core_ext' rescue LoadError # string equivalence end if Hash.respond_to?(:from_xml) Hash.from_xml("<root>#{self}</root>") == Hash.from_xml("<root>#{other}</root>") else # Poor mans equivalent value == other.value end end
[ "def xml_cmp a, b\n a = REXML::Document.new(a.to_s)\n b = REXML::Document.new(b.to_s)\n\n normalized = Class.new(REXML::Formatters::Pretty) do\n def write_text(node, output)\n super(node.to_s.strip, output)\n end\n end\n\n normalized.new(indentation=0,ie_hack=false).write(node=a, a_normalized='')\n normalized.new(indentation=0,ie_hack=false).write(node=b, b_normalized='')\n\n a_normalized == b_normalized\n end", "def xml_should_eql(actual, expected)\n same = xml_cmp(actual, expected)\n actual.should.== expected unless same \nend", "def xml_compare a, b\n a = REXML::Document.new(a.to_s)\n b = REXML::Document.new(b.to_s)\n\n normalized = Class.new(REXML::Formatters::Pretty) do\n def write_text(node, output)\n super(node.to_s.strip, output)\n end\n end\n\n normalized.new(indentation=0,ie_hack=false).write(node=a, a_normalized='')\n normalized.new(indentation=0,ie_hack=false).write(node=b, b_normalized='')\n\n a_normalized == b_normalized\n end", "def xml_should_be_same(expected, actual)\n expected = Hpricot(expected)\n actual = Hpricot(actual)\n \n blame = \"\\n\\n#################### expected\\n#{expected.to_html}\\n\\n\" \"#################### actual:\\n#{actual.to_html}\\n\\n\" \n (xml_cmp(expected, actual)).should.blaming(blame).equal true\nend", "def test_match\n # two nodes with same name\n node1 = XML::Node.new( 'nexml' )\n node2 = XML::Node.new( 'nexml' )\n\n # same attributes\n node1.attributes = { :version => '0.9', :generator => 'bioruby' }\n node2.attributes = { :generator => 'bioruby', :version => '0.9' }\n\n # childe nodes for node1\n child11 = XML::Node.new( 'otus' )\n child12 = XML::Node.new( 'otus' )\n child11.attributes = { :id => 'taxa1', :label => 'Taxa 1' }\n child12.attributes = { :id => 'taxa2', :label => 'Taxa 2' }\n\n # childe nodes for node2\n child21 = XML::Node.new( 'otus' )\n child22 = XML::Node.new( 'otus' )\n child21.attributes = { :id => 'taxa1', :label => 'Taxa 1' }\n child22.attributes = { :id => 'taxa2', :label => 'Taxa 2' }\n\n # same children\n node1 << child11\n node1 << child12\n node2 << child22\n node2 << child21\n\n assert match?( node1, node2 )\n end", "def == other\n return false if other.class != self.class \n return false if @__xmlele - other.__xmlele == []\n return false if @__xmlattr != other.__xmlattr\n return true\n end", "def equivalent_nokogiri(other)\n if defined?(::EquivalentXml)\n EquivalentXml.equivalent?(object, other.object)\n else\n equivalent_rexml(other)\n end\n end", "def assert_equivalent_xml(expected, actual)\n expected_xml = Nokogiri::XML(\"<test-xml>\\n#{expected}\\n</test-xml>\")\n actual_xml = Nokogiri::XML(\"<test-xml>\\n#{actual}\\n</test-xml>\")\n ignored_attributes = %w(style data-disable-with)\n\n equivalent = EquivalentXml.equivalent?(expected_xml, actual_xml, {\n ignore_attr_values: ignored_attributes\n }) do |a, b, result|\n if result === false && b.is_a?(Nokogiri::XML::Element)\n if b.attr('name') == 'utf8'\n # Handle wrapped utf8 hidden field for Rails 4.2+\n result = EquivalentXml.equivalent?(a.child, b)\n end\n if b.delete('data-disable-with')\n # Remove data-disable-with for Rails 5+\n # Workaround because ignoring in EquivalentXml doesn't work\n result = EquivalentXml.equivalent?(a, b)\n end\n if a.attr('type') == 'datetime' && b.attr('type') == 'datetime-local'\n a.delete('type')\n b.delete('type')\n # Handle new datetime type for Rails 5+\n result = EquivalentXml.equivalent?(a, b)\n end\n end\n result\n end\n\n assert equivalent, lambda {\n # using a lambda because diffing is expensive\n Diffy::Diff.new(\n sort_attributes(expected_xml.root),\n sort_attributes(actual_xml.root)\n ).to_s(:color)\n }\n end", "def equivalent_nodes(node_1, node_2)\n EquivalentXml.equivalent?(node_1,\n node_2,\n element_order: false,\n normalize_whitespace: true,\n ignore_attr_values: ['version', 'xmlns', 'xmlns:xsi', 'schemaLocation'])\n end", "def assert_xml_equal(expected, actual)\n expected_xml = Nokogiri::XML(\"<test-xml>\\n#{expected}\\n</test-xml>\", &:noblanks)\n actual_xml = Nokogiri::XML(\"<test-xml>\\n#{actual}\\n</test-xml>\", &:noblanks)\n\n equivalent = EquivalentXml.equivalent?(expected_xml, actual_xml)\n assert equivalent, -> {\n # using a lambda because diffing is expensive\n Diffy::Diff.new(\n sort_attributes(expected_xml.root).to_xml(indent: 2),\n sort_attributes(actual_xml.root).to_xml(indent: 2)\n ).to_s\n }\n end", "def ns_semantic_equivalent_xml?(noko_a, noko_b)\n noko_a = noko_a.root if noko_a.kind_of?(Nokogiri::XML::Document)\n noko_b = noko_b.root if noko_b.kind_of?(Nokogiri::XML::Document)\n\n noko_a.name == noko_b.name &&\n noko_a.namespace&.prefix == noko_b.namespace&.prefix &&\n noko_a.namespace&.href == noko_b.namespace&.href &&\n noko_a.attributes == noko_b.attributes &&\n noko_a.children.length == noko_b.children.length &&\n noko_a.children.each_with_index.all? do |a_child, index|\n ns_semantic_equivalent_xml?(a_child, noko_b.children[index])\n end\n end", "def ==(other)\n if other.class == self.class\n xml.to_s == other.xml.to_s\n else\n super\n end\n end", "def test_renormalize\n a = \"<foo></foo>\"\n b = \"<foo></foo><bar></bar>\"\n \n assert_equal(\"<foo/>\", XML.renormalize(a), \"XML#renormalize should work\")\n assert_equal(\"<foo/>\", XML.renormalize_sequence(a), \"XML#renormalize_sequence should work\")\n assert_equal(\"<foo/><bar/>\", XML.renormalize_sequence(b), \"XML#renormalize_sequence should work\")\n end", "def test_in_different_access\n doc = Document.new <<-EOL\n <?xml version='1.0' encoding='ISO-8859-1'?>\n <a a=\"\\xFF\">\\xFF</a>\n EOL\n expect = \"\\303\\277\"\n expect.force_encoding(::Encoding::UTF_8)\n assert_equal( expect, doc.elements['a'].attributes['a'] )\n assert_equal( expect, doc.elements['a'].text )\n end", "def test_get_xml_for\n order_1 = orders(:santa_next_christmas_order)\n\n # Order with a blank shipping type, just to cover a comparison in the method.\n order_2 = orders(:an_order_ordered_paid_shipped)\n order_2.order_shipping_type = nil\n \n # Test the XML.\n require 'rexml/document'\n \n xml = REXML::Document.new(Order.get_xml_for([order_1, order_2]))\n assert xml.root.name, \"orders\"\n\n # TODO: For some elements the name don't correspond with the content.\n # This can be tested a little more.\n end", "def xml_get_has_xml( xml ); nil end", "def be_well_formed_xml\n Matchers::XmlChecker.new\n end", "def xmlliteral?; encoding == Encoding.xmlliteral; end", "def dom_equal?(one, two)\n dom_one = HTML::Document.new(one.to_s).root\n dom_two = HTML::Document.new(two.to_s).root\n ActionController::Assertions::DomAssertions.strip_whitespace!(dom_one.children)\n ActionController::Assertions::DomAssertions.strip_whitespace!(dom_two.children)\n\n dom_one == dom_two\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Affiche en console la liste des instances
def show_list clear puts "= LISTE DES INSTANCES #{name} =".bleu puts "\n\n" len_delim = defined?(LIST_ENTETE) ? LIST_ENTETE.length + 2 : 80 delim = ("-"*len_delim).bleu if defined?(LIST_ENTETE) puts delim puts LIST_ENTETE end puts delim all.each do |inst| puts " #{inst.to_console}" end puts delim puts "\n\n" end
[ "def print_instances_details(only_running=true)\n @groups.values.each_with_index do |instances, i|\n instances.each do |instance|\n if only_running and (not instance.ready?)\n next\n end\n puts sprintf \"%02d: %-20s %-20s %-20s %-20s %-25s %-20s (%s) (%s) (%s)\",\n i, (instance.tags[\"Name\"] || \"\").green,instance.private_dns_name ,instance.id.red, instance.flavor_id.cyan,\n instance.dns_name.blue, instance.availability_zone.magenta, (instance.tags[\"role\"] || \"\").yellow,\n (instance.tags[\"group\"] || \"\").yellow, (instance.tags[\"app\"] || \"\").green\n end\n end\n end", "def instances\n all_instances.sort_by(&:first).map(&:last)\n end", "def instances\n Egi::Fedcloud::Vmhound::Log.info \"[#{self.class}] Retrieving active instances\"\n fetch_instances\n end", "def command_showAll\n entries = @log.get_entries()\n entries.each { |i|\n puts i.to_s\n }\n end", "def active_instances\n Egi::Fedcloud::Vmhound::Log.info \"[#{self.class}] Retrieving running instances\"\n []\n end", "def list_of_instances(keypair = Application.keypair)\n get_instances_description.select {|a| a[:keypair] == keypair}\n end", "def list_course_instances\n CourseInstance.find_each do |course_instance|\n puts \" [%03d] % 15s % 4s-%d % 15s\" % [ course_instance.id, course_instance.abstract_course.code, course_instance.period.symbol, course_instance.length, course_instance.period.name(@locale) ]\n end\n end", "def instances(type)\n @instances[type]\n end", "def list_of_instances(keyp=nil)\n tmp_key = (keyp ? keyp : keypair).to_s\n unless @describe_instances\n tmpInstanceList = describe_instances.select {|a| a if tmp_key ? a[:keypair] == tmp_key : true }\n has_master = !tmpInstanceList.select {|a| a[:name] == \"master\" }.empty? \n if has_master\n @describe_instances = tmpInstanceList\n else\n @id = 0\n running = select_from_instances_on_status(/running/, tmpInstanceList)\n pending = select_from_instances_on_status(/pending/, tmpInstanceList)\n terminated = select_from_instances_on_status(/shutting/, tmpInstanceList)\n \n running = running.map do |inst|\n inst[:name] = (@id == 0 ? \"master\" : \"node#{@id}\")\n @id += 1\n inst\n end.sort_by {|a| a[:index] }\n \n @describe_instances = [running, pending, terminated].flatten\n end\n end\n @describe_instances\n end", "def get_instances\n\t\t\t@cluster.getInstances()\n\t\tend", "def aws_dump_instances( fout = $stdout )\n fout.puts '['\n rows = @aws_instances.sort { |p,n| p[:name] <=> n[:name] }\n rows.each_with_index do |row, i|\n fout.puts( \" \" + JSON.generate( row, :space => ' ', :object_nl => ' ' ) +\n ( ( i == ( rows.length - 1 ) ) ? '' : ',' ) )\n end\n fout.puts ']'\n end", "def active_instances\n Egi::Fedcloud::Vmhound::Log.info \"[#{self.class}] Retrieving running instances\"\n fetch_instances ['ACTIVE']\n end", "def displayClients\n puts @clients.map { |cur| \"#{cur.name}\"}.join(', ')\n return\n end", "def list\n all.each { |device| puts(device.pretty_name) }\n end", "def list_pokemon\n puts \"\"\n puts \"See below for the list of the original Pokemon!\"\n puts \"\"\n @pokemon_objects.each.with_index(1) do |a, i|\n puts \"#{i}. #{a.name}\"\n end\n puts \"\"\n end", "def list_instances(an_array)\n SystemRepository.__list_instances(an_array)\n end", "def get_docker_instance_list(options)\n message = \"Information:\\tListing docker images\"\n command = \"docker ps\"\n output = execute_command(options,message,command)\n instances = output.split(/\\n/)\n return instances\nend", "def instances_status\n @instances.each do |i_id, meta|\n status = AWS::CLI_Interface.ec2_instance_status(i_id)\n output = \"#{meta['name']} (#{i_id})\".colorize(color: :white, background: :blue) +\n \" : \".colorize(:yellow) +\n \"#{status[:label]}\".colorize(color: :white, background: status[:color])\n\n if meta.has_key? 'timeout'\n output += \" : \".colorize(:yellow)\n output += \"Timeout: #{meta['timeout']}\".colorize(color: :black, background: :light_yellow)\n end\n\n Logging.log output\n end\n end", "def list_of_instances(keyp=nil)\n tmp_key = (keyp ? keyp : nil)\n \n unless @describe_instances\n tmpInstanceList = remote_base.describe_instances(options).select {|a| a if (tmp_key.nil? || tmp_key.empty? ? true : a[:keypair] == tmp_key) }\n has_master = !tmpInstanceList.select {|a| a[:name] == \"master\" }.empty? \n if has_master\n @describe_instances = tmpInstanceList\n else\n @id = 0\n running = select_from_instances_on_status(/running/, tmpInstanceList)\n pending = select_from_instances_on_status(/pending/, tmpInstanceList)\n terminated = select_from_instances_on_status(/shutting/, tmpInstanceList)\n \n running = running.map do |inst|\n inst[:name] = (@id == 0 ? \"master\" : \"node#{@id}\")\n @id += 1\n inst\n end.sort_by {|a| a[:index] }\n \n @describe_instances = [running, pending, terminated].flatten\n end\n end\n @describe_instances\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /fhir_base_urls GET /fhir_base_urls.json
def index @fhir_base_urls = FhirBaseUrl.all respond_to do |format| format.html # index.html.erb format.json { render json: @fhir_base_urls } end end
[ "def base_urls\n return @base_urls\n end", "def base_urls=(value)\n @base_urls = value\n end", "def base_url\n return url\n end", "def base_url_path; end", "def base_uri(endpoint)\n \"https://www.bloc.io/api/v1/#{endpoint}\"\n end", "def base_url\n @base_url ||= File.join(JsonApiServer.configuration.base_url, request.path)\n end", "def base_url\n @base_url || value('base_url')\n end", "def new\n @fhir_base_url = FhirBaseUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fhir_base_url }\n end\n end", "def full_urls(input)\n expand_urls(strip_baseurls(input), site_url)\n end", "def base_uri\n ary = contents_uri.to_s.split(\"/\")\n ary.pop if ary[-1].blank?\n ary.pop\n ary.join(\"/\") + \"/\"\n end", "def api_all_url\n \"#{self.name.split(\"::\").last.downcase}\"\n end", "def crowdflower_base\n uri = URI.parse(domain_base)\n \"#{uri.host.gsub(\"api.\", \"\")}\"\n end", "def base_url\n BASE_URL.dup % [\"%s\", \"%s\", @api_key, \"%s\"] \n end", "def raplet_base_url\n \"#{request.scheme}://#{request.host}:#{request.port}\"\n end", "def generate_base_urls \n set_scheme\n if(ENV['ENVIRONMENT']=='sandbox')\n @base_url = @sandbox + @bbc_domain \n @static_base_url = @static_sandbox + @bbc_domain\n elsif (ENV['ENVIRONMENT']=='live' && ENV['WWW_LIVE']=='false')\n @base_url = @www_prefix.chop + @bbc_domain\n @static_base_url = @static_prefix.chop + @bbci_domain\n @open_base_url = @open_prefix.chop + @bbc_domain\n elsif (ENV['ENVIRONMENT'].split('.')[0].include? 'pal') #address specific box\n @base_url = \"#{scheme}://#{ENV['ENVIRONMENT']}\" \n else\n @base_url = @www_prefix + ENV['ENVIRONMENT'] + @bbc_domain\n @static_base_url = @static_prefix + ENV['ENVIRONMENT'] + @bbci_domain\n @static_base_url = @static_prefix.chop + @bbci_domain if ENV['ENVIRONMENT'] == 'live'\n @open_base_url = @open_prefix + ENV['ENVIRONMENT'] + @bbc_domain\n end\n proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] \n @proxy_host = proxy.scan(/http:\\/\\/(.*):80/).to_s if proxy\n end", "def resource_base_uri\n @resource ||= \"#{Hyperloop::Resource::ClientDrivers.opts[:resource_api_base_path]}/#{self.to_s.underscore.pluralize}\"\n end", "def show\n @base_url = BaseUrl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @base_url }\n end\n end", "def base_url\n @base_url || DEFAULT_BASE_URL\n end", "def GetBaseSearchURL\n @base_url\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /fhir_base_urls/new GET /fhir_base_urls/new.json
def new @fhir_base_url = FhirBaseUrl.new respond_to do |format| format.html # new.html.erb format.json { render json: @fhir_base_url } end end
[ "def new\n @base_url = BaseUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @base_url }\n end\n\n end", "def create\n @fhir_base_url = FhirBaseUrl.new(params[:fhir_base_url])\n\n respond_to do |format|\n if @fhir_base_url.save\n format.html { redirect_to @fhir_base_url, notice: 'Fhir base url was successfully created.' }\n format.json { render json: @fhir_base_url, status: :created, location: @fhir_base_url }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fhir_base_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @url = Url.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @url }\n end\n end", "def new\n @uri = Uri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @uri }\n end\n end", "def create\n @base_url = BaseUrl.new(params[:base_url])\n\n respond_to do |format|\n if @base_url.save\n format.html { redirect_to @base_url, notice: 'Base url was successfully created.' }\n format.json { render json: @base_url, status: :created, location: @base_url } \n else\n format.html { render action: \"new\" }\n format.json { render json: @base_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @page_title = 'New URL'\n @url = ShortenUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @url }\n end\n end", "def create\n \t@url = Url.build(params[:link],request.base_url) \t\n \trender json: @url.to_json\n end", "def new\n @sampled_url = SampledUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sampled_url }\n end\n end", "def new\n @collected_url = CollectedUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collected_url }\n end\n end", "def new\n @domainurl = Domainurl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @domainurl }\n end\n\n end", "def new\n @basis = Base.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @basis }\n end\n end", "def new\n @starturl = Starturl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @starturl }\n end\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 @url_connector = UrlConnector.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @url_connector }\n end\n end", "def create_api\n\n @url = Url.new(:url => params[:url])\n\n if @url.save\n url_hash = Hash.new\n\n url_hash[:short_url] = root_url.to_s() + \"urls_api/\" + (@url.id).to_s(36)\n url_hash[:url] = @url.url\n\n render :json => url_hash.to_json\n end\n\n end", "def new\n @spider_url = SpiderUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spider_url }\n end\n end", "def new\n @blorescrapurl = Blorescrapurl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @blorescrapurl }\n end\n end", "def new\n @list_url = ListUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list_url }\n end\n end", "def new\n add_breadcrumb 'Your hubs', :hubs_path\n add_breadcrumb 'New hub', new_hub_path\n append_title 'New hub'\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @hub }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /fhir_base_urls POST /fhir_base_urls.json
def create @fhir_base_url = FhirBaseUrl.new(params[:fhir_base_url]) respond_to do |format| if @fhir_base_url.save format.html { redirect_to @fhir_base_url, notice: 'Fhir base url was successfully created.' } format.json { render json: @fhir_base_url, status: :created, location: @fhir_base_url } else format.html { render action: "new" } format.json { render json: @fhir_base_url.errors, status: :unprocessable_entity } end end end
[ "def index\n @fhir_base_urls = FhirBaseUrl.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fhir_base_urls }\n end\n end", "def base_urls=(value)\n @base_urls = value\n end", "def create\n @base_url = BaseUrl.new(params[:base_url])\n\n respond_to do |format|\n if @base_url.save\n format.html { redirect_to @base_url, notice: 'Base url was successfully created.' }\n format.json { render json: @base_url, status: :created, location: @base_url } \n else\n format.html { render action: \"new\" }\n format.json { render json: @base_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @fhir_base_url = FhirBaseUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fhir_base_url }\n end\n end", "def full_urls(input)\n expand_urls(strip_baseurls(input), site_url)\n end", "def post_api_uri(endpoint)\n URI(@api_base_url + endpoint)\n end", "def generate_base_urls \n set_scheme\n if(ENV['ENVIRONMENT']=='sandbox')\n @base_url = @sandbox + @bbc_domain \n @static_base_url = @static_sandbox + @bbc_domain\n elsif (ENV['ENVIRONMENT']=='live' && ENV['WWW_LIVE']=='false')\n @base_url = @www_prefix.chop + @bbc_domain\n @static_base_url = @static_prefix.chop + @bbci_domain\n @open_base_url = @open_prefix.chop + @bbc_domain\n elsif (ENV['ENVIRONMENT'].split('.')[0].include? 'pal') #address specific box\n @base_url = \"#{scheme}://#{ENV['ENVIRONMENT']}\" \n else\n @base_url = @www_prefix + ENV['ENVIRONMENT'] + @bbc_domain\n @static_base_url = @static_prefix + ENV['ENVIRONMENT'] + @bbci_domain\n @static_base_url = @static_prefix.chop + @bbci_domain if ENV['ENVIRONMENT'] == 'live'\n @open_base_url = @open_prefix + ENV['ENVIRONMENT'] + @bbc_domain\n end\n proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] \n @proxy_host = proxy.scan(/http:\\/\\/(.*):80/).to_s if proxy\n end", "def generate_urls\n # strip trailing / from the base URL\n base_url = @options[:base_url].gsub /\\/$/, ''\n \n # set up a hash of URLs\n @urls = {\n :login => base_url.gsub(/^https?:\\/\\/\\w+\\.(.+)$/, 'http://www.\\1') + \"/servlets/Login\",\n :forums => \"#{base_url}/ds/viewForums.do\"\n }\n end", "def base_url\n BASE_URL.dup % [\"%s\", \"%s\", @api_key, \"%s\"] \n end", "def base_url\n @base_url ||= File.join(JsonApiServer.configuration.base_url, request.path)\n end", "def base_url_path; end", "def create_api\n\n @url = Url.new(:url => params[:url])\n\n if @url.save\n url_hash = Hash.new\n\n url_hash[:short_url] = root_url.to_s() + \"urls_api/\" + (@url.id).to_s(36)\n url_hash[:url] = @url.url\n\n render :json => url_hash.to_json\n end\n\n end", "def base_urls\n return @base_urls\n end", "def base_uri(endpoint)\n \"https://www.bloc.io/api/v1/#{endpoint}\"\n end", "def new\n @base_url = BaseUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @base_url }\n end\n\n end", "def api_base_url=(url)\n version = Apipie.configuration.default_version\n @api_base_url[version] = url\n end", "def generate_base_urls \n if(ENV['ENVIRONMENT']=='sandbox')\n @base_url = SANDBOX + BBC_DOMAIN \n @static_base_url = STATIC_SANDBOX + BBC_DOMAIN\n elsif (ENV['ENVIRONMENT']=='live' && ENV['WWW_LIVE']=='false')\n @base_url = WWW_PREFIX + BBC_DOMAIN\n @static_base_url = STATIC_PREFIX + BBC_DOMAIN\n @open_base_url = OPEN_PREFIX + BBC_DOMAIN\n elsif (ENV['ENVIRONMENT'].split('.')[0].include? 'pal') #address specific box\n @base_url = \"#{scheme}://#{ENV['ENVIRONMENT']}\" \n else\n @base_url = WWW_PREFIX + ENV['ENVIRONMENT'] + BBC_DOMAIN\n @static_base_url = STATIC_PREFIX + ENV['ENVIRONMENT'] + BBC_DOMAIN\n @open_base_url = OPEN_PREFIX + ENV['ENVIRONMENT'] + BBC_DOMAIN\n end\n end", "def create\n \t@url = Url.build(params[:link],request.base_url) \t\n \trender json: @url.to_json\n end", "def generate_base_uri request, set=nil\n b_uri= uri request.env['REQUEST_URI'].to_s[0..-request.env['PATH_INFO'].length]\n @base_uri = b_uri if set\n b_uri\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /fhir_base_urls/1 PUT /fhir_base_urls/1.json
def update @fhir_base_url = FhirBaseUrl.find(params[:id]) respond_to do |format| if @fhir_base_url.update_attributes(params[:fhir_base_url]) format.html { redirect_to @fhir_base_url, notice: 'Fhir base url was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @fhir_base_url.errors, status: :unprocessable_entity } end end end
[ "def update\n @base_url = BaseUrl.find(params[:id])\n\n respond_to do |format|\n if @base_url.update_attributes(params[:base_url])\n format.html { redirect_to @base_url, notice: 'Base url was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @base_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fhir_base_url = FhirBaseUrl.new(params[:fhir_base_url])\n\n respond_to do |format|\n if @fhir_base_url.save\n format.html { redirect_to @fhir_base_url, notice: 'Fhir base url was successfully created.' }\n format.json { render json: @fhir_base_url, status: :created, location: @fhir_base_url }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fhir_base_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def base=(new_base)\n @base = Addressable::URI.parse(new_base)\n self.resources.each do |resource|\n resource.base = @base\n end\n self.methods.each do |method|\n method.base = @base\n end\n end", "def base_urls=(value)\n @base_urls = value\n end", "def set_uri(base, path)\n @uri = \"#{base}/#{path}/#{self.identifier}\"\n end", "def rewrite_iiif_base_uri(info_original)\n parsed_json = JSON.parse(info_original)\n public_base_uri = \"#{ENV['IIIF_SERVER_URL']}#{trailing_slash_fix}#{identifier}\"\n parsed_json[\"@id\"] = public_base_uri\n JSON.generate(parsed_json)\n end", "def api_url=(url)\n if !url =~ URI::regexp\n raise 'Please set a valid api base url'\n end\n\n @api_url = Base.rstrip(url, '/') + '/'\n end", "def api_base_url=(url)\n version = Apipie.configuration.default_version\n @api_base_url[version] = url\n end", "def index\n @fhir_base_urls = FhirBaseUrl.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fhir_base_urls }\n end\n end", "def hyperlink_base=(v); end", "def base_url=(url)\n @base_url = url\n end", "def favorite\n url = Addressable::URI.new(\n scheme: 'http',\n host: 'localhost',\n port: 3000,\n path: '/contacts/2/favorite'\n ).to_s\n\n puts RestClient.patch(\n url,{}\n )\nend", "def base_url=(val)\n @base_url = val\n end", "def drop_url_version\n \n # Convert api_base to URI\n url = URI(APP_CONFIG['api_base'])\n \n # Start building back the new url with scheme and host\n new_url = url.scheme + \"://\" + url.host\n \n # Check if there is a port, if so add it\n if url.port\n new_url += \":\" + url.port.to_s\n end\n \n # Split the parts from the url. The first part will be blank since url.path starts with a slash\n # Skip that one, and if it is the last part, then don't add it as it will be the version.\n url_path_parts = url.path.split(\"/\")\n url_path_parts.each do |part|\n if part == url_path_parts.first\n next\n end\n if !(part == url_path_parts.last)\n new_url += \"/\" + part\n end\n end\n \n # return the new url\n new_url\n end", "def schema_base_url=(base_url)\n @schema_base_url = base_url\n end", "def new\n @fhir_base_url = FhirBaseUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fhir_base_url }\n end\n end", "def update\n update_object(@scheme, schemes_url, scheme_params)\n end", "def create\n @base_url = BaseUrl.new(params[:base_url])\n\n respond_to do |format|\n if @base_url.save\n format.html { redirect_to @base_url, notice: 'Base url was successfully created.' }\n format.json { render json: @base_url, status: :created, location: @base_url } \n else\n format.html { render action: \"new\" }\n format.json { render json: @base_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def base_file_url=(new_base_url)\n @base_file_url = base_for(new_base_url)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /fhir_base_urls/1 DELETE /fhir_base_urls/1.json
def destroy begin @fhir_base_url = FhirBaseUrl.find(params[:id]) @fhir_base_url.destroy rescue ActiveRecord::DeleteRestrictionError flash[:"alert-danger"] = "Could not delete the URL because there are resources assigned to it." redirect_to resources_path return end respond_to do |format| format.html { redirect_to fhir_base_urls_url } format.json { head :no_content } end end
[ "def destroy\n @base_url = BaseUrl.find(params[:id])\n @base_url.destroy\n\n respond_to do |format|\n format.html { redirect_to base_urls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @basis = Base.find(params[:id])\n @basis.destroy\n\n respond_to do |format|\n format.html { redirect_to bases_url }\n format.json { head :no_content }\n end\n end", "def destroy_intent(base_path)\n delete_json(intent_url(base_path))\n rescue GdsApi::HTTPNotFound => e\n e\n end", "def delete_endpoint\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @blorescrapurl = Blorescrapurl.find(params[:id])\n @blorescrapurl.destroy\n\n respond_to do |format|\n format.html { redirect_to blorescrapurls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sampled_url = SampledUrl.find(params[:id])\n @sampled_url.destroy\n\n respond_to do |format|\n format.html { redirect_to sampled_urls_url }\n format.json { head :no_content }\n end\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def delete_content(base_path)\n request_url = \"#{base_url}/content?link=#{base_path}\"\n delete_json(request_url)\n end", "def destroy\n\t\tarray_of_short_urls = params[:id].split(\",\")\n\t\t@urls = UrlGenerator.where(encoded_url:array_of_short_urls)\n\t\tif @urls.empty?\n\t\t\trender json:{error:\"not found\"}\n\t\telse\n\t\t\t@urls.destroy_all\n\t\t\trender json:{notice:\"successfully destroyed\"}\n\t\tend\n\tend", "def destroy\n @shortenedurl.destroy\n respond_to do |format|\n format.html { redirect_to shortenedurls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @baseline.destroy\n respond_to do |format|\n format.html { redirect_to baselines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_base_graph.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_base_graphs_url, notice: 'Base graph was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n\n head :no_content\n end", "def destroy\n @api_v1_sample.destroy\n head :no_content\n end", "def webhelper_delete_all_apps (username, password, base_url = @base_url)\r\n private_resource = RestClient::Resource.new base_url + \"/api/v1/apps\" , {:user => username , :password => password , :timeout => 30}\r\n response = private_resource.get :accept => :json\r\n json = JSON.parse(response)\r\n json['apps'].each do |i|\r\n url = base_url + i['link']\r\n private_resource = RestClient::Resource.new url , {:user => username , :password => password , :timeout => 30}\r\n response = private_resource.delete \r\n puts response.to_str\r\n end\r\n end", "def destroy\n @uriy.destroy\n respond_to do |format|\n format.html { redirect_to uriys_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @base_version.destroy\n respond_to do |format|\n format.html { redirect_to base_versions_url, notice: 'Base version was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_short_url\n\t\turl_id = get_id_from_short_url params[:short_url]\n\t\turl = Url.find(url_id)\n\t\tcurrent_page_url = \"/urls/show_short_urls\"\n\n\t\turl.destroy\n respond_to do |format|\n format.html { redirect_to current_page_url, notice: 'url is successfully Deleted.' }\n format.json { head :no_content }\n end\n\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /reports GET /reports.xml
def index @reports = Report.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @reports } end end
[ "def index\n @daily_reports = DailyReport.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @daily_reports }\n end\n end", "def reports\n collection(\"reports\")\n end", "def index\n @reports = report_model.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @weekly_reports }\n end\n end", "def index\n @custom_reports = CustomReport.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @custom_reports }\n end\n end", "def report(id)\n get(\"reports/#{id}\")\n end", "def index\n @fields_reports = FieldsReport.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @fields_reports }\n end\n end", "def index\n @incident_reports = IncidentReport.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @incident_reports }\n end\n end", "def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end", "def index\n @report_links = ReportLink.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @report_links }\n end\n end", "def show\n @user_reports = UserReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_reports }\n end\n end", "def get_report(id) path = \"/api/v2/reports/#{id}\"\n get(path, {}, AvaTax::VERSION) end", "def index\n @reports = Report.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end", "def index\n # need to find a list of available core reports\n report_ids = ReportManager.instance.reports.keys\n @reports = report_ids.collect {|r| [ReportManager.instance.reports.fetch(r)[:name], r]} \n end", "def index\n @report_templates = ReportTemplate.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @report_templates }\n end\n end", "def show\n @dailyreport = Dailyreport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @dailyreport }\n end\n end", "def index\n @reporte_accidentes = ReporteAccidente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reporte_accidentes }\n end\n end", "def get_report_list\n res=api_call('GetReportList')[:data]\n end", "def reports\r\n ReportsController.instance\r\n end", "def my_reports\n @reports ||= Report.user(current_user).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /reports/1 PUT /reports/1.xml
def update @report = Report.find(params[:id]) respond_to do |format| if @report.update_attributes(params[:report]) format.html { redirect_to(@report, :notice => 'Report was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @report.errors, :status => :unprocessable_entity } end end end
[ "def update\n @report_request = ReportRequest.find(params[:id])\n\n @report_request.update_attributes(params[:report_request])\n \n respond_to do |format|\n format.html # update.html.erb\n if @report_request.errors.empty?\n format.xml { head :ok }\n else\n format.xml { render :xml => @report_request.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_report_template(args = {}) \n put(\"/reports.json/template/#{args[:templateId]}\", args)\nend", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post opts.fetch(:path, update_path), opts\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update(report, options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n body[:report] = report\n\n response = @client.put \"/api/topics/#{@topic_id}/reports/#{@id}\", body, options\n\n return response\n end", "def update\n @report = Mg::Report.find(params[:id])\n\n respond_to do |format|\n if @report.update_attributes(params[:report])\n format.html { redirect_to(@report, :notice => 'Mg::Report was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @api_v1_report = Api::V1::Report.find(params[:id])\n\n if @api_v1_report.user_id == @current_user.id && @api_v1_report.update(api_v1_report_params)\n head :no_content\n else\n render json: @api_v1_report.errors, status: :unprocessable_entity\n end\n end", "def update\n @incident_report = IncidentReport.find(params[:id])\n\n respond_to do |format|\n if @incident_report.update_attributes(params[:incident_report])\n format.html { redirect_to(@incident_report, :notice => 'Incident report was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @incident_report.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @api_report = Report.find(params[:id])\n if @api_report.update(params[:api_report])\n render json: @api_report, status: :success\n else\n render json: @api_report.errors, status: :unprocessable_entity\n end\n end", "def update\n @endtime = Time.now\n begin\n # Submit the half-finished object via a post request\n response = Inventory.request[\"reports/#{@id}\"].put self.to_json, :content_type => :json, :accept => :json\n report = JSON.parse(response)\n rescue => exception\n puts exception.message\n puts exception.response\n exit 1\n end\n end", "def update\n @fleet = Fleet.find(params[:fleet_id])\n @report = Report.find(params[:id])\n\n respond_to do |format|\n if @report.update_attributes(params[:report])\n format.html { redirect_to(@report, :notice => 'Report was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @user_reports = UserReport.find(params[:id])\n\n respond_to do |format|\n if @user_reports.update_attributes(params[:user_report])\n flash[:notice] = 'UserReport was successfully updated.'\n format.html { redirect_to(@user_reports) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_reports.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @stores_report = Stores::Report.find(params[:id])\n\n respond_to do |format|\n if @stores_report.update_attributes(params[:stores_report])\n format.html { redirect_to @stores_report, notice: 'Report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stores_report.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @reports_task = ReportsTask.find(params[:id])\n\n if @reports_task.update(params[:reports_task])\n head :no_content\n else\n render json: @reports_task.errors, status: :unprocessable_entity\n end\n end", "def update\n @custom_report = CustomReport.find(params[:id])\n\n respond_to do |format|\n if @custom_report.update_attributes(params[:custom_report])\n flash[:notice] = 'Custom Report was successfully updated.'\n format.html { \n if request.xhr?\n render :text => \"Success\"\n else\n redirect_to(@custom_report)\n end\n }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @custom_report.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @custom_report = CustomReport.find(params[:id])\n\n if @custom_report.update(params[:custom_report])\n head :no_content\n else\n render json: @custom_report.errors, status: :unprocessable_entity\n end\n end", "def update\n @report2 = Report2.find(params[:id])\n\n respond_to do |format|\n if @report2.update_attributes(params[:report2])\n format.html { redirect_to(@report2, :notice => 'Report2 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @report2.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @users_report = UsersReport.find(params[:id])\n\n if @users_report.update(params[:users_report])\n head :no_content\n else\n render json: @users_report.errors, status: :unprocessable_entity\n end\n end", "def update\r\n @test_report = TestReport.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @test_report.update_attributes(params[:test_report])\r\n format.html { redirect_to @test_report, notice: 'Test report was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @test_report.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return if a dataset with provided name exists
def dataset?(name) datasets.key?(name) end
[ "def data_source_exists?(name)\n query_values(data_source_sql(name), \"SCHEMA\").any? if name.present?\n rescue NotImplementedError\n data_sources.include?(name.to_s)\n end", "def data_source_exists?(name); end", "def data_has? data, name\n data.has_key?(name) || data.has_key?(name.to_s)\n end", "def dataset(name)\n self[name] || connection.create_dataset(name)\n end", "def dataset?(index)\n client.indices.exists?(index: index)\n end", "def data? id\n File.exist? _data_path(id)\n end", "def data_set_exists?\n Pathname.new(header_file_full_path).exist?\n end", "def photoset_exist? name\n @flickr.photosets.getList.each do |x|\n return true if x.title == name\n end\n return false\n end", "def exists? (name:, database: Arango.current_database)\n args = { name: name }\n result = Arango::Requests::Graph::Get.execute(server: database.server, args: args)\n result.graphs.map { |c| c[:name] }.include?(name)\n end", "def exists?(name)\n @inputs.detect { |input| input[:name] == name.to_s }.present?\n end", "def dictionary_exist?(dic_name)\n\t\t@db::Dictionary.where(:title => dic_name).present?\n\tend", "def dataset(name)\n connection[name]\n end", "def name_exists?\n ensure_data_loaded\n return false unless @exist\n unless @data['name'].nil?\n Puppet.debug \"Deployment found: #{@resource[:name]}\"\n return true\n end\n Puppet.debug \"No deployment matching #{@resource[:name]} found.\"\n false\n end", "def task_data_has_name? task_data\n return false unless task_data.key?(:name)\n return false if task_data[:name].empty?\n true\n end", "def exists?\n !data.empty?\n end", "def contains(name)\n database.has_key? name\n end", "def has_package_set?(name)\n each_package_set.find { |set| set.name == name }\n end", "def datacenter_exists?(name)\n filter = Com::Vmware::Vcenter::Datacenter::FilterSpec.new(names: Set.new([name]))\n dc_obj = Com::Vmware::Vcenter::Datacenter.new(vapi_config)\n dc = dc_obj.list(filter)\n\n raise format('Unable to find data center: %s', name) if dc.empty?\n end", "def content_exists?\n File.exist?(datafile_name)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Private: Fail the check if ActiveRecord cannot check migration status
def unsupported mark_failure mark_message "This version of ActiveRecord does not support checking whether migrations are pending" end
[ "def migration_error?\n render :migration_error unless ENV[\"DB_MIGRATE_FAILED\"].blank?\n end", "def migration_error?\n render :migration_error, status: 500 unless ENV[\"DB_MIGRATE_FAILED\"].blank?\n end", "def migrate?\n raise NotImplementedError\n end", "def supports_migrations?\n false\n end", "def integrity_check\n execute( \"PRAGMA integrity_check\" ) do |row|\n raise Exceptions::DatabaseException, row[0] if row[0] != \"ok\"\n end\n end", "def integrity_check\n execute( \"PRAGMA integrity_check\" ) do |row|\n raise DatabaseException, row[0] if row[0] != \"ok\"\n end\n end", "def integrity_check\n execute( \"PRAGMA integrity_check\" ) do |row|\n raise Exception, row[0] if row[0] != \"ok\"\n end\n end", "def supports_migrations?\n true\n end", "def needs_up?\n return true unless migration_info_table_exists?\n migration_record.empty?\n end", "def supports_migrations? #:nodoc:\n true\n end", "def check_database_health\n begin\n db_healthy = ActiveRecord::Migrator.current_version != 0\n status = 200\n rescue StandardError => e\n Rails.logger.error \"Database error: #{e}\"\n db_healthy = false\n status = 503\n end\n [db_healthy, status]\n end", "def not_a_sqitch_db_yet?\n !(@stderr =~ /ERROR: relation \"changes\" does not exist/).nil?\n end", "def skip_migration_creation?\n !migration\n end", "def check_schema_migrations\n schema_migrate = run_cmd(\n \"cd /opt/dell/crowbar_framework/; \" \\\n \"sudo -u crowbar RAILS_ENV=production bin/rake crowbar:schema_migrate_prod\"\n )\n return true if schema_migrate[:exit_code].zero?\n msg = \"There was an error during crowbar schema migrations.\"\n Rails.logger.error msg\n ::Crowbar::UpgradeStatus.new.end_step(\n false,\n services: {\n data: msg,\n help: \"Check the admin server upgrade log /var/log/crowbar/admin-server-upgrade.log \" \\\n \"and /var/log/crowbar/component_install.log for possible hints. \" \\\n \"After fixing the problem, run the crowbar migrations manually and repeat this step.\"\n }\n )\n false\n end", "def migrate!\n _validate_required_configuration\n begin\n resp = @client.describe_table(table_name: @model_class.table_name)\n if _compatible_check(resp)\n nil\n else\n # Gotcha: You need separate migrations for indexes and throughput\n unless _throughput_equal(resp)\n @client.update_table(_update_throughput_opts(resp))\n @client.wait_until(\n :table_exists,\n table_name: @model_class.table_name\n )\n end\n unless _gsi_superset(resp)\n @client.update_table(_update_index_opts(resp))\n @client.wait_until(\n :table_exists,\n table_name: @model_class.table_name\n )\n end\n end\n rescue DynamoDB::Errors::ResourceNotFoundException\n # Code Smell: Exception as control flow.\n # Can I use SDK ability to skip raising an exception for this?\n @client.create_table(_create_table_opts)\n @client.wait_until(:table_exists, table_name: @model_class.table_name)\n end\n # At this stage, we have a table and need to check for after-effects to\n # apply.\n # First up is TTL attribute. Since this migration is not exact match,\n # we will only alter TTL status if we have a TTL attribute defined. We\n # may someday support explicit TTL deletion, but we do not yet do this.\n if @ttl_attribute\n unless _ttl_compatibility_check\n client.update_time_to_live(\n table_name: @model_class.table_name,\n time_to_live_specification: {\n enabled: true,\n attribute_name: @ttl_attribute\n }\n )\n end # Else TTL is compatible and we are done.\n end # Else our work is done.\n end", "def shared_migrations_pending?\n ActiveRecord::Migrator.new(:up,Roomer.shared_migrations_directory)\n end", "def requires_migration?\n (new_fields + new_indices + old_fields + old_indices).any?\n end", "def pending_migrations?\n ROM::SQL.with_gateway(self) {\n migrator.pending?\n }\n end", "def check_schema!\n # The following cases will fail later when this migration attempts\n # to add a foreign key for non-existent columns.\n columns_to_check = [\n [:epics, :parent_id], # Added in GitLab 11.7\n [:geo_event_log, :cache_invalidation_event_id], # Added in GitLab 11.4\n [:vulnerability_feedback, :merge_request_id] # Added in GitLab 11.9\n ].freeze\n\n columns_to_check.each do |table, column|\n check_ee_columns!(table, column)\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Make sure a pitch fits in the key's allowed range.
def check_pitch pitch raise ArgumentError, "pitch is less than pitch range min" if pitch < @pitch_range.min raise ArgumentError, "pitch is more than pitch range max" if pitch > @pitch_range.max end
[ "def validate_private_key_range(private_key)\n value = private_key.to_i(16)\n MIN_PRIV_KEY_MOD_ORDER <= value && value <= MAX_PRIV_KEY_MOD_ORDER\n end", "def include? pitch\n self.old_include?(pitch % 12)\n end", "def key_length_valid?(number)\n number >= 1024 && number & (number - 1) == 0\n end", "def key_length_valid?(number)\n number >= 1024 && ( number & (number - 1) == 0 )\n end", "def calculate_key_from_pitch(pitch)\n KEYS_FOR_PITCHES[pitch % 12]\n end", "def range\n value = read_attr :range\n return unless value\n if value.include?('Hz')\n value\n elsif VALID_PITCHES.include?(value.to_sym)\n value.to_sym\n end\n end", "def valid_key?(key)\n return false unless key.is_a?(String)\n return false unless key = encoded_key(key)\n key.length >= 2 && key.length <= 255 && (key !~ BAD_KEY_RE rescue false)\n end", "def valid_key?(ssn, key)\n return (97 - ssn.delete(' ')[0..12].to_i) % 97 == key.to_i\nend", "def validate_key(key)\n if key.length == key_size || key_sizes.include?(key.length)\n key\n else\n raise(InvalidKeyError, \"Key length #{key.length} is not supported by #{algorithm}.\")\n end\n end", "def pitch_to_ratio(_pitch = nil)\n #This is a stub, used for indexing\nend", "def validate_length(key)\n if key == 'text'\n instance_variable_get(\"@#{key}\").size.between?(1, 120)\n else\n instance_variable_get(\"@#{key}\").size.between?(6, 16)\n end\n end", "def in_range?(key)\n (key>=range_start) && (range_end==LAST_POSSIBLE_KEY || key < range_end)\n end", "def valid?\n (@suffixes.empty? || hash.end_with?('0' * @strength)) && @time < Time.now\n end", "def random lower, upper\n 50.times do\n pitch = (rand(upper - lower) + lower)\n return pitch if self.include? pitch\n end\n end", "def in_key_bounds?(key, x, y)\n bounds = @keys[key]\n x += @params[:xoffset]\n y += @params[:yoffset]\n x >= bounds[:left] - @params[:hmargin] / 2 &&\n x <= bounds[:right] + @params[:hmargin] / 2 &&\n y >= bounds[:top] - @params[:vmargin] / 2 &&\n y <= bounds[:bottom] + @params[:vmargin] / 2\n end", "def eql?(pitch)\n (self <=> pitch) == 0\n end", "def ratio_to_pitch(_ratio = nil)\n #This is a stub, used for indexing\nend", "def valid_key?(key)\n @allowed_keys.nil? || @allowed_keys.include?(key)\n end", "def build_pitch\n if @original_pitch\n self.pitch = @original_pitch.to_i(@pattern)\n @key = calculate_key_from_pitch(@pitch)\n @octave = calculate_octave_from_pitch(@pitch)\n @accidental = calculate_accidental_from_pitch(@pitch)\n else\n @key = @original_key.upcase\n @octave = (@original_octave && @original_octave.to_i) || 5\n @accidental = @original_accidental.downcase if @original_accidental\n self.pitch = calculate_pitch_from_key_octave_and_accidental(@key, @octave, @accidental)\n end\n @pitch\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /datasets/1 GET /datasets/1.xml GET /dataset/1.eml
def show @dataset = Dataset.find(params[:id]) @title = @dataset.title @roles = @dataset.roles respond_to do |format| format.html # show.rhtml format.eml { render :xml => @dataset.to_eml } format.xml { render :xml => @dataset.to_xml } end end
[ "def index\n @datasets = Dataset.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @datasets }\n end\n end", "def show\n @dataset = Dataset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @dataset }\n end\n end", "def show\n @dataset = Dataset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @dataset }\n end\n end", "def get_dataset\n @dataset = Dataset.find_by(id: params.require(:id))\n if @dataset.nil?\n error = \"No dataset with the specified id exists.\"\n respond_to do |format|\n format.json {render json: {success: false, error: error}}\n format.html do\n render file: \"#{Rails.root}/public/404.html\" , status: 404\n end\n end\n end\n end", "def index\n @datasets = Dataset.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @datasets }\n end\n end", "def show\n @dataset = Dataset.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dataset }\n end\n end", "def show\n @dataset = Dataset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dataset }\n end\n end", "def get_data_set(data_set_id)\n _get(\"/d2l/api/lp/#{$lp_ver}/dataExport/list/#{data_set_id}\")\n # returns a DataSetData JSON block\nend", "def set_datasets\n @datasets = @site.get_datasets\n end", "def index\n @dataset = Dataset.find( params[:dataset_id] )\n @dataset_header_props = @dataset.get_dataset_header_props\n end", "def index\n @fmr_datasets = FmrDataset.all\n end", "def index\n @page_title = \"Data Sets\"\n @data_sets = DataSet.all\n add_crumb(\"Admin\", '/admin')\n add_crumb(\"Data Sets\")\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @data_sets }\n end\n end", "def index\n @dataset_data = DatasetDatum.all\n end", "def dataset( ds_name )\n data_service.dataset( ds_name.to_s )\n end", "def new\n @dataset = Dataset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @dataset }\n end\n end", "def datasets\n metadata[:datasets].map{ |name| dataset(name) }\n end", "def datasets\n @datasets || []\n end", "def download\n @data = HeyDan::Helper.get_data_from_url(HeyDan.cdn + '/' + dataset_file_name)\n end", "def index\n @qdatasets = Qdataset.all\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /datasets/1 PUT /datasets/1.xml
def update @dataset = Dataset.find(params[:id]) respond_to do |format| if @dataset.update_attributes(params[:dataset]) flash[:notice] = 'Dataset was successfully updated.' format.html { redirect_to dataset_url(@dataset) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @dataset.errors.to_xml } end end end
[ "def update\n\t\t@dataset = VOID::Dataset.find(params[:id])\n\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n flash[:notice] = 'Dataset was successfully updated.'\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @dataset.errors, :status => :unprocessable_entity }\n end\n end\n\t\n end", "def update\n @dataset = Dataset.find(params[:id])\n\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n flash[:notice] = 'Dataset was successfully updated.'\n format.html { redirect_to(@dataset) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @dataset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @dataset = Dataset.find(params[:id])\n\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n format.html { redirect_to(@dataset, :notice => 'Dataset was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @dataset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @dataset = Dataset.find(params[:id])\n\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n format.html { redirect_to @dataset, notice: 'Dataset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n format.html { redirect_to @dataset, notice: 'Dataset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @image_dataset = ImageDataset.find(params[:id])\n\n respond_to do |format|\n if @image_dataset.update_attributes(params[:image_dataset])\n flash[:notice] = 'ImageDataset was successfully updated.'\n format.html { redirect_to(@image_dataset) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @image_dataset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put_datastream(pid, dsID, xml)\n uri = URI.parse(@fedora + '/objects/' + pid + '/datastreams/' + dsID ) \n RestClient.put(uri.to_s, xml, :content_type => \"application/xml\")\n rescue => e\n e.response \n end", "def update\n @page_title = \"Data Sets\"\n @data_set = DataSet.find(params[:id])\n\n respond_to do |format|\n if @data_set.update_attributes(params[:data_set])\n flash[:notice] = 'DataSet was successfully updated.'\n format.html { redirect_to(@data_set) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @data_set.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n do_patch { return } # check if patch and do submission and return early if it is a patch (submission)\n # otherwise this is a PUT of the dataset metadata\n check_status { return } # check it's in progress, clone a submitted or raise an error\n respond_to do |format|\n format.json do\n dp = if @resource\n DatasetParser.new(hash: params['dataset'], id: @resource.identifier, user: @user) # update dataset\n else\n DatasetParser.new(hash: params['dataset'], user: @user, id_string: params[:id]) # upsert dataset with identifier\n end\n @stash_identifier = dp.parse\n ds = Dataset.new(identifier: @stash_identifier.to_s) # sets up display objects\n render json: ds.metadata, status: 200\n end\n end\n end", "def 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 = DatasetParser.new(hash: params['dataset'], id: @resource.identifier, user: @user)\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 @data_set = DataSet.find(params[:id])\n\n respond_to do |format|\n if @data_set.update_attributes(params[:data_set])\n format.html { redirect_to @data_set, notice: 'Data set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @data_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @label_data_set = LabelDataSet.find(params[:id])\n\n respond_to do |format|\n if @label_data_set.update_attributes(params[:label_data_set])\n format.html { redirect_to(@label_data_set, :notice => 'Label data set was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @label_data_set.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\t\t@data_set = DataSet.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @data_set.update_attributes(params[:data_set])\n\t\t\t\tformat.html { redirect_to @data_set, notice: 'Data set was successfully updated.' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @data_set.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def set_dataset\n # TODO\n #@dataset = DatasetService.get_dataset\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post opts.fetch(:path, update_path), opts\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n end\n end", "def test_put_existing\n request = Http::Request.new('PUT', '/file1', {}, 'bar')\n\n response = self.request(request)\n\n assert_equal(204, response.status)\n\n assert_equal(\n 'bar',\n @server.tree.node_for_path('file1').get\n )\n\n assert_equal(\n {\n 'X-Sabre-Version' => [Version::VERSION],\n 'Content-Length' => ['0'],\n 'ETag' => [\"\\\"#{Digest::MD5.hexdigest('bar')}\\\"\"]\n },\n response.headers\n )\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /dairies GET /dairies.json
def index @dairies = Dairy.all end
[ "def index\n @dices = Dice.all\n render json: @dices\n end", "def index\n @dices = Dice.all\n\n render json: @dices\n end", "def index\n @dairies = Dairy.all\n end", "def index\n @dioceses = Diocese.all\n\n render json: @dioceses\n end", "def index\n @my_dairies = MyDairy.all\n end", "def show\n render json: @dice\n end", "def index\n @dances = current_user.dances\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dances }\n end\n end", "def index\n @dossiers = Dossier.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dossiers }\n end\n end", "def all\n dishes = Dish.all\n render json: dishes\n end", "def index\n @carbon_dioxides = CarbonDioxide.all\n render json: @carbon_dioxides\n end", "def index\n @dashes = Dash.all.where(user_id: current_user)\n render json: @dashes\n end", "def show\n @kf_diary = Kf::Diary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_diary }\n end\n end", "def show\n @diary = Diary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @diary }\n end\n end", "def index\n @api_dishes = Dish.all\n end", "def show\n @daily_diet = DailyDiet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daily_diet }\n end\n end", "def show\n @riesgo = Riesgo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @riesgo }\n end\n end", "def show\n @diary = current_user.diaries.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @diary }\n end\n end", "def index\n\t\t@dishes = Dish.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @dishes }\n\t\tend\n\tend", "def index\n @riesgos = Riesgo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @riesgos }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Clean the changed paths and return only valid PHPUnit tests files.
def clean(paths) paths.uniq! paths.compact! populate_test_files paths = paths.select { |p| test_file?(p) } clear_tests_files_list paths end
[ "def clean_tests\n puts \"Removing generated tests from '#{Settings[:test_dir]}'...\"\n Dir.foreach(Settings[:test_dir]) do |dir|\n path = Pathname.new(Settings[:test_dir]) + dir\n next if dir == '.' or dir == '..' or dir == 'support' or not path.directory?\n FileUtils.rm_rf(path)\n end\nend", "def remove_old_tests\n remove_dir('test')\n remove_dir('spec')\n end", "def clean_genFiles\n module_names = Dir[\"**/*.fun\"].map{|mn| mn.chomp(\".fun\")}\n tbCancelled = module_names.map{|mn| mn+\"_fun.\"} + [\"TestRunner.\"]\n tbCancelled = tbCancelled.map{|tbc| [tbc+\"f90\",tbc+\"o\",tbc+\"MOD\"]}.flatten\n tbCancelled += Dir[\"**/TestRunner\"]\n tbCancelled += Dir[\"**/makeTestRunner\"]\n tbCancelled = (tbCancelled+tbCancelled.map{|tbc| tbc.downcase}).uniq\n FileUtils.rm_f(tbCancelled)\n end", "def filter_by_changed_paths\n base_sha = capture([\"git\", \"merge-base\", \"HEAD\", \"main\"]).strip\n changed_paths = capture([\"git\", \"--no-pager\", \"diff\", \"--name-only\", \"HEAD\", base_sha]).split(\"\\n\")\n puts \"Changed paths:\", :bold\n changed_paths.each { |changed_path| puts changed_path }\n infra_dirs = [\"spec/\", \".kokoro/\", \".toys/\"]\n if changed_paths.any? { |changed_path| infra_dirs.any? { |dir| changed_path.start_with? dir } }\n # Spanner takes a long time, so omit it when testing infrastructure changes\n @products.delete \"spanner\"\n puts \"Test drivers may have changed; running all tests except spanner.\", :bold\n return\n end\n puts \"Filtering tests based on what has changed...\", :bold\n @products.select! do |product_dir|\n keep = changed_paths.any? { |changed_path| changed_path.start_with? \"#{product_dir}/\" }\n if keep\n puts \"Keeping #{product_dir}\"\n else\n puts \"Omitting #{product_dir}\"\n end\n keep\n end\nend", "def get_unit_test_files\n path = $yml_cfg['compiler']['unit_tests_path'] + 'test_*' + C_EXTENSION\n path.gsub!(/\\\\/, '/')\n FileList.new(path)\n end", "def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)\r\n FileList[source_pattern].map do |path|\r\n if File.mtime(path) > touched_since\r\n tests = []\r\n source_dir = File.dirname(path).split(\"/\")\r\n source_file = File.basename(path, '.rb')\r\n\r\n # Support subdirs in app/models and app/controllers\r\n modified_test_path = source_dir.length > 2 ? \"#{test_path}/\" << source_dir[1..source_dir.length].join('/') : test_path\r\n\r\n # For modified files in app/ run the tests for it. ex. /test/functional/account_controller.rb\r\n test = \"#{modified_test_path}/#{source_file}_test.rb\"\r\n tests.push test if File.exist?(test)\r\n\r\n # For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb\r\n test = \"#{modified_test_path}/#{File.basename(path, '.rb').sub(\"_controller\",\"\")}\"\r\n FileList[\"#{test}/*_test.rb\"].each { |f| tests.push f } if File.exist?(test)\r\n\r\n return tests\r\n\r\n end\r\n end.flatten.compact\r\nend", "def remove_tests spec\n say \"\\tRemoving tests\" if @verbose\n Dir['{test,spec}'].each do |dir|\n rm_rf dir\n end\n end", "def new_and_modified_test_cases\n @new_and_modified_test_cases ||= changed_files.filter do |file|\n # NOTE: add back if we roll-out source file generation for spec:acceptance\n # next true if file.end_with? '.feature'\n\n next true if file.end_with? '_spec.rb'\n\n false\n end\n end", "def functionals_changed(test_changed_files, t)\n changed_controllers = []\n changed_functional_tests = []\n changed_view_directories = Set.new\n test_changed_files.each do |file|\n controller_match = file.match(/app\\/controllers\\/(.*).rb/)\n if controller_match\n changed_controllers << controller_match[1]\n end\n\n view_match = file.match(/app\\/views\\/(.*)\\/.+\\.erb/)\n if view_match\n changed_view_directories << view_match[1]\n end\n\n functional_test_match = file.match(/test\\/functional\\/(.*).rb/)\n if functional_test_match\n changed_functional_tests << functional_test_match[1]\n end\n end\n\n test_files = FileList['test/functional/**/*_test.rb'].select{|file| changed_controllers.any?{|controller| file.match(/test\\/functional\\/#{controller}_test.rb/) }} +\n FileList['test/functional/**/*_test.rb'].select{|file| changed_view_directories.any?{|view_directory| file.match(/test\\/functional\\/#{view_directory}_controller_test.rb/) }} +\n FileList['test/functional/**/*_test.rb'].select{|file|\n (changed_functional_tests.any?{|functional_test| file.match(/test\\/functional\\/#{functional_test}.rb/) } ||\n test_changed_files.any?{|changed_file| file==changed_file })\n }\n\n test_files = test_files.uniq\n test_files = test_files.reject{ |f| Smokescreen.critical_tests.include?(f) }\n\n t.libs << \"test\"\n t.verbose = true\n if !test_files.empty?\n t.test_files = test_files\n else\n t.test_files = []\n end\n end", "def clear_test_directory\n files = Dir.glob(File.join(@grader_config.test_root, \"*\"))\n files.delete(@grader_config.checker_filepath)\n FileUtils.rm(files, :force => true)\n end", "def clean_tests\n depends :init\n\n TestRunResults.clean_all(@build_results, ant)\n end", "def units_changed_tests(test_changed_files, t)\n test_changed_files = test_changed_files.split(\"\\n\") if test_changed_files.is_a?(String)\n test_files = FileList['test/unit/*_test.rb'].select{|file| test_changed_files.any?{|changed_file| file==changed_file }}\n test_files = test_files.uniq\n\n t.libs << \"test\"\n t.verbose = true\n if !test_files.empty?\n t.test_files = test_files\n else\n t.test_files = []\n end\n end", "def recheck\n depends :init, :compile\n\n if config_source['testrun'].nil?\n latest_record = TestRunRecord.latest_record(@build_results.build_dir, @module_set)\n descrip = \"The latest test run\"\n else\n latest_record = named_testrun_record(config_source['testrun'])\n descrip = \"The specified test run\"\n end\n\n failed_test_classnames = latest_record.failed_test_classnames\n\n puts \"\"\n if failed_test_classnames.empty?\n puts \"%s, in '%s', passed. There is nothing to recheck.\" % [ descrip, latest_record.directory_description ]\n else\n puts \"%s, in '%s', failed %d tests. Re-running the following tests:\" % [ descrip, latest_record.directory_description, failed_test_classnames.length ]\n\n patterns = [ ]\n failed_test_classnames.each do |classname|\n puts \" %s\" % classname\n components = classname.split(/\\./)\n patterns << FilePath.new(*components).to_s\n end\n\n puts \"\"\n\n run_tests(FixedPatternSetTestSet.new(config_source, @module_groups, patterns))\n end\n end", "def excluded_test_files\n [\"ignore_spec.rb\", \"bad_test.rb\"].collect { |x| \"#{$test_dir}/x\" }\nend", "def clear_changed_files\n @changed_files.clear\n end", "def clean()\n\t\tDir.chdir @project_directory \n\t\tDir.entries('.').each do \n\t\t\t|item|\n\t\t\tif item != \".\" and item !=\"..\"\n\t\t\t\tFileUtils.rm_rf(item)\n\t\t\tend\n\t\tend\n\tend", "def clean_templates\n Dir.glob(@project.build_path.join('**/*.php')).each do |path|\n clean_template(path)\n end\n end", "def cleanup_temp_files!\n Dir[\"#{File.dirname(__FILE__)}/../../tmp/spec.*tmp\"].each do |file|\n File.unlink(file)\n end\n end", "def remove_all_diffs_and_tests\n UiChanged::Screenshot.remove_all_diffs_and_tests\n head :ok\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the paths is a valid test file.
def test_file?(path) @tests_files.include?(path) end
[ "def check_valid_paths(paths)\n\t\t\t\n\t\t\tpaths.each { |p|\n\t\t\t\tif p =~ /\\s/\n\t\t\t\t\n\t\t\t\t\tTextMate::HTMLOutput.show(:title => \"FCSH Path Error\", :sub_title => \"\" ) do |io|\n\n\t\t\t\t\t\tio << \"<h2>FCSH Path Error</h2>\"\n\t\t\t\t\t\tio << \"<p>Warning fsch cannot handle paths containing a space.\"\n\t\t\t\t\t\tio << \" \"\n\t\t\t\t\t\tio << \"/path_to/app.mxml works\"\n\t\t\t\t\t\tio << \"/path to/app.mxml fails as there is a space between path and to\"\n\t\t\t\t\t\tio << \" \"\n\t\t\t\t\t\tio << \"The path that caused the problem was\"\n\t\t\t\t\t\tio << \" \"\n\t\t\t\t\t\tio << \"#{p}\"\n\t\t\t\t\t\tio << \" \"\n\t\t\t\t\t\tio << \"See bundle help for more information.\"\t\t\n\t\t\t\t\t\tio << \"</p>\"\n\n\t\t\t\t\tend\n\t\t\t\t\n\t\t\t\tend\n\t\t\t}\n\t\t\t\n\t\tend", "def assert_valid_file(path)\n\t\tif !File.file?(path)\n\t\t\traise InvalidPath, \"'#{path}' is not a valid file.\"\n\t\tend\n\tend", "def check_valid_paths(paths)\n\n paths.each { |p|\n if p =~ /\\s/\n\n TextMate::HTMLOutput.show(:title => \"FCSH Path Error\", :sub_title => \"\" ) do |io|\n\n io << \"<h2>FCSH Path Error</h2>\"\n io << \"<p>Warning fsch cannot handle paths containing a space.\"\n io << \" \"\n io << \"/path_to/app.mxml works\"\n io << \"/path to/app.mxml fails as there is a space between path and to\"\n io << \" \"\n io << \"The path that caused the problem was\"\n io << \" \"\n io << \"#{p}\"\n io << \" \"\n io << \"See bundle help for more information.\"\n io << \"</p>\"\n\n end\n\n end\n }\n\n end", "def validate_paths(paths)\n normalize_paths paths\n nil\nend", "def valid?\n File.exist?(path) && File.readable?(path)\n end", "def valid_path path\n path and File.exists? path\n end", "def check_file_presence\n spec.icons.values.each do |path|\n fail_if_not_exist \"Icon\", path\n end\n\n if spec.browser_action\n fail_if_not_exist \"Browser action popup\", spec.browser_action.popup\n fail_if_not_exist \"Browser action icon\", spec.browser_action.icon\n end\n\n if spec.page_action\n fail_if_not_exist \"Page action popup\", spec.page_action.popup\n fail_if_not_exist \"Page action icon\", spec.page_action.icon\n end\n\n if spec.packaged_app\n fail_if_not_exist \"App launch page\", spec.packaged_app.page\n end\n\n spec.content_scripts.each do |content_script|\n content_script.javascripts.each do |script_path|\n fail_if_not_exist \"Content script javascript\", script_path\n end\n content_script.stylesheets.each do |style_path|\n fail_if_not_exist \"Content script style\", style_path\n end\n end\n\n spec.background_scripts.each do |script_path|\n fail_if_not_exist \"Background script style\", script_path\n end\n\n fail_if_not_exist \"Background page\", spec.background_page\n fail_if_not_exist \"Options page\", spec.options_page\n\n spec.web_intents.each do |web_intent|\n fail_if_not_exist \"Web intent href\", web_intent.href\n end\n\n spec.nacl_modules.each do |nacl_module|\n fail_if_not_exist \"NaCl module\", nacl_module.path\n end\n\n spec.web_accessible_resources.each do |path|\n fail_if_not_exist \"Web accessible resource\", path\n end\n end", "def check_paths paths\n exist_count = paths.inject(0){|cnt, path| cnt += 1 if exists?(path); cnt}\n raise \"Indeterminate output state\" if (exist_count > 0) && (exist_count < paths.size)\n return true if exist_count == 0\n false\n end", "def test_file?(filename)\n @test_files.include?(filename)\n end", "def has_tests?\n FileList[test_pattern].any?\n end", "def file_correct?(file_path)\n raise 'ERROR: Is your file path correct ?' unless File.exist?(file_path)\n end", "def check_exists files\n files = [files].flatten\n rtn = true\n files.each do |file|\n if !file or !File.exists?(file)\n log \"# Error: file not found:#{file}.\"\n rtn = false unless @options[:test]\n end\n end\n rtn\n end", "def valid?\n File.exist?(source_filepath)\n end", "def valid?\n return false unless @paths.count > 1\n @paths.each do |p|\n return false unless p.valid?\n end\n true\n end", "def check_file?(path)\n Actions.check_file path\n rescue FileError\n false\n else true\n end", "def validate_file_path\n base_path = ::File.realpath(self.class.temp_dir)\n @path = ::File.realpath(params.permit(:file)[:file], base_path)\n unless @path.start_with?(base_path)\n raise ViewComponent::SystemTestControllerNefariousPathError\n end\n end", "def error_check(paths)\r\n e = check_files(paths)\r\n Message::Error.no_files(e) unless e.empty? && file_order.any?\r\n\r\n file_order.map! { |f| File.absolute_path(f) }\r\n\r\n e = check_extnames\r\n self.ext ||= \"\"\r\n Message::Warning.ext_warn(e, ext) unless e.empty?\r\n end", "def validate_paths!\n ensure_clean_build_path!\n ensure_existing_target_path!\n end", "def compares_files?\n preprocessed_expected.is_a? Pathname\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A constructor that requires both the IP address of the machine to communicate with as well as the secret (string) needed to perform communication. AppControllers will reject SOAP calls if this secret (basically a password) is not present it can be found in the user's .appscale directory, and a helper method is usually present to fetch this for us.
def initialize(ip, secret) @ip = ip @secret = secret @conn = SOAP::RPC::Driver.new("https://#{@ip}:17443") @conn.add_method("set_parameters", "djinn_locations", "database_credentials", "app_names", "secret") @conn.add_method("set_apps", "app_names", "secret") @conn.add_method("set_apps_to_restart", "apps_to_restart", "secret") @conn.add_method("status", "secret") @conn.add_method("get_stats", "secret") @conn.add_method("update", "app_names", "secret") @conn.add_method("stop_app", "app_name", "secret") @conn.add_method("get_all_public_ips", "secret") @conn.add_method("is_done_loading", "secret") @conn.add_method("is_done_initializing", "secret") @conn.add_method("add_role", "new_role", "secret") @conn.add_method("remove_role", "old_role", "secret") @conn.add_method("get_queues_in_use", "secret") @conn.add_method("add_appserver_to_haproxy", "app_id", "ip", "port", "secret") @conn.add_method("remove_appserver_from_haproxy", "app_id", "ip", "port", "secret") @conn.add_method("add_appserver_process", "app_id", "secret") @conn.add_method("remove_appserver_process", "app_id", "port", "secret") end
[ "def initialize(ip, secret)\n @ip = ip\n @secret = secret\n \n @conn = SOAP::RPC::Driver.new(\"https://#{@ip}:#{SERVER_PORT}\")\n @conn.add_method(\"start_job\", \"jobs\", \"secret\")\n @conn.add_method(\"put_input\", \"job_data\", \"secret\")\n @conn.add_method(\"get_output\", \"job_data\", \"secret\")\n @conn.add_method(\"get_acl\", \"job_data\", \"secret\")\n @conn.add_method(\"set_acl\", \"job_data\", \"secret\")\n @conn.add_method(\"compile_code\", \"job_data\", \"secret\")\n @conn.add_method(\"get_supported_babel_engines\", \"job_data\", \"secret\")\n @conn.add_method(\"does_file_exist\", \"file\", \"job_data\", \"secret\")\n @conn.add_method(\"get_profiling_info\", \"key\", \"secret\")\n end", "def initialize(params)\n @ip_address = params[:ip_address]\n @port = params[:port]\n @keystone = params[:keystone]\n end", "def initialize(name, ip, url_endpoint)\n @name = name\n @ip = ip\n @url = \"http://#{ip}/#{url_endpoint}\"\n @username = \"\"\n @password = \"\"\n end", "def initialize(host = nil, port = DEFAULT_PORT, user = nil, secret = nil)\n if host\n connect(host, port)\n authenticate(user, secret) if user and secret\n end\n end", "def initialize(appid=nil, secret=nil, securityalgorithm=nil)\n self.appid = appid if appid\n self.secret = secret if secret\n self.securityalgorithm = securityalgorithm if securityalgorithm\n end", "def initialize(controller: nil, name: nil, ip_addr: nil,\n port_number: nil, admin_name: nil, admin_password: nil,\n tcp_only: false)\n super(controller: controller, name: name)\n raise ArgumentError, \"IP Address (ip_addr) required\" unless ip_addr\n raise ArgumentError, \"Port Number (port_number) required\" unless port_number\n raise ArgumentError, \"Admin Username (admin_name) required\" unless admin_name\n raise ArgumentError, \"Admin Password (admin_password) required\" unless admin_password\n \n @ip = ip_addr\n @port = port_number\n @username = admin_name\n @password = admin_password\n @tcp_only = tcp_only\n end", "def initialize(env: nil, client_id: nil, secret: nil)\n env && self.env = env\n self.client_id = client_id\n self.secret = secret\n end", "def initialize(secret = '', base64: false)\n raise 'Secret can\\'t be nil' if secret.nil?\n @secret = secret\n @base64 = base64\n end", "def initialize(key, secret, options = {})\n @key = key\n @secret = secret\n if options[:redirect_uri] \n @redirect_uri = options[:redirect_uri] \n end\n if options[:services]\n @services = options[:services] \n end\n if options[:auth_server_url]\n @auth_server_url = options[:auth_server_url]\n end\n end", "def initialize(address, port, token)\n throw \"bad vault address\" if nil==address\n throw \"bad vault port\" if nil==port\n throw \"bad vault token\" if nil==token\n @url = \"http://#{address}:#{port}/v1/\"\n @token = token\n @all_repos_path = 'secret/all_repos_path_storage_hash'\n @online = false\n end", "def initialize(connexion:, token:, secret:)\n @connexion = connexion\n @token = token\n @secret = secret\n end", "def initialize(api_key, secret, method=nil)\n @api_key = api_key\n @secret = secret\n @method = method\n end", "def initialize(params)\n @ip_address = params[:ip_address]\n @port = params[:port]\n @user_name = params[:user_name]\n @password = params[:password]\n @tenant_name = params[:tenant_name]\n @tenant_id = get_tenant_id(tenant_name)\n end", "def initialize(app_key, username, password)\n @app_key = app_key\n @username = username\n @password = password\n end", "def initialize(app_key = nil, opts = {})\n api_server = opts[:api_server] || 'api.empiredata.co'\n\n @app_key = app_key\n @enduser = opts[:enduser]\n @session_key = nil\n\n @http_client = HTTPClient.new\n\n protocol = api_server.start_with?('localhost') ? 'http' : 'https'\n @base_url = \"#{protocol}://#{api_server}/empire/\"\n\n @service_secrets = nil\n if opts[:secrets_yaml]\n @service_secrets = YAML.load_file opts[:secrets_yaml]\n end\n end", "def initialize(config = {})\n @host = extract_value(config, :host)\n @service_owner_api_key = extract_value(config, :service_owner_api_key)\n @service_owner_api_secret = extract_value(config, :service_owner_api_secret)\n @service_api_key = extract_value(config, :service_api_key)\n @service_api_secret = extract_value(config, :service_api_secret)\n end", "def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})\n init({ :name => 'EC2',\n :default_host => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).host : DEFAULT_HOST,\n :default_port => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).port : DEFAULT_PORT,\n :default_service => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).path : DEFAULT_PATH,\n :default_protocol => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).scheme : DEFAULT_PROTOCOL,\n :default_api_version => @@api },\n aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'] , \n aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],\n params)\n end", "def initialize(secret, *_signature_key_or_options)\n @box = RbNaCl::SimpleBox.from_secret_key(secret)\n end", "def initialize_secret(opts = {})\n secret = if opts[:username] && opts[:password]\n Egi::Fedcloud::Vmhound::Log.debug \"[#{self.class}] Using provided plain credentials\"\n \"#{opts[:username]}:#{opts[:password]}\"\n else\n Egi::Fedcloud::Vmhound::Log.debug \"[#{self.class}] Falling back to file and environment credentials\"\n opts[:auth_file] ? File.read(opts[:auth_file]) : nil\n end\n secret.strip! if secret\n secret\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Provides automatic retry logic for transient SOAP errors. Args: time: A Fixnum that indicates how long the timeout should be set to when executing the caller's block. retry_on_except: A boolean that indicates if nontransient Exceptions should result in the caller's block being retried or not. callr: A String that names the caller's method, used for debugging purposes. Raises: FailedNodeException: if the given block contacted a machine that is either not running or is rejecting connections. SystemExit: If a nontransient Exception was thrown when executing the given block. Returns: The result of the block that was executed, or nil if the timeout was exceeded.
def make_call(time, retry_on_except, callr) refused_count = 0 max = 5 begin Timeout::timeout(time) { yield if block_given? } rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH if refused_count > max raise FailedNodeException.new("Connection was refused. Is the " + "AppController running?") else refused_count += 1 Kernel.sleep(1) retry end rescue Timeout::Error Djinn.log_warn("[#{callr}] SOAP call to #{@ip} timed out") return rescue OpenSSL::SSL::SSLError, NotImplementedError, Errno::EPIPE, Errno::ECONNRESET, SOAP::EmptyResponseError retry rescue Exception => except if retry_on_except retry else trace = except.backtrace.join("\n") HelperFunctions.log_and_crash("[#{callr}] We saw an unexpected error" + " of the type #{except.class} with the following message:\n" + "#{except}, with trace: #{trace}") end end end
[ "def try times = 1, options = {}, &block\n val = yield\n rescue options[:on] || Exception\n retry if (times -= 1) > 0\n else\n val\n end", "def retry_on_transient_error\n (options.retry_count.to_i + 1).times do |n|\n logger.debug \"Attempt ##{n}\"\n begin\n result = yield\n rescue Fog::Compute::AWS::Error => e\n sleep_seconds = options.retry_interval * (n+1)\n logger.warn \"Received AWS error: #{e}\"\n logger.warn \"Sleeping #{sleep_seconds} seconds before retrying\"\n sleep sleep_seconds\n else\n return result\n end\n end\n nil\n end", "def make_call(timeout, retry_on_except, callr)\n result = \"\"\n Djinn.log_debug(\"Calling the AppManager - #{callr}\")\n begin\n Timeout::timeout(timeout) do\n begin\n yield if block_given?\n end\n end\n rescue OpenSSL::SSL::SSLError\n Djinn.log_warn(\"Saw a SSLError when calling #{callr}\" +\n \" - trying again momentarily.\")\n retry\n rescue Errno::ECONNREFUSED => except\n if retry_on_except\n Djinn.log_warn(\"Saw a connection refused when calling #{callr}\" +\n \" - trying again momentarily.\")\n sleep(1)\n retry\n else\n trace = except.backtrace.join(\"\\n\")\n HelperFunctions.log_and_crash(\"We saw an unexpected error of the \" +\n \"type #{except.class} with the following message:\\n#{except}, with\" +\n \" trace: #{trace}\")\n end \n rescue Exception => except\n if except.class == Interrupt\n Djinn.log_fatal(\"Saw an Interrupt exception\")\n HelperFunctions.log_and_crash(\"Saw an Interrupt Exception\")\n end\n\n Djinn.log_error(\"An exception of type #{except.class} was thrown: #{except}.\")\n retry if retry_on_except\n end\n end", "def attempt(times, &block)\n n = times\n result = nil\n begin\n result = block.call(self) unless block.nil?\n rescue Exception => ex\n times -= 1\n retry if times >= 0\n raise ex\n end\n result\n end", "def retry_timeout\n if !block_given?\n return @j_del.java_method(:retryTimeout, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling retry_timeout()\"\n end", "def exponential_retry(method_name, &block)\n @generic_client.retry(method_name, lambda {|first, time_of_failure, attempts| 1}, block)\n end", "def make_call(timeout, retry_on_except, callr)\n result = \"\"\n Djinn.log_debug(\"Calling the TaskQueue Server: #{callr}\")\n begin\n Timeout::timeout(timeout) do\n begin\n yield if block_given?\n end\n end\n rescue Errno::ECONNREFUSED => except\n if retry_on_except\n Djinn.log_warn(\"Saw a connection refused when calling #{callr}\" +\n \" - trying again momentarily.\")\n sleep(1)\n retry\n else\n trace = except.backtrace.join(\"\\n\")\n Djinn.log_warn(\"We saw an unexpected error of the type #{except.class} with the following message:\\n#{except}, with trace: #{trace}\")\n end \n rescue Exception => except\n if except.class == Interrupt\n HelperFunctions.log_and_crash(\"Saw an Interrupt when talking to the\" +\n \" TaskQueue server.\")\n end\n\n Djinn.log_warn(\"An exception of type #{except.class} was thrown: #{except}.\")\n retry if retry_on_except\n end\n end", "def retry_times(times)\r\n begin\r\n begin\r\n result = yield\r\n end while result.nil? && ((times -= 1) > 0)\r\n result\r\n rescue Exception\r\n times -= 1\r\n times > 0 ? retry : raise\r\n end\r\n end", "def retry_execution(retry_message, times = AgentConfig.max_packages_install_retries)\n count = 0\n success = false\n begin\n count += 1\n success = yield\n @audit.append_info(\"\\n#{retry_message}\\n\") unless success || count > times\n end while !success && count <= times\n success\n end", "def visit_retry(node); end", "def with_retry(up_to=DEFAULT_MAX_NETWORK_RETRY, &block)\n up_to = DEFAULT_MAX_NETWORK_RETRY if up_to.nil?\n (1..up_to).each do |attempt|\n delay_seconds = 2**attempt\n begin\n return block.call\n rescue => e\n sleep(delay_seconds)\n\n if attempt == up_to\n # Give up by re-raising the exception\n raise e\n end\n end\n end\n end", "def do_retries\n yield\n rescue @from => e\n raise e unless (@tries -= 1).positive?\n\n sleep (@sleep_duration += 1)**2 if @backoff # rubocop:disable Lint/ParenthesesAsGroupedExpression\n retry\n end", "def retry_exponential_backoff(max_retry: 8, base_time_sec: 1, &block)\n tries = 0\n begin\n tries += 1\n block.call\n\n rescue => err\n @job_log.warn \"Error detected, possibly recoverable (try # #{tries}/#{max_retry}) - #{err.class.name} - #{err}\"\n @job_log.warn \"#{$!}\\n\\t#{err.backtrace.join(\"\\n\\t\")}\"\n if tries <= max_retry\n sleep(base_time_sec * 0.5 * 2**tries)\n retry\n else\n raise err\n end\n end\n end", "def retry_block(n = MAX_NODE_QUERY_RETRIES, &block)\n begin\n block.call\n rescue Selenium::WebDriver::Error::StaleElementReferenceError, Capybara::TimeoutError, Capybara::ElementNotFound, Selenium::WebDriver::Error::UnknownError, Capybara::Driver::Webkit::NodeNotAttachedError\n if (n -= 1) >= 0\n sleep(30 / (n + 1))\n retry\n else\n raise\n end\n end\nend", "def _retryable(a_func, retry_options)\n delay_mult = retry_options.backoff_settings.retry_delay_multiplier\n max_delay = (retry_options.backoff_settings.max_retry_delay_millis /\n MILLIS_PER_SECOND)\n timeout_mult = retry_options.backoff_settings.rpc_timeout_multiplier\n max_timeout = (retry_options.backoff_settings.max_rpc_timeout_millis /\n MILLIS_PER_SECOND)\n total_timeout = (retry_options.backoff_settings.total_timeout_millis /\n MILLIS_PER_SECOND)\n\n proc do |request, **kwargs|\n delay = retry_options.backoff_settings.initial_retry_delay_millis\n timeout = (retry_options.backoff_settings.initial_rpc_timeout_millis /\n MILLIS_PER_SECOND)\n exc = nil\n result = nil\n now = Time.now\n deadline = now + total_timeout\n\n while now < deadline\n begin\n exc = nil\n result = _add_timeout_arg(a_func, timeout).call(request, **kwargs)\n break\n rescue => exception\n if exception.respond_to?(:code) &&\n !retry_options.retry_codes.include?(exception.code)\n raise RetryError.new('Exception occurred in retry method that ' \\\n 'was not classified as transient',\n cause: exception)\n end\n exc = RetryError.new('Retry total timeout exceeded with exception',\n cause: exception)\n sleep(rand(delay) / MILLIS_PER_SECOND)\n now = Time.now\n delay = [delay * delay_mult, max_delay].min\n timeout = [timeout * timeout_mult, max_timeout, deadline - now].min\n end\n end\n raise exc unless exc.nil?\n result\n end\n end", "def retry_execution(retry_message, times=InstanceConfiguration::MAX_PACKAGES_INSTALL_RETRIES)\n count = 0\n success = false\n begin\n count += 1\n success = yield\n @auditor.append_info(\"\\n#{retry_message}\\n\") unless success || count > times \n end while !success && count <= times\n success\n end", "def retry_service(e) # e == rescued error\n\t\t\tif self.tries <= 10\n\t\t\t\tself.tries += 1\n\t\t\t\t# puts \"Connection issues... retrying in 3 seconds\"\n\t\t\t\tsleep(3)\n\t\t\t\tself.call_service\n\t\t\telse\n\t\t\t\tputs \"Backtrace: #{e.backtrace}\"\n\t\t\t\tputs \"BIG TIME ERROR getting: #{self.url}\"\n\t\t\tend\n\t\tend", "def retry_call endpoint\r\n\t \t@retries_left -= 1\r\n\r\n\t \tsleepTime = (50 + rand(950)) / 1000\r\n\t \tsleep(sleepTime)\r\n\r\n\t \tcall(endpoint)\r\n\t end", "def retryable(a_func, retry_options, metadata)\n delay_mult = retry_options.backoff_settings.retry_delay_multiplier\n max_delay = (retry_options.backoff_settings.max_retry_delay_millis /\n MILLIS_PER_SECOND)\n timeout_mult = retry_options.backoff_settings.rpc_timeout_multiplier\n max_timeout = (retry_options.backoff_settings.max_rpc_timeout_millis /\n MILLIS_PER_SECOND)\n total_timeout = (retry_options.backoff_settings.total_timeout_millis /\n MILLIS_PER_SECOND)\n\n proc do |request, block|\n delay = retry_options.backoff_settings.initial_retry_delay_millis\n timeout = (retry_options.backoff_settings.initial_rpc_timeout_millis /\n MILLIS_PER_SECOND)\n deadline = Time.now + total_timeout\n begin\n op = a_func.call(request,\n deadline: Time.now + timeout,\n metadata: metadata,\n return_op: true)\n res = op.execute\n block.call res, op if block\n res\n rescue => exception\n unless exception.respond_to?(:code) &&\n retry_options.retry_codes.include?(exception.code)\n raise RetryError.new('Exception occurred in retry method that ' \\\n 'was not classified as transient')\n end\n sleep(rand(delay) / MILLIS_PER_SECOND)\n now = Time.now\n delay = [delay * delay_mult, max_delay].min\n timeout = [timeout * timeout_mult, max_timeout, deadline - now].min\n if now >= deadline\n raise RetryError.new('Retry total timeout exceeded with exception')\n end\n retry\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tells an AppController that it needs to restart one or more Google App Engine applications. Args: app_names: An Array of Strings, where each String is an appid corresponding to an application that needs to be restarted.
def set_apps_to_restart(app_names) make_call(NO_TIMEOUT, RETRY_ON_FAIL, "set_apps_to_restart") { @conn.set_apps_to_restart(app_names, @secret) } end
[ "def restart_appengine_apps\n # use a copy of @apps_to_restart here since we delete from it in\n # setup_appengine_application\n apps = @apps_to_restart\n apps.each { |app_name|\n if !my_node.is_login? # this node has the new app - don't erase it here\n Djinn.log_info(\"Removing old version of app #{app_name}\")\n Djinn.log_run(\"rm -fv /opt/appscale/apps/#{app_name}.tar.gz\")\n end\n Djinn.log_info(\"About to restart app #{app_name}\")\n APPS_LOCK.synchronize {\n setup_appengine_application(app_name, is_new_app=false)\n }\n }\n end", "def set_apps_to_restart(apps_to_restart, secret)\n if !valid_secret?(secret)\n return BAD_SECRET_MSG\n end\n\n APPS_LOCK.synchronize {\n @apps_to_restart += apps_to_restart\n @apps_to_restart.uniq!\n }\n Djinn.log_debug(\"Apps to restart is now [#{@apps_to_restart.join(', ')}]\")\n\n return \"OK\"\n end", "def app_restart\n return unless restart_required?\n callback(:app_restart) do\n notify(:app_restart)\n heroku.app_restart\n end\n end", "def script name, app_names\n each_app(*app_names) do |server_app|\n server_app.run_script name\n end\n end", "def delete_all_apps\n apps.map { |a| delete_app a['name'] }\n end", "def stopApplications()\n debug(\"Stop all applications\")\n @applications.each_key { |name|\n stopApplication(name)\n }\n end", "def restart_all\n each_broker(&:restart)\n end", "def update_app_list\n # Differentiate between a null app_nids params and no app_nids params\n return unless params[:organization].key?(:app_nids) && (desired_nids = Array(params[:organization][:app_nids]))\n\n existing_apps = @organization.app_instances.active\n\n existing_apps.each do |app_instance|\n desired_nids.delete(app_instance.app.nid) || app_instance.terminate\n end\n\n desired_nids.each do |nid|\n begin\n @organization.app_instances.create(product: nid)\n rescue => e\n Rails.logger.error { \"#{e.message} #{e.backtrace.join(\"\\n\")}\" }\n end\n\n end\n\n # Force reload\n existing_apps.reload\n end", "def startApplications()\n debug(\"Start all applications\")\n @applications.each_key { |name|\n startApplication(name)\n }\n end", "def restart\n (old_services.keys & new_services.keys).select do |s|\n old_services[s] != new_services[s] && new_services[s].on_change == :restart\n end.map { |s| new_services[s] }\n end", "def reset_apps\n # Set default hash value to false, so attempts to uninstall\n # non-existent apps will fail\n @apps = Hash.new(false)\n @apps.merge!(DEFAULT_APPS)\n end", "def restart options=nil\n with_server_apps options,\n :msg => \"Running restart script\",\n :send => :restart\n end", "def describe_applications(application_names=[])\n options = {}\n options.merge!(AWS.indexed_param('ApplicationNames.member.%d', [*application_names]))\n request({\n 'Operation' => 'DescribeApplications',\n :parser => Fog::Parsers::AWS::ElasticBeanstalk::DescribeApplications.new\n }.merge(options))\n end", "def reset_apps\n @apps = Hash.new(false)\n @apps.merge!(DEFAULT_APPS)\n end", "def restart_failed_jobs\n res = Messaging::JobReview.restart_failed_jobs!\n\n flash.now[:notice] = \"Restarted #{res} #{'job'.pluralize(res)}\"\n index\n end", "def delete_apps()\n apps = @client.describe_apps({:stack_id => stack_id})[:apps]\n apps.each do |a|\n @client.delete_app({:app_id => a[:app_id]})\n puts \"App '#{a[:name]}' deleted.\"\n end\n end", "def rename\n newname = shift_argument\n if newname.nil? || newname.empty?\n raise(Heroku::Command::CommandFailed, \"Usage: heroku apps:rename NEWNAME\\nMust specify a new name.\")\n end\n validate_arguments!\n\n action(\"Renaming #{app} to #{newname}\") do\n api.put_app(app, \"name\" => newname)\n end\n\n app_data = api.get_app(newname).body\n hputs([ app_data[\"web_url\"], app_data[\"git_url\"] ].join(\" | \"))\n\n if remotes = git_remotes(Dir.pwd)\n remotes.each do |remote_name, remote_app|\n next if remote_app != app\n git \"remote rm #{remote_name}\"\n git \"remote add #{remote_name} #{app_data[\"git_url\"]}\"\n hputs(\"Git remote #{remote_name} updated\")\n end\n else\n hputs(\"Don't forget to update your Git remotes on any local checkouts.\")\n end\n end", "def remove_apps\n @apps.each do |name, app|\n Camping::Apps.delete(app)\n Object.send :remove_const, name\n end\n end", "def app_instances(name)\n require_login\n raise CloudFoundry::Client::Exception::BadParams, \"Name cannot be blank\" if name.nil? || name.empty?\n get(\"#{CloudFoundry::Client::APPS_PATH}/#{name}/instances\")\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tells an AppController to no longer route HAProxy traffic to the given location. Args: app_id: A String that identifies the application that runs the AppServer to remove. ip: A String that identifies the private IP address where the AppServer to remove runs. port: A Fixnum that identifies the port where the AppServer was running. secret: A String that is used to authenticate the caller.
def remove_appserver_from_haproxy(app_id, ip, port) make_call(NO_TIMEOUT, RETRY_ON_FAIL, "remove_appserver_from_haproxy") { @conn.remove_appserver_from_haproxy(app_id, ip, port, @secret) } end
[ "def remove_appserver_from_haproxy(app_id, ip, port, secret)\n if !valid_secret?(secret)\n return BAD_SECRET_MSG\n end\n\n if !my_node.is_login?\n return NO_HAPROXY_PRESENT\n end\n\n Djinn.log_debug(\"Removing AppServer for app #{app_id} at #{ip}:#{port}\")\n get_scaling_info_for_app(app_id)\n @app_info_map[app_id]['appengine'].delete(\"#{ip}:#{port}\")\n HAProxy.update_app_config(my_node.private_ip, app_id,\n @app_info_map[app_id])\n get_scaling_info_for_app(app_id, update_dashboard=false)\n\n return \"OK\"\n end", "def remove_appserver_process(app_id, port, secret)\n if !valid_secret?(secret)\n return BAD_SECRET_MSG\n end\n\n app = app_id\n @state = \"Stopping an AppServer to free unused resources\"\n Djinn.log_debug(\"Deleting appserver instance to free up unused resources\")\n\n uac = UserAppClient.new(@userappserver_private_ip, @@secret)\n app_manager = AppManagerClient.new(my_node.private_ip)\n warmup_url = \"/\"\n\n my_public = my_node.public_ip\n my_private = my_node.private_ip\n\n app_data = uac.get_app_data(app)\n\n Djinn.log_debug(\"Get app data for #{app} said [#{app_data}]\")\n\n app_is_enabled = uac.does_app_exist?(app)\n Djinn.log_debug(\"is app #{app} enabled? #{app_is_enabled}\")\n if app_is_enabled == \"false\"\n return\n end\n\n if !app_manager.stop_app_instance(app, port)\n Djinn.log_error(\"Unable to stop instance on port #{port} app #{app_name}\")\n end\n\n # Tell the AppController at the login node (which runs HAProxy) that this\n # AppServer isn't running anymore.\n acc = AppControllerClient.new(get_login.private_ip, @@secret)\n acc.remove_appserver_from_haproxy(app, my_node.private_ip, port)\n\n # And tell the AppDashboard that the AppServer has been killed.\n delete_instance_from_dashboard(app, \"#{my_node.private_ip}:#{port}\")\n end", "def unbind_app_url(app, host, domain)\n route = @client.routes.find { |route| route.host == host && route.domain.name == domain }\n app.remove_route(route)\n\n end", "def stop_app(app_name, secret)\n if !valid_secret?(secret)\n return BAD_SECRET_MSG\n end\n\n app_name.gsub!(/[^\\w\\d\\-]/, \"\")\n Djinn.log_info(\"Shutting down app named [#{app_name}]\")\n result = \"\"\n Djinn.log_run(\"rm -rf /var/apps/#{app_name}\")\n \n # app shutdown process can take more than 30 seconds\n # so run it in a new thread to avoid 'execution expired'\n # error messages and have the tools poll it \n Thread.new {\n # Tell other nodes to shutdown this application\n if @app_names.include?(app_name) and !my_node.is_appengine?\n @nodes.each { |node|\n next if node.private_ip == my_node.private_ip\n if node.is_appengine? or node.is_login?\n ip = node.private_ip\n acc = AppControllerClient.new(ip, @@secret)\n\n begin\n result = acc.stop_app(app_name)\n Djinn.log_debug(\"Removing application #{app_name} from #{ip} \" +\n \"returned #{result}\")\n rescue FailedNodeException\n Djinn.log_warn(\"Could not remove application #{app_name} from \" +\n \"#{ip} - moving on to other nodes.\")\n end\n end\n }\n end\n\n # Contact the soap server and remove the application\n if (@app_names.include?(app_name) and !my_node.is_appengine?) or @nodes.length == 1\n ip = HelperFunctions.read_file(\"#{CONFIG_FILE_LOCATION}/masters\")\n uac = UserAppClient.new(ip, @@secret)\n result = uac.delete_app(app_name)\n Djinn.log_debug(\"(stop_app) Delete app: #{ip} returned #{result} (#{result.class})\")\n end\n \n # may need to stop XMPP listener\n if my_node.is_login? \n pid_files = HelperFunctions.shell(\"ls #{CONFIG_FILE_LOCATION}/xmpp-#{app_name}.pid\").split\n unless pid_files.nil? # not an error here - XMPP is optional\n pid_files.each { |pid_file|\n pid = HelperFunctions.read_file(pid_file)\n Djinn.log_run(\"kill -9 #{pid}\")\n }\n\n result = \"true\"\n end\n stop_xmpp_for_app(app_name)\n end\n\n Djinn.log_debug(\"(stop_app) Maybe stopping taskqueue worker\")\n maybe_stop_taskqueue_worker(app_name)\n Djinn.log_debug(\"(stop_app) Done maybe stopping taskqueue worker\")\n\n APPS_LOCK.synchronize {\n if my_node.is_login?\n Nginx.remove_app(app_name)\n Nginx.reload\n HAProxy.remove_app(app_name)\n end\n\n if my_node.is_appengine?\n Djinn.log_debug(\"(stop_app) Calling AppManager for app #{app_name}\")\n app_manager = AppManagerClient.new(my_node.private_ip)\n if !app_manager.stop_app(app_name)\n Djinn.log_error(\"(stop_app) ERROR: Unable to stop app #{app_name}\")\n else\n Djinn.log_info(\"(stop_app) AppManager shut down app #{app_name}\")\n end\n\n ZKInterface.remove_app_entry(app_name, my_node.public_ip)\n end\n\n # If this node has any information about AppServers for this app,\n # clear that information out.\n if !@app_info_map[app_name].nil?\n @app_info_map.delete(app_name)\n end\n\n @apps_loaded = @apps_loaded - [app_name] \n @app_names = @app_names - [app_name]\n\n if @apps_loaded.empty?\n @apps_loaded << \"none\"\n end\n\n if @app_names.empty?\n @app_names << \"none\"\n end\n } # end of lock\n } # end of thread\n\n return \"true\"\n end", "def del_ip(vid, ip_address)\n perform_request(action: 'vserver-delip', vserverid: vid, ipaddr: ip_address)\n end", "def del_ip(vid, ip_address)\n perform_request(:action => 'vserver-delip', :vserverid => vid, :ipaddr => ip_address)\n end", "def unregister_server(id)\n puts \"Removing entry to #{id} from HA configurations\"\n name = 'webserver'\n tempfile = '/tmp/haproxy.cfg'\n server_config = \"server #{name}\"\n \n contents = File.read(File.expand_path(@haproxy_config_file))\n\n open(tempfile, 'w+') do |f|\n contents.each_line do |line|\n f.puts line unless line.match(id)\n end\n end\n FileUtils.mv(tempfile, @haproxy_config_file)\n end", "def remove_ip(ip)\n send_req({a: :nul, key: ip})\n end", "def remove_ip instance, ip\n puts \"Detaching IP from server\"\n instance.disassociate_address(ip.ip)\n end", "def delete_app(app)\n connection.request(\n :method => :delete,\n :path => \"/apps/#{app}\"\n )\n end", "def stop_app_instance(version_key, port)\n uri = URI(\"http://#{@ip}:#{SERVER_PORT}/versions/#{version_key}/#{port}\")\n request = Net::HTTP::Delete.new(uri.path)\n make_call(request, uri)\n end", "def add_appserver_to_haproxy(app_id, ip, port, secret)\n if !valid_secret?(secret)\n return BAD_SECRET_MSG\n end\n\n if !my_node.is_login?\n return NO_HAPROXY_PRESENT\n end\n\n if @app_info_map[app_id].nil? or @app_info_map[app_id]['appengine'].nil?\n return NOT_READY\n end\n\n Djinn.log_debug(\"Adding AppServer for app #{app_id} at #{ip}:#{port}\")\n get_scaling_info_for_app(app_id)\n @app_info_map[app_id]['appengine'] << \"#{ip}:#{port}\"\n HAProxy.update_app_config(my_node.private_ip, app_id,\n @app_info_map[app_id])\n get_scaling_info_for_app(app_id, update_dashboard=false)\n\n return \"OK\"\n end", "def relocate_app(appid, http_port, https_port, secret)\n if !valid_secret?(secret)\n return BAD_SECRET_MSG\n end\n\n Djinn.log_debug(\"@app_info_map is #{@app_info_map.inspect}\")\n http_port = Integer(http_port)\n https_port = Integer(https_port)\n\n # First, only let users relocate apps to ports that the firewall has open\n # for App Engine apps.\n if http_port != 80 and (http_port < 8080 or http_port > 8100)\n return \"Error: HTTP port must be 80, or in the range 8080-8100.\"\n end\n\n if https_port != 443 and (https_port < 4380 or https_port > 4400)\n return \"Error: HTTPS port must be 443, or in the range 4380-4400.\"\n end\n\n # Next, make sure that no other app is using either of these ports for\n # nginx, haproxy, or the AppServer itself.\n @app_info_map.each { |app, info|\n # Of course, it's fine if it's our app on a given port, since we're\n # relocating that app.\n next if app == appid\n\n if [http_port, https_port].include?(info['nginx'])\n return \"Error: Port in use by nginx for app #{app}\"\n end\n\n if [http_port, https_port].include?(info['nginx_https'])\n return \"Error: Port in use by nginx for app #{app}\"\n end\n\n if [http_port, https_port].include?(info['haproxy'])\n return \"Error: Port in use by haproxy for app #{app}\"\n end\n\n # On multinode deployments, the login node doesn't serve App Engine apps,\n # so this may be nil.\n if info['appengine']\n info['appengine'].each { |appserver_port|\n if [http_port, https_port].include?(appserver_port)\n return \"Error: Port in use by AppServer for app #{app}\"\n end\n }\n end\n }\n\n if RESERVED_APPS.include?(appid)\n return \"Error: Can't relocate the #{appid} app.\"\n end\n\n # Next, remove the old port from the UAServer and add the new one.\n my_public = my_node.public_ip\n uac = UserAppClient.new(@userappserver_private_ip, @@secret)\n uac.delete_instance(appid, my_public, @app_info_map[appid]['nginx'])\n uac.add_instance(appid, my_public, http_port)\n\n # Next, rewrite the nginx config file with the new ports\n Djinn.log_info(\"Regenerating nginx config for relocated app #{appid}\")\n @app_info_map[appid]['nginx'] = http_port\n @app_info_map[appid]['nginx_https'] = https_port\n proxy_port = @app_info_map[appid]['haproxy']\n my_private = my_node.private_ip\n login_ip = get_login.private_ip\n\n # Since we've changed what ports the app runs on, we should persist this\n # immediately, instead of waiting for the main thread to do this\n # out-of-band.\n backup_appserver_state\n\n if my_node.is_login?\n static_handlers = HelperFunctions.parse_static_data(appid)\n Nginx.write_fullproxy_app_config(appid, http_port, https_port, my_public,\n my_private, proxy_port, static_handlers, login_ip)\n end\n\n Djinn.log_debug(\"Done writing new nginx config files!\")\n Nginx.reload()\n\n # Same for any cron jobs the user has set up.\n # TODO(cgb): We do this on the login node, but the cron jobs are initially\n # set up on the shadow node. In all supported cases, these are the same\n # node, but there may be an issue if they are on different nodes in\n # the future.\n # TODO(cgb): This doesn't remove the old cron jobs that were accessing the\n # previously used port. This isn't a problem if nothing else runs on that\n # port, or if anything else there.\n CronHelper.update_cron(my_public, http_port,\n @app_info_map[appid]['language'], appid)\n\n # Finally, the AppServer takes in the port to send Task Queue tasks to\n # from a file. Update the file and restart the AppServers so they see\n # the new port. Do this in a separate thread to avoid blocking the caller.\n port_file = \"/etc/appscale/port-#{appid}.txt\"\n HelperFunctions.write_file(port_file, http_port)\n\n Thread.new {\n @nodes.each { |node|\n if node.private_ip != my_node.private_ip\n HelperFunctions.scp_file(port_file, port_file, node.private_ip,\n node.ssh_key)\n end\n next if not node.is_appengine?\n app_manager = AppManagerClient.new(node.private_ip)\n app_manager.restart_app_instances_for_app(appid)\n }\n }\n\n # Once we've relocated the app, we need to tell the XMPPReceiver about the\n # app's new location.\n MonitInterface.restart(\"xmpp-#{appid}\")\n\n return \"OK\"\n end", "def delete_api_app(opts)\n path = '/api_app/' + opts[:client_id]\n delete(path)\n end", "def stop_app(version_key)\n uri = URI(\"http://#{@ip}:#{SERVER_PORT}/versions/#{version_key}\")\n request = Net::HTTP::Delete.new(uri.path)\n make_call(request, uri)\n end", "def unmap_route(app_name, route_host, route_domain)\n if is_app_bound_to_route?(app_name, Route.new(route_host, route_domain))\n #TODO 3: insert command for unmapping the route\n command = \"cf unmap-route #{app_name} -n #{route_host} #{route_domain}\"\n log_message = \"- 3) Unmapping #{app_name} from #{route_host}.#{route_domain}\"\n\n execute_cf_command(command, log_message)\n end\n\n end", "def delete_vapp(vapp_id)\n params = {\n 'method' => :delete,\n 'command' => \"/vApp/vapp-#{vapp_id}\"\n }\n\n _response, headers = send_request(params)\n task_id = URI(headers['Location']).path.gsub('/api/task/', '')\n task_id\n end", "def uninstall!(app_id)\n SimCtl.uninstall_app(self, app_id)\n end", "def delete(uid, ip, port)\n raise \"No UID specified\" if uid == nil\n raise \"No IP specified\" if ip == nil\n raise \"No port specified\" if port == nil\n raise \"Invalid port specified\" unless port.is_a? Integer\n\n target_addr = \"#{ip}:#{port}\"\n\n mapped_proxy_port = find_mapped_proxy_port(uid, ip, port)\n\n # No existing mapping, nothing to do.\n return if mapped_proxy_port == nil\n\n out, err, rc = system_proxy_delete(mapped_proxy_port)\n\n if rc != 0\n raise FrontendProxyServerException.new(\n \"System proxy failed to delete #{mapped_proxy_port} => #{target_addr}(#{rc}): stdout: #{out} stderr: #{err}\", uid)\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
creates a audit log record instance that each method model will use
def initialize_audit_log # only save logs for POST,PUT,PATCH and DELETE methods # creates if (request.post? || request.patch? || request.put? || request.delete? ) @audit_log = AuditLog.new @audit_log.ip = request.remote_ip @audit_log.user_name = current_user.full_name end end
[ "def audit_log\n AuditLog.new(space_id, store_id)\n end", "def build_created_audit(rec, eh)\n build_audit_payload(rec, eh[:new], nil, \"#{rec.class.to_s.downcase}_record_add\", \"Record created\")\n end", "def audit_create\n action_name = get_action_name('create')\n write_audit(action: action_name, audited_changes: audited_attributes, comment: audit_comment,\n user_id: set_user_id, module_name: set_module_name, domain_id: set_domain_id, conversation_id: set_conversation_id, path: audit_path)\n end", "def audit\n data = {\"changes\" => changes, \"metadata\" => audit_metadata}\n Audit::Tracking.log.record(audit_bucket, self.id, data)\n end", "def save_audit_log\n if (@audit_log && @audit_log.auditable)\n if [\"update\",\"destroy\"].include?(action_name)\n update_and_destroy_audit\n elsif action_name == \"create\"\n create_audit\n end \n end\n end", "def log_record\n @log_record ||= get_log_record\n end", "def activity_log_create\n write_activity_log(:create)\n end", "def update_log\n recorded_user = begin\n current_resource_owner&.id || 'N/A'\n rescue ActiveRecord::RecordNotFound\n 'N/A'\n end\n description = controller_name + ' ' + action_name\n params.each do |variable|\n description = description + ' ' + variable.to_s\n end\n AuditLog.create(requester_info: recorded_user, event: 'event', event_time: Time.current.inspect, description: description)\n end", "def after_create(record)\n AuditTrail.create(:action => \"CREATED\" , :element_id => record.slug, :element_class => record.class, :username => record.user.username)\n end", "def history_create\n # history_log('created', created_by_id)\n end", "def audit_trail(context_to_log = nil)\n @transition_auditor ||= StateMachine::AuditTrail::Backend.create_for_transition_class(transition_class, self.owner_class, context_to_log)\n end", "def create_with_audit!(relation, attributes)\n object = relation.create!(attributes)\n audit_create(object)\n object\n end", "def create_with_audit(relation, attributes)\n object = relation.create(attributes)\n audit_create(object) if object.valid?\n object\n end", "def audit_trail_event\n @audit_trail_event_resource ||= AuditTrailEvent.new(@client)\n end", "def create_audit_log(request)\n start.uri('/api/system/audit-log')\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end", "def create_audit_log(request)\n start.uri('/api/system/audit-log')\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end", "def audit_log(action, optional_params = {})\n description = params.slice(:record_id, :section, :id).merge(optional_params).map { |key, value| \"#{key}:#{value}\"}.join('|')\n requester = current_user.try(:email) || 'NONE'\n AuditLog.create(event: action, description: description, requester_info: requester)\n description\n end", "def registration_auditory(method, functionality, ip)\n \tif(!@current_user.nil?)\n \t log = Log.create(user_id: @current_user.id, functionality: functionality, method: method, ip: ip, log_type: 2)\n \telse\n \t log = Log.create(user_id: 0, method: method, functionality: functionality, error: error, ip: ip, log_type: 1)\n \tend\n end", "def audit_class\n Audited::Audit\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
saves the initialzied audit log
def save_audit_log if (@audit_log && @audit_log.auditable) if ["update","destroy"].include?(action_name) update_and_destroy_audit elsif action_name == "create" create_audit end end end
[ "def set_audit_log_data\n @audit_log.auditable = @job if @audit_log\n end", "def save_with_auditing\n with_auditing { save }\n end", "def initialize_audit_log\n # only save logs for POST,PUT,PATCH and DELETE methods\n # creates\n if (request.post? || request.patch? || request.put? || request.delete? )\n @audit_log = AuditLog.new\n @audit_log.ip = request.remote_ip\n @audit_log.user_name = current_user.full_name\n end\n\n end", "def set_audit_log_data\n @audit_log.auditable = @room if @audit_log\n end", "def audit_create\n action_name = get_action_name('create')\n write_audit(action: action_name, audited_changes: audited_attributes, comment: audit_comment,\n user_id: set_user_id, module_name: set_module_name, domain_id: set_domain_id, conversation_id: set_conversation_id, path: audit_path)\n end", "def update_log\n recorded_user = begin\n current_resource_owner&.id || 'N/A'\n rescue ActiveRecord::RecordNotFound\n 'N/A'\n end\n description = controller_name + ' ' + action_name\n params.each do |variable|\n description = description + ' ' + variable.to_s\n end\n AuditLog.create(requester_info: recorded_user, event: 'event', event_time: Time.current.inspect, description: description)\n end", "def audit_update \n unless (changes = audited_changes).empty?\n if valid_model\n action_name = get_action_name\n write_audit(action: action_name, audited_changes: set_update_changes, comment: set_audit_comment,\n username: set_username, user_id: set_user_id, module_name: set_module_name, domain_id: set_domain_id, conversation_id: set_conversation_id, path: audit_path)\n end\n end\n end", "def set_audit_log_data\n @audit_log.auditable = @product_section if @audit_log\n end", "def audit\n data = {\"changes\" => changes, \"metadata\" => audit_metadata}\n Audit::Tracking.log.record(audit_bucket, self.id, data)\n end", "def save_log(description, action, owner_user_id)\n Log.save_log(description, action, owner_user_id, me.id)\n end", "def save_log(description, action, owner_user_id)\n Log.save_log(description, action, owner_user_id, me.id)\n end", "def save_with_audit!(object)\n before, after = changed_attributes(object)\n saved = object.save!\n audit_update(object, before, after)\n saved\n end", "def activity_log_create\n write_activity_log(:create)\n end", "def create_audit_log(request)\n start.uri('/api/system/audit-log')\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end", "def create_audit_log(request)\n start.uri('/api/system/audit-log')\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end", "def touch_when_logging\n self.log_updated_at = Time.zone.now\n save\n end", "def audit\n audit_content([])\n end", "def save\n logdate = @logdate.strftime '%Y-%m-%d'\n\n if log.has_key? logdate\n log[logdate].push @contents\n else\n log[logdate] = [@contents]\n end\n\n Task.write_log log\n end", "def save_with_audit(object)\n before, after = changed_attributes(object)\n saved = object.save\n audit_update(object, before, after) if saved\n saved\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parse locations of chunks Offset: bytes 0 2 Sectors: byte 3 Empty offset, is an empty chunk
def locations @locations ||= bytes(L_BYTES).each_slice(4).map do |loc_bytes| { offset: ByteArray.to_i(loc_bytes[0..2]), sector_count: loc_bytes[3] } end.reject{ |l| l[:offset] == 0 } end
[ "def data_chunk_start_pos\n read_page_header_and_data_chunk_start unless defined? @data_chunk_start\n\n @data_chunk_start\n end", "def get_line_and_column_from_chunk(offset)\n if offset.zero?\n return [@chunk_line, @chunk_column]\n end\n\n string =\n offset >= @chunk.size ? @chunk : @chunk[0..offset-1]\n\n line_count = string.count(\"\\n\")\n\n column = @chunk_column\n if line_count > 0\n lines = string.split(\"\\n\")\n column = lines.empty? ? 0 : lines[-1].size\n else\n column += string.size\n end\n\n [@chunk_line + line_count, column]\n end", "def parse_chunk(string_chunk)\n #This is a stub, used for indexing\n end", "def first_offset\n\t\tOffset.new(@ida, @chunk.startEA)\n\tend", "def read_chunk(chunk)\n puts \"[ESP DEBUG] - Read chunk #{chunk.name}...\" if @debug\n description = nil\n decoded_data = nil\n subchunks = []\n header = chunk.header\n case chunk.name\n when 'TES4'\n # Always read fields of TES4 as they define the masters, which are needed for others\n puts \"[ESP DEBUG] - Read children chunks of #{chunk}\" if @debug\n subchunks = chunk.sub_chunks(sub_chunks_format: {\n '*' => { header_size: 0, size_length: 2 },\n 'ONAM' => {\n data_size_correction: proc do |file|\n # Size of ONAM field is sometimes badly computed. Correct it.\n file.seek(4, IO::SEEK_CUR)\n stored_size = file.read(2).unpack('S').first\n file.read(chunk.size).index('INTV') - stored_size\n end\n }\n })\n chunk_type = :record\n when 'MAST'\n description = chunk.data[0..-2].downcase\n @masters << description\n @master_ids[sprintf('%.2x', @master_ids.size)] = description\n chunk_type = :field\n when 'GRUP'\n puts \"[ESP DEBUG] - Read children chunks of #{chunk}\" if @debug\n subchunks = chunk.sub_chunks(sub_chunks_format: Hash[(['GRUP'] + KNOWN_GRUP_RECORDS_WITHOUT_FIELDS + KNOWN_GRUP_RECORDS_WITH_FIELDS).map do |known_sub_record_name|\n [\n known_sub_record_name,\n {\n header_size: 16,\n data_size_correction: known_sub_record_name == 'GRUP' ? -24 : 0\n }\n ]\n end])\n chunk_type = :group\n when *KNOWN_GRUP_RECORDS_WITHOUT_FIELDS\n # GRUP record having no fields\n form_id_str = sprintf('%.8x', header[4..7].unpack('L').first)\n @form_ids << form_id_str\n description = \"FormID: #{form_id_str}\"\n puts \"[WARNING] - #{chunk} seems to have fields: #{chunk.data.inspect}\" if @warnings && chunk.data[0..3] =~ /^\\w{4}$/\n chunk_type = :record\n when *KNOWN_GRUP_RECORDS_WITH_FIELDS\n # GRUP record having fields\n form_id_str = sprintf('%.8x', header[4..7].unpack('L').first)\n @form_ids << form_id_str\n description = \"FormID: #{form_id_str}\"\n if @decode_fields\n puts \"[ESP DEBUG] - Read children chunks of #{chunk}\" if @debug\n subchunks = chunk.sub_chunks(sub_chunks_format: { '*' => { header_size: 0, size_length: 2 } })\n end\n chunk_type = :record\n when *KNOWN_FIELDS\n # Field\n record_module_name =\n if Data.const_defined?(chunk.parent_chunk.name.to_sym)\n chunk.parent_chunk.name.to_sym\n elsif Data.const_defined?(:All)\n :All\n else\n nil\n end\n unless record_module_name.nil?\n record_module = Data.const_get(record_module_name)\n data_class_name =\n if record_module.const_defined?(\"#{record_module_name}_#{chunk.name}\".to_sym)\n \"#{record_module_name}_#{chunk.name}\".to_sym\n elsif record_module.const_defined?(\"#{record_module_name}_All\".to_sym)\n \"#{record_module_name}_All\".to_sym\n else\n nil\n end\n unless data_class_name.nil?\n data_info = record_module.const_get(data_class_name)\n decoded_data = {}\n data_info.read(chunk.data).each_pair do |property, value|\n decoded_data[property] = value\n end\n end\n end\n chunk_type = :field\n else\n warning_desc = \"Unknown chunk: #{chunk}. Data: #{chunk.data.inspect}\"\n if @ignore_unknown_chunks\n puts \"[WARNING] - #{warning_desc}\" if @warnings\n @unknown_chunks << chunk\n chunk_type = :unknown\n else\n raise warning_desc\n end\n end\n # Decorate the chunk with our info\n esp_info = {\n description: description,\n type: chunk_type\n }\n esp_info[:decoded_data] = decoded_data unless decoded_data.nil?\n unless header.empty?\n header_class_name =\n if Headers.const_defined?(chunk.name.to_sym)\n chunk.name.to_sym\n elsif Headers.const_defined?(:All)\n :All\n else\n nil\n end\n unless header_class_name.nil?\n header_info = Headers.const_get(header_class_name)\n esp_info[:decoded_header] = {}\n header_info.read(header).each_pair do |property, value|\n esp_info[:decoded_header][property] = value\n end\n end\n end\n chunk.instance_variable_set(:@esp_info, esp_info)\n @chunks_tree[chunk] = subchunks\n subchunks.each.with_index do |subchunk, idx_subchunk|\n read_chunk(subchunk)\n end\n end", "def calculate_offsets\n\n # Maintain the offset into the the file on disk. This is used\n # to update the various structures.\n offset = @header.bytesize\n\n # First pass over load commands. Most sizes are filled in here.\n @load_commands.each do |cmd|\n case cmd[:cmd]\n\n when LC_SEGMENT\n seg = cmd\n sections = @sections[seg[:segname]]\n section_size = sections.size * Section.bytesize\n section_vm_size = sections.inject(0) { |total, sect| total + sect[:size] }\n section_disk_size = sections.inject(0) do |total, sect|\n total + @section_disk_size[sect[:sectname]]\n end\n\n ### TODO this should be redundant. try commenting it out one day.\n seg[:nsects] = sections.size\n seg[:cmdsize] = seg.bytesize + section_size\n ###\n\n seg[:vmsize] = section_vm_size\n seg[:filesize] = section_disk_size\n\n when LC_SYMTAB\n # nop\n\n else\n raise \"unsupported load command: #{cmd.inspect}\"\n end\n\n offset += cmd[:cmdsize]\n end\n\n\n # offset now points to the end of the Mach-O headers, or the beginning\n # of the binary blobs of section data at the end.\n\n # Second pass over load commands. Fill in file offsets.\n @load_commands.each do |cmd|\n case cmd[:cmd]\n\n when LC_SEGMENT\n seg = cmd\n sections = @sections[seg[:segname]]\n seg[:fileoff] = offset\n sections.each do |sect|\n sect[:offset] = offset\n offset += @section_disk_size[sect[:sectname]]\n end\n\n when LC_SYMTAB\n if @reloc_info\n # update text section with relocation info\n __text = @sections[@text_segname][@text_sect_index]\n __text[:reloff] = offset\n __text[:nreloc] = @reloc_info.length\n offset += @reloc_info.first.bytesize * @reloc_info.length\n end\n st = cmd\n st[:symoff] = offset\n offset += st[:nsyms] * Nlist.bytesize\n st[:stroff] = offset\n offset += st[:strsize]\n\n\n # No else clause is necessary, the first iteration should have caught them.\n\n end\n\n end # @load_commands.each\n\n end", "def get_block_containing_offset(offset = 0)\n #puts \"[IOBlockReader] - get_block_containing_offset(#{offset})\"\n # Use the cache if possible\n return [ @cached_block.data, @cached_block.offset, @cached_block.last_block? ] if ((@cached_block != nil) and (offset >= @cached_block.offset) and (offset < @cached_block_end_offset))\n #puts \"[IOBlockReader] - get_block_containing_offset(#{offset}) - Cache miss\"\n single_block_index, _ = offset.divmod(@block_size)\n if ((block = @blocks[single_block_index]) == nil)\n read_needed_blocks([single_block_index], single_block_index, single_block_index)\n block = @blocks[single_block_index]\n else\n block.touch\n end\n set_cache_block(block)\n return block.data, block.offset, block.last_block?\n end", "def parse_markers\n while header = @file.read(2)\n marker, type = header.unpack(\"CC\")\n\n case type\n when START_OF_IMAGE # 216\n # Do nothing\n when START_OF_FRAME # 192\n @start_of_frame = read_data_segment()\n when PROGRESSIVE_START_OF_FRAME\n raise \"unimplemented marker\"\n when DEFINE_HUFFMAN_TABLES # 196\n @huffman_tables << read_data_segment()\n when DEFINE_QUANTIZATION_TABLES # 219\n @quantization_tables << read_data_segment()\n when DEFINE_RESTART_INTERVAL\n raise \"unimplemented marker\"\n when START_OF_SCAN\n @start_of_scan = read_entropy_encoded_segment()\n when RESTART\n raise \"unimplemented marker\"\n when APPLICATION_SPECIFIC # 224..240\n @application_specific << read_data_segment()\n when COMMENT\n @comment << read_data_segment()\n when END_OF_IMAGE\n # All Done\n else\n raise \"unrecognized marker: #{marker} #{type}\"\n # We have an unrecognized method, we will try to fetch it's data\n #read_data_segment()\n end\n end\n @file.close\n end", "def parse_cuesheet\n begin\n @cuesheet['block_size'] = @fp.read(3).unpack(\"B*\")[0].to_i(2)\n @cuesheet['offset'] = @fp.tell\n\n @metadata_blocks[-1] << @cuesheet['offset']\n @metadata_blocks[-1] << @cuesheet['block_size']\n\n @fp.seek(@cuesheet['block_size'], IO::SEEK_CUR)\n rescue\n raise FlacInfoReadError, \"Could not parse METADATA_BLOCK_CUESHEET\"\n end\n end", "def read_page_header_and_data_chunk_start\n go_to_page_header_start_pos \n page_header = ::PageHeader.new\n page_header.read(proto)\n\n @page_header ||= page_header\n @data_chunk_start = input_io.pos\n end", "def to_parser_offset(offset); end", "def parse_index_offset\n return -1 if @isMzData\n r = %r{\\<indexOffset\\>(\\d+)\\<\\/indexOffset\\>}\n seekoffset = -120\n while true \n self.seek(seekoffset, IO::SEEK_END)\n if (r.match(self.read)) then \n return $1.to_i\n end\n seekoffset -= 10\n return -1 if seekoffset <= -1000\n end\n end", "def parse\n start_x = 0\n start_y = 0\n\n @maze.each_with_index do |line, index|\n if line.include? 'S'\n start_y = line.index('S')\n start_x = index\n break\n end\n end\n [start_x, start_y]\n end", "def parse_oob(oob, chunk, chunkseq)\n\t\tcase @chunksize\n\t\twhen 512\n\t\t\tparse_oob_yaffs1(oob, chunk, chunkseq)\n\t\telse\n\t\t\tparse_oob_yaffs2(oob, chunk, chunkseq)\n\t\tend\n\tend", "def parse_chunk(string, i)\n case string[i, string.size]\n when /^\\\\\\\\(t|n).*/\n [ string[i + 1, 2], i + 4 ]\n when /^\\\\(t|n).*/\n [(string[i, 2] == '\\t') ? \"\\t\" : \"\\n\", i + 2 ]\n else\n [ string[i].chr, i + 1 ]\n end\n end", "def handle_missing_extent\n @bytecount, @byteoffset, @startblock, @fileoffset, @partition = 0, 0, 0, 0, 'b'\n end", "def fragment_offset\n Utils.word16((bytes[6] & 0x1F), bytes[7])\n end", "def parse\n read_header\n parse_text_segment\n parse_data_segment\n @data = nil\n end", "def parse_position(info)\n ## FIXME: push into parse\n if RbConfig::CONFIG['target_os'].start_with?('mingw') and\n info =~ /^[A-Za-z]:/\n drive_letter = info[0..1]\n info = info[2..-1]\n else\n drive_leter = nil\n end\n info = parse_location(info) if info.kind_of?(String)\n case info.container_type\n when :fn\n if (meth = method?(info.container)) && meth.iseq\n return [meth, meth.iseq.source_container[1], info.position,\n info.position_type]\n else\n return [nil] * 4\n end\n when :file\n filename = canonic_file(info.container)\n # ?? Try to look up method here?\n frame =\n if @frame\n container = frame_container(@frame, false)\n try_filename = container[1]\n frame = (canonic_file(try_filename) == filename) ? @frame : nil\n else\n nil\n end\n # else\n # LineCache.compiled_method(filename)\n # end\n return frame, filename, info.position, info.position_type\n when nil\n if [:line, :offset].member?(info.position_type)\n if @frame\n container = frame_container(@frame, false)\n filename = container[1]\n else\n errmsg \"No stack\"\n return [nil] * 4\n end\n\n return @frame, canonic_file(filename), info.position, info.position_type\n elsif !info.position_type\n errmsg \"Can't parse #{arg} as a position\"\n return [nil] * 4\n else\n errmsg \"Unknown position type #{info.position_type} for location #{arg}\"\n return [nil] * 4\n end\n else\n errmsg \"Unknown container type #{info.container_type} for location #{arg}\"\n return [nil] * 4\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Timestamps are 4 bytes read with Timeat
def timestamps @timestamps ||= bytes[T_BYTES].each_slice(4).map do |t_bytes| ByteArray.to_i(t_bytes) end.reject{ |t| t == 0 } end
[ "def read_timestamps\n FFMpeg.log.inject([]) do |array, log|\n array << (log[1] =~ /time=([\\w|\\.]+ )/ && [log[0], $1.to_f] || nil)\n end.compact\n end", "def read(timestamp); []; end", "def parse_timestamps\n self.keys.each do |key|\n self[key].map! do |timestamp| \n timestamp.is_a?(Time) ? timestamp : Time.parse(timestamp)\n end\n end\n end", "def parse_timestamps\n @created = Time.at(created.to_i) if created\n @expires_in = Time.at(expires_in.to_i) if expires_in\n @last_login = Time.at(last_login.to_i) if last_login\n end", "def read_time # :nodoc:\n\t rt_sec, rt_usec = rio.read(TIME_SIZE).unpack('VV')\n\t Time.at(rt_sec, rt_usec)\n\tend", "def timestamps_offset\n @timestamps_offset ||= attribute.bytes[4]\n end", "def signed_time(*) end", "def pack_VT_FILETIME(localtime) #:nodoc:\n type = 0x0040\n\n epoch = DateTime.new(1601, 1, 1)\n\n t = localtime.getgm\n\n datetime = DateTime.new(\n t.year,\n t.mon,\n t.mday,\n t.hour,\n t.min,\n t.sec,\n t.usec\n )\n bignum = (datetime - epoch) * 86400 * 1e7.to_i\n high, low = bignum.divmod 1 << 32\n\n [type].pack('V') + [low, high].pack('V2')\nend", "def parse_timestamps\n @created_time = created_time.to_i if created_time.is_a? String\n @created_time = Time.at(created_time) if created_time\n end", "def time_to_live\n bytes[8]\n end", "def convert_time_to_timestamp(time); end", "def timestamp\n @packet.timestamp\n end", "def decode_time(raw, offset=0)\n time_raw, read = decode_uint64(raw, offset)\n [Time.at(time_raw), read]\n end", "def received_at\n return nil unless (temp_extended_received_at = read_attribute(:received_at))\n temp_received_at1 = encrypt_remove_pre_and_postfix(temp_extended_received_at, 'received_at', 5)\n temp_received_at2 = YAML::load(temp_received_at1)\n temp_received_at2 = temp_received_at2.to_time if temp_received_at2.class.name == 'Date'\n temp_received_at2\n end", "def parse_timestamps\n @created = created.to_i if created.is_a? String\n @created = Time.at(created) if created\n end", "def translate_timestamp(timestamp)\n Time.at((timestamp >> 18) / 1000)\nend", "def handle_ts\n handle_at\n handle_in\n @time_special = @tokens[@index].get_tag(TimeSpecial).type\n @index += 1\n @precision = :time_special\n end", "def read_timestamps(file_name)\n timestamps = []\n\n min_initted = false\n min_timestamp = 0\n File.open(file_name) do |file|\n file.each do |line|\n unless line.start_with?(\"#\")\n unless min_initted then\n min_timestamp = line.partition(\",\")[2].chop().to_i\n min_initted = true\n end\n timestamp = line.partition(\",\")[2].chop().to_i\n diff = timestamp - min_timestamp\n\n # TODO - do we need to replace timestamp with some better date?\n #date = DateTime.strptime timestamp, \"%Q\"\n #puts date, date.strftime(\"%M:%S:%L\")\n #timestamps << date.strftime(\"%S.%L\")\n\n # we return date in relative to the start format \"second.millisecond\"\n\n timestamps << diff / 1000.0\n end\n end\n end\n\n timestamps\nend", "def timestamp\n Time.at(coff.FileHeader.TimeDateStamp)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
////////////////////////////////////////////////////////////////////////// Properties ////////////////////////////////////////////////////////////////////////// Get icon_index of the element GET
def icon_index() return CORE_CONFIG::ELEMENT_ICONS[self.id] end
[ "def icon_index(item)\n return $data_items[item.item_id].icon_index if item.item?\n return ($data_items.find { |i| !i.nil? && i.subtype_id == item.category_id}).icon_index if item.category?\n end", "def icon\n return @icon\n end", "def icon\n @icon\n end", "def ImageList_ExtractIcon(hi, himl, i)\r\n ImageList_GetIcon(himl, i, 0)\r\n end", "def parse_custom_icon_index\n # offset the index as necessary, using the icon sheet to look up the offset\n self.icon_index = TH::Custom_Icon_Sheets.icon_offsets[self.icon_sheet] + @custom_icon_index\n @custom_icon_index_checked = true\n end", "def icons key\n (icons_info[key.to_s] || key)\n end", "def icon\n begin\n i = Icon.find(icon_id)\n rescue ActiveRecord::RecordNotFound\n i = package_category.icon\n end\n i\n end", "def icon\n self.class.icon\n end", "def icons key\n icons_info[key.to_s]\n end", "def icon\n begin\n i = Icon.find(icon_id)\n rescue ActiveRecord::RecordNotFound\n i = package_branch.version_tracker.icon\n i ||= package_category.icon if package_category.respond_to?(:icon)\n end\n i\n end", "def buff_icon_index(buff_level, param_id)\n if buff_level > 0\n return ICON_BUFF_START + (buff_level - 1) * 8 + param_id\n elsif buff_level < 0\n return ICON_DEBUFF_START + (-buff_level - 1) * 8 + param_id \n else\n return 0\n end\n end", "def buff_icon_index(buff_level, param_id)\r\n if buff_level > 0\r\n return ICON_BUFF_START + (buff_level - 1) * 8 + param_id\r\n elsif buff_level < 0\r\n return ICON_DEBUFF_START + (-buff_level - 1) * 8 + param_id \r\n else\r\n return 0\r\n end\r\n end", "def get_element_index(locator)\n return get_number(\"getElementIndex\", [locator,])\n end", "def icon_type\n return @icon_type\n end", "def icons(key)\n (icons_info[key.to_s] || key)\n end", "def icon_for(project)\n\t\tic = property(:icon)\n\t\tif ic\n\t\t\tic[project]\n\t\telse\n\t\t\tnil\n\t\tend\n\tend", "def update_button_icon\n index = start_index\n each do |button|\n button.icon_data = @item_list[index]\n index += 1\n end\n end", "def icons()\n return @icons \n end", "def getImageIndex(iID)\n if (@Id2Idx[iID] == nil)\n # Bitmap unknown.\n # First create it.\n lBitmap = yield\n # Then check if we need to resize it\n lBitmap = getResizedBitmap(lBitmap, @Width, @Height)\n # Then add it to the image list, and register it\n @Id2Idx[iID] = @ImageList.add(lBitmap)\n end\n\n return @Id2Idx[iID]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Allows for purchasing a product. Creates a new transaction with the proper data if the product is in stock. Takes a product and a date argument. The date can be passed as string "20160525" or as a date value type. The date defaults to today's date.
def purchase(product, date = Date.today) date = date.is_a?(String) ? Date.parse(date) : date if product.in_stock? Transaction.new(self, product, date) else raise OutOfStockError, "'#{product.title}' is out of stock." end end
[ "def purchase(product)\n \t\tif product.in_stock?\n \t\t\tTransaction.new(self, product)\n \t\telse\n \t\t\traise OutOfStockError, \"#{product.title} is out of stock\"\n \t\tend\n \tend", "def buying_a_product\n\t\t# Deleting all data from the database\n\t\tLineItem.delete_all\n\t\tOrder.delete_all\n\n\t\truby_book = products(:ruby)\n\n\t\t# A user goes to the store index page\n\t\tget \"/\"\n\t\tassert_response :success\n\t\tassert_template \"index\"\n\n\t\t# They select a product, adding it to their cart\n\t\txml_http_request :post, '/line_items', product_id: ruby_book.id\n\t\tassert_response :success\n\n\t\tcart = Cart.find(session[:cart_id])\n\t\tassert_equal 1, cart.line_items.size\n\t\tassert_equal ruby_book, cart.line_items[0].product\n\n\t\t# Check out\n\t\tget \"/orders/new\"\n\t\tassert_response :success\n\t\tassert_template \"new\"\n\n\t\t# Place Order\n\t\tpost_via_redirect \"/orders\", order: { name: \"Dave Thomas\", address: \"123 The Street\", email: \"dave@example.com\", payment_type_id:\"2\" }\n\t\tassert_response :success\n\t\tassert_template \"index\"\n\t\tcart = Cart.find(session[:cart_id])\n\t\tassert_equal 0, cart.line_items.size\n\n\t\t# Check the Databse is correct\n\t\torders = Order.all\n\t\tassert_equal 1, orders.size\n\t\torder = orders[0]\n\n\t\tassert_equal \"Dave Thomas\", order.name\n\t\tassert_equal \"123 The Street\", order.address\n\t\tassert_equal \"dave@example.com\", order.email\n\t\tassert_equal 2, order.payment_type_id\n\n\t\tassert_equal 1, order.line_items.size\n\t\tline_item = order.line_items[0]\n\t\tassert_equal ruby_book, line_item.product\n\n\t\t# Checking the email is correct\n\t\tmail = ActionMailer::Base.deliveries.last\n\t\tassert_equal [\"dave@example.com\"], mail.to\n\t\tassert_equal 'Sam Ruby <depot@example.com>', mail[:from].value\n\t\tassert_equal 'Pragmatic Store Order Confirmation', mail.subject\n\tend", "def create(product)\n validate_type!(product)\n\n attributes = sanitize(product)\n _, _, root = @client.post(\"/products\", attributes)\n\n Product.new(root[:data])\n end", "def purchase\n @product = Product.find(params[:id]) \n if @product.inventory_count > 0\n @product.update(inventory_count: @product.inventory_count - 1)\n puts \"Product Successfully Purchased: #{@product.inventory_count} \" \\\n + \"items left in stock for #{@product.title}\"\n render json: @product\n else\n puts \"Product Failed to Purchase: #{@product.inventory_count}\" \\\n + \" items left in stock for #{@product.title}\"\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create_stock_if_necessary(_product, _store)\n if _product.product_type.id != 2\n _stock = Stock.find_by_product_and_store(_product, _store)\n if _stock.nil?\n # Insert a new empty record if Stock doesn't exist\n #_stock = Stock.create(product_id: _product.id, store_id: _store.id, initial: 0, current: 0, minimum: 0, maximum: 0, location: nil, created_by: current_user.nil? ? nil : current_user.id)\n _stock = Stock.create(product_id: _product.id, store_id: _store.id, initial: 0, current: 0, minimum: 0, maximum: 0, location: nil, created_by: receipt_note.created_by)\n end\n end\n true\n end", "def add_to_transactions\n if @product.in_stock?(quantity)\n in_stock_add_to_transactions\n else\n raise OutOfStockError, \"#{@product.title} is currently out of stock\"\n end\n end", "def create\n @purchase = Purchase.create(purchase_params)\n # render text: params.inspect\n @product = Product.find(params[:purchase][:product_id].to_i)\n @product.purchases << @purchase\n current_user.purchases << @purchase\n @new_qty = @product.qty - params[:purchase][:qty].to_i\n @product.update(qty: @new_qty)\n\n # product.qty -= params[:purchase][:qty].to_i\n @product.save\n\n # Send email to products users if quantity hits 0\n if @new_qty <= 0 # this will change to == 0 when limit is accounted for\n @prod_users = @product.purchases.map { |p| p.user }.flatten.uniq\n @prod_users.each do |user|\n UserMailer.welcome_email(user, @product).deliver\n end\n end\n redirect_to user_purchases_path(current_user)\n end", "def create_purchase_price_if_necessary(_product, _supplier)\n _purchase_price = PurchasePrice.find_by_product_and_supplier(_product, _supplier)\n if _purchase_price.nil?\n # Insert a new empty record if PurchasePrice doesn't exist\n #_purchase_price = PurchasePrice.create(product_id: _product.id, supplier_id: _supplier.id, code: nil, price: 0, measure_id: _product.measure.id, factor: 1, prev_code: nil, prev_price: 0, created_by: current_user.nil? ? nil : current_user.id)\n _purchase_price = PurchasePrice.create(product_id: _product.id, supplier_id: _supplier.id, code: nil, price: 0, measure_id: _product.measure.id, factor: 1, prev_code: nil, prev_price: 0, created_by: receipt_note.created_by)\n end\n true\n end", "def cart_inserter(product, options = {})\n options.assert_valid_keys(:save_for_later, :discount)\n\n # if the product is disabled for whatever reason, bail now.\n return unless product.display?\n cart_item = find_item_for_product(product)\n\n if cart_item\n # if this product is already in the cart, we still want to\n # update its saved_for_later status:\n cart_item.update_attributes(:saved_for_later => !options[:save_for_later].nil?,\n :discount => (options[:discount] or BigDecimal(\"0.0\")))\n\n # We have a duplicate item: return unless it's a gift cert,\n # for which duplicates are allowed (and encouraged!:-)\n return if !product.is_a?(GiftCert)\n end\n\n # At this point, we know that either the product is not in the\n # shopping cart, or we have a gift certificate in hand. In either\n # case, we need to make a new cart item, and place it in the\n # basket:\n cart_item = CartItem.for_product(product)\n cart_item.update_attributes(:saved_for_later => !options[:save_for_later].nil?,\n :discount => (options[:discount] or BigDecimal(\"0.0\")))\n\n # actually add the item to the cart.\n self.cart_items << cart_item\n end", "def create_product(*args)\n \tCreateProduct.new(self).run(*args)\n end", "def purchase_one\n product = Product.find(params[:id])\n company = Company.first\n if product[:inventory_count] > 0\n if product.decrement!(:inventory_count)\n total = company[:money] + product[:price]\n\n company.update_!(money: total)\n render json: {\n status: :ok,\n message: 'Successfully bought'\n }.to_json\n else\n render json: {\n status: :internal_server_error,\n message: 'Error purchasing product'\n }\n end\n else\n render json: {\n status: :ok,\n message: 'Item is no longer available'\n } \n end\n end", "def create\n @product_transaction = ProductTransaction.new(params[:product_transaction])\n\n respond_to do |format|\n if @product_transaction.save\n format.html { redirect_to @product_transaction, notice: 'Product transaction was successfully created.' }\n format.json { render json: @product_transaction, status: :created, location: @product_transaction }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product_transaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def buy(params)\n params[:side] = 'buy'\n params[:product_id] = id\n\n Order.create(params)\n end", "def product_id= prod_id\n return if product\n super\n commit_quantity\n end", "def add_purchase(customer_id, product_id)\n item = DirectedEdge::Item.new(@database, \"customer#{customer_id}\")\n item.link_to(\"product#{product_id}\")\n item.save\n end", "def zuora_create_product(zuora_client, id, name, description)\n product = false\n\n # If SKU already exists by sku.id, skip creating the product in Zuora.\n pp \"Checking for product %s\" % id\n\n # Find existing product by SKU by fetching the catalog.\n # This can probably use some optimization in the future.\n products = zuora_get_products(zuora_client)\n products.each { |_product|\n if _product['sku'] == id\n product = _product\n end\n }\n\n if product == false\n pp \"Product not found\"\n product = zuora_request(zuora_client, \"object/product\",\n {\n \"Description\": description,\n \"Name\": name,\n \"EffectiveEndDate\": \"2066-10-20\",\n \"EffectiveStartDate\": \"1966-10-20\",\n \"SKU\": id,\n },\n :post\n )\n else\n pp \"Existing product found: %s\" % product\n response = zuora_request(zuora_client, \"object/product/%s\" % product['id'],\n {\n \"Description\": description,\n \"Name\": name,\n \"EffectiveEndDate\": \"2066-10-20\",\n \"EffectiveStartDate\": \"1966-10-20\",\n \"SKU\": id,\n },\n :put\n )\n if response.length == 1\n product = response[0]\n end\n end\n\n return product\nend", "def initialize(customer_obj, product_obj)\n\t\t@customer = customer_obj\n\t\t@product = product_obj\n\t\t@id = @@id\n\t\t@@id += 1\n\t\t@product.stock -= 1\n\t\t@date = Time.now\n\t\tadd_transaction\n\tend", "def create_product_activity_event(data = {})\n %i[provider action product_id name price].each do |key|\n raise ArgumentError, \"#{key}: parameter required\" unless data.key?(key)\n end\n\n data[:occurred_at] = Time.now.iso8601 unless data.key?(:occurred_at)\n make_json_request :post, \"v3/#{account_id}/shopper_activity/product\", data\n end", "def create\n @spree_product = Spree::Product.new(spree_product_params)\n\n respond_to do |format|\n if @spree_product.save\n format.html { redirect_to @spree_product, notice: t(\"activerecord.models.spree/product\") + t(\"messages.successfully_created\") }\n format.json { render :show, status: :created, location: @spree_product }\n else\n format.html { render :new }\n format.json { render json: @spree_product.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Allows for returning a product. Checks if a transaction has been made in the store. It takes a product and a defect argument. The defect argument if true signals that the product bought has a defect.
def return_product(product, defect = false) if Transaction.find_by(customer: self, product: product).empty? raise NotRecordedTransactionError, "There was no such transaction recorded." else ProductReturn.new(self, product, defect) end end
[ "def call\n product = context.existing_product || context.product\n\n if product.used?\n context.fail!(error: I18n.t('inventory.product_is_used_already'))\n end\n end", "def purchase(product)\n \t\tif product.in_stock?\n \t\t\tTransaction.new(self, product)\n \t\telse\n \t\t\traise OutOfStockError, \"#{product.title} is out of stock\"\n \t\tend\n \tend", "def purchase?(product)\n products.include?(product)\n end", "def check_product\n return unless product_item_params.key?(:product_id)\n\n unless Product.exists?(product_item_params[:product_id])\n raise ActiveRecord::RecordNotFound, \"Product with id='#{product_item_params[:product_id]}' not found\"\n end\n end", "def find_product? (aProductId)\r\n return false if (find_product(aProductId) == {})\r\n return true\r\n end", "def purchase\n @product = Product.find(params[:id]) \n if @product.inventory_count > 0\n @product.update(inventory_count: @product.inventory_count - 1)\n puts \"Product Successfully Purchased: #{@product.inventory_count} \" \\\n + \"items left in stock for #{@product.title}\"\n render json: @product\n else\n puts \"Product Failed to Purchase: #{@product.inventory_count}\" \\\n + \" items left in stock for #{@product.title}\"\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def is_applied_to_product?(product)\n if discount_on_product\n return (product_id == product.id)\n end\n\n return true\n end", "def get_product\n @product = Product.find_by_uuid(params[:product_id])\n if @product.nil?\n raise Repia::Errors::NotFound\n end\n end", "def add_product(product_name, product_price)\n if @fulfillment_status == :pending || @fulfillment_status == :paid\n return super\n else\n raise ArgumentError.new(\"ERROR: status is not pending or paid\")\n end\n end", "def require_product?\n !!!catalog_request?\n end", "def buying_a_product\n\t\t# Deleting all data from the database\n\t\tLineItem.delete_all\n\t\tOrder.delete_all\n\n\t\truby_book = products(:ruby)\n\n\t\t# A user goes to the store index page\n\t\tget \"/\"\n\t\tassert_response :success\n\t\tassert_template \"index\"\n\n\t\t# They select a product, adding it to their cart\n\t\txml_http_request :post, '/line_items', product_id: ruby_book.id\n\t\tassert_response :success\n\n\t\tcart = Cart.find(session[:cart_id])\n\t\tassert_equal 1, cart.line_items.size\n\t\tassert_equal ruby_book, cart.line_items[0].product\n\n\t\t# Check out\n\t\tget \"/orders/new\"\n\t\tassert_response :success\n\t\tassert_template \"new\"\n\n\t\t# Place Order\n\t\tpost_via_redirect \"/orders\", order: { name: \"Dave Thomas\", address: \"123 The Street\", email: \"dave@example.com\", payment_type_id:\"2\" }\n\t\tassert_response :success\n\t\tassert_template \"index\"\n\t\tcart = Cart.find(session[:cart_id])\n\t\tassert_equal 0, cart.line_items.size\n\n\t\t# Check the Databse is correct\n\t\torders = Order.all\n\t\tassert_equal 1, orders.size\n\t\torder = orders[0]\n\n\t\tassert_equal \"Dave Thomas\", order.name\n\t\tassert_equal \"123 The Street\", order.address\n\t\tassert_equal \"dave@example.com\", order.email\n\t\tassert_equal 2, order.payment_type_id\n\n\t\tassert_equal 1, order.line_items.size\n\t\tline_item = order.line_items[0]\n\t\tassert_equal ruby_book, line_item.product\n\n\t\t# Checking the email is correct\n\t\tmail = ActionMailer::Base.deliveries.last\n\t\tassert_equal [\"dave@example.com\"], mail.to\n\t\tassert_equal 'Sam Ruby <depot@example.com>', mail[:from].value\n\t\tassert_equal 'Pragmatic Store Order Confirmation', mail.subject\n\tend", "def wants product\n if already_wants? product\n item = items.wanted.where(:product_id => product.id).first\n else\n item = Item.create_from_product(product, :possession_status => 'want')\n self.items << item\n ActivityLogger.user_want_product :for => [item, product], :from => self\n end\n item\n end", "def purchase\n begin\n ActiveRecord::Base.transaction do\n @user.coin_credit -= @product.price\n requested_detail = @product.details.available.first\n requested_detail.available = false # makes the detail unavailable\n requested_detail.save!\n @user.save!\n @user.purchased_details << requested_detail # adds the detail to purchased_details of the user\n @purchased_detail = requested_detail\n end\n true\n rescue => e\n Rails.logger.error e\n @user.reload\n @user.errors.add(:base, :purchase_problem)\n false\n end\n end", "def purchase(product, date = Date.today)\n\t\tdate = date.is_a?(String) ? Date.parse(date) : date\n\t\tif product.in_stock?\n\t\t\tTransaction.new(self, product, date)\n\t\telse\n\t\t\traise OutOfStockError, \"'#{product.title}' is out of stock.\"\n\t\tend\n\tend", "def purchase_one\n product = Product.find(params[:id])\n company = Company.first\n if product[:inventory_count] > 0\n if product.decrement!(:inventory_count)\n total = company[:money] + product[:price]\n\n company.update_!(money: total)\n render json: {\n status: :ok,\n message: 'Successfully bought'\n }.to_json\n else\n render json: {\n status: :internal_server_error,\n message: 'Error purchasing product'\n }\n end\n else\n render json: {\n status: :ok,\n message: 'Item is no longer available'\n } \n end\n end", "def can_review_product?(product)\n find_review_by_product(product).nil?\n end", "def get_product\n @product = Product.find_by_uuid(params[:id])\n if @product.nil?\n raise Repia::Errors::NotFound, \"Product #{params[:id]} is not found\"\n end\n end", "def validate\n unless context.product.valid?\n context.fail!(:message => 'Invalid Product details')\n end\n end", "def chkproduct( product_id, sess)\n @product = TempProduct.where(:product_id => product_id).\n where(:sess => sess)\n if @product.count > 0\n true # return true if exist\n else\n false # return false if don't exist\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin This method checks if a user thumbed up this comment before Inputs: user who we want to check if he upped or not. Output: boolean true or false Author: Menisy =end
def upped_by_user?(user) up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # get the up that a user gave to this comment before "if exists" !up.nil? # if up is nil then return false if not then return true end
[ "def downed_by_user?(user)\n down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) # get the down that a user gave to this comment before \"if exists\"\n !down.nil? # if down is nil then return false if not then return true\n end", "def up_comment(user)\n upped_before = self.upped_by_user?(user)\n downed_before = self.downed_by_user?(user)\n if !upped_before && !downed_before then #if user never upped or downed the comment then up it\n up = CommentUpDown.new(:action => 1)\n up.comment = self\n up.user = user\n up.save\n up.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for liking a comment \n if user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:5 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n #############################\n return true\n elsif downed_before then\n self.comment_up_downs.find_by_user_id_and_action(user.id,2).destroy #if user disliked it, now make him like it!\n up = CommentUpDown.new(:action => 1)\n up.comment = self\n up.user = user\n up.save\n up.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for liking a comment \n if comment.user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:5 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n #############################\n return true\n elsif upped_before\n old_up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # if upped before, then un-up\n old_up.add_to_log(self.user,2)\n old_up.destroy\n return true\n else\n return false\n end \n end", "def down_comment(user)\n upped_before = self.upped_by_user?(user)\n downed_before = self.downed_by_user?(user)\n if !upped_before && !downed_before then #if user never upped or downed the comment then up it\n down = CommentUpDown.new(:action => 2)\n down.comment = self\n down.user = user\n down.save\n down.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for disliking a comment \n if comment.user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:6 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n ###################################\n return true\n elsif upped_before then\n self.comment_up_downs.find_by_user_id_and_action(user.id,1).destroy #if user disliked it, now make him like it!\n down = CommentUpDown.new(:action => 2)\n down.comment = self\n down.user = user\n down.save\n down.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for disliking a comment \n if user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:6 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n ###################################\n return true\n elsif downed_before\n old_down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) #if downed before then un-down\n old_down.add_to_log(self.user,2)\n old_down.destroy\n return true\n else\n return false\n end\n end", "def thumbs?(contributer, comments, pull)\n return true if contributer.github == pull.user.login\n return false if comments.empty?\n comments = comments.collect { |c| c if contributer.github == c.user.login }.compact\n comments.collect { |c| c.body.include? \":+1:\" }.any?\n end", "def original_photo(photourl)\n if(current_user.upvotes.find_by(photourl: photourl) || current_user.downvotes.find_by(photourl: photourl)) \n return false\n end\n return true\nend", "def upvote?\n note.start_with?('+1') || note.start_with?(':+1:')\n end", "def upvoted?(post)\n voted_up_on? post\n end", "def wasReviewed?(user)\n return true\n tivit_user_status = self.activity.tivit_user_statuses.find_by_user_id(user.id)\n if (tivit_user_status != nil && tivit_user_status.last_reviewed != nil)\n if (self.user != user && self.created_at > tivit_user_status.last_reviewed)\n return false \n else\n # puts \"[Yaniv] Found new comment for logged in user!\"\n return true\n end\n \n else\n # puts \"someting is fishi in activity \"+self.activity.name\n # puts \"tivit_user_status \"+tivit_user_status.to_s\n# Ilan: revisit this funciton. might have issuein the logic \n return true\n end\n \n end", "def duplicate_vote_up?(rel_obj, user, is_post)\n if (is_post)\n num = VotesPost.where(:post_id => rel_obj.id, :user_id => user.id)\n else\n num = VotesComment.where(:comment_id => rel_obj.id, :user_id => user.id)\n end\n\n num.count > 0\n end", "def is_upvoteable?\n true\n end", "def user_vote_check(user_id, image_id)\n if ImageLike.where(user_id: user_id, image_id: image_id).count == 0\n user_is_vote = nil\n else\n user_is_vote = true\n end\n end", "def upvote(current_user)\n if current_user && current_user.voted_up_on?(self)\n self.unliked_by current_user\n else\n self.liked_by current_user\n end\n end", "def duplicate_vote_up?(post, user)\n num = VotesPost.where(:post_id => post.id, :user_id => user.id)\n\n num.count > 0\n end", "def user_voted?(naming, user)\n !lookup_naming(naming).users_vote(user).nil?\n end", "def comment?\n !@user.nil? && !session.meetup.archived && \\\n @session.assistances.where('user_id = ? AND review IS NULL', @user.id).exists? && \\\n !@session.nil? && @session&.event&.date <= Date.today && \\\n !@session.meetup.holdings.where(user_id: @user.id).exists?\n end", "def upvoted?(link)\n votes.exists?(upvote: 1, link: link)\n end", "def vote_up(user_ip)\r\n if user_already_voted?(user_ip)\r\n false\r\n else\r\n if self.votes.create(:user_ip => user_ip)\r\n true\r\n else\r\n false\r\n end\r\n end\r\n end", "def can_vote_up?\n self.reputation_points >= Reputation::Threshold.vote_up # e.g. 15\n end", "def user_has_liked?\n client = Instagram.client(access_token: @access_token)\n media = client.media_shortcode(@campaign.target)\n media.user_has_liked\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin This method checks if a user thumbed down this comment before Inputs: user who we want to check if he upped or not. Output: boolean true or false Author: Menisy =end
def downed_by_user?(user) down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) # get the down that a user gave to this comment before "if exists" !down.nil? # if down is nil then return false if not then return true end
[ "def upped_by_user?(user)\n up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # get the up that a user gave to this comment before \"if exists\"\n !up.nil? # if up is nil then return false if not then return true\n end", "def up_comment(user)\n upped_before = self.upped_by_user?(user)\n downed_before = self.downed_by_user?(user)\n if !upped_before && !downed_before then #if user never upped or downed the comment then up it\n up = CommentUpDown.new(:action => 1)\n up.comment = self\n up.user = user\n up.save\n up.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for liking a comment \n if user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:5 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n #############################\n return true\n elsif downed_before then\n self.comment_up_downs.find_by_user_id_and_action(user.id,2).destroy #if user disliked it, now make him like it!\n up = CommentUpDown.new(:action => 1)\n up.comment = self\n up.user = user\n up.save\n up.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for liking a comment \n if comment.user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:5 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n #############################\n return true\n elsif upped_before\n old_up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # if upped before, then un-up\n old_up.add_to_log(self.user,2)\n old_up.destroy\n return true\n else\n return false\n end \n end", "def down_comment(user)\n upped_before = self.upped_by_user?(user)\n downed_before = self.downed_by_user?(user)\n if !upped_before && !downed_before then #if user never upped or downed the comment then up it\n down = CommentUpDown.new(:action => 2)\n down.comment = self\n down.user = user\n down.save\n down.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for disliking a comment \n if comment.user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:6 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n ###################################\n return true\n elsif upped_before then\n self.comment_up_downs.find_by_user_id_and_action(user.id,1).destroy #if user disliked it, now make him like it!\n down = CommentUpDown.new(:action => 2)\n down.comment = self\n down.user = user\n down.save\n down.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for disliking a comment \n if user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:6 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n ###################################\n return true\n elsif downed_before\n old_down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) #if downed before then un-down\n old_down.add_to_log(self.user,2)\n old_down.destroy\n return true\n else\n return false\n end\n end", "def thumbs?(contributer, comments, pull)\n return true if contributer.github == pull.user.login\n return false if comments.empty?\n comments = comments.collect { |c| c if contributer.github == c.user.login }.compact\n comments.collect { |c| c.body.include? \":+1:\" }.any?\n end", "def original_photo(photourl)\n if(current_user.upvotes.find_by(photourl: photourl) || current_user.downvotes.find_by(photourl: photourl)) \n return false\n end\n return true\nend", "def wasReviewed?(user)\n return true\n tivit_user_status = self.activity.tivit_user_statuses.find_by_user_id(user.id)\n if (tivit_user_status != nil && tivit_user_status.last_reviewed != nil)\n if (self.user != user && self.created_at > tivit_user_status.last_reviewed)\n return false \n else\n # puts \"[Yaniv] Found new comment for logged in user!\"\n return true\n end\n \n else\n # puts \"someting is fishi in activity \"+self.activity.name\n # puts \"tivit_user_status \"+tivit_user_status.to_s\n# Ilan: revisit this funciton. might have issuein the logic \n return true\n end\n \n end", "def upvote?\n note.start_with?('+1') || note.start_with?(':+1:')\n end", "def has_downvoted_for(user_id, post_id)\n\t\trelationship = Vote.find_by(user_id: user_id, post_id: post_id, vote_type: \"downvote\")\n \treturn true if relationship\n\tend", "def comment?\n !@user.nil? && !session.meetup.archived && \\\n @session.assistances.where('user_id = ? AND review IS NULL', @user.id).exists? && \\\n !@session.nil? && @session&.event&.date <= Date.today && \\\n !@session.meetup.holdings.where(user_id: @user.id).exists?\n end", "def user_vote_check(user_id, image_id)\n if ImageLike.where(user_id: user_id, image_id: image_id).count == 0\n user_is_vote = nil\n else\n user_is_vote = true\n end\n end", "def duplicate_vote_up?(rel_obj, user, is_post)\n if (is_post)\n num = VotesPost.where(:post_id => rel_obj.id, :user_id => user.id)\n else\n num = VotesComment.where(:comment_id => rel_obj.id, :user_id => user.id)\n end\n\n num.count > 0\n end", "def upvoted?(post)\n voted_up_on? post\n end", "def downvote?\n note.start_with?('-1') || note.start_with?(':-1:')\n end", "def allow_commenting?\n return false unless user\n event.user_joined?(user) or event.is_owner?(user) or event.user_invited?(user)\n end", "def user_voted?(naming, user)\n !lookup_naming(naming).users_vote(user).nil?\n end", "def user_has_liked?\n client = Instagram.client(access_token: @access_token)\n media = client.media_shortcode(@campaign.target)\n media.user_has_liked\n end", "def is_upvoteable?\n true\n end", "def show_featured_debates?\n !login_or_signup? and !admin_user? \n end", "def unsubscribed?(commenter)\n return true if commenter.downcase == REDD_USERNAME.downcase ||\n DB.get_first_value('select count(*) from unsubscribed where LOWER(username) = ?', commenter.downcase) > 0\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin Returns number of ups for a comment Inputs: none Output: int number of ups Author: Menisy =end
def get_num_ups ups = self.comment_up_downs.find_all_by_action(1).size end
[ "def get_num_downs\n downs = self.comment_up_downs.find_all_by_action(2).size\n end", "def comments_count\n 0\n end", "def compute_comment_score(c)\n upcount = (c['up'] ? c['up'].length : 0)\n downcount = (c['down'] ? c['down'].length : 0)\n upcount-downcount\n end", "def show_comment_count(pairing)\n \"Comments: #{pairing.comments_count}\"\n end", "def num_developers(lines)\n\tauthorsArray = Array.new\n\tdiffArray = Array.new\n\tres = 0\n\tindex = -1\n\tcount = 0\n\tlines.each do |x|\n \t\tif x.start_with?(\"Author: \")\n \t\tindex +=1\n \t\tauthorsArray[index] = x\n \t\tend\n \tend\n\tdiffArray = authorsArray.uniq!\n\tres = diffArray.size\n\tres\nend", "def num_developers(lines)\n count=0\n email=\"\"\n search=Array.new\n i=0\n lines.each do |line|\n line=line.chomp.split(/ +/)\n if line[0].eql?(\"Author:\")\n email=line[-1].gsub(/[<>]/,\"\")\n search[i]=email\n i+=1\n end\n end\n search=search.uniq\n count=search.length\n return count\nend", "def comments_count\n count = node_text(node.at_xpath(\"//slash:comments\"))\n count.to_i unless count.nil?\n end", "def comment_counts(opts = {})\n opts = Disqus::defaults.merge(opts) \n validate_opts!(opts)\n s = <<-WHIMPER\n <script type=\"text/javascript\">\n //<![CDATA[\n (function() {\n var links = document.getElementsByTagName('a');\n var query = '?';\n for(var i = 0; i < links.length; i++) {\n if(links[i].href.indexOf('#disqus_thread') >= 0) {\n query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';\n }\n }\n document.write('<' + 'script type=\"text/javascript\" src=\"#{ROOT_PATH}get_num_replies.js' + query + '\"></' + 'script>');\n })();\n //]]>\n </script>\n WHIMPER\n s % opts[:account]\n end", "def numbered_comments(post_num_input)\n puts ''\n BLOG[post_num_input].comments.each do |x|\n puts \"[#{BLOG[post_num_input].comments.index(x) + 1}] #{x.username} - #{x.comment}\"\n end\n puts ''\n end", "def comments_count\n data[:comments_count]\n end", "def comments_count\n if @article.comments.nil? then 0 else @article.comments.size end\n end", "def comments_word_count\n self.turker_comments.present? ? self.turker_comments.split(/\\s/).length : 0\n end", "def count_of_comment\n Comment.number_of_comment(self)\n end", "def count(line)\n wrap_line do\n count = comment_count_ending_on_line(line)\n if count > 0\n %Q{<a href=\"\" class=\"diff-comment-count round-10 shadow-2\">#{count.to_s}</a>}\n else\n \"\"\n end\n end\n end", "def CommentCount\n return Comment.where(:user_id => id).count\n end", "def review_comment_count\n self.reviews.map { |review| review.comments.count }.inject(:+)\n end", "def get_comment_age\n page.css(\".comment-tree\").css(\".comhead\").map do |header| \n header.text.match(/\\S+\\s\\S+/).to_s.split(' ')[1]\n end\n end", "def num_commit_comments(onwer, repo, from, to)\n q = <<-QUERY\n select count(*) as commit_comment_count\n from project_commits pc, projects p, users u, commit_comments cc\n where pc.commit_id = cc.commit_id\n and p.id = pc.project_id\n and p.owner_id = u.id\n and u.login = ?\n and p.name = ?\n and cc.created_at between timestamp(?) and timestamp(?)\n QUERY\n db.fetch(q, onwer, repo, from, to).first[:commit_comment_count]\n end", "def num_pr_comments(pr)\n q = <<-QUERY\n select count(*) as comment_count\n from pull_request_comments prc\n where prc.pull_request_id = ?\n and prc.created_at < (\n select max(created_at)\n from pull_request_history\n where action = 'closed' and pull_request_id = ?)\n QUERY\n db.fetch(q, pr[:id], pr[:id]).first[:comment_count]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin Returns number of downs for a comment Inputs: none Output: int number of downs Author: Menisy =end
def get_num_downs downs = self.comment_up_downs.find_all_by_action(2).size end
[ "def get_num_ups\n ups = self.comment_up_downs.find_all_by_action(1).size\n end", "def compute_comment_score(c)\n upcount = (c['up'] ? c['up'].length : 0)\n downcount = (c['down'] ? c['down'].length : 0)\n upcount-downcount\n end", "def comments_count\n 0\n end", "def review_comment_downvote_count\n number_of_downvotes = 0\n self.reviews.each do |review|\n votes = Vote.where(votable_type: \"Review\", votable_id: review.id, value: -1).count || 0\n number_of_downvotes += votes\n end\n number_of_downvotes\n end", "def comments_count\n count = node_text(node.at_xpath(\"//slash:comments\"))\n count.to_i unless count.nil?\n end", "def comments_count\n data[:comments_count]\n end", "def down_comment(user)\n upped_before = self.upped_by_user?(user)\n downed_before = self.downed_by_user?(user)\n if !upped_before && !downed_before then #if user never upped or downed the comment then up it\n down = CommentUpDown.new(:action => 2)\n down.comment = self\n down.user = user\n down.save\n down.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for disliking a comment \n if comment.user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:6 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n ###################################\n return true\n elsif upped_before then\n self.comment_up_downs.find_by_user_id_and_action(user.id,1).destroy #if user disliked it, now make him like it!\n down = CommentUpDown.new(:action => 2)\n down.comment = self\n down.user = user\n down.save\n down.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for disliking a comment \n if user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:6 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n ###################################\n return true\n elsif downed_before\n old_down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) #if downed before then un-down\n old_down.add_to_log(self.user,2)\n old_down.destroy\n return true\n else\n return false\n end\n end", "def downvotes\n notes.select(&:downvote?).size\n end", "def comment_column\n res = 0\n @page.css('thead tr th').each do |x|\n res += 1\n if x.text == \"Comments\"\n break\n end\n end\n return res\n end", "def comment_length\n\t120\nend", "def count_of_comment\n Comment.number_of_comment(self)\n end", "def show_comment_count(pairing)\n \"Comments: #{pairing.comments_count}\"\n end", "def comment_counts(opts = {})\n opts = Disqus::defaults.merge(opts) \n validate_opts!(opts)\n s = <<-WHIMPER\n <script type=\"text/javascript\">\n //<![CDATA[\n (function() {\n var links = document.getElementsByTagName('a');\n var query = '?';\n for(var i = 0; i < links.length; i++) {\n if(links[i].href.indexOf('#disqus_thread') >= 0) {\n query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';\n }\n }\n document.write('<' + 'script type=\"text/javascript\" src=\"#{ROOT_PATH}get_num_replies.js' + query + '\"></' + 'script>');\n })();\n //]]>\n </script>\n WHIMPER\n s % opts[:account]\n end", "def numbered_comments(post_num_input)\n puts ''\n BLOG[post_num_input].comments.each do |x|\n puts \"[#{BLOG[post_num_input].comments.index(x) + 1}] #{x.username} - #{x.comment}\"\n end\n puts ''\n end", "def decrement_comments_count\n return unless commented_on_card?\n commentable.update(comments_count: commentable.comments_count - 1)\n end", "def numComments(actionIdeaID) \n \treturn ActionIdeaComment.where(actionIdeaID =self.action_idea_id).count()\n end", "def comments_count\n if @article.comments.nil? then 0 else @article.comments.size end\n end", "def count(line)\n wrap_line do\n count = comment_count_ending_on_line(line)\n if count > 0\n %Q{<a href=\"\" class=\"diff-comment-count round-10 shadow-2\">#{count.to_s}</a>}\n else\n \"\"\n end\n end\n end", "def get_comment_age\n page.css(\".comment-tree\").css(\".comhead\").map do |header| \n header.text.match(/\\S+\\s\\S+/).to_s.split(' ')[1]\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin Ups a comment. Input: user who is upping the comment. Output: boolean indicating success or failure Author: Menisy =end
def up_comment(user) upped_before = self.upped_by_user?(user) downed_before = self.downed_by_user?(user) if !upped_before && !downed_before then #if user never upped or downed the comment then up it up = CommentUpDown.new(:action => 1) up.comment = self up.user = user up.save up.add_to_log(self.user) #Author: Omar #adding the notification to the database for liking a comment if user != self.user UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:5 , new:true) self.user.notifications = self.user.notifications.to_i + 1 self.user.save end ############################# return true elsif downed_before then self.comment_up_downs.find_by_user_id_and_action(user.id,2).destroy #if user disliked it, now make him like it! up = CommentUpDown.new(:action => 1) up.comment = self up.user = user up.save up.add_to_log(self.user) #Author: Omar #adding the notification to the database for liking a comment if comment.user != self.user UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:5 , new:true) self.user.notifications = self.user.notifications.to_i + 1 self.user.save end ############################# return true elsif upped_before old_up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # if upped before, then un-up old_up.add_to_log(self.user,2) old_up.destroy return true else return false end end
[ "def up_comment\n comment = Comment.find(params[:comment_id])\n upped = comment.up_comment(current_user)\n if upped \n redirect_to :action => \"get\" ,:id => params[:id]\n else\n flash[:notice] = \"Temporary error has occured $red\"\n redirect_to :action => \"get\" ,:id => params[:id]\n end\n end", "def upped_by_user?(user)\n up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # get the up that a user gave to this comment before \"if exists\"\n !up.nil? # if up is nil then return false if not then return true\n end", "def comment?\n !@user.nil? && !session.meetup.archived && \\\n @session.assistances.where('user_id = ? AND review IS NULL', @user.id).exists? && \\\n !@session.nil? && @session&.event&.date <= Date.today && \\\n !@session.meetup.holdings.where(user_id: @user.id).exists?\n end", "def commented_on(username, *args)\n path = \"user/#{username}/commented\"\n Rdigg.fetch(path, \"comment\", args)\n end", "def add_comment\n # they didn't come with the right stuff\n if params[:do] != '1' or (params[:human_check] and params[:human_check] != '8') or !params[:comment][:post_id]\n logger.warn(\"[Human check #{Time.sl_local.strftime('%m-%d-%Y %H%:%M:%S')}]: Comment did not pass human check so it was blocked.\")\n redirect_to '/' and return false\n end\n # grab the ticket info\n @comment = Comment.new(params[:comment])\n # grab the user's IP\n @comment.ip = request.remote_ip\n # save it (gets checked for spam as well)\n if @comment.save\n # comment was saved successfully\n if Preference.get_setting('COMMENTS_APPROVED') != 'yes'\n # approval is required, notify accordingly\n flash[:notice] = 'Your comment will be reviewed and will appear once it is approved.'\n redirect_to params[:return_url] + \"#comments\"\n else\n # comment is posted, let's send them there\n redirect_to params[:return_url] + '#c' + @comment.id.to_s\n end\n else\n # whoops!\n @post = Post.find_individual(params[:link])\n # set the page title\n $page_title = (Preference.get_setting('SIMPLE_TITLES') == 'yes' ? create_html_title(@post[0]) : @post[0].title)\n render :template => 'posts/show'\n end\n end", "def allow_comment?(user) \n # for now, we allow everyone\n return true \n end", "def already_commented_by_user?(the_user)\n !self.comments.where([\"user_id = ?\", the_user.id]).empty?\n end", "def downed_by_user?(user)\n down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) # get the down that a user gave to this comment before \"if exists\"\n !down.nil? # if down is nil then return false if not then return true\n end", "def is_comment\n user_comment.nil? ? false : true\n end", "def allow_comment?\n comment_status == 'open'\n end", "def test05_FlagArticleComment\n\t\tcommentArticlePop\n\t\tsleep 4\n\t\tcommentPopSubmit\n\t\tsleep 4\n\t\tcommentFlag\n\t\t\n\t\tbegin \n\t\tassert $comment_flag_success.exists?\n\t\t\trescue => e\n\t\t\tputs \"IPS04T05: FAILED! User unable to flag comment!\"\n\t\t\tputs e\n\t\tend\n\tend", "def down_comment(user)\n upped_before = self.upped_by_user?(user)\n downed_before = self.downed_by_user?(user)\n if !upped_before && !downed_before then #if user never upped or downed the comment then up it\n down = CommentUpDown.new(:action => 2)\n down.comment = self\n down.user = user\n down.save\n down.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for disliking a comment \n if comment.user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:6 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n ###################################\n return true\n elsif upped_before then\n self.comment_up_downs.find_by_user_id_and_action(user.id,1).destroy #if user disliked it, now make him like it!\n down = CommentUpDown.new(:action => 2)\n down.comment = self\n down.user = user\n down.save\n down.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for disliking a comment \n if user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:6 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n ###################################\n return true\n elsif downed_before\n old_down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) #if downed before then un-down\n old_down.add_to_log(self.user,2)\n old_down.destroy\n return true\n else\n return false\n end\n end", "def allow_commenting?\n return false unless user\n event.user_joined?(user) or event.is_owner?(user) or event.user_invited?(user)\n end", "def execute(iUserID, iComment)\n # Do nothing, it will just be logged\n return nil\n end", "def joke7(joke_to_tell)\n\tputs(joke_to_tell)\n\tuser_input = gets.chomp.downcase\n\t\tif user_input == \"I don't know\"\n\t\t\tputs \"snarky comment!\"\n\t\t\treturn false\n\t\telse\n\t\t\tputs \"joke gotten!\"\n\t\t\treturn true\n\t\tend\nend", "def test_ID_25868_comments_on_a_post_i_commented_on()\n login_as_user1\n post_to_any_group(\"Living\",\"House & Home\")\n comment_on_a_post\n logout_common\n login_as_user2\n comment_on_a_post_which__i_commented_before(\"Living\",\"House & Home\")\n logout_common\n login_as_user1\n verify_updates\n end", "def test03_flag_repost_event_TC_24323\n\t\trepostEventPop\n\t\tsleep 2\n\t\trepost\n\t\tcommentFlag\n\t\tsleep 2\n\t\t\n\t\tbegin\n\t\tassert $browser.text.include?(\"Comment\")\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"R8_T3: FAILED! User unable to flag post.\"\n\t\tend\n\tend", "def atest_ID_25868_comments_on_a_post_i_commented_on()\n login_as_user1\n post_to_any_group(\"Living\",\"House & Home\")\n comment_on_a_post\n logout_common\n login_as_user2\n comment_on_a_post_which__i_commented_before(\"Living\",\"House & Home\")\n logout_common\n login_as_user1\n verify_updates\n end", "def test02_flag_repost_article_TC_24323\n\t\trepostArticlePop\n\t\tsleep 2\n\t\trepost\n\t\tcommentFlag\n\t\tsleep 2\n\t\t\n\t\tbegin\n\t\tassert $browser.text.include?(\"Comment\")\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"R8_T2: FAILED! User unable to flag post.\"\n\t\tend\n\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin Downs a comment. Input: user who is downing the comment. Output: boolean indicating success or failure Author: Menisy =end
def down_comment(user) upped_before = self.upped_by_user?(user) downed_before = self.downed_by_user?(user) if !upped_before && !downed_before then #if user never upped or downed the comment then up it down = CommentUpDown.new(:action => 2) down.comment = self down.user = user down.save down.add_to_log(self.user) #Author: Omar #adding the notification to the database for disliking a comment if comment.user != self.user UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:6 , new:true) self.user.notifications = self.user.notifications.to_i + 1 self.user.save end ################################### return true elsif upped_before then self.comment_up_downs.find_by_user_id_and_action(user.id,1).destroy #if user disliked it, now make him like it! down = CommentUpDown.new(:action => 2) down.comment = self down.user = user down.save down.add_to_log(self.user) #Author: Omar #adding the notification to the database for disliking a comment if user != self.user UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:6 , new:true) self.user.notifications = self.user.notifications.to_i + 1 self.user.save end ################################### return true elsif downed_before old_down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) #if downed before then un-down old_down.add_to_log(self.user,2) old_down.destroy return true else return false end end
[ "def downed_by_user?(user)\n down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) # get the down that a user gave to this comment before \"if exists\"\n !down.nil? # if down is nil then return false if not then return true\n end", "def downcomment\n comm = Comment.find_by_id(params[:id])\n if !comm.nil?\n comm.vote(current_user, false)\n end\n end", "def up_comment(user)\n upped_before = self.upped_by_user?(user)\n downed_before = self.downed_by_user?(user)\n if !upped_before && !downed_before then #if user never upped or downed the comment then up it\n up = CommentUpDown.new(:action => 1)\n up.comment = self\n up.user = user\n up.save\n up.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for liking a comment \n if user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:5 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n #############################\n return true\n elsif downed_before then\n self.comment_up_downs.find_by_user_id_and_action(user.id,2).destroy #if user disliked it, now make him like it!\n up = CommentUpDown.new(:action => 1)\n up.comment = self\n up.user = user\n up.save\n up.add_to_log(self.user)\n #Author: Omar\n #adding the notification to the database for liking a comment \n if comment.user != self.user\n UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:5 , new:true)\n self.user.notifications = self.user.notifications.to_i + 1\n self.user.save\n end\n #############################\n return true\n elsif upped_before\n old_up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # if upped before, then un-up\n old_up.add_to_log(self.user,2)\n old_up.destroy\n return true\n else\n return false\n end \n end", "def upped_by_user?(user)\n up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # get the up that a user gave to this comment before \"if exists\"\n !up.nil? # if up is nil then return false if not then return true\n end", "def step_down\n @member = Member.find_by(band_id: params[:id], user_id: params[:user_id])\n @member.update!(is_admin: false)\n\n flash[:success] = \"You have stepped down as an admin.\"\n\n redirect_to band_url(params[:id])\n end", "def check_down; end", "def downvote(link_or_comment)\n vote link_or_comment, -1\n end", "def points_down\n @comment = Comment.find(params[:id])\n vote_result = Vote.vote(\"down\", current_user.id, nil, @comment.id)\n if vote_result\n if vote_result == \"new\"\n @comment.update_attributes(points: (@comment.points - 1))\n else\n @comment.update_attributes(points: (@comment.points - 2))\n end\n if @comment.save\n respond_to do |format|\n format.html { redirect_to request.referrer}\n format.js\n end\n else\n flash[:notice] = \"Error Voting Please Try Again\"\n redirect_to request.referrer\n end\n else\n flash[:notice] = \"\"\n redirect_to request.referrer\n end\n end", "def down?\n !(up?)\n end", "def double_down()\r\n if(@curplayer.nummoves > 0)\r\n return false\r\n end\r\n if(@curplayer.money - @curplayer.curBet >= 0)\r\n money = @curplayer.curBet\r\n @curplayer.curBet += money\r\n @curplayer.money -= money\r\n hit()\r\n return true\r\n else\r\n return false\r\n end\r\n end", "def system_down(down_count)\n mail( :to => 'andy@denenberg.net' , # user.email \n :subject => \"Talon Watcher is not updating - \" + down_count.to_i.ordinalize + \" time\" ,\n :body => \"Checker has determined that Talon Watcher is not updating\\n\\n\" +\n \"The Watcher is down for the \" + down_count.to_i.ordinalize + \" time\" )\n # , :body => user.name + \" \" + user.email + \" \" + user.comments )\n end", "def userMoveDown()\n if (Gosu::button_down?(Gosu::KbDown) or\n Gosu::button_down?(Gosu::GpButton0))\n @button_down = true\n return moveDown()\n end\n return true\n end", "def downvote?\n note.start_with?('-1') || note.start_with?(':-1:')\n end", "def down?(type, name)\n check(type, name, :down)\n end", "def undownvote \n # The user need to login first\n unless logged_in?\n flash[:danger] = \"Please Login\"\n redirect_to_page login_path\n return\n end\n # Check if the specific comment exist\n @comment = Comment.find(params[:id])\n if @comment.nil?\n flash[:danger] = \"The comment does not exist\"\n redirect_to_path locations_path\n end\n \n # Check if the user has downvoted or not\n set_vote\n if (@vote.nil?) || (@vote[:downvote] == 0) # The user has not downvoted the comment\n @message = \"You have not downvoted yet\"\n respond_to do |format|\n format.js { render 'error.js.html' }\n end\n return\n end\n # In order to maintain the consistency of the database, we should start a transcation here to update the votes table and comments table\n Vote.transaction do \n # Update the vote\n @vote[:downvote] = 0\n # Update the specific record by descrease the downvote field by 1\n @comment[:downvote] = @comment[:downvote] - 1\n @vote.save\n @comment.save\n end\n\n # Check if the update is success or not\n if @vote[:downvote] == 1\n flash[:danger] = \"Undownvote failed\"\n redirect_to_path locations_path\n return\n else\n respond_to do |format|\n format.js {}\n end\n end\n end", "def down?\n @last_status == :down\n end", "def down?\n direction == DOWN\n end", "def up_comment\n comment = Comment.find(params[:comment_id])\n upped = comment.up_comment(current_user)\n if upped \n redirect_to :action => \"get\" ,:id => params[:id]\n else\n flash[:notice] = \"Temporary error has occured $red\"\n redirect_to :action => \"get\" ,:id => params[:id]\n end\n end", "def device_down(down_count, device)\n mail( :to => 'andy@denenberg.net' , # user.email \n :subject => device + \" is not responding\" ,\n :body => \"Talon watcher has determined that \" + device + \" is not updating\\n\\n\" +\n device + \" is down for the \" + down_count.to_i.ordinalize + \" time\" )\n # , :body => user.name + \" \" + user.email + \" \" + user.comments )\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin Description: This story is mainly used in the notification system to summarize the content of the comment to fit within a certain length input: char_num:Int which is the number of chars it will be summarized to output: String > The summarized String Author: Kiro =end
def summarize_content (char_num) if self.content.length <= char_num return self.content else return self.content[0..(char_num-1)] + "..." end end
[ "def summarize_title (char_num)\n if self.title.length <= char_num\n return self.title\n else return self.title[0..(char_num-1)] + \"...\"\n end\n end", "def comment_length\n\t120\nend", "def summarize(length = SUMMARY_LENGTH)\n summary = text.mb_chars.slice(0, length).to_s\n summary << ('…' if summary.mb_chars.length < text.mb_chars.length).to_s\n end", "def shortened_summary(document)\n max_chars = 280\n \n summary_presenter = marc_presenter(document, :summary)\n \n return nil unless summary_presenter.lines.length > 0\n\n # just the first line, grab the text\n text = summary_presenter.lines[0].join\n\n # and truncate if needed\n if (text.length > max_chars)\n truncate_at = text.rindex(\" \", max_chars)\n text = html_escape(text[0..truncate_at-1]) + \"&#8230\".html_safe # elipsis\n end\n\n return text\n end", "def description_length(pr)\n pull_req = pull_req_entry(pr)\n title = unless pull_req['title'].nil? then pull_req['title'] else ' ' end\n body = unless pull_req['body'].nil? then pull_req['body'] else ' ' end\n (title + ' ' + body).gsub(/[\\n\\r]\\s+/, ' ').split(/\\s+/).size\n end", "def description_complexity(pr)\n pull_req = pull_req_entry(pr[:id])\n (pull_req['title'] + ' ' + pull_req['body']).gsub(/[\\n\\r]\\s+/, ' ').split(/\\s+/).size\n end", "def summary(len = 60)\n if description.size <= len\n summary = description\n else\n split = description.rindex(' ', len)\n split = len if split.nil?\n summary = description[0,split]\n end\n summary.gsub(/<[^>]*>/, ' ')\n end", "def description_from_string(str)\n len = 12\n return str unless str.length > len\n \"#{str[0..len - 1]}...\" # Is this length correct?\n end", "def description_complexity(build)\n pull_req = pull_req_entry(build[:pull_req_id])\n (pull_req['title'] + ' ' + pull_req['body']).gsub(/[\\n\\r]\\s+/, ' ').split(/\\s+/).size\n end", "def text_summary\n summary = self.text\n summary = summary[(summary.index(\" \") + 1)...summary.length] if self.text[0...1] == \"@\"\n summary = (summary.length > 30 ? \"#{summary[0..30]}...\" : summary[0..30])\n summary\n end", "def comment_describing(line_number); end", "def snippet(text, wordcount, omission)\n text.split[0..(wordcount-1)].join(\" \") + (text.split.size > wordcount ? \" \" + omission : \"\")\n end", "def author(first_len = 4..6, last_len = 8..12)\n str = String.new\n if first_len.class == Range\n str << name_builder(sampler(first_len))\n else\n str << name_builder(first_len.to_i)\n end\n str << ' '\n if last_len.class == Range\n str << name_builder(sampler(last_len))\n else\n str << name_builder(last_len.to_i)\n end\n end", "def text_summary\n summary = attribute_get(:text)\n summary = summary[(summary.index(\" \") + 1)...summary.length] if summary[0...1] == \"@\"\n summary = (summary.length > 30 ? \"#{summary[0..30]}...\" : summary[0..30])\n summary\n end", "def citation_comment\n Rantly {\n freq(\n [5, :literal, ''],\n [1, :literal, sized(50) { string(:alnum) }]\n )\n }\n end", "def paragraph_by_chars(number: 256, supplemental: false)\n paragraph = paragraph(sentence_count: 3, supplemental: supplemental)\n\n paragraph += \" #{paragraph(sentence_count: 3, supplemental: supplemental)}\" while paragraph.length < number\n\n \"#{paragraph[0...number - 1]}.\"\n end", "def post_summary(post, length_limit)\n \"#{post[:post_id]}. <news>#{post[:author]}</>: #{post[:title][0, length_limit]}\"\n end", "def finalize_description(ticket_desc, nxid)\n nxid_line = \"\\n\\n\\n#{nxid}\"\n \n #If the ticket is too long, truncate it to fit the NXID\n max_len = @options[:max_ticket_length]\n if max_len > 0 and (ticket_desc + nxid_line).length > max_len\n #Leave space for newline characters, nxid and ellipsis (...)\n ticket_desc = ticket_desc[0...max_len - (nxid_line.length+5)]\n ticket_desc << \"\\n...\\n\"\n end\n\n \"#{ticket_desc}#{nxid_line}\"\n end", "def get_comment(n, algebraic_structure)\n ret = <<EOS\n/**\n * Combine #{n} #{algebraic_structure}s into a product #{algebraic_structure}\n */\nEOS\n ret.strip\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Field assigments Assigns the tweet's fields from a Twitter status object Returns the tweet record without saving it and persisting the changes to the database
def assign_fields(status) self.text = expand_urls(status.text, status.urls) self.in_reply_to_user_id = status.in_reply_to_user_id self.in_reply_to_status_id = status.in_reply_to_status_id self.source = status.source self.lang = status.lang self.retweet_count = status.retweet_count self.favorite_count = status.favorite_count self.created_at = status.created_at self end
[ "def find_or_create_tweet(status, author, twitter_account, state)\n tweet = tweets.where(twitter_id: status.id).first_or_initialize\n\n tweet.author = author\n tweet.twitter_account = twitter_account\n tweet.assign_state(state)\n\n # Saves the record\n tweet.update_fields_from_status(status)\n end", "def save_status(status, user)\n current_workspace = Birdwatcher::Console.instance.current_workspace\n db_status = current_workspace.add_status(\n :user_id => user.id,\n :twitter_id => status.id.to_s,\n :text => Birdwatcher::Util.strip_control_characters(Birdwatcher::Util.unescape_html(status.text)),\n :source => Birdwatcher::Util.strip_control_characters(Birdwatcher::Util.strip_html(status.source)),\n :retweet => status.retweet?,\n :geo => status.geo?,\n :favorite_count => status.favorite_count,\n :retweet_count => status.retweet_count,\n :possibly_sensitive => status.possibly_sensitive?,\n :lang => status.lang,\n :posted_at => status.created_at,\n )\n if status.geo? && status.geo.coordinates\n db_status.longitude = status.geo.coordinates.first\n db_status.latitude = status.geo.coordinates.last\n end\n if status.place?\n db_status.place_type = status.place.place_type\n db_status.place_name = Birdwatcher::Util.strip_control_characters(status.place.name)\n db_status.place_country_code = Birdwatcher::Util.strip_control_characters(status.place.country_code)\n db_status.place_country = Birdwatcher::Util.strip_control_characters(status.place.country)\n end\n db_status.save\n if status.hashtags?\n status.hashtags.each do |hashtag|\n tag = Birdwatcher::Util.strip_control_characters(hashtag.text)\n db_hashtag = current_workspace.hashtags_dataset.first(:tag => tag) || current_workspace.add_hashtag(:tag => tag)\n db_status.add_hashtag(db_hashtag)\n end\n end\n if status.user_mentions?\n status.user_mentions.each do |mention|\n screen_name = Birdwatcher::Util.strip_control_characters(mention.screen_name)\n name = Birdwatcher::Util.strip_control_characters(mention.name)\n db_mention = current_workspace.mentions_dataset.first(:twitter_id => mention.id.to_s) || current_workspace.add_mention(:twitter_id => mention.id.to_s, :screen_name => screen_name, :name => name)\n db_status.add_mention(db_mention)\n end\n end\n if status.urls?\n status.urls.each do |url|\n expanded_url = Birdwatcher::Util.strip_control_characters(url.expanded_url.to_s)\n db_url = current_workspace.urls_dataset.first(:url => expanded_url) || current_workspace.add_url(:url => expanded_url, :posted_at => status.created_at)\n db_status.add_url(db_url)\n end\n end\n db_status\n end", "def transfer_attr(tweet, final_tweet)\n final_tweet['created_at'] = tweet['created_at'] unless tweet['created_at'].nil?\n unless tweet['user'].nil?\n final_tweet['user'] = Hash.new\n final_tweet['user']['location'] = tweet['user']['location'] unless tweet['user']['location'].nil?\n end\nend", "def assign_fields(user)\n self.screen_name = user.screen_name\n self.name = user.name\n description_urls = user.attrs[:entities].try(:fetch, :description).try(:fetch, :urls, nil)\n self.description = description_urls ? expand_urls(user.description, description_urls) : user.description\n self.location = user.location\n self.profile_image_url = user.profile_image_url_https\n url_urls = user.attrs[:entities].try(:fetch, :url, nil).try(:fetch, :urls, nil)\n self.url = url_urls ? expand_urls(user.url, url_urls) : user.url\n self.followers_count = user.followers_count\n self.statuses_count = user.statuses_count\n self.friends_count = user.friends_count\n self.joined_twitter_at = user.created_at\n self.lang = user.lang\n self.time_zone = user.time_zone\n self.verified = user.verified\n self.following = user.following\n self\n end", "def save_tweet(mash)\n props = {\n original_id: mash.id,\n user_screen_name: mash.user.screen_name,\n text: mash.text,\n in_reply_to_screen_name: mash.in_reply_to_screen_name,\n in_reply_to_status_id: mash.in_reply_to_status_id,\n source: mash.source,\n posted_at: mash.created_at,\n }\n\n tweet = Tweet.find_by_original_id(mash.id)\n\n if tweet\n tweet.update_attributes(props)\n else\n tweet = Tweet.new(props)\n tweet.processed = false\n end\n\n tweet.save\n tweet\n end", "def fix_raw_tweet!\n return unless raw_tweet\n raw_tweet['id'] = ModelCommon.zeropad_id( raw_tweet['id'])\n raw_tweet['created_at'] = ModelCommon.flatten_date(raw_tweet['created_at'])\n raw_tweet['favorited'] = ModelCommon.unbooleanize(raw_tweet['favorited'])\n raw_tweet['truncated'] = ModelCommon.unbooleanize(raw_tweet['truncated'])\n raw_tweet['twitter_user_id'] = ModelCommon.zeropad_id( raw_tweet['twitter_user_id'] )\n raw_tweet['in_reply_to_user_id'] = ModelCommon.zeropad_id( raw_tweet['in_reply_to_user_id']) unless raw_tweet['in_reply_to_user_id'].blank? || (raw_tweet['in_reply_to_user_id'].to_i == 0)\n raw_tweet['in_reply_to_status_id'] = ModelCommon.zeropad_id( raw_tweet['in_reply_to_status_id']) unless raw_tweet['in_reply_to_status_id'].blank? || (raw_tweet['in_reply_to_status_id'].to_i == 0)\n Wukong.encode_components raw_tweet, 'text', 'in_reply_to_screen_name'\n end", "def insert_tweet( table, tweet )\n record = {}\n # direct fields\n record[:id] = tweet[:id]\n record[:id_str] = tweet[:id_str]\n record[:text] = tweet[:text]\n record[:created_at] = tweet[:created_at]\n record[:retweeted] = tweet[:retweeted]\n record[:retweet_count] = tweet[:retweet_count]\n record[:source] = tweet[:source]\n\n # user fields\n user = tweet[:user]\n record[:user_id] = tweet[:user][:id]\n record[:user_id_str] = tweet[:user][:id_str]\n\n # other fields\n record[:hashtags] = tweet[:entities][:hashtags].collect{ |hm| hm[:text] }.join(',') # Apple and #Android -> \"Apple,Android\"\n record[:hashtags_count] = tweet[:entities][:hashtags].length\n record[:user_mentions] = tweet[:entities][:user_mentions].collect{ |mm| mm[:screen_name] }.join(',')\n record[:user_mentions_count] = tweet[:entities][:user_mentions].length\n\n table.insert(record)\nend", "def save_tweet(tweet, user)\n RawTweet.create(tweet_id: tweet.id) do |t|\n t.full_text = tweet.full_text\n t.uri = tweet.uri\n t.tweet_posted_at = tweet.created_at\n t.username = user.screen_name\n t.place = place(tweet)\n end\n end", "def update_twitter_data\n twitter_username = user.twitter_screen_name\n twitter_user = Twitter.user(twitter_username)\n\n self.twitter_location = twitter_user.location\n self.twitter_bio = twitter_user.description\n self.twitter_image_url = twitter_user.profile_image_url\n self.twitter_joined = twitter_user.created_at\n end", "def fetch_details_from_twitter\n\t\t# twitter_object = Twitter::Client.new(\n\t\t# \t:oauth_token => self.token,\n\t\t# \t:oauth_token_secret => self.secret\n\t\t# \t)\n\t\t# twitter_data = Twitter.user(self.uid.to_i)\n\t\t# self.username = twitter_data.username\n\t\t# self.save\n\t\t# self.user.username = twitter_data.username if self.user.username.blank?\n\t\t# self.user.image = twitter_data.profile_image_url if self.user.image.blank?\n\t\t# self.user.location = twitter_data.location if self.user.location.blank?\n\t\t# self.user.save(:validate => false)\n\t\tself.user.has_twitter = true\n\t\tself.user.save\n\tend", "def from_api(status)\n attrs = {}\n attrs[:truncated] = status.truncated\n attrs[:favorited] = status.favorited\n attrs[:text] = status.text\n attrs[:twitter_id] = status.id\n attrs[:in_reply_to_status_id] = status.in_reply_to_status_id\n attrs[:in_reply_to_user_id] = status.in_reply_to_user_id\n attrs[:source] = status.source\n attrs[:timestamp] = status.created_at\n if status.user\n attrs[:user_id] = status.user.id\n attrs[:user_name] = status.user.name\n attrs[:user_screen_name] = status.user.screen_name\n attrs[:user_profile_image_url] = status.user.profile_image_url\n end\n attrs\n end", "def parse_retweeted_status(rs)\n if rs.nil?\n nil\n else\n rs = { \n :created_at => rs.created_at,\n :id => rs.id,\n :text => rs.text,\n :source => rs.source, \n :truncated => rs[\"truncated\"],\n :in_reply_to_status_id => rs[\"in_reply_to_status_id\"],\n :in_reply_to_user_id => rs[\"in_reply_to_user_id\"],\n :in_reply_to_screen_name => rs[\"in_reply_to_screen_name\"],\n :user_id => rs[\"user\"][\"id\"] \n }\n rs\n end\n end", "def tweet(status)\n @client.update(status)\n end", "def status_tweets\n logger.debug { \"#{__method__} is called twitter_user_id=#{id}\" }\n tweets = []\n tweets = InMemory::StatusTweet.find_by(uid) if InMemory.enabled? && InMemory.cache_alive?(created_at)\n tweets = Efs::StatusTweet.where(uid: uid) if tweets.blank? && Efs::Tweet.cache_alive?(created_at)\n tweets = ::S3::StatusTweet.where(uid: uid) if tweets.blank?\n tweets.map { |tweet| ::TwitterDB::Status.new(uid: uid, screen_name: screen_name, raw_attrs_text: tweet.raw_attrs_text) }\n end", "def store_tweet tweet\n tweet_id = tweet.id.to_s\n\n h = {\n created_at: tweet.created_at,\n text: tweet.attrs[:full_text],\n tweet_id: tweet_id\n }\n\n unless @db[:tweets].where(tweet_id: tweet_id).count > 0\n @db[:tweets].insert h\n end\n end", "def map_twitter_tweet(tweet)\n {created_at: tweet.created_at,\n from_user: tweet.from_user,\n text: tweet.text,\n twitter_id: tweet.id,\n profile_image_url: tweet.profile_image_url,\n source: tweet.source,\n to_user: tweet.to_user}\n end", "def fixed_values\n if self.entry.present?\n self.published = self.entry.published\n self.entry_created_at = self.entry.created_at\n end\n end", "def retweeted_status\n @retweeted_status ||= self.class.fetch_or_new(@attrs[:retweeted_status]) unless @attrs[:retweeted_status].nil?\n end", "def import_profile_from_twitter\n self.profile.first_name = @credentials['name']\n self.profile.website = @credentials['url']\n self.profile.federated_profile_image_url = @credentials['profile_image_url']\n self.profile.save\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Assigns a certain workflow state given a symbol or string Knows about a whitelist of valid states
def assign_state(state) state &&= state.try(:to_sym) raise "Unknown state: #{ state }" unless Tweet.available_states.include?(state) case state when :conversation then self.state ||= state # do not override existing states with :conversation state else self.state = state end end
[ "def state=(str)\n @address[:state] = simple_check_and_assign!(str)\n end", "def WorkflowState(input, workflow, &block) # rubocop:disable Naming/MethodName\n result = case input\n when Sipity::WorkflowState\n input\n when Symbol, String\n WorkflowState.find_by(workflow_id: workflow.id, name: input)\n end\n\n handle_conversion(input, result, :to_sipity_workflow_state, &block)\n end", "def change_state_of(symbol_call, new_state)\n @actions[symbol_call][:state] = new_state\n end", "def impose_state(s) # :args: state\n @_hegemon_state = s\n nil end", "def get_state(symbol)\n states[normalize_text(symbol)]\n end", "def [](state, string)\n unless @states.include?(state)\n raise RLSM::Error, \"Unknown state: #{state}\"\n end\n\n present_state = state\n string.scan(/./).each do |letter|\n if @transitions[present_state].nil?\n return nil\n else\n present_state = @transitions[present_state][letter]\n end\n end\n\n present_state\n end", "def state(*state_names)\n state_names.flatten!\n state_names.map do |state_name|\n if state_name.kind_of? Symbol\n state_name = state_name.to_s\n else\n begin\n state_name = state_name.to_str\n rescue NoMethodError\n raise SyntaxError, \"Not a valid state name: #{state_name.inspect}\"\n end\n end\n \n unless state_name =~ /^[A-Z]/\n raise SyntaxError,\n \"State name #{state_name.inspect} does not begin with [A-Z].\"\n end\n \n begin\n val = const_get(state_name)\n rescue NameError\n attach_state(state_name)\n else\n case val\n when State\n raise NameError, \"state #{state_name} already exists\"\n else\n raise NameError,\n \"state name '#{state_name}' is already used for a constant \" +\n \"of type #{val.class}.\"\n end\n end\n end\n end", "def accept(state, symbol)\n raise ArgumentError, 'symbol must be a terminal' unless \n @terminals.include?(symbol) \n (@action_table[state] ||= {})[symbol] = ACCEPT\n end", "def request_state(s, *flags) # :args: state, *flags\n return true if @_hegemon_state==s\n return false unless @_hegemon_states[@_hegemon_state].transitions[s]\n @_hegemon_states[@_hegemon_state].transitions[s].try(*flags)\n end", "def assign_state(state)\n @state = state\n end", "def mod st\n st[:state] = state\n end", "def assign_state(name_or_abbr)\n raise Greenhorn::Errors::InvalidOperationError,\n \"Can't assign a state to a country-based tax zone\" if countryBased\n state = Greenhorn::Commerce::State.find_by_name_or_abbr(name_or_abbr)\n raise Greenhorn::Errors::InvalidStateError, name_or_abbr if state.nil?\n associated_states.find_or_create_by(state: state)\n end", "def state=(sta)\n raise ArgumentError, 'Not a valid state' unless states.include?(sta)\n\n @state = sta\n end", "def state=(s)\n @tasks.each_value do |task|\n task.state = s\n end\n end", "def action(action_name,states_for_action,&block)\n # convert to array if we were called with a single state\n states_for_action = arrayify(states_for_action)\n @actions[action_name] = Struct.new(:block,:legal_states)[block,states_for_action]\n end", "def set_state(new_state)\n Torrent::STATES.each_with_index do |allowed_state, index|\n if allowed_state == new_state\n self.state = index\n end\n end\n end", "def add_state(s)\n @states << s\n self\n end", "def update_state(*args)\n state[args.first.to_sym] = args.last\n end", "def addState(input,params)\n\tkey,unused=params\n\treturn input + $savedStates[key]\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Implement an instance method in your Ingredient class that helps check whether an ingredient is valid (i.e., contains only the ingredient names above)?
def allowed_ingredients SAFE_INGREDIENTS.include?(name.downcase) end
[ "def has_ingredient?(ingredient_name)\n ingredient_names.include?(ingredient_name)\n end", "def has_ingredient?(name)\n ingredient(name).present?\n end", "def must_have_ingredients\n unless ingredients.length > 0\n errors.add(:ingredients, \"must have at least one ingredient\")\n end\n end", "def ingredients_with_errors\n ingredients.select { |i| i.errors.any? }\n end", "def allergic_to_ingredients(ingredients)\n allergic_ingredients = self.allergens #ingredinets the user is allergic to\n x = 0 \n while x < allergic_ingredients.length \n if !ingredients.include?(allergic_ingredients[x])\n return true \n end \n x += 1\n end \n return false\n end", "def strict_matching(ingredient_name,item)\n return item.downcase.include?(ingredient_name)\nend", "def enough_ingredients_for?(recipe)\n #this should assert to false when recipe.amount_required is not >=\n # pantry.checkstock.\n end", "def has_validations?\n ingredients.any?(&:has_validations?)\n end", "def check_food_for_allergens(foods, restriction)\n contains = \"contains_\"+ restriction.to_s\n contains = contains.to_sym\n foods.each do |food|\n food_name = food.name.downcase\n food_description = food.description.downcase\n food_ingredients = food.ingredients\n if Food.check_restrictions(food_description.split(), restriction) || Food.check_restrictions(food_name.split(), restriction) || Food.check_restrictions(food_ingredients.to_s.downcase.split(', '), restriction)\n food[contains]= true\n food.save!\n else\n food[contains]= false\n food.save!\n end\n end\nend", "def is_safe?(recipe)\n !recipe.ingredients.any? do |ingredient|\n allergens.include?(ingredient)\n end\n end", "def safe_recipes\n my_ingredients = allergens.map {|allergen| allergen.ingredient}\n Recipe.all.select do |recipe|\n recipe.ingredients.none? do |ingredient|\n my_ingredients.include?(ingredient)\n end\n end\n end", "def validate_item(source_item)\n valid_for = []\n text = source_item.get_text.to_string\n $validation_terms.each do |entity_type, terms|\n # Check if item text includes $validation_terms\n valid_for << entity_type if terms.any? { |term| text.include? term }\n end\n valid_for\nend", "def new_ingredient_info_passed?\n passed = false\n new_ingredient_params.each do |key, value|\n passed = true if !value.blank?\n end\n return passed\n end", "def has_ingredients_defined?\n element.definition.fetch(:ingredients, []).any?\n end", "def safety\n unsafe = []\n @ingredients.each do |food|\n if food.valid? == false\n unsafe << food.name\n end\n end\n print \"\\nThis recipe is \"\n if safe_to_eat? == true\n puts \"SAFE to eat\\n\"\n else\n puts \"NOT SAFE to eat. Please remove the following items:\"\n unsafe.each {|food| puts \"- #{food}\"}\n end\n end", "def allergens\n # first get an array of all possible allergic ingredients\n allergic_ingredients = Allergen.all.map do |allergen|\n allergen.ingredient\n end.uniq\n\n # iterate through this recipes ingredients and see if they're\n # in the list of allergic ingredients\n self.ingredients.select do |ingredient|\n allergic_ingredients.include? ingredient\n end\n end", "def probable_matching(ingredient_long_name,item)\n return (item.downcase.split(\" \") & ingredient_long_name.split(\" \")).size >= 2\nend", "def valid?\n @name.is_a?(String) &&\n !@name.empty? &&\n (@variant.nil? || @variant.is_a?(String))\n end", "def get_recipe_ingredients\n puts \"\\nWhat ingredients are in your recipe? Please enter ingredients separated by commas with no ands.\\n \".colorize(:green).bold\n user_ingredients = gets.strip\n if valid_user_input?(user_ingredients)\n user_ingredients.split(/\\s*\\,\\s*/)\n else\n puts \"\\nInvalid ingredients!\\n \".colorize(:red).bold\n get_recipe_ingredients\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get the document an allowable privacy object for the document according to the db_tag raise if it is an invalid db_tag
def get_privacy db_tag privacy_obj = privacy_objects.find{|p| p.db_tag == db_tag} raise unless privacy_obj return privacy_obj end
[ "def set_privacy db_tag\r\n privacy_obj = privacy_objects.find{|p| p.db_tag == db_tag}\r\n raise unless privacy_obj\r\n self.update_attribute(\"privacy\",privacy_obj.db_tag)\r\n return privacy_obj\r\n end", "def can_view_document(document)\n # allow access if user is logged in\n return true if !User.current.nil? and User.current.admin?\n # current user is a member of the category's\n # group for a document that is private\n unless document.category.group.nil?\n return true if document.is_private? and \n (document.category.group.members.include?(User.current) or\n document.category.group.leaders.include?(User.current))\n end\n !document.is_private?\n end", "def can_view_document(document)\n # allow access if user is logged in\n return true if !current_user.nil? and current_user.is_admin?\n # current user is a member of the category's\n # group for a document that is private\n unless document.category.group.nil? or current_user.nil?\n return current_user.member_of(document.category.group.id) if document.is_private?\n end\n return !document.is_private?\n end", "def editor! doc\n if doc.default_level == \"owner\" or doc.default_level == \"editor\"\n return\n else\n perm = doc.permissions(user: current_user)\n if perm.length > 0 && (perm[0].level == \"owner\" or perm[0].level == \"editor\")\n return\n end\n end\n halt 403\n end", "def can_edit?(document)\n if has_permission?('account_holder || administrator') || current_user.id == document.user_id\n true\n else\n false\n end\n end", "def enforce_show_permissions(_opts = {})\n permissions = current_ability.permissions_doc(params[:id])\n unless can? :discover, permissions\n raise Blacklight::AccessControls::AccessDenied.new('You do not have sufficient access privileges to view this document, which has been marked private.', :discover, params[:id])\n end\n permissions\n end", "def find_doc_owner_by_obj(doc)\n return doc.user.email if doc && doc.user\n end", "def restricted_should_authenticate\n authenticate_user! unless @document.public?\n end", "def get_permission\n project_id_key = get_project_id_key()\n project = Project.find(params[project_id_key])\n\n if (current_user)\n permission = Permission.where({\n user_id: current_user.id,\n project_id: params[project_id_key]\n }).first\n end\n\n project.try(:public) || permission\n end", "def is_public_read(document)\n is_public_read = false\n read_access_group = document.get(\"read_access_group_ssim\")\n unless read_access_group.blank? \n if read_access_group.is_a? Array\n is_public_read = read_access_group.include? \"public\"\n else\n is_public_read = read_access_group == \"public\"\n end\n end\n return is_public_read\n end", "def permission\n database.permission\n end", "def privacy_object_id\r\n\t\t\treturn self.id\r\n\t\tend", "def enforce_show_permissions(_opts = {})\n permissions = current_ability.permissions_doc(solr_id)\n if (permissions['read_access_group_ssim'].present? && permissions['read_access_group_ssim'].include?('registered')) || can?(:discover, permissions)\n permissions\n else\n raise Blacklight::AccessControls::AccessDenied.new('You do not have sufficient access privileges to view this document, which has been marked private.', :discover, params[:id])\n end\n end", "def can_revise_document(document)\n # deny user if not logged in\n return false if User.current.nil?\n # current user is an admin\n return true if User.current.admin?\n # current user is a member of the category's\n # group for a document that is write protected\n unless document.category.group.nil?\n return true if !document.is_writable? and \n (document.category.group.members.include?(User.current) or\n document.category.group.leaders.include?(User.current))\n end\n return document.is_writable?\n end", "def design_doc\n database.get(\"_design/#{design_doc_slug}\")\n end", "def can_read_document?(doc = nil)\r\n true\r\n end", "def restricted_should_authenticate\n unless @document.public?\n authenticate_user!\n end\n end", "def get_denylist\n FavouriteGroup.where(user_id: id, name: FavouriteGroup::DENYLIST_NAME).first\n end", "def ensure_user_is_tag_owner\n access_denied if current_user.nil? || current_user.id != @tag.user_id\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
set the document privacy according to the db_tag raise if it is an invalid db_tag
def set_privacy db_tag privacy_obj = privacy_objects.find{|p| p.db_tag == db_tag} raise unless privacy_obj self.update_attribute("privacy",privacy_obj.db_tag) return privacy_obj end
[ "def get_privacy db_tag\r\n privacy_obj = privacy_objects.find{|p| p.db_tag == db_tag}\r\n raise unless privacy_obj\r\n return privacy_obj \r\n end", "def doc_security=(v); end", "def set_privacy(user=nil,level=0)\n # TODO finish and test\n # currently 0 = public, 1 = public but read only, 2 = private, 3 = private and read only\n # in all cases if you are a member you can see it\n end", "def privacy(arg = nil)\n set_or_return(\n :privacy,\n arg,\n kind_of: [ TrueClass, FalseClass ]\n )\n end", "def set_privacy(user=nil,level=0)\n # currently 0 = public, 1 = public but read only, 2 = private, 3 = private and read only\n # in all cases if you are a member you can see it\n end", "def privacy_changed\r\n begin \r\n document = logged_in_user.is_admin? ? Document.find(params[:d]) : logged_in_user.documents.find(params[:d])\r\n #must return a privacy object from which the openness value is used\r\n #to gauge the openness graph and update the explaination\r\n #to represent the privacy openness\r\n #if the privacy is invalid it will raise exception\r\n if params[:save] == \"true\"\r\n document.set_privacy(params[:p])\r\n unless %w(me friends).include?(document.privacy.db_tag)\r\n document.anonymous = (params[\"anonymous\"] == \"true\" ? :y : nil) \r\n else\r\n document.anonymous = nil\r\n end\r\n document.save \r\n render :inline=>\"<%=fbml_success 'Document Privacy Saved.'%>\"\r\n else\r\n privacy = document.get_privacy(params[:p])\r\n anon = %w(me friends).include?(privacy.db_tag) ? false : true\r\n render_json :showAnon=>anon,:image_src=>\"http://sfu.facebook.com/images/privacy/sparkline_#{privacy.openness}.jpg\"\r\n return\r\n end\r\n rescue Exception=>e\r\n# p e.message\r\n render_return \r\n end \r\n end", "def add_privacy\n if self.published?\n self.update_attributes(:privacy => \"public\")\n end\n end", "def update_user_privacy(user, is_public)\n\treturn if is_public == nil\n\treturn if user == nil\n\treturn if user[\"is_public\"] == is_public\n\n\tusers = settings.db.collection(\"Users\")\n\tremakes = settings.db.collection(\"Remakes\")\n\n\tremakes.update({user_id:user[\"_id\"]}, {\"$set\" => {is_public: is_public}}, {multi:true})\n\tusers.update({_id: user[\"_id\"]}, {\"$set\" => {is_public: is_public}})\nend", "def doc_security=(v)\n Axlsx.validate_int v\n @doc_security = v\n end", "def save_design_doc_on(db)\n update_design_doc(Design.new(design_doc), db)\n end", "def add_doc_to_group\n return if authorize_user_for_level(2) == false\n @document = DocumentRepository.find @doc\n return if @document == nil\n return if @document.author_credentials2['id'].to_i != @user.id\n group = \"#{@user.screen_name}_#{@to_group}\"\n if @doc_modifier == 'read_only'\n @document.acl_set(:group, group, 'r')\n else\n @document.acl_set(:group, group, 'rw')\n end\n DocumentRepository.update @document\n @response = 'set_acl'\n end", "def private! if_metageneration_match: nil\n update_predefined_acl! \"private\", if_metageneration_match: if_metageneration_match\n end", "def privacy_advertising_id=(value)\n @privacy_advertising_id = value\n end", "def public_write! if_metageneration_match: nil\n update_predefined_acl! \"publicReadWrite\", if_metageneration_match: if_metageneration_match\n end", "def privacy\n\n end", "def privacy\n end", "def setPrivate(photoId)\r\n\t\tcon.query(\"\r\n\t\t\tUPDATE photo\r\n\t\t\tSET is_private='1'\r\n\t\t\tWHERE id = \" + photoId)\r\n\tend", "def project_private! if_metageneration_match: nil\n update_predefined_default_acl! \"projectPrivate\", if_metageneration_match: if_metageneration_match\n end", "def privacy_statement=(value)\n @children['privacy-statement'][:value] = value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /subscriptions/1 PATCH/PUT /subscriptions/1.json
def update @subscription = Subscription.find(params[:id]) if @subscription.update(subscription_params) head :no_content else render json: @subscription.errors, status: :unprocessable_entity end end
[ "def update_subscription(subscription_id, params)\n request :patch,\n \"/v3/subscriptions/#{subscription_id}.json\",\n params\n end", "def update\n @subscription = Subscription.get(params[:id])\n @subscription.update(params[:subscription])\n respond_with(@subscription.reload)\n end", "def update_webhook_subscription(id,opts={})\n query_param_keys = [\n \n\n ]\n\n form_param_keys = [\n \n\n ]\n\n # verify existence of params\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :id => id\n\n )\n\n # resource path\n path = path_replace(\"/lti/subscriptions/{id}\",\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_query_params(options, query_param_keys)\n\n response = mixed_request(:put, path, query_params, form_params, headers)\n response\n \n\n end", "def update\n respond_to do |format|\n if @api_subscription.update(api_subscription_params)\n format.html { redirect_to @api_subscription, notice: 'Subscription was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_subscription }\n else\n format.html { render :edit }\n format.json { render json: @api_subscription.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_subscription(subscription_id, prop_patch)\n end", "def update\n @subscription_request = SubscriptionRequest.find(params[:id])\n\n respond_to do |format|\n if @subscription_request.update_attributes(params[:subscription_request])\n format.html { redirect_to @subscription_request, notice: 'Subscription request was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscription_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @subscription = Subscription.find(params[:id])\n auth!\n\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n format.html { redirect_to(manage_screen_field_subscriptions_path(@screen, @field), :notice => t(:subscription_updated)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n res = @protocol_subscription.update(protocol_subscription_update_params)\n return unprocessable_entity(@protocol_subscription.errors) unless res\n\n RescheduleResponses.run!(protocol_subscription: @protocol_subscription,\n future: TimeTools.increase_by_duration(Time.zone.now, 1.hour))\n render status: :ok, json: { status: 'ok' }\n end", "def subscribe_to_updates\n if @subscription = @requestor.find_or_create_subscriptions(@target.id)\n @subscription.update_attributes(blocked: false) if @subscription.blocked?\n render json: { success: true }\n else\n render json: {message: @subscription.errors&.full_messages || 'Unable to subscriber updates, please try again'}, status: 202\n end\n end", "def update\n respond_to do |format|\n if @subscribe.update(subscribe_params)\n format.html { redirect_to @subscribe, notice: 'Subscribe was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscribe }\n else\n format.html { render :edit }\n format.json { render json: @subscribe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin_subscribe.update(admin_subscribe_params)\n format.html { redirect_to @admin_subscribe, notice: 'Subscribe was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_subscribe }\n else\n format.html { render :edit }\n format.json { render json: @admin_subscribe.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_subscription(id, data)\r\n # Subscription.new.edit(id, data)\r\n Subscription.new(id).edit(data)\r\n end", "def update\n @regularsubscription = Regularsubscription.find(params[:id])\n\n respond_to do |format|\n if @regularsubscription.update_attributes(params[:regularsubscription])\n format.html { redirect_to @regularsubscription, notice: 'Regularsubscription was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @regularsubscription.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @panel_subscription = Panel::Subscription.find(params[:id])\n respond_to do |format|\n if @panel_subscription.update_attributes(params[:panel_subscription])\n format.html { redirect_to(@panel_subscription, :notice => 'Subscription was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @panel_subscription.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_webhook_subscription(subscription_id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::PUT,\n '/v2/webhooks/subscriptions/{subscription_id}',\n 'default')\n .template_param(new_parameter(subscription_id, key: 'subscription_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def update(prorate, options = nil)\n request = Request.new(@client)\n path = \"/subscriptions/\" + CGI.escape(@id) + \"\"\n data = {\n \"trial_end_at\"=> @trial_end_at, \n 'prorate'=> prorate\n }\n\n response = Response.new(request.put(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"subscription\"]\n \n \n return_values.push(self.fill_with_data(body))\n \n\n \n return_values[0]\n end", "def update_subscriptions\n @subscription = @customer.subscription\n @options[:prorate] ||= ChargebeeRails.configuration.proration\n @result = ChargeBee::Subscription.update(@subscription.chargebee_id, @options)\n @plan = Plan.find_by(plan_id: @result.subscription.plan_id)\n @subscription.update(subscription_attrs)\n end", "def update\n @subscribtion = Subscribtion.find(params[:id])\n\n respond_to do |format|\n if @subscribtion.update_attributes(params[:subscribtion])\n format.html { redirect_to @subscribtion, notice: 'Subscribtion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscribtion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update \n @service_subscription = ServiceSubscription.find(params[:id])\n \n respond_to do |format|\n if @service_subscription.update_attributes(params[:service_subscription])\n format.html { redirect_to(service_subscriptions_path, :notice => 'Your settings were successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @service_subscription.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return the vCloud data associated with vAppTemplate
def vcloud_attributes Vcloud::Core::Fog::ServiceInterface.new.get_vapp_template(id) end
[ "def get_vapp_template(vapp_id)\n end", "def get_vapp_template(vAppId)\n params = {\n 'method' => :get,\n 'command' => \"/vAppTemplate/vappTemplate-#{vAppId}\"\n }\n\n response, headers = send_request(params)\n\n vapp_node = response.css('VAppTemplate').first\n if vapp_node\n name = vapp_node['name']\n status = convert_vapp_status(vapp_node['status'])\n end\n\n description = response.css(\"Description\").first\n description = description.text unless description.nil?\n\n ip = response.css('IpAddress').first\n ip = ip.text unless ip.nil?\n\n vms = response.css('Children Vm')\n vms_hash = {}\n\n vms.each do |vm|\n vms_hash[vm['name']] = {\n :id => vm['href'].gsub(\"#{@api_url}/vAppTemplate/vm-\", '')\n }\n end\n\n # TODO: EXPAND INFO FROM RESPONSE\n { :name => name, :description => description, :vms_hash => vms_hash }\n end", "def get_vapp_template(vAppId)\n params = {\n 'method' => :get,\n 'command' => \"/vAppTemplate/vappTemplate-#{vAppId}\"\n }\n\n response, headers = send_request(params)\n\n vapp_node = response.css('VAppTemplate').first\n if vapp_node\n name = vapp_node['name']\n status = convert_vapp_status(vapp_node['status'])\n end\n\n description = response.css(\"Description\").first\n description = description.text unless description.nil?\n\n ip = response.css('IpAddress').first\n ip = ip.text unless ip.nil?\n\n vms = response.css('Children Vm')\n vms_hash = {}\n\n vms.each do |vm|\n vms_hash[vm['name']] = {\n :id => vm['href'].gsub(/.*\\/vAppTemplate\\/vm\\-/, \"\")\n }\n end\n\n { :name => name, :description => description, :vms_hash => vms_hash }\n end", "def get_vapp_template(vapp_id)\n params = {\n 'method' => :get,\n 'command' => \"/vAppTemplate/vappTemplate-#{vapp_id}\"\n }\n\n response, _headers = send_request(params)\n\n vapp_node = response.css('VAppTemplate').first\n if vapp_node\n name = vapp_node['name']\n convert_vapp_status(vapp_node['status'])\n end\n\n description = response.css('Description').first\n description = description.text unless description.nil?\n\n vms = response.css('Children Vm')\n vms_hash = {}\n\n vms.each do |vm|\n vms_hash[vm['name']] = {\n :id => URI(vm['href']).path.gsub('/api/vAppTemplate/vm-', '')\n }\n end\n\n { :name => name, :description => description, :vms_hash => vms_hash }\n end", "def get_vapp_templates(name)\n get_nodes(\"ResourceEntity\",\n {\"type\"=>MEDIA_TYPE[:VAPP_TEMPLATE], \"name\"=>name})\n end", "def vcloud_attributes\n Vcloud::Core::Fog::ServiceInterface.new.get_vapp(id)\n end", "def get_vapp_templates(name)\n get_nodes(\"ResourceEntity\",\n type: MEDIA_TYPE[:VAPP_TEMPLATE], name: name)\n end", "def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end", "def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end", "def create_vcenter_template(ds, options, template, image = nil)\n ret = {}\n keys = ['VCENTER_TEMPLATE_REF',\n 'VCENTER_CCR_REF',\n 'VCENTER_INSTANCE_ID']\n\n if ds['//VCENTER_TEMPLATE_REF']\n keys.each do |key|\n ret[key] = ds[\"//#{key}\"]\n end\n else\n require 'vcenter_driver'\n\n # Get vi client for current datastore\n vi_client = VCenterDriver::VIClient.new_from_datastore(\n ds.id\n )\n\n # Get datastore object\n ds_ref = ds['//VCENTER_DS_REF']\n datastore = VCenterDriver::Datastore.new_from_ref(\n ds_ref,\n vi_client\n )\n\n # Get resource pool\n host_ref = datastore['host'].first.key.parent._ref\n vi_client.ccr_ref = host_ref\n\n host = VCenterDriver::ClusterComputeResource.new_from_ref(\n host_ref,\n vi_client\n )\n\n rp = host.resource_pools.first\n\n # Get vCentrer instance ID\n uuid = vi_client.vim.serviceContent.about.instanceUuid\n\n # Create VM folder it not exists\n dc = datastore.obtain_dc.item\n vm_folder = dc.find_folder('one_default_template')\n\n if vm_folder.nil?\n dc.vmFolder.CreateFolder(\n :name => 'one_default_template'\n )\n vm_folder = dc.find_folder('one_default_template')\n end\n\n # Define default VM config\n vm_cfg = { :name => \"one_app_template-#{ds.id}\",\n :guestId => 'otherGuest',\n :numCPUs => 1,\n :memoryMB => 128,\n :files => {\n :vmPathName => \"[#{datastore.item.name}]\"\n } }\n\n # Create the VM\n vm = vm_folder.CreateVM_Task(\n :config => vm_cfg,\n :pool => rp\n ).wait_for_completion\n\n # Create the VM template\n vm.MarkAsTemplate\n\n ret['VCENTER_TEMPLATE_REF'] = vm._ref\n ret['VCENTER_CCR_REF'] = host_ref\n ret['VCENTER_INSTANCE_ID'] = uuid\n\n ret.each do |key, value|\n ds.update(\"#{key}=\\\"#{value}\\\"\", true)\n end\n end\n\n tmpl = <<-EOT\n NAME = \"#{options[:vmtemplate_name] || options[:name]}\"\n HYPERVISOR = \"vcenter\"\n EOT\n\n tmpl << \"DISK = [ IMAGE_ID = \\\"#{image.id}\\\" ]\" if image\n\n template ||= ''\n template = Base64.decode64(template)\n\n template.split(\"\\n\").each do |line|\n # Legacy, some apps in the marketplace have the sched\n # requirement to just be run on KVM, with this\n # the template cannot be run on vCenter, so don't add\n # it in the final VM template\n next if line =~ /SCHED_REQUIREMENTS/ || line.empty?\n\n tmpl << \"#{line}\\n\"\n end\n\n ret.each do |key, value|\n tmpl << \"#{key}=\\\"#{value}\\\"\\n\"\n end\n\n vmtpl = Template.new(Template.build_xml, @client)\n\n rc = vmtpl.allocate(tmpl)\n\n if OpenNebula.is_error?(rc)\n rc\n else\n Template.new_with_id(vmtpl.id, @client)\n end\n end", "def create_vapp_from_template(vdc, vapp_name, vapp_description, vapp_template_id, poweron = false)\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.InstantiateVAppTemplateParams(\n 'xmlns' => 'http://www.vmware.com/vcloud/v1.5',\n 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1',\n 'name' => vapp_name,\n 'deploy' => 'true',\n 'powerOn' => poweron\n ) { xml.Description vapp_description xml.Source(\n 'href' => \"#{@api_url}/vAppTemplate/#{vapp_template_id}\"\n )\n }\n end\n\n params = {\n 'method' => :post,\n 'command' => \"/vdc/#{vdc}/action/instantiateVAppTemplate\"\n }\n\n response, headers = send_request(\n params,\n builder.to_xml,\n 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml'\n )\n\n vapp_id = URI(headers['Location']).path.gsub('/api/vApp/vapp-', '')\n\n task = response.css(\n \"VApp Task[operationName='vdcInstantiateVapp']\"\n ).first\n\n task_id = URI(task['href']).path.gsub(\"/api/task/\", '')\n\n { :vapp_id => vapp_id, :task_id => task_id }\n end", "def create_vapp_from_template(vdc, vapp_name, vapp_description, vapp_templateid, poweron=false)\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.InstantiateVAppTemplateParams(\n \"xmlns\" => \"http://www.vmware.com/vcloud/v1.5\",\n \"xmlns:xsi\" => \"http://www.w3.org/2001/XMLSchema-instance\",\n \"xmlns:ovf\" => \"http://schemas.dmtf.org/ovf/envelope/1\",\n \"name\" => vapp_name,\n \"deploy\" => \"true\",\n \"powerOn\" => poweron) {\n xml.Description vapp_description\n xml.Source(\"href\" => \"#{@api_url}/vAppTemplate/#{vapp_templateid}\")\n }\n end\n\n params = {\n \"method\" => :post,\n \"command\" => \"/vdc/#{vdc}/action/instantiateVAppTemplate\"\n }\n\n response, headers = send_request(params, builder.to_xml, \"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\")\n\n vapp_id = headers[:location].gsub(\"#{@api_url}/vApp/vapp-\", \"\")\n\n task = response.css(\"VApp Task[operationName='vdcInstantiateVapp']\").first\n task_id = task[\"href\"].gsub(\"#{@api_url}/task/\", \"\")\n\n { :vapp_id => vapp_id, :task_id => task_id }\n end", "def get_vapp(vAppId)\n params = {\n 'method' => :get,\n 'command' => \"/vApp/vapp-#{vAppId}\"\n }\n\n response, headers = send_request(params)\n #puts response.to_xml\n\n vapp_node = response.css('VApp').first\n if vapp_node\n name = vapp_node['name']\n status = convert_vapp_status(vapp_node['status'])\n end\n\n description = response.css(\"Description\").first\n description = description.text unless description.nil?\n\n ip1 = response.css('IpAddress').last\n ip1 = ip1.text unless ip1.nil?\n ip2 = response.css('IpAddress').first\n ip2 = ip2.text unless ip2.nil?\n \n\n vms = response.css('Children Vm')\n vms_hash = {}\n\n # ipAddress could be namespaced or not: see https://github.com/astratto/vcloud-rest/issues/3\n vms.each do |vm|\n vapp_local_id = vm.css('VAppScopedLocalId')\n addresses = vm.css('rasd|Connection').collect{|n| n['vcloud:ipAddress'] || n['ipAddress'] }\n vms_hash[vm['name']] = {\n :addresses => addresses,\n :status => convert_vapp_status(vm['status']),\n :id => vm['href'].gsub(\"#{@api_url}/vApp/vm-\", ''),\n :vapp_scoped_local_id => vapp_local_id.text\n }\n end\n\n # TODO: EXPAND INFO FROM RESPONSE\n { :name => name, :description => description, :status => status, :ip1 => ip1, :ip2 => ip2, :vms_hash => vms_hash }\n end", "def get_vapp(vAppId)\n params = {\n 'method' => :get,\n 'command' => \"/vApp/vapp-#{vAppId}\"\n }\n\n response, headers = send_request(params)\n\n vapp_node = response.css('VApp').first\n if vapp_node\n name = vapp_node['name']\n status = convert_vapp_status(vapp_node['status'])\n end\n\n description = response.css(\"Description\").first\n description = description.text unless description.nil?\n\n ip = response.css('IpAddress').first\n ip = ip.text unless ip.nil?\n\n vms = response.css('Children Vm')\n vms_hash = {}\n\n # ipAddress could be namespaced or not: see https://github.com/astratto/vcloud-rest/issues/3\n vms.each do |vm|\n vapp_local_id = vm.css('VAppScopedLocalId')\n addresses = vm.css('rasd|Connection').collect{|n| n['vcloud:ipAddress'] || n['ipAddress'] }\n vms_hash[vm['name']] = {\n :addresses => addresses,\n :status => convert_vapp_status(vm['status']),\n :id => vm['href'].gsub(\"#{@api_url}/vApp/vm-\", ''),\n :vapp_scoped_local_id => vapp_local_id.text\n }\n end\n\n # TODO: EXPAND INFO FROM RESPONSE\n { :name => name, :description => description, :status => status, :ip => ip, :vms_hash => vms_hash }\n end", "def find_vm_template(uuid)\n vapp = @vdc_ci.find_vapp_by_id(uuid)\n return vapp.vms.first if !vapp.vms.nil?\n end", "def create_vapp_from_template(vdc, vapp_name, vapp_description, vapp_templateid, poweron=false)\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.InstantiateVAppTemplateParams(\n \"xmlns\" => \"http://www.vmware.com/vcloud/v1.5\",\n \"xmlns:xsi\" => \"http://www.w3.org/2001/XMLSchema-instance\",\n \"xmlns:ovf\" => \"http://schemas.dmtf.org/ovf/envelope/1\",\n \"name\" => vapp_name,\n \"deploy\" => \"true\",\n \"powerOn\" => poweron) {\n xml.Description vapp_description\n xml.Source(\"href\" => \"#{@api_url}/vAppTemplate/#{vapp_templateid}\")\n }\n end\n\n params = {\n \"method\" => :post,\n \"command\" => \"/vdc/#{vdc}/action/instantiateVAppTemplate\"\n }\n\n response, headers = send_request(params, builder.to_xml, \"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\")\n\n vapp_id = headers[:location].gsub(/.*\\/vApp\\/vapp\\-/, \"\")\n task = response.css(\"VApp Task[operationName='vdcInstantiateVapp']\").first\n task_id = task[\"href\"].gsub(/.*\\/task\\//, \"\")\n\n { :vapp_id => vapp_id, :task_id => task_id }\n end", "def get_volume_template_uri(template_data)\n storage_pool_uri = self['storagePoolUri'] || self['properties']['storagePool']\n storage_pool = OneviewSDK::API500::C7000::StoragePool.new(@client, uri: storage_pool_uri)\n raise 'StoragePool or snapshotPool must be set' unless storage_pool.retrieve!\n storage_system = OneviewSDK::API500::C7000::StorageSystem.new(@client, uri: storage_pool['storageSystemUri'])\n templates = storage_system.get_templates\n template = templates.find { |item| item['isRoot'] == template_data[:isRoot] && item['family'] == template_data[:family] }\n template['uri'] if template\n end", "def get_vapp(vapp_id)\n params = {\n 'method' => :get,\n 'command' => \"/vApp/vapp-#{vapp_id}\"\n }\n\n response, _headers = send_request(params)\n\n vapp_node = response.css('VApp').first\n if vapp_node\n name = vapp_node['name']\n status = convert_vapp_status(vapp_node['status'])\n end\n\n description = response.css('Description').first\n description = description.text unless description.nil?\n\n ip = response.css('IpAddress').first\n ip = ip.text unless ip.nil?\n\n vms = response.css('Children Vm')\n vms_hash = {}\n\n # ipAddress could be namespaced or not:\n # see https://github.com/astratto/vcloud-rest/issues/3\n vms.each do |vm|\n vapp_local_id = vm.css('VAppScopedLocalId')\n addresses = vm.css('rasd|Connection').collect {\n |n| n['vcloud:ipAddress'] || n['ipAddress']\n }\n vms_hash[vm['name'].to_sym] = {\n :addresses => addresses,\n :status => convert_vapp_status(vm['status']),\n :id => URI(vm['href']).path.gsub('/api/vApp/vm-', ''),\n :vapp_scoped_local_id => vapp_local_id.text\n }\n end\n\n # TODO: EXPAND INFO FROM RESPONSE\n {\n :name => name,\n :description => description,\n :status => status,\n :ip => ip,\n :vms_hash => vms_hash\n }\n end", "def create_vapp_from_template(vdc, vapp_name, vapp_description,\n vapp_templateid, poweron = false)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
stop_data contains any information we need for creating new stops. e.g. city id's stop time and ticket price
def update(stop_data) @color = stop_data.fetch(:color, @color) DB.exec("UPDATE trains SET color = '#{@color}' WHERE id = #{@id};") times = stop_data.fetch(:times, []) stop_data.fetch(:city_ids, []).each_with_index do |city_id, index| DB.exec("INSERT INTO stops (train_id, city_id, time) VALUES (#{@id}, #{city_id}, '#{times[index] ? times[index] : "00:00:00"}');") end end
[ "def create\n @stop = @tour.stops.build(stop_params)\n\n respond_to do |format|\n if @stop.save\n format.html { redirect_to tour_path(@tour), notice: \"Stop was successfully created.\" }\n format.json { render :show, status: :created, location: @stop }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @stop.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @stop = @trip.stops.new(stop_params)\n\n respond_to do |format|\n if @stop.save\n format.html { redirect_to trip_path(@trip), notice: 'Stop was successfully created.' }\n format.json { render :show, status: :created, location: @stop }\n else\n format.html { render :new }\n format.json { render json: @stop.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @stop = Stop.new(params[:stop])\n\n if @stop.save\n render json: @stop, status: :created, location: @stop\n else\n render json: @stop.errors, status: :unprocessable_entity\n end\n end", "def create\n if @stop.save\n render 'api/v1/stops/show'\n else\n render 'api/v1/stops/show', :status => :bad_request\n end\n end", "def create\n @route_stop = RouteStop.new(route_stop_params)\n\n if @route_stop.save\n render json: @route_stop, status: :created\n else\n render json: @route_stop.errors, status: :unprocessable_entity\n end\n end", "def stop_times\n @trip_id = self.trip_id\n @stop_times = StopTime.where(trip_id: @trip_id)\n end", "def create\n @stop_time = StopTime.new(params[:stop_time])\n\n respond_to do |format|\n if @stop_time.save\n format.html { redirect_to @stop_time, notice: 'Stop time was successfully created.' }\n format.json { render json: @stop_time, status: :created, location: @stop_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stop_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_stop_time_from_stop_time_page stop_time_page\n StopTime.new.tap do |stop_time|\n stop_time.trip = self\n stop_time.stop_time_page! stop_time_page\n stop_time.save\n end\n end", "def stop_times_by_stop_id(stop_id)\n get \"/gtfs/stoptimes/stopid/#{stop_id}\"\n end", "def stop_time_for_stop(stop)\n ret = stop_times.find_by_stop_id(stop)\n\n return ret\n end", "def import_stops_data\n stops = VehicleStop.in_academic_year(import_from_id)\n stops.each do |s|\n stop_kopy = s.deep_clone do |original, kopy|\n kopy.academic_year_id = import_to_id if original.respond_to? :academic_year_id\n end\n unless stop_kopy.save\n log_error! \"<b>#{t('routes.stop')} - #{stop_kopy.name}</b> : #{stop_kopy.errors.full_messages.join(',')}\"\n end\n end\n end", "def get_stop_info_by_id(stop_id)\n return @db.execute(\"select * from stops where stop_id = #{stop_id}\")[0]\n end", "def create\n @train_stop = TrainStop.new(train_stop_params)\n\n respond_to do |format|\n if @train_stop.save\n format.html { redirect_to @train_stop, notice: 'Train stop was successfully created.' }\n format.json { render :show, status: :created, location: @train_stop }\n else\n format.html { render :new }\n format.json { render json: @train_stop.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @stop_time = StopTime.new(stop_time_params)\n\n respond_to do |format|\n if @stop_time.save\n format.html { redirect_to @stop_time, notice: 'Stop time was successfully created.' }\n format.xml { render :show, status: :created, location: @stop_time }\n format.json { render :show, status: :created, location: @stop_time }\n else\n format.html { render :new }\n format.xml { render xml: @stop_time.errors, status: :unprocessable_entity }\n format.json { render json: @stop_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def arrivals_and_departures_for_stop(stop)\n @client = OneBusAway::Client.new(\n api_method: ['arrivals-and-departures-for-stop', \"1_#{stop}\"]\n )\n call_api\n end", "def create\n @stop_order = StopOrder.new(stop_order_params)\n\n respond_to do |format|\n if @stop_order.save\n format.html { redirect_to @stop_order, notice: 'Stop order was successfully created.' }\n format.json { render :show, status: :created, location: @stop_order }\n else\n format.html { render :new }\n format.json { render json: @stop_order.errors, status: :unprocessable_entity }\n end\n end\n end", "def depatures_by_stop(stop_id)\n departures('departures/bystop/' + stop_id)\n end", "def stop_time_page! stop_time_page\n self.arrival_time = stop_time_page.arrival_time\n self.stop = Stop.find_or_add_from_stop_page stop_time_page.stop_page\n self.stop_sequence = stop_time_page.stop_sequence\n end", "def create\n @vehicle_stop_time = VehicleStopTime.new(vehicle_stop_time_params)\n\n respond_to do |format|\n if @vehicle_stop_time.save\n format.html { redirect_to @vehicle_stop_time, notice: 'Vehicle stop time was successfully created.' }\n format.json { render :show, status: :created, location: @vehicle_stop_time }\n else\n format.html { render :new }\n format.json { render json: @vehicle_stop_time.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
input = two arguments, a positive integer representing salary, and a boolean output = an integer representing bonus for salary rules: if boolean == true, bonus is half of salary if boolean == false, bonus is 0 test cases: what if salary is 0 and boolean is true? what if salary is an odd number, should integer or float division be used? => float logic if condition to check value of boolean IF true, return salary.to_f / 2 ELSE false, return 0 def calculate_bonus(salary, boolean) if boolean return salary.to_f / 2 else return 0 end end refactor for brevity using ternary operator
def calculate_bonus(salary, boolean) boolean ? (salary.to_f / 2) : 0 end
[ "def calculate_bonus(salary, boolean)\n if boolean == true\n salary / 2\n else\n 0\n end\nend", "def calculate_bonus(salary, bonus)\n if bonus == true\n salary / 2\n elsif bonus == false\n 0\n end\nend", "def calculate_bonus salary, bool\n if bool == true\n salary/2\n else\n return 0\n end\nend", "def calculate_bonus(salary, bonus)\n if bonus == true\n salary / 2\n else\n 0\n end\nend", "def calculate_bonus(salary_integer, bonus_boolean)\n potential_bonus = salary_integer / 2 # => 1400, 500, 25000\n if bonus_boolean # => true, false, true\n potential_bonus # => 1400, 25000\n else\n 0 # => 0\n end # => 1400, 0, 25000\nend", "def calculate_bonus(positive_integer_salary, bonus_boolean)\n bonus_boolean ? positive_integer_salary * 0.5 : 0\nend", "def calculate_bonus(salary, bonus_eligibility)\n bonus_eligibility ? salary / 2 : 0\nend", "def calculate_bonus(int, bool)\n bonus = 0\n if bool == true\n bonus = int/2\n else\n bonus = 0\n end\n return bonus\nend", "def calc_bonus(salary, getting)\n getting ? (salary / 2) : 0\nend", "def bonus_time(salary, bonus)\n format(\"$%d\", bonus ? salary * 10 : salary)\nend", "def apply_bonus(user_total, loyalty_points)\n if (user_total > 20)\n loyalty_points += 20\n else\n loyalty_points += 5\n end\n return loyalty_points\nend", "def heavy_luggage_calc(price, user_response)\n if 7 < user_response && user_response < 30\n return (price * @heavy_luggage_premium) - price\n else\n return 0\n end\nend", "def return_calc(price, user_response)\n if (user_response == \"return\" || user_response == \"Return\" || user_response == \"RETURN\" || user_response == \"r\" || user_response == \"R\")\n return (price * @return_premium) - price\n elsif (user_response == \"one way\" || user_response == \"ONE WAY\" || user_response == \"One Way\")\n return 0\n end\nend", "def calculate_total_salary\n @player[:sueldo].to_i + total_bonus_amount\n end", "def f(n=false)\n (n.kind_of?(Integer) && n > 0) ? (n+1) * n /2 : false\nend", "def test_if_qualify(current_salary, monthly_payment)\n\tmonthly_salary = current_salary / 12\n\ttimes_greater = monthly_salary / monthly_payment\n\tif times_greater >= 2 \n\t\tanswer = true \n\telse\n\t\tanswer = false \n\tend\n\treturn answer\nend", "def duty_free(price, discount, holiday_cost)\r\n (holiday_cost/(price*discount/100.0)).to_i\r\nend", "def conditional(ab, b)\n return 0.0 if b.zero?\n ab / b.to_f\n end", "def rent?(baller, furnished, rent)\n ###if baller then\n # if furnished || rent < 2100\n # return true\n # end\n # else\n # return false\n # end\n# end\n# \n\nreturn true if baller && (furnished || rent <2100) else false end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /roster_squares/1/edit edit the behavior squares available to a student
def edit @roster_square = RosterSquare.new @roster_squares = RosterSquare.all @student = Student.find_by_id(params[:id]) @student_squares = RosterSquare.where(student_id: @student.id) @not_student_squares = [] #Set the squares for the specific school @school_squares = Square.where(school_id: @student.school_id) @square = Square.find_by_id(params[:id]) @squares = Square.all if params[:remove_square] if params[:remove_square_id] != nil @roster_squares.delete(RosterSquare.find(params[:remove_square_id])) # flash[:success] = 'Roster square was successfully removed.' redirect_to "/roster_squares/#{params[:id]}/edit" end end end
[ "def update\n respond_to do |format|\n if @roster_square.update(roster_square_params)\n format.html { redirect_to @roster_square, notice: 'Roster square was successfully updated.' }\n format.json { render :show, status: :ok, location: @roster_square }\n else\n format.html { render :edit }\n format.json { render json: @roster_square.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @square = Square.find(params[:id])\n end", "def edita\n @square = Square.find(params[:id])\n end", "def edit\n respond_with(@sicoss_location)\n end", "def updateb_squares\n # add square to roster\n if params[:editb_add] \n if params[:add_square_id].present?\n @student.squares << Square.find(params[:add_square_id])\n end\n redirect_to editb_student_path(@student)\n\n # remove square from roster\n elsif params[:editb_remove]\n if params[:remove_square_id].present?\n @student.squares.delete(Square.find(params[:remove_square_id]))\n end\n redirect_to editb_student_path(@student)\n end\n end", "def edit\n respond_with(@sicoss_damaged)\n end", "def edit\n respond_with(@sicoss_situation)\n end", "def edit\n @resident = Resident.find(params[:id])\n @all_rooms = Room.all()\n end", "def edit\n respond_with(@sicoss_format)\n end", "def edit\n respond_with(@sicoss_activity)\n end", "def update\n @rooster = Rooster.find(params[:id])\n\n respond_to do |format|\n if @rooster.update_attributes(params[:rooster])\n format.html { redirect_to @rooster, notice: 'Rooster was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rooster.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @square = Square.find(params[:id])\n\n respond_to do |format|\n if @square.update_attributes(params[:square])\n format.html { redirect_to @square, notice: 'Square was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @square.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @square.update(square_params)\n format.html { redirect_to squares_path, notice: 'Square was successfully updated.' }\n format.json { render :show, status: :ok, location: @square }\n else\n format.html { render :edit }\n format.json { render json: @square.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @socio_rg.update(socio_rg_params)\n format.html { redirect_to @socio_rg, notice: 'Socio rg was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @socio_rg.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @square = Square.find(params[:id])\n\n respond_to do |format|\n if @square.update_attributes(params[:square])\n format.html { redirect_to(@square, :notice => 'Square was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @square.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @athletes_roster = AthletesRoster.find(params[:id])\n\n respond_to do |format|\n if @athletes_roster.update_attributes(params[:athletes_roster])\n format.html { redirect_to(@athletes_roster, :notice => 'Athletes roster was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @athletes_roster.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @sour = @swit.sours.find(params[:id])\n respond_to do |format|\n if @sour.update(sour_params)\n format.html { redirect_to [@swit, @sour], notice: 'Sour was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sour.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n respond_with(@sicoss_regimen_type)\n end", "def update\n @draft_roster = DraftRoster.find(params[:id])\n\n respond_to do |format|\n if @draft_roster.update_attributes(params[:draft_roster])\n format.html { redirect_to team_draft_roster_path(@team, @draft_roster), notice: 'Draft roster was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @draft_roster.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the square is used for the specific student. Unused at the moment
def is_student_square(square) @is_square = false @student_squares.each do |student_square| if square.id == student_square.square_id @is_square = true break end if @is_square != true @is_square = false end end if @is_square == false @not_student_squares.push(square) end @is_square end
[ "def get_student_squares( student)\n the_squares = student.squares\n if the_squares.nil? || the_squares.empty?\n # no default squares for student, so use all squares at the school\n the_squares = Square.where(school_id: student.school_id)\n end\n the_squares\n end", "def squares_valid?\n (0...3).each do |sq_i|\n (0...3).each do |sq_j|\n square = []\n (0...3).each do |i|\n (0...3).each do |j|\n square << @board[sq_i * 3 + i][sq_j * 3 + j]\n end\n end\n assigned_values = square.reject { |c| c == '_' }\n unless assigned_values == assigned_values.uniq\n return false\n end\n end\n end\n true\n end", "def square?()\n return (@height == @width) & (@type == \"rectangle\")\n end", "def isSquareAttackedBy?(coord,colour, board)\n board.pieces[colour].each do |pieceType, listOfCoord|\n listOfCoord.each do |fromCoord, piece| \n m = Move.new(board, piece, coord, fromCoord)\n return true if isLegalMove?(m)\n end\n end\n return false\n end", "def square? \n (@rows == @cols) && @rows > 0 ? true : false\n end", "def valid_in_square?(row_index, column_index, value)\n # Top row of the square\n square_row = 3 * (row_index / 3)\n # Starting column of the square\n square_col = 3 * (column_index / 3)\n\n # Get the indices for the 4 open positions in the square\n # (ignoring values in the row+column the value is in)\n row_index_1 = (row_index + 2) % 3\n row_index_2 = (row_index + 4) % 3\n col_index_1 = (column_index + 2) % 3\n col_index_2 = (column_index + 4) % 3\n\n # Check the 4 open positions\n return false if @board[square_row + row_index_1][square_col + col_index_1] == value\n return false if @board[square_row + row_index_2][square_col + col_index_1] == value\n return false if @board[square_row + row_index_1][square_col + col_index_2] == value\n return false if @board[square_row + row_index_2][square_col + col_index_2] == value\n true\n end", "def real_student?\n student? && !phantom\n end", "def attempt_solution_by_only_square_rule\n only_square_rule(@row_members)\n only_square_rule(@column_members)\n only_square_rule(@square_members)\n end", "def solved?\n return @squares.size == 13\n end", "def is_squared?()\n self.getCls == self.getRws ? (return true) : (return false)\n end", "def any_board_space?(available_squares)\n available_squares.any?\n end", "def check_square\n begin\n @colt_property.checkSquare(@colt_matrix)\n rescue java.lang.IllegalArgumentException\n raise \"rows != columns. Not square matrix\"\n end\n end", "def square_occupied?(x, y)\n game.pieces.exists?(position_x: x, position_y: y)\n end", "def square?\n width == height\n end", "def tutored_student?(student)\n self.courses.any? { |course| course.student == student}\n end", "def checkStress(syllable)\n # this catches the first syllable\n if syllable == nil\n return true\n end\n\n # if the previous syllable had stress\n # then we shouldn't apply the rule\n if syllable.hasStress\n return false\n end\n\n # return true otherwise\n return true\nend", "def square?\n width == height\n end", "def isMine(x, y)\n if @squares[x][y].value == MINE_CHARACTER\n return true\n else\n return false\n end\n end", "def square?(num)\n Math.sqrt(num) % 1 == 0\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get an Array of all scripts that have been imported into the Plot.
def imported_scripts @imported_scripts ||= [] end
[ "def get_script_list\n @scripts = Dir.glob(\"#{@config[:scripts_directory]}/*.rb\")\n @scripts.map { |filename|\n filename[0...-3]\n }\n end", "def modules_imported_script\n Array.new.tap { |scripts|\n scripts.concat bot_modules.usable(self).map(&:script)\n scripts.push self.script\n }.join('')\n end", "def get_scripts\n return [] unless page_exists?\n\n # Get all the script sources (URLs), using Nokogiri\n scripts_links = get_doc.css('script').map{ |script| script['src'] }.compact\n\n # Create the absolute path of the scripts\n scripts_links.map!{ |script| create_absolute_url( script ) }\n\n return scripts_links.uniq # Return links to scripts without duplicates\n end", "def get_scripts\n return [] if not @history or not @script_dir\n\n @scripts ||= upgrade_scripts(@script_dir, @history.get_last_script)\n @scripts\n end", "def scripts\n Dir.glob(File.join(script_dir, \"*.rb\")).inject([]) do |a, e|\n Kernel.load(e)\n a + [initialize_script(e)]\n end\n end", "def script_list\n Dir['script/*'].map{|f| File.basename(f, '.*')}\nend", "def get_full_scripts\n \n full_scripts = []\n \n if parent\n full_scripts.concat(ThemeManager.instance.theme(parent).scripts)\n end\n \n full_scripts.concat(@scripts)\n \n return full_scripts\n \n end", "def scripts\n script_tag(fancyviews.included_scripts.map do |name, js|\n \"\\n/* -- #{name} -- */\\n\" + js\n end.join)\n end", "def script_names\n property_values('script_name')\n end", "def read_scripts(scripts)\n files = Dir.entries(scripts).select{ |f| File.file? File.join(scripts, f) }\n return files\n end", "def scripts\n\t\t@scripts.each { |script| yield script } if block_given?\n\n\t\t@scripts\n\tend", "def script_filenames filename\n script_processor.filenames filename\n end", "def script_aliases\n arr = Array.new\n @script_aliases.each do |key, value|\n arr.push(key)\n end\n return arr\n end", "def scripts\n begin\n scripts = send_command('LISTSCRIPTS')\n rescue SieveCommandError => e\n raise e, \"Cannot list scripts: #{e}\"\n end\n return scripts unless block_given?\n scripts.each { |name, status| yield(name, status) }\n end", "def get_additional_scripts\n ctrl_script_url = \"page/\" + params[:controller] + \"/overall.js\"\n page_script_url = \"page/\" + params[:controller] + \"/\" + params[:action] + \".js\"\n\n res = Array.new\n\n if check_asset_existency ctrl_script_url\n res << \"/assets/#{ctrl_script_url}\"\n end\n\n if check_asset_existency page_script_url\n res << \"/assets/#{page_script_url}\"\n end\n \n return res\n end", "def find_scripts(dir, gem_units)\n scripts = []\n\n dir = File.expand_path(dir)\n Dir.glob(File.join(dir, \"**/*.rb\")).map do |script_file|\n scripts << script_file\n end\n\n scripts\n end", "def all_javascript_paths\n all_paths = []\n all_paths += @javascripts\n all_paths += @background_scripts\n all_paths += @content_scripts.map { |cs| cs.javascripts }.compact\n all_paths.flatten.uniq\n end", "def include_js\n []\n end", "def find_scripts(dir)\n scripts = []\n\n dir = File.expand_path(dir)\n Dir.glob(File.join(dir, \"**/*.rb\")).reject{|f| f[\"/spec/\"] || f[\"/specs/\"] || f[\"/test/\"] || f[\"/tests/\"]}.map do |script_file|\n scripts << script_file\n end\n\n scripts\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get an Array of the Plot's current Syntaxes.
def syntaxes playbook.syntaxes end
[ "def syntaxes\n Uv.syntaxes\n end", "def list_syntaxes\n uri = URI.parse(\"#{BASE_URL}/syntaxes\")\n response = JSON.parse(@client.get(uri).body)\n return response['syntaxes'].map { |obj| Pastee::Syntax.new(obj) } if response['success']\n\n throw_error(response)\n end", "def syntaxes\n playbook.syntaxes\n end", "def syntax\n contents.zip(gaps).flatten\n end", "def syntax_errors\n (@syntax_errors ||= [])\n end", "def syntax(syntax = nil)\n @syntax = syntax if syntax\n syntax_list = []\n if parent\n syntax_list << parent.syntax.to_s.gsub(/<[\\w\\s-]+>/, '').gsub(/\\[[\\w\\s-]+\\]/, '').strip\n end\n syntax_list << (@syntax || name.to_s)\n syntax_list.join(\" \")\n end", "def getAllTexts intervalRange\n texts = [[]]\n curr_alts = []\n # Go through the interval token by token. It is indexed by token, \n # not by character\n intervalRange.each do |j|\n tok = @tokens.get(j)\n\n # If the text is parsed code or whitespace\n if (tok.channel == 0 || tok.channel == 1)\n texts.each do |text|\n text << tok.getText\n end\n\n # Get directives\n elsif (tok.channel == 2)\n d = strip_directive(tok)\n # TODO make sure combinations of alts are handled\n case d.command\n when\"ALT\"\n # Trigger creation of alternative magnet\n curr_alts << []\n texts.each do |text|\n curr_alt = Array.new(text)\n curr_alt << d.arg\n curr_alts.last << curr_alt\n end\n when \"ENDALT\"\n texts << curr_alts.pop\n end\n end\n end\n\n ret = texts.map {|t| t.join}\n # puts \"Ret\"\n # pp ret\n return ret\n end", "def augments_syntax_tokens; end", "def current_snippets\n self[Vim.evaluate('&filetype')]\n end", "def augments_syntax_tokens\n attributes.fetch(:augmentsSyntaxTokens)\n end", "def symbols\n return @keyword_set.to_a\n end", "def syntax\n\t\treturn self.schema.ldap_syntaxes[ self.syntax_oid ]\n\tend", "def pygments_stylesheet_data style = nil\n (SyntaxHighlighter.for 'pygments').read_stylesheet style\n end", "def expressions\n return @expressions\n end", "def highlighted_lines(options)\n JSON.parse('{' + options.to_s + '}')['hl_lines'] || []\n end", "def tokens\n @tokens ||= []\n end", "def tokens\n results = []\n PyCall::List.(@py_span).each do |py_token|\n results << Token.new(py_token)\n end\n results\n end", "def syntax\n\t\tif oid = self.syntax_oid\n\t\t\treturn self.schema.ldap_syntaxes[ oid ]\n\t\telsif self.sup\n\t\t\treturn self.sup.syntax\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def tokens\n @tokens ||= []\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return => An Array of Squirrel instances
def squirrels # self.nests # what are my nests? self.nests.map do |nest| # Nest instance nest.squirrel end # binding.pry # [#<Nest>, #<Nest>, #<Nest>] # || # \/ # [#<Squirrel>, #<Squirrel>, #<Squirrel>] end
[ "def my_squirrels\n my_nests.map do |nest|\n nest.squirrel\n end\n end", "def index\n @squirrels = Squirrel.all\n end", "def queries\n qrs = []\n self.each_query {|qr| qrs << qr }\n qrs\n end", "def get_shelves\n shelves = [@shelf_ag, @shelf_hp, @shelf_qz]\n return shelves\n end", "def my_squirrels\n # which one knows about BOTH the trees and the nests?\n my_nests.map do |nest|\n nest.squirrel.name\n end\n end", "def instances(return_type)\n return nil unless(active_rdf? && is_iri?)\n qry = ActiveRDF::Query.new(URI).distinct.select(:s)\n qry.where(:s, RDF.type, self)\n qry.execute\n end", "def sparqls\n Enumerator.new do |y|\n begin\n anchored_pgps.each do |anchored_pgp|\n GraphFinder.new(anchored_pgp, @endpoint, @graph_uri, @options)\n .queries\n .each { |q| y << q[:sparql] }\n end\n rescue OpenSSL::SSL::SSLError => e\n Lodqa::Logger.debug 'Sparql SSL connection failed', error_message: e.message\n end\n end\n end", "def questions\n qs = []\n qs |= self.class.questions if self.class.respond_to? :questions\n qs |= (@_questions||=[])\n qs.map{|q| q.for_instance(self) }\n end", "def instances #:nodoc:\n r = []\n ObjectSpace.each_object(self) { |mod| r << mod }\n r\n end", "def find_all\n result = self.database.get self.java_class\n ret = []\n result.each { |x| ret << x }\n ret\n end", "def sets \n all = instance.all_explorator::set \n \n if all == nil\n Array.new \n end\n all\n end", "def gymclasses()\n sql = \"SELECT gymclasses.* FROM gymclasses INNER JOIN bookings\n ON gymclasses.id = bookings.gymclass_id WHERE client_id = $1\"\n values = [@id]\n gymclasses = SqlRunner.run(sql,values)\n result = gymclasses.map{|gymclass| GymClass.new(gymclass)}\n return result\n end", "def questions\n extracted_questions = []\n\n unless self.qp_questions.nil?\n self.qp_questions.each do |question| \n extracted_questions.push(Question.new(question))\n end \n end\n\n return extracted_questions\t\t\t\n\t\tend", "def shoes\n results = DATABASE.execute(\"SELECT * FROM shoes WHERE location_id = #{@id};\")\n\n store_results = []\n\n results.each do |hash|\n store_results << Shoe.new(hash)\n end\n\n return store_results\n end", "def find_all\n result = MysqlAdapter.execute \"SHOW DATABASES\"\n return [] if result.num_rows == 0\n\n array = []\n while row = result.fetch_row\n instance = new\n instance.name = row[0]\n array << instance\n end\n\n array\n end", "def songs\n Song.all_by_artist(self)\n end", "def rq_sp_resources_all\n rq_sp_resources = Array.new\n item_sp_resource_invs.each do |item_sp_resource_inv|\n rq_sp_resources << item_sp_resource_inv.sp_resource\n end\n return rq_sp_resources\n end", "def songs\n #use select to iterate thru songs\n Song.all.select{|song| song.artist == self}\n end", "def procedure_sets\n @objects.deref!(resources[:ProcSet]) || []\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /job_requests/1 PUT /job_requests/1.json
def update begin @job_request = job_requests.find( params[ :id ] ) rescue ActiveRecord::RecordNotFound @job_request = nil end respond_to do |format| if @job_request && @job_request.update_attributes( params[ :job_request ] ) format.html { redirect_to root_path, notice: "Job Requests Updated Successfully"} format.json { head :no_content } else format.html { redirect_to root_path, notice: "Update Failed" } format.json { render json: @job_request.errors, status: :unprocessable_entity } end end end
[ "def update\r\n begin\r\n @job_request = @organization.job_requests.find( params[ :id ] )\r\n rescue ActiveRecord::RecordNotFound\r\n @job_request = nil\r\n end\r\n\r\n respond_to do |format|\r\n if @job_request && @job_request.update_attributes( params[ :job_request ] )\r\n format.html { redirect_to root_path, notice: \"Job Requests Updated Successfully\"}\r\n format.json { head :no_content }\r\n else\r\n format.html { redirect_to root_path, notice: \"Update Failed\" }\r\n format.json { render json: @job_request.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n job = Job.find(params[:id])\n job.update_attributes(job_params)\n render json: job\n end", "def update\n @job = Job.find(params[:id])\n\n if @job.update(job_params)\n head :no_content\n else\n render json: @job.errors, status: :unprocessable_entity\n end\n end", "def create_batch_job(job_id)\n request = Net::HTTP::Put.new(\"/jobs/#{job_id}\")\n response = http.request(request)\n handle_response({ request_method: request.method, request_path: request.path }, response)\n end", "def save\n #puts \"Saving job:\\n -X PUT #{@@client['jobs']}/#{@id} -H 'Content-Type: application/json' -d '#{self.to_json}'\"\n response = @client[\"jobs/#{@id}\"].put(self.to_json,\n {:content_type => :json,\n :accept => :json}).body\n JSON.parse(response)\n end", "def update\n respond_to do |format|\n if @pending_job.update(pending_job_params)\n format.html { redirect_to @pending_job, notice: 'Pending job was successfully updated.' }\n format.json { render :show, status: :ok, location: @pending_job }\n else\n format.html { render :edit }\n format.json { render json: @pending_job.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @jobs = Job.all\n respond_to do |format|\n if @job.update(job_params)\n format.html { redirect_to @job, notice: 'Successfully updated.' }\n format.json { render :show, status: :ok, location: @job }\n else\n format.html { render :edit }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @create_job.update(create_job_params)\n format.html { redirect_to @create_job, notice: 'job was successfully updated.' }\n format.json { render :show, status: :ok, location: @create_job }\n else\n format.html { render :edit }\n format.json { render json: @create_job.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @launched_job.update(launched_job_params)\n format.html { redirect_to @launched_job, notice: 'Launched job was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @launched_job.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @batch_job.update(batch_job_params)\n format.html { redirect_to @batch_job, notice: 'Batch job was successfully updated.' }\n format.json { render :show, status: :ok, location: @batch_job }\n else\n format.html { render :edit }\n format.json { render json: @batch_job.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @training_job = Training::Job.find(params[:id])\n\n respond_to do |format|\n if @training_job.update_attributes(params[:training_job])\n format.html { redirect_to @training_job, notice: 'Job was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @training_job.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @analysis_job = AnalysisJob.find(params[:id])\n\n respond_to do |format|\n if @analysis_job.update_attributes(params[:analysis_job])\n format.json { head :no_content }\n else\n format.json { render json: @analysis_job.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @labeljob = Labeljob.find(params[:id])\n\n respond_to do |format|\n if @labeljob.update_attributes(params[:labeljob])\n format.html { redirect_to @labeljob, notice: 'Labeljob was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @labeljob.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_sauce_job_status(json_data = {})\n host = \"http://#{settings.sl_user}:#{settings.sl_api_key}@saucelabs.com\"\n path = \"/rest/v1/#{settings.sl_user}/jobs/#{session_id}\"\n url = \"#{host}#{path}\"\n ::RestClient.put url, json_data.to_json, content_type: :json, accept: :json\n end", "def update\n @job_info_session = JobInfoSession.find(params[:id])\n\n if @job_info_session.update(job_info_session_params)\n head :no_content\n else\n render json: @job_info_session.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @act_job.update(act_job_params)\n format.html { redirect_to @act_job, notice: 'Act job was successfully updated.' }\n format.json { render :show, status: :ok, location: @act_job }\n else\n format.html { render :edit }\n format.json { render json: @act_job.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n request = Request.find_by_id(params[:id])\n if request\n request.status = 1\n if request.save\n render json: {\n status: 'success',\n message: 'Request marked as fulfilled',\n },\n status: :ok\n else\n render json: {\n status: 'error',\n message: 'Request failed',\n data: request.errors,\n },\n status: :unprocessable_entity\n end\n else\n render status: :unauthorized\n end\n end", "def update\n respond_to do |format|\n if @jobseeker.update(jobseeker_params)\n format.html { redirect_to @jobseeker, notice: 'Jobseeker was successfully updated.' }\n format.json { render :show, status: :ok, location: @jobseeker }\n else\n format.html { render :edit }\n format.json { render json: @jobseeker.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @job_item = @job.job_items.find(params[:id])\n\n respond_to do |format|\n if @job_item.update_attributes(params[:job_item])\n format.html { redirect_to [@job, @job_item], notice: 'Job item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job_item.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
slurp CDS > Protein a.) common_data
def slurp_commondata(f) var1=Hash.new File.new(f,'r').each_line{|l| l.chomp! l.gsub!('"','') cols= l.split(/\t/) var1[cols[0]]=cols[1] } return var1 end
[ "def read_ICECommon\n # ICE_COMMON_FILE\n if @CTFile == nil\n ice_common_data = Common.file_read(\"#{ICE_COMMON_FILE}\")\n ice_common_data.each{|line|\n if line[0] != 35 && line.size != 0 # Comment Line\n @ICECommonSignal << line.split[0].strip\n end\n }\n @ICECommonSignal.uniq.compact\n else\n # \"-ct\" option\n get_csv = GetCSV.new\n @CT_PortInf = get_csv.reader_CT(@CTFile)\n @CT_PortInf.each{|data|\n # get Pin Name\n if data.FPGASignal != nil\n @ICECommonSignal_CT << data.FPGASignal\n end\n }\n\n end\n end", "def split_refseq\n # prepare output files\n system(%Q[cut -f4 #{$prepare_dir}/refseq_genes_result.tsv | cut -c1-5 | sort | uniq > #{$prepare_dir}/refp_prefix_list.txt ]) # get exist prefix list of protein_id\n FileUtils.mkdir_p(\"#{$prepare_dir}/refp\") unless File.exist?(\"#{$prepare_dir}/refp\")\n refp_output = {}\n File.open(\"#{$prepare_dir}/refp_prefix_list.txt\") do |f|\n f.each_line do |line|\n prefix = line.chomp.strip\n refp_output[prefix] = File.open(\"#{$prepare_dir}/refp/#{prefix}.dat\", \"w\")\n end\n end\n refp_output[\"no_protein_id\"] = File.open(\"#{$prepare_dir}/refp/no_protein_id.dat\", \"w\") # protein_id is optional\n\n File.open(\"#{$prepare_dir}/refseq_genes_result.tsv\") do |f|\n f.each_line do |line|\n columns = line.chomp.strip.split(\"\\t\")\n prefix = (columns[3].nil? || columns[3] == \"\") ? \"no_protein_id\" : columns[3][0..4] # protein_id is optional\n refp_output[prefix].puts line.chomp.strip\n end\n end\n refp_output.each do |k, v|\n v.flush\n v.close\n end\nend", "def extract_genes file_prefix\n\n if ! File.exists? file_prefix+\".cds.fasta\"\n\n puts \" ..extracting genes from #{file_prefix}\"\n\n fasta_f = file_prefix + \".fasta\"\n gbk_f = file_prefix + \".gb\"\n gbk_parser = GenbankParser.new(gbk_f)\n cds = gbk_parser.getFtsProtSequences(\"#{File.basename(file_prefix)}\", true)\n\n File.open(file_prefix+\".cds.fasta\",\"w\") do |fout|\n fout.write(cds)\n end\n\n fts_f = file_prefix + \".gb.fts.tsv\"\n fasta_parser = FastaParser.new(fasta_f)\n trna_output = \"\"\n rrna_output = \"\"\n\n File.open(fts_f, \"r\").drop(1).each do |f|\n lA = f.chomp!.split(\"\\t\")\n next if lA[5] == \"1\" # skip partial gene\n basename = File.basename(fasta_f).gsub('.fasta','')\n header = \"#{basename}|#{lA[1]}|#{lA[6]}|#{lA[7]}|#{lA[8]}|#{lA[9]}\"\n if lA[0] == \"tRNA\"\n trna_output += fasta_parser.getSeqLoc(lA[1], \"#{lA[2]}..#{lA[3]}\", \"#{lA[4]}\", 0, header)\n elsif lA[0] == \"rRNA\"\n rrna_output += fasta_parser.getSeqLoc(lA[1], \"#{lA[2]}..#{lA[3]}\", \"#{lA[4]}\", 0, header)\n end\n end\n\n # write output\n File.open(file_prefix+\".trna.fasta\", \"w\") do |f_out|\n f_out.write(trna_output)\n end\n\n File.open(file_prefix+\".rrna.fasta\", \"w\") do |f_out|\n f_out.write(rrna_output)\n end\n\n end\n\nend", "def read_data_to(dir, data); end", "def findAllPepLocations\n hits = @doc.xpath(\"//#{@xmlns}search_hit\")\n #alt_prots = @doc.xpath(\"//#{@xmlns}alternative_protein\")\n all = []\n @locations = []\n i = 0\n \n # Parses out each peptide and protein\n hits.each do |hit|\n all << [hit.xpath(\"./@peptide\").to_s, proteinID(hit.xpath(\"./@protein\").to_s)]\n if !hit.xpath(\".//#{@xmlns}alternative_protein\").empty?\n alt_prot_arr = hit.xpath(\".//#{@xmlns}alternative_protein\")\n alt_prot_arr.each do |alt_prot_node|\n pro = proteinID(alt_prot_node.xpath(\"./@protein\").to_s)\n all << [hit.xpath(\"./@peptide\").to_s, proteinID(alt_prot_node.xpath(\"./@protein\").to_s)]\n end \n end\n i += 1\n end\n \n \n all.uniq!\n dataHash = Hash.new\n \n @database = @databaseName\n Ms::Fasta.foreach(@database) do |entry|\n# Ms::Fasta.foreach(\"./spec/test_files/C_albicans_SC5314_version_A21-s02-m01-r07_orf_trans_all_plus_contaminants_DECOY.fasta\") do |entry|\n @numsequences += 1\n pID = \"\"\n if @database == \"C_albicans_SC5314_version_A21-s02-m01-r07_orf_trans_all_plus_contaminants_DECOY.fasta\" #if de Vital\n candi_orf_header = entry.header.split(\"\\s\")[0] #if entry.header =~ /^orf/\n pID = proteinID(candi_orf_header)\n else #esto es como estaba. Quitar el if, este else y el end y dejar solo la linea sig\n pID = proteinID(entry.header)\n end\n dataHash[pID] = entry.sequence\n @proteinIndices << pID\n end\n \n all.each do |set|\n if dataHash[set[1]] != nil\n startVal = dataHash[set[1]].scan_i(set[0])[0]\n @locations << [set[0], set[1], startVal + 1, startVal + set[0].length] unless startVal == nil\n end\n end\n end", "def predict_secondary_structure_all()\n non_ambig_dir = \"endo_nonAmbig\"\n proteins=Dir.glob(\"#{non_ambig_dir}/*/seq_aa.fasta\")\n fastas_to_combine = \"\"\n proteins.each do |f|\n fastas_to_combine = \"#{fastas_to_combine} #{f}\"\n end\n system (\"cat #{fastas_to_combine} > #{non_ambig_dir}/endo_all_nonAmbig.fasta\\n\")\n system (\"#{blast_dir}/formatdb -p T -i #{non_ambig_dir}/endo_all_nonAmbig.fasta -n #{non_ambig_dir}/endoBlastdb\")\nend", "def read\n\t\t\n\t\t# Parse NMEA sentence until we find one we can use\n\t\twhile true do\n\t\t\tnmea = next_sentence\n\t\t\tdata = parse_NMEA(nmea)\n\t\t\t\n\t\t\t# Sentence parsed, now merge\n\t\t\tunless data[:last_nmea].nil?\n\t\t\t\t@collected << data[:last_nmea]\n\t\t\t\t@collected.uniq!\n\t\t\t\t@data.merge!(data)\t\n\t\t\t\t\n\t\t\t\tbreak\n\t\t\tend\n\t\t\t\n\t\tend\n\n\t\treturn @data\n\tend", "def merge_aln_crp(output_file, full_aln_path, full_crp_path)\n array_crp = get_crp(full_aln_path, full_crp_path)\n \n array_crp.each_with_index do |line, index|\n # puts \"#{line}\"\n if not line[1].match(/^</)\n output_file.write(line[1].to_s)\n output_file.write(line[2].to_s)\n output_file.write(line[3].to_s)\n output_file.write(\"\\n\")\n end\n end\n end", "def main\n db = HTPH::Hathidb::Db.new();\n conn = db.get_conn();\n @log = HTPH::Hathilog::Log.new();\n @tables = %w[isbn issn lccn oclc title enumc pubdate publisher sudoc].sort;\n\n # Look up attributes and values for the documents.\n union_sql = @tables.map { |x|\n format('SELECT \\'%s\\' AS t, hx.str_id, hx.gd_id FROM hathi_%s AS hx WHERE hx.gd_id = ?', x, x)\n }.join(\"\\nUNION\\n\");\n\n @union_q = conn.prepare(union_sql);\n @ping_q = conn.prepare(\"SELECT 1\");\n @ping_t = Time.new();\n # File with ^(cluster|solo)\\t\\d+(,(\\d+,)\\d*)$ on each line\n # output from only_join_on_ids.rb.\n hdin = HTPH::Hathidata::Data.new(ARGV.shift).open('r');\n @solos = HTPH::Hathidata::Data.new(\"solos_$ymd.tsv\").open('w');\n @rels = HTPH::Hathidata::Data.new(\"related_$ymd.tsv\").open('w');\n @dups = HTPH::Hathidata::Data.new(\"duplicates_$ymd.tsv\").open('w');\n @huge = HTPH::Hathidata::Data.new(\"huge_$ymd.tsv\").open('w');\n i = 0;\n # Any bigger than this and we can't even.\n cluster_max_size = 25000;\n\n # Go through input file\n hdin.file.each_line do |line|\n next if line !~ /^(solo|cluster)\\t/;\n line.strip!;\n (type, idstr) = line.split(\"\\t\");\n ids = idstr.nil? ? [] : idstr.split(',').map{|x| x.to_i};\n i += 1;\n # if i % 1000 == 0 then\n @log.d(\"input line #{i} has #{ids.size} ids\");\n # end\n\n if type == 'cluster' then\n if ids.size > cluster_max_size then\n # This is too big. We have to deal with them differently.\n @huge.file.puts(line);\n else\n # This is where we actually look closer.\n analyze_cluster(ids);\n end\n elsif type == 'solo' then\n # Just put solos in solo file.\n @solos.file.puts(line);\n end\n end\n hdin.close();\n [@solos, @rels, @dups, @huge].each do |f|\n f.close();\n end\nend", "def read_other_csvs(directory_name)\n Import.find_all_by_directory_name(directory_name).each do |import| \n if !import.file_name.eql?(METADATA_FILE) \n update_status(import, :in_progress)\n unique_id = import.file_name.split(\".csv\")[0]\n location = Location.find_by_unique_id(unique_id)\n if location.present?\n delete_query = \"DELETE FROM location_data where location_id = #{location.id}\"\n ActiveRecord::Base.connection.execute(delete_query)\n\n CSV.foreach(%(#{directory_name}/#{import.file_name})) do |row|\n date_time = (row[1].to_i * 60) + 1388534400\n Datum.create(:location_id => location.id, :date_time => date_time, :instantaneous_power => row[1])\n update_status(import, :success)\n end\n else\n update_status(import, :failed, \"Location with unique_id #{unique_id} not found\")\n end\n end\n end\n end", "def get_crp(full_aln_path, full_crp_path)\n array_crps = []\n arr = []\n flag_para = false\n alns = get_aln(full_aln_path)\n index_aln = 0\n # File.open(DATA_PATH + \"/full_crp_kigoshi.txt\", 'r').each_with_index do |line, index|\n File.open(full_crp_path, 'r').each_with_index do |line, index| \n if (index%3 == 0)\n arr = []\n arr << line\n next\n end\n\n if (index - 1)%3 == 0\n arr << line\n next\n end\n\n if (index - 2)%3 == 0\n arr << line\n arr << alns[index_aln]\n array_crps << arr\n index_aln += 1\n end\n end\n return array_crps\n end", "def obedience_process_main_file(filename, sid)\n mainfile = File.open(filename, 'r')\n line = mainfile.gets\n data = line.split('; ')\n #puts \"Name=#{data[0]}, City=#{data[1]}, State=#{data[2]}, Date=#{data[3]}\"\n show = Show.find_or_create_by_show_id(sid, :name=>data[0], :city=>data[1],\n :state=>data[2], :date=>data[3])\n puts \"Obedience Show id: #{show.id}\"\n while (line = mainfile.gets)\n data = line.split('; ')\n puts \" Class=#{data[0]},Judge Name=#{data[1]}, Judge id=#{data[2]}, Dogs=#{data[3]}\"\n judge = Judge.find_or_create_by_judge_id(data[2], :name=>data[1]) \n obed = Obedclass.find_or_create_by_judge_id_and_show_id_and_classname(judge.id, show.id, data[0],:dogs_in_class=>data[3])\n #puts \" Judge id: #{judge.id} Class id: #{obed.id}\"\n end\n end", "def person_from_plink_file(target_subject)\n File.open(@options.ped_file).each_line do |line|\n parts = line.chomp.split(/\\s/)\n #Family_ID Person_ID\tPaternal_ID\tMaternal_ID\tSex Phenotype calls\n next unless parts[1].to_i == target_subject\n \n person = Person.new(parts[0],parts[1],parts[2],parts[3],parts[4],parts[5])\n offset = 6\n marker = 0\n alleles = nil\n parts.slice(offset,parts.size).each_with_index do |c,i|\n if nil == alleles then\n alleles = [c]\n else\n alleles.push(c)\n geno = Genotype.new(nil,alleles)\n person.add_genotype(geno)\n marker+=1\n alleles = nil\n end\n end\n return person\n end\n return nil\n end", "def load_shared_items(item_class = RPG::Item)\r\r\n \r\r\n container = $game_party.item_container(item_class)\r\r\n file = File.new(\"000_MLP_Shared.rvdata2\",\"r\")\r\r\n counter = 0\r\r\n @shared_items = []\r\r\n \r\r\n while (line = file.gets)\r\r\n counter += 1\r\r\n if counter == 11\r\r\n data = line.split('|')\r\r\n data.delete_at(3)\r\r\n data.delete_at(0)\r\r\n puts \"Shared Data Index:\\n#{data}\"\r\r\n puts \"----------------------------------------------\"\r\r\n end\r\r\n \r\r\n end\r\r\n file.close\r\r\n \r\r\n index = data[0].split(':').at(1)\r\r\n if !index.nil?\r\r\n index[0] = index[index.length - 1] = \"\"\r\r\n index = index.split(',')\r\r\n \r\r\n index.each do |item|\r\r\n item = item.split(\"=>\")\r\r\n id = item[0].to_i\r\r\n num = item[1].to_i\r\r\n @shared_items.push([id,num])\r\r\n end\r\r\n end\r\r\n \r\r\n puts \"#{@shared_items}\"\r\r\n end", "def prepare_identities_from_files; end", "def readPhobius_sp\n # Initialize all Variables \n query = readQuery\n if( !File.exists?( self.actions[0].flash['phobiusfile'] ) ) then return {} end\n ret={'sppred' =>\"\"}\n ar = IO.readlines( self.actions[0].flash['phobiusfile'])\n \n # Signal Peptide\n sp_start_array = Array.new\n sp_end_array = Array.new\n \n # Cleavage Site\n cs_start_array = Array.new\n cs_end_array = Array.new\n \n \n result=\"\"\n \n \n # Calculate Output from data \n ar.each do |line|\n \n # Check for Signal Peptide\n line =~ /SIGNAL/\n if $& then\n line =~ /(\\d+)\\s+(\\d+)/\n sp_start_array.push($1)\n sp_end_array.push($2)\n logger.debug \"L80 SIGNAL PEPTIDE Start#{$1} End #{$2} \"\n end\n \n \n # Check for Cleavage Site in Signal\n line =~ /C-REGION/\n if $& then\n line =~ /(\\d+)\\s+(\\d+)/\n cs_start_array.push($1)\n cs_end_array.push($2)\n logger.debug \"L80 Cleavage Site Start#{$1} End #{$2} \"\n end\n \n end\n \n result=\"\"\n for i in 0..@query_sequence_length\n result = result+ \"--\" \n end\n \n # Signal Peptide\n sp_start_array.length.times { |i|\n result[sp_start_array[i].to_i-1..sp_end_array[i].to_i] ='S'*( sp_end_array[i].to_i+1 - sp_start_array[i].to_i )\n }\n \n # Cleavage Site\n cs_start_array.length.times { |i|\n result[cs_start_array[i].to_i-1..cs_end_array[i].to_i] ='C'*( cs_end_array[i].to_i+1 - cs_start_array[i].to_i )\n }\n \n ret['sppred'] += result\n \n ret\n end", "def find_transcript_pbs(fasta)\n proteins = {}\n fasta = (fasta || '').gsub(/(n|N)/, '')\n unless fasta.empty?\n begin\n uri = URI(@config[:rbpdb][:url] + @config[:rbpdb][:pbs_path])\n res = Net::HTTP.post_form(\n uri,\n 'thresh' => 0.8,\n 'seq' => fasta\n )\n page = Nokogiri::HTML(res.body)\n page.css('table.pme-main tr.pme-row-0, table.pme-main tr.pme-row-1').each do |row|\n # Fetch base data.\n pos = Container::Position.new(\n score: row.children[1].text[0...-1].to_i,\n start: row.children[3].text.to_i,\n end: row.children[4].text.to_i,\n seq: row.children[5].text\n )\n\n # Fetch protein name and build result structure.\n prot = row.children[2].children[0].text.upcase\n proteins[prot] ||= Container::Protein.new(name: prot)\n proteins[prot].positions << pos\n end\n rescue StandardError => e\n puts e.message, e.backtrace\n retry\n end\n end\n proteins\n end", "def getFtProtID\n protein_id = ARGV[1]\n protId = \"\"\n @gbkObj.each_cds do |ft|\n ftH = ft.to_hash\n ftloc = ft.locations\n if ftH[\"protein_id\"][0].include? protein_id\n gene = []\n product = []\n gene = ftH[\"gene\"] if !ftH[\"gene\"].nil?\n product = ftH[\"product\"] if !ftH[\"product\"].nil?\n protId = ftH[\"protein_id\"][0] if !ftH[\"protein_id\"].nil?\n locustag = ftH[\"locus_tag\"][0] if !ftH[\"locus_tag\"].nil?\n if ftloc[0].strand == -1\n location = \"c#{ftloc[0].from}..#{ftloc[0].to}\"\n else\n location = \"#{ftloc[0].from}..#{ftloc[0].to}\"\n end\n dna = getDna(ft,@gbkObj.to_biosequence)\n seqout = dna.output_fasta(\"#{@accession}|#{location}|#{protId}|#{locustag}|#{gene[0]}|#{product[0]}\",60)\n puts seqout\n end\n end\n end", "def combined_data\n\t\t\t\t\treturn self.common_data.merge(self.specific_data)\n\t\t\t\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Takes a string as argument, and returns the first Todo object that matches the argument. Return nil if no todo is found.
def find_by_title(str) self.each do |todo| return todo if todo.title == str end nil # select { |todo| todo.title == str }.first # alt from solution end
[ "def find_by_title(todo_title)\n select { |todo| todo.title == todo_title }.first\n end", "def find_by_title(title)\n select { |todo| todo.title == title }.first\n end", "def find(todo_id)\n sql = \"SELECT * FROM todos WHERE id=$1\"\n result = Repos.db_adapter.exec(sql, [todo_id])\n Todo.new(result[0][\"value\"], result[0][\"status\"], result[0][\"id\"])\n end", "def find(identifier)\n pattern = Regexp.new identifier\n tasks.each do |task|\n return task if task.identifier =~ pattern\n end\n\n return nil\n end", "def todo_with_substring(substring) \n issue_todo = @remaining_todos.detect{ |t| !t.content.index(substring).nil? }\n issue_todo ||= @completed_todos.detect { |t| !t.content.index(substring).nil? }\n end", "def todo_with_substring(substring)\n issue_todo = @remaining_todos.detect{ |t| !t.content.index(substring).nil? }\n issue_todo ||= @completed_todos.detect { |t| !t.content.index(substring).nil? }\n end", "def first(name=nil)\n name ? find(name, false).first : matches.first\n end", "def first(name=nil)\n name.nil? ? matches.first : find(name, false).first\n end", "def todo\n todos.first\n end", "def find_first(name)\n object = build(name)\n object.retrieve\n end", "def load_todo(list, id)\n list[:todos].find { |todo| todo[:id] == id }\nend", "def load_todo(id)\n @list[:todos].find { |todo| todo[:id] == id }\nend", "def find_task task_name, source_name = nil\n # if source is specified, target it directly\n if source_name\n return lookup_task source_name, task_name\n\n # if source and task is specified in a single string\n elsif task_name.to_s.include? '#'\n source_task = task_name.split('#').reverse\n source_name = source_task[1].to_sym\n task_name = source_task[0].to_sym\n\n return lookup_task source_name, task_name\n\n # otherwise loop through sources until a template is found\n else\n @@sources.values.each do |source|\n return source.tasks[task_name.to_sym] || next\n end\n S.ay \"No `#{task_name}` task was found in any of the sources\", :error\n end\n\n return nil\n end", "def find_first(name)\n object = build(name)\n object.retrieve\n end", "def find(task_id)\n raise \"task_id is required\" if task_id.nil?\n task = @tasks.select { |task| task.id == task_id.to_i }.first\n raise \"No task with id #{task_id}\" if task.nil?\n task\n end", "def find_task(name)\n name = name.to_sym unless name.nil?\n @tasks[name]\n end", "def extract_first(str)\n extract_multi(str).first\n end", "def load_todo(list, todo_id)\n todo = list[:todos].find{|todo| todo[:id] == todo_id } || nil\n return todo if todo\n\n session[:error] = \"The specified todo was not found.\"\n redirect_and_halt\nend", "def first(c)\n if c and c.class == String\n return c\n elsif c and c.length > 0 \n return c[0]\n else\n return nil\n end\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Takes a string as argument, and marks the first Todo object that matches the argument as done.
def mark_done(str) todo = self.find_by_title(str) todo.done! if todo # find_by_title(str) && find_by_title(str).done! # alt from solution end
[ "def mark_todo\n puts \"Which todo have you finished?\"\n action = get_input.to_i\n arr_index = 0\n @todos.each do |x|\n if x[\"completed\"] == \"no\"\n arr_index = arr_index + 1\n if arr_index == action\n x[\"completed\"] = \"yes\"\n save!\n break\n end\n end\n end\n end", "def mark_as_done(todo)\n todo.mark_as_done!\n edit(todo)\n end", "def mark_as_done(todo)\n @data_object.aff_to_do &= ~todo\n end", "def mark_done(title)\n find_by_title(title)&.done!\n end", "def task_in_todo (nb)\n t = get_todo (nb)\n if t\n task_in t.chomp\n else\n puts \"No task specified\"\n end\n end", "def complete_todo\n cli.die \"That task is already completed!\" if @todo.completed?\n @todo.complete!\n puts \"#{@todo.label}: '#{@todo.todo}' marked as completed at #{@todo.stop}\"\n end", "def markDone(id)\n item = Todo.find(id)\n item.done = true\n item.save\nend", "def complete(todo)\n todo.complete\n save_todos\n end", "def todo_with_substring(substring) \n issue_todo = @remaining_todos.detect{ |t| !t.content.index(substring).nil? }\n issue_todo ||= @completed_todos.detect { |t| !t.content.index(substring).nil? }\n end", "def todo_class(todo)\n \"complete\" if todo[:completed]\n end", "def todo_with_substring(substring)\n issue_todo = @remaining_todos.detect{ |t| !t.content.index(substring).nil? }\n issue_todo ||= @completed_todos.detect { |t| !t.content.index(substring).nil? }\n end", "def change_to_todo\n @task = Task.find(params[:id])\n @task.done = false\n @task.save\n redirect_to root_path\nend", "def todo(todo=nil)\n if todo\n @todo = todo\n else\n @todo\n end\n end", "def tip_markdone(id)\n post(\"tips/#{id}/markdone\").todo\n end", "def test_mark_udone_at\n # Setup, Execute and Assert Pre-Condition (mark @todo1 done):\n @list.mark_done_at(0)\n assert_equal(true, @todo1.done?)\n\n # Setup, Execute and Assert (mark @todo1 undone and assert the not_done):\n @list.mark_undone_at(0)\n assert_equal(true, @todo1.not_done?)\n assert_equal(false, @todo1.done?)\n\n assert_raises (IndexError) { @list.mark_undone_at(1000) }\n end", "def test_mark_done_at\n @list.mark_done_at(0)\n assert_equal(true, @todo1.done?)\n\n assert_equal(false, @list.item_at(1).done?)\n assert_equal(true, @list.item_at(1).not_done?)\n\n @list.mark_done_at(2)\n assert_equal(true, @todo3.done?)\n\n assert_raises(IndexError) { @list.mark_done_at(1000) }\n end", "def mark_complete(identifier, status=true)\n complete = list.collect do |to_do|\n to_do if to_do.values.include?(identifier)\n end.compact\n complete.each do |to_do|\n if to_do.complete == false\n puts \"'#{to_do.task}' marked as complete in '#{self.name}.'\"\n else\n puts \"'#{to_do.task}' marked as incomplete in '#{self.name}.'\"\n end\n end\n list.each do |to_do|\n to_do.complete = status if to_do.values.include?(identifier)\n end\n end", "def mark_complete(name)\n this_item = find_index(name)\n #if this_item == nil\n # puts \"...item not listed...\"\n if /\\D/.match(name) || /^$/.match(name)\n @todo_items[this_item].mark_complete!\n elsif /\\d/.match(name)\n complete_item_by_index(name)\n else\n puts \"\\n\"\n puts \"!!! You gotta give me either the index or the list item.\"\n @out_of_bounds = true\n end\n end", "def mark_all_done\n each {|todo| todo.done!}\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Mark every todo as done
def mark_all_done self.each { |todo| todo.done! } end
[ "def mark_all_done\n each {|todo| todo.done!}\n end", "def mark_all_todos_as_done\n post('/todos/mark_as_done')\n end", "def mark_as_done(todo)\n todo.mark_as_done!\n edit(todo)\n end", "def mark_as_done(todo)\n @data_object.aff_to_do &= ~todo\n end", "def mark_todo\n puts \"Which todo have you finished?\"\n action = get_input.to_i\n arr_index = 0\n @todos.each do |x|\n if x[\"completed\"] == \"no\"\n arr_index = arr_index + 1\n if arr_index == action\n x[\"completed\"] = \"yes\"\n save!\n break\n end\n end\n end\n end", "def all_done\n completed_todos = TodoList.new(\"Completed Todo's\")\n each { |todo| completed_todos.add(todo) if todo.done? }\n completed_todos\n end", "def mark_all_undone\n all_done.each { |todo| todo.undone! } # should just iterate with each else new list is returned\n end", "def test_mark_all_done\n @list.mark_all_done\n assert(@todos.all? { |todo| todo.done? }) # this assertion was tested in #test_done!\n end", "def mark_done(str)\n todo = self.find_by_title(str)\n todo.done! if todo\n # find_by_title(str) && find_by_title(str).done! # alt from solution\n end", "def complete(todo)\n todo.complete\n save_todos\n end", "def complete_todo\n cli.die \"That task is already completed!\" if @todo.completed?\n @todo.complete!\n puts \"#{@todo.label}: '#{@todo.todo}' marked as completed at #{@todo.stop}\"\n end", "def markDone(id)\n item = Todo.find(id)\n item.done = true\n item.save\nend", "def done\n return unless doings_to_dones\n todos_to_doings\n end", "def mark_all_todos_as_completed(list_id)\n sql = \"UPDATE todos SET completed = true WHERE list_id = $1\"\n query(sql, list_id)\n end", "def mark_done(title)\n find_by_title(title)&.done!\n end", "def mark_as_done\n CONNECTION.execute(\"UPDATE tasks SET done = 1 WHERE id = #{self.id}\")\n self.done = true\n end", "def mark_all_undone\n each {|todo| todo.undone!}\n end", "def mark_done_at(idx)\n item_at(idx).done!\n end", "def close_tasks(tasks)\n return if tasks.nil? || tasks.empty?\n\n tasks.each do |task|\n puts \"Setting #{task.formatted_i_d} as Completed\"\n task.update(:state => \"Completed\", :to_do => \"0.0\")\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Move a +Tile+ on the +Map+. This movement action causes a chain reaction potentially moving (or killing) tiles down the map in that same direction. It does this by comparing each neighboring pair tile_1 > tile_2 tile_2 > tile_3 tile_3 > tile_4 And follows these rules empty tiles don't transfer movement enemies block enemies players are killed when touching enemies enemies get squished by players players get squished by queens rocks block everything
def move(tile, direction) tiles = send(direction, tile) move = [] tiles.each_cons(2) do |this, that| break if this.empty? # break move.clear if (tile == this) && this.enemy? && that.empty? break move.clear if this.enemy? && that.enemy? break move.clear if this.egg? && that.enemy? break move.clear if this.enemy? && that.egg? break this.destroy! if this.player? && (that.enemy? || that.egg?) break that.destroy! if (this.enemy? || this.egg?) && that.player? if (this.worker? || this.queen? || this.egg?) && tile.player? && (that.dirt? || that.rock?) this.destroy! break end if this.soldier? && tile.player? && that.rock? (neighbors(this) - neighbors(tile)).each &:worker! this.destroy! break end if this.player? && tile.queen? && !that.empty? this.destroy! break end break move.clear if that.rock? move << [that, this.type, this.age] end return if move.empty? tile.empty! move.each { |t, type, age| t.send(type, age) } end
[ "def move_if_needed\n positions.each {|dir, pos|\n t = tile_at(pos)\n if t\n @direction, @position = directions.invert[dir], pos\n # Update the image so that the user actually sees the bug\n # turning if it did.\n update_image\n t.on\n return true\n end\n }\n return false\n end", "def move(from, to)\n if !towers.include?(from)\n puts \"Tower #{from} does not exist.\"\n elsif !towers.include?(to)\n puts \"Tower #{to} does not exist.\"\n elsif from.equal?(to)\n puts \"You can't put the same disc where you got it from!\"\n elsif tower(to).any? && tower(to).last < tower(from).last\n puts \"Invalid move. You can't place a bigger tile on top of a smaller one.\"\n else\n tower(to) << tower(from).pop\n self.moves += 1\n end\n end", "def move!(position_1, position_2, player)\n fail_move_errors(position_1, position_2, player)\n row, col = position_1\n piece = @squares[row][col].contents\n piece.first_move = false if piece.is_a? Pawn\n remove_threats(piece)\n piece.position = position_2\n @squares[row][col].contents = ' '\n row, col = position_2\n if @squares[row][col].contents.is_a? ChessPiece\n remove_threats(@squares[row][col].contents)\n end\n @squares[row][col].contents = piece\n # update threats whose path may be blocked after the move is made\n @squares[row][col].threats.each do |threat|\n remove_threats(threat)\n add_threats(threat)\n end\n add_threats(piece)\n end", "def move!\n return if @road.dist_btw_next_car(self) <= ONE_UNIT\n\n if about_to_enter_lane?\n enter_lane!\n elsif about_to_leave_lane?\n leave_lane!\n else\n move_a_unit!\n end\n end", "def move_one begTile\n @maze.get_adjacent_tiles(begTile).each do |tile|\n if (tile.is_floor) && (!@tiles.include? tile)\n @tiles.push tile\n self.move_one tile\n end\n end\n end", "def move_for(entity, battle)\n initialize_battle_data(battle, entity)\n\n known_enemy_positions = @battle_data[battle][entity][:known_enemy_positions]\n hiding_spots = @battle_data[battle][entity][:hiding_spots]\n investigate_location = @battle_data[battle][entity][:investigate_location]\n\n enemy_positions = {}\n observe_enemies(battle, entity, enemy_positions)\n\n available_actions = entity.available_actions(@session, battle)\n\n # generate available targets\n valid_actions = []\n\n if enemy_positions.empty? && investigate_location.empty? && LookAction.can?(entity, battle)\n action = LookAction.new(battle.session, entity, :look)\n puts \"#{entity.name}: Where are you?\"\n return action\n end\n\n # try to stand if prone\n valid_actions << StandAction.new(@session, entity, :stand) if entity.prone? && StandAction.can?(entity, battle)\n\n available_actions.select { |a| a.action_type == :attack }.each do |action|\n next unless action.npc_action\n\n valid_targets = battle.valid_targets_for(entity, action)\n unless valid_targets.first.nil?\n action.target = valid_targets.first\n valid_actions << action\n end\n end\n\n # movement planner if no more attack options and enemies are in sight\n if valid_actions.empty? && !enemy_positions.empty?\n\n valid_actions += generate_moves_for_positions(battle, entity, enemy_positions)\n end\n\n # attempt to investigate last seen positions\n if enemy_positions.empty?\n my_group = battle.entity_group_for(entity)\n investigate_location = known_enemy_positions.map do |enemy, position|\n group = battle.entity_group_for(enemy)\n next if my_group == group\n\n [enemy, position]\n end.compact.to_h\n\n valid_actions += generate_moves_for_positions(battle, entity, investigate_location)\n end\n\n if HideBonusAction.can?(entity, battle) # bonus action hide if able\n hide_action = HideBonusAction.new(battle.session, entity, :hide_bonus)\n hide_action.as_bonus_action = true\n valid_actions << hide_action\n end\n\n if valid_actions.first&.action_type == :move && DisengageBonusAction.can?(entity,\n battle) && !retrieve_opportunity_attacks(\n entity, valid_actions.first.move_path, battle\n ).empty?\n return DisengageBonusAction.new(battle.session, entity, :disengage_bonus)\n end\n\n valid_actions << DodgeAction.new(battle.session, entity, :dodge) if entity.action?(battle)\n\n return valid_actions.first unless valid_actions.empty?\n end", "def move\n return false unless on_the_table?\n\n next_x, next_y = facing.next_move_position(x, y)\n unless falls_off?(next_x, next_y)\n self.x = next_x\n self.y = next_y\n true\n else\n false\n end\n end", "def move(all_units)\n all_units.each do |char|\n next unless char.alive\n\n targets = []\n\n queue = []\n queue.push([1, char.pos])\n\n distances = Hash.new\n previous = Hash.new\n\n while queue.length > 0\n curr = queue.shift\n # puts \"Q: #{curr[0]} POS: #{curr[1]}\"\n new_round = curr[0] + 1\n next if targets.length > 0 # Skip branches if we've found targets.\n\n DIRS.each do |dir| # For each potential neighbor...\n f_pos = curr[1] + dir\n # puts \"\\tCHECKING: #{f_pos} LINE: #{LINES[f_pos[0]][f_pos[1]]}\"\n if LINES[f_pos[0]][f_pos[1]] == '.' # Check map for wall\n skip_add = false\n all_units.each do |check|\n next if check == char || !check.alive\n if check.pos == f_pos\n if char.type != check.type # If enemy...\n # targets.push([check, curr[2]]) # Using state path\n targets.push([check, curr[0], curr[1]]) # Using previous hash\n end\n skip_add = true # Can't walk through units.\n end\n end\n # puts \"\\tSKIP CHECK: #{skip_add} PAST: #{curr[2]} EXISTS: #{curr[2].include?(f_pos)}\"\n # if !skip_add && !curr[2].include?(f_pos)\n # # puts \"\\tADDING: #{f_pos}\"\n # new_path = Marshal.load(Marshal.dump(curr[2]))\n # not_queued = queue.index {|q| q[1] == f_pos}.nil?\n # queue.push([new_round, f_pos, new_path.push(f_pos)]) if not_queued\n # end\n if (!skip_add && (distances[f_pos].nil? || new_round < distances[f_pos]))\n distances[f_pos] = new_round\n previous[f_pos] = curr[1]\n queue.push([new_round, f_pos])\n end\n end\n end\n end\n\n targets.each_with_index do |target, i|\n # puts \"#{char} #{i}: #{target[0]} PATH:#{target[1]}\"\n # puts \"#{char} #{i}: #{target[0]} NUM_STEPS:#{target[1]}\"\n end\n if targets.length > 0\n # Move\n nearest_target = targets[0] # Only interested in nearest enemy.\n # if nearest_target[1].length > 1 # More than 1 step away?\n # char.pos = nearest_target[1][1] # Step towards nearest enemy.\n # end\n if nearest_target[1] > 1 # More than 1 step away?\n next_pos = nearest_target[2]\n next_pos = previous[next_pos] while previous[next_pos] != char.pos\n # char.pos = nearest_target[1][1] # Step towards nearest enemy.\n # puts \"#{char} GOES TO #{next_pos}\"\n char.pos = next_pos # Step towards nearest enemy.\n end\n\n d_to_closest = (nearest_target[0].pos - char.pos).to_a.collect!{|v| v.abs}.sum\n # puts \"\\tC:#{char} T:#{nearest_target[0]} D_TO_T: #{d_to_closest}\"\n if d_to_closest == 1 # In melee range!\n targets_by_hp = targets.select {|t| (t[0].pos - char.pos).to_a.collect!{|t| t.abs}.sum == 1}.sort_by {|t| t[0].hp}\n target = targets_by_hp[0] # Lowest hp in melee range.\n target[0].hp -= char.attack\n # puts \"#{char} HITS #{target[0]}\"\n\n if target[0].hp <= 0\n puts \"#{char} KILLS #{target[0]}\"\n target[0].hp = 0\n target[0].alive = false\n end\n end\n else\n all_alive = all_units.select {|unit| unit.alive }\n all_elves = all_alive.select {|unit| unit.type == 'E'}\n return false if all_elves.length == 0 || all_elves.length == all_alive.length\n end\n end\n\n return true\nend", "def check_move (x, y, map)\n # Check if -1 <= x <= 1 and the position the bot wants to be at is Air\n map.in_bounds(@x + x, @y + y) and x.between?(-1, 1) and y.between?(-1, 1) and map.get(@x + x, @y + y).is_ghost\n end", "def perform_move(move)\n start_location = move[0]\n destination = move[1]\n i,j = start_location\n a,b = destination\n jumped = false\n #unless on_board?(destination)\n #raise error\n\n piece = @rows[i][j]\n all_possible_moves = piece.slide_moves(@rows) + piece.jump_moves(@rows)\n\n unless !all_possible_moves.include?(destination)#change to throw error\n\n jump = piece.jump_moves(@rows)\n if jump.include?(destination)\n jumped = true\n #removes jumped piece from board\n add = (piece.color == :white ? -1 : 1)\n if destination[1] > start_location[1]\n middle_b = destination[1] - 1\n middle_a = destination[0] + add\n delete_piece = @rows[middle_a][middle_b]\n delete_piece.location = nil\n @rows[middle_a][middle_b] = nil\n else\n middle_b = destination[1] + 1\n middle_a = destination[0] + add\n delete_piece = @rows[middle_a][middle_b]\n delete_piece.location = nil\n @rows[middle_a][middle_b] = nil\n end\n end\n\n @rows[i][j] = nil\n piece.location = [a,b]\n @rows[a][b] = piece\n end\n #checks if moved piece should be kinged, if so sets king to true\n piece.make_king\n if jumped\n #go_again unless (@rows[a][b]).jump_moves(@rows).nil?\n end\n end", "def possible_moves\n # Remove the two space move on the Pawn's first move\n @move_tree_template = @move_count.zero? ? build_pawn_move_tree_first_move : build_pawn_move_tree\n super\n end", "def possible_moves\n row, col = @position\n @move_tree = @move_tree_template.clone || move_tree\n @move_tree.each do |node|\n r, c = node.loc\n potential_space = [row + r, col + c]\n node.loc = potential_space\n end\n\n move_tree_in_bounds\n end", "def update_move\n super\n Yuki::MapLinker.test_warp unless moving?\n end", "def move\n # Choose a random cell\n # JAVI: Extend this part of the method to choose cell with lower number of surveys (on average)\n cell = cells_around(@loc).rand\n \n # possibly a good location\n # first look ahead \n if !touches_path? cell, @path, @loc \n \n # do 1 more look ahead for each further possible step to avoid this:\n #\n # . . . . .\n # v < < . .\n # v . ^ . .\n # v . ^ < .\n # v . x o .\n # v x ? x .\n # > > ^ . .\n # . . . . . \n #\n # ^v<> = path\n # o = start\n # ? = possible good looking next move\n # x = shows that this is a dead end. All further steps are not allowed.\n #\n # Therefore, if any further step from cell is possible, then we're good to go\n \n # Configure future\n future_path = @path.dup\n future_path << cell\n second_steps = cells_around(cell)\n \n # If at least one of the future steps is valid, go for it\n second_steps.each do |ss|\n if !touches_path? ss, future_path, cell\n @path << cell\n @loc = cell\n @distance -= 1 \n return true\n end\n end \n end \n \n Rails.logger.debug \"*****************\"\n Rails.logger.debug \"Location: #{@loc.to_s}, New move: #{cell.to_s}.\"\n Rails.logger.debug \"Path: #{@path.to_s}\" \n \n false \n #cells = Cell.all :conditions => \"(x = #{@x-1} AND y = #{@y}) OR (x = #{@x+1} AND y = #{@y}) OR (x = #{@x} AND y = #{@y-1}) OR (x = #{@x} AND y = #{@y+1})\",\n # :order => \"positive_count + negative_count ASC\"\n \n # if all the cells have already been surveyed, weight index to those with few surveys \n #if cells.size == 4\n # i = rand(3)\n # i = (i - (i * 0.1)).floor \n # @x = cells[i].x\n # @y = cells[i].y\n # return\n #end\n \n # if there are empty cells, make a new cell where there's a gap and use that \n #[@x, @y-1] *<-- ALWAYS GOING DOWN\n #existing_cells = cells.map {|c| [c.x, c.y]}\n #survey_cell = (possible_cells - existing_cells).rand\n end", "def move\n\t@objects.each do |go|\n\t\tgo.move\n\t\t\n\t\t@objects.delete(go) if go.kind_of? PTorpedo and (go.xCenter > @xMax or go.yCenter > @yMax)\n\tend\n\t\n\t# check for collisions between objects and act accordingly\n\tcollisions if not @ship.destroyed\n end", "def print_possible_moves(player)\n y = player.location.first\n x = player.location.second\n tiles = player.map.tiles\n\n print \"* Movement: \"\n\n if x > 0 && tiles[y][x - 1].passable\n print \"← \"\n end\n\n if y > 0 && tiles[y - 1][x].passable\n print \"↑ \"\n end\n\n if y < (tiles.length-1) && tiles[y + 1][x].passable\n print \"↓ \"\n end\n\n if x < (tiles[y].length-1) && tiles[y][x + 1].passable\n print \"→ \"\n end\n\n print \"\\n\\n\"\nend", "def jump_moves\n moves = [] # initializes empty move array\n\n # choses \"forward\" y direction based on piece team\n if @team == \"l\"\n dir = 1\n else\n dir = -1\n end\n\n # looks at the two forward far diagonal positions and adds them to moves array if there are no pieces there and an opponent piece in between\n pos1 = [@x_pos + 2, @y_pos + 2*dir]\n moves << pos1 if Piece.all.find{|p| p.x_pos == @x_pos + 1 && p.y_pos == @y_pos + dir && p.team != @team} && Piece.all.none?{|p| [p.x_pos, p.y_pos] == pos1}\n pos2 = [@x_pos - 2, @y_pos + 2*dir]\n moves << pos2 if Piece.all.find{|p| p.x_pos == @x_pos - 1 && p.y_pos == @y_pos + dir && p.team != @team} && Piece.all.none?{|p| [p.x_pos, p.y_pos] == pos2}\n \n\n # deletes any moves with coordinates that aren't on the board\n moves.delete_if{|move| move.find{|n| n < 0 || n > 7}}\n return moves\n end", "def move_neighbours()\n # Make sure to check for doorways that can't be passed through diagonally!\n # Start with the current list from neighbours()\n # foreach cell in that list, remove that cell if either of the conditions are met:\n # it is not passable\n # it is diagonal, and either it or this square is a doorway\n end", "def determine_moves(loc)\n\n piece = @spaces[loc]\n\n moveset = []\n attackset = []\n new_moves = []\n\n x = loc[0]\n y = loc[1]\n\n enemy_king_checked = false\n\n\n case piece.type\n\n when \"pawn\"\n\n if piece.color == \"white\"\n\n new_moves << [x, y+1]\n new_moves << [x,y+2] if y == 1\n\n if @spaces[new_moves[0]].nil?\n\n moveset << new_moves[0]\n moveset << new_moves[1] if y == 1\n\n end\n\n atk_moves = [[x+1, y+1], [x-1, y+1]]\n atk_moves.each do |move|\n attackset << move if @spaces[move].nil?.! and @spaces[move].color == \"black\"\n if @spaces[move].nil?.!\n enemy_king_checked = true if @spaces[move].color == \"black\" and @spaces[move].type == \"king\"\n end\n end\n \n\n elsif piece.color == \"black\"\n\n new_moves = [[x, y-1]]\n new_moves << [x,y-2] if y == 6\n\n if @spaces[new_moves[0]].nil?\n\n moveset << new_moves[0]\n moveset << new_moves[1] if loc[1] == 6\n\n end\n\n atk_moves = [[x+1, y-1], [x-1, y-1]]\n atk_moves.each do |move|\n attackset << move if @spaces[move].nil?.! and @spaces[move].color == \"white\"\n if @spaces[move].nil?.!\n enemy_king_checked = true if @spaces[move].color == \"white\" and @spaces[move].type == \"king\"\n end\n end\n end\n\n @spaces[loc].moveset = moveset\n @spaces[loc].attackset = attackset\n \n\n when \"rook\"\n\n runner(loc, :north)\n runner(loc, :east)\n runner(loc, :south)\n runner(loc, :west)\n\n when \"knight\"\n\n possible_directions =\n [ [x+1, y+2],\n [x+1, y-2],\n [x-1, y+2],\n [x-1, y-2],\n [x+2, y+1],\n [x+2, y-1],\n [x-2, y+1],\n [x-2, y-1] ]\n\n moveset = possible_directions.select do |d|\n (d[0].between?(0,7) & d[1].between?(0,7)) and @spaces[d].nil?\n end\n\n attackset = possible_directions.select do |d|\n (d[0].between?(0,7) & d[1].between?(0,7)) and (@spaces[d].nil?.! and @spaces[d].color != @spaces[loc].color)\n end\n\n @spaces[loc].moveset = moveset\n @spaces[loc].attackset = attackset\n\n\n when \"bishop\"\n\n runner(loc, :northeast)\n runner(loc, :southeast)\n runner(loc, :northwest)\n runner(loc, :southwest)\n\n\n when \"queen\"\n\n runner(loc, :north)\n runner(loc, :northeast)\n runner(loc, :east)\n runner(loc, :southeast)\n runner(loc, :south)\n runner(loc, :southwest)\n runner(loc, :west)\n runner(loc, :northwest)\n\n\n when \"king\"\n\n runner(loc, :north, 1)\n runner(loc, :northeast, 1)\n runner(loc, :east, 1)\n runner(loc, :southeast, 1)\n runner(loc, :south, 1)\n runner(loc, :southwest, 1)\n runner(loc, :west, 1)\n runner(loc, :northwest, 1)\n\n end\n\n\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
show navbar date component
def show_header_date I18n.localize(Date.today, format: :long) end
[ "def navbar_date\n begin\n if @driver.find_element(:class, 'business-date pull-right').displayed?\n return @driver.find_element(:class, 'business-date pull-right')\n end\n rescue Selenium::WebDriver::Error::NoSuchElementError\n $results.info(\"Cannot find navbar date\")\n end\n end", "def interaction_add_date_navigation(view, page = 1, pages = 1, date = 0, label = \"\")\n interaction_add_navigation(\n view,\n labels: [\"❙❮\", \"❮\", label, \"❯\", \"❯❙\"],\n disabled: [page == 1, page == 1, true, page == pages, page == pages],\n ids: [\"button:date:-1000000000\", \"button:date:-1\", \"button:date:#{date}\", \"button:date:1\", \"button:date:1000000000\"]\n )\nend", "def render(date = Date.today)\n @date = date\n label.text = date.strftime date.year == Date.today.year ? '%B' : '%B %Y'\n render_header\n render_body(date) do |*args|\n yield(*args) if block_given?\n end\n trigger :rendered\n end", "def print_layout_start_date\n return if not_waste_producer_water_discount?\n\n { code: :start_date, # section code\n key: :title, # key for the title translation\n key_scope: %i[applications slft start_date], # scope for the title translation\n divider: true, # 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: :start_date, format: :date }] }\n end", "def upcoming_delivery_date_heading(current_user)\n \"#{seller_display_date(current_user)}\"\n end", "def date_element(event)\n # generate a microformat HTML date element\n ical_date = h event.date.to_formatted_s(:ical)\n full_date = h event.date.to_formatted_s(:rfc822)\n content_tag :abbr, full_date, :class => :dtstart, :title => ical_date\n end", "def showDate(date)\n puts \"#{date}\"\n items = @logHash[date]\n items.each do |item|\n puts \" #{item.name}\"\n end\n end", "def view_title\n month = month_name(@refdate.month)\n year = @refdate.year\n return \"#{month} #{year}\"\n end", "def calendar_header(cal)\n content_tag(:div, cal.month_name + ' ' + cal.day.to_s + ', ' + cal.year.to_s, :class => 'month_header')\n end", "def formatear_datepicker(date)\n date.strftime '%d-%m-%Y' if date\n end", "def date\n # self.start_time.in_time_zone(self.school.timezone).strftime('%A - %-m/%d/%y')\n \"#{self.start_time.in_time_zone(self.school.timezone).strftime('%A')}</br>#{self.start_time.in_time_zone(self.school.timezone).strftime('%-m/%d/%y')}\".html_safe()\n end", "def header\n content_tag 'div', class: \"cal-row-fluid cal-row-head\" do\n build_header(day_names, \"cal-span1 hidden-xs\") +\n build_header(mobile_day_names, \"cal-span1 visible-xs\")\n end\n end", "def appointment_date\n set_text('Date:', 90)\n set_text(formatted_date, 90, 'value')\n end", "def show_date_condition\n false\n end", "def embargo_date_display(errata, opts={})\n if errata.embargo_date.present?\n if errata.not_embargoed?\n \"<div class='compact'>Embargo<br/>#{errata.embargo_date.to_s(:Y_mmm_d)}</div>\".html_safe\n else\n (\"<div class='compact red bold'>\" +\n (opts[:skip_label] ? \"\" : \"<small>EMBARGOED!</small><br/>\") +\n \"#{errata.embargo_date.to_s(:Y_mmm_d)} #{\"<br/>\" unless opts[:no_br]}\" +\n \"<small>(#{time_ago_future_or_past(errata.embargo_date)})</small>\" +\n \"</div>\").html_safe\n end\n else\n \"<div class='small superlight'>#{opts[:none_text]||'-'}</div>\".html_safe\n end\n end", "def transaction_date_field(transaction_date=Date.today_with_timezone.to_date, attrs={})\n \"<div class='label-field-pair3 special_case payment_mode_block'>\n <label>#{t('payment_date') }</label>\n <div class='date-input-bg'>\n #{calendar_date_select_tag 'transaction_date', I18n.l(transaction_date, :format => :default),\n {:popup => 'force', :class => 'start_date'}.merge(attrs) }\n </div>\n </div>\".html_safe\n end", "def print_date\n\t\tcurrent_time = DateTime.now\n\t\tdate_today = current_time.strftime \"%d/%m/%Y\"\n\t\tputs \"Today's date is: \" + date_today \n\tend", "def date_select(f)\n h.content_tag :div, class: \"form-group col-#{f[:width] || wdtsel}\" do\n @form.label(f[:attribute], f[:label]) +\n @form.date_select(f[:attribute], class: 'form-control')\n end\n end", "def should_show_setlist_editor(show)\n (show.enddate? ? show.enddate : show.date) <= Date.today\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Select all the paragraphs from the body text which are actual paragraphs (ie not headings). It's probably not an entirely accurate algorithm, but I think it's good enough for extracting the first paragraph to use as an excerpt.
def article_paragraphs(article) source = article.file_descriptor.read body = source.split("---\n", 3).last body.split(/\n{2,}/).select { |paragraph| paragraph !~ /^#/ } end
[ "def paragraphs s\n s.remall(@parreg).rems.map(&:to_s).map(&:strip).reject{|e| !e.match?(/\\w/)}\n end", "def html_paragraphs(text)\n h(text).split(/\\n\\s*\\n/).collect { |para| \"<p>#{para}</p>\" }.join(\"\\n\")\n end", "def parse_paragraphs(html)\n html.search('p').map { |p| parse_paragraph p }\n end", "def paragraphs\n result = []\n paragraph = []\n loop do\n if eof?\n result << paragraph.join(NL)\n return result\n elsif current_line.empty?\n if paragraph.empty?\n # No action\n else\n result << paragraph.join(NL)\n paragraph = []\n end\n else\n paragraph << current_line\n end\n move_on\n end\n end", "def first_paragraph_of(text)\n if defined?(Nokogiri)\n Nokogiri::HTML(text).at('p').try(:to_html).try(:html_safe) || text\n end\n end", "def textParagraphs\n paras = []\n thisPara = []\n markerLength = 0\n marker = ''\n text.each do |textline|\n case textline\n when /^(\\s*([-*])\\s*)(.*)/ \n paras.push([ marker, thisPara ])\n marker = $2\n markerLength = $1.length\n thisPara = [ $3 ]\n when /^(\\s*)(.+)/\n if $1.length == markerLength\n thisPara.push($2)\n else\n paras.push([ marker, thisPara ])\n markerLength = $1.length\n thisPara = [ $2 ]\n marker = ''\n end\n when /^\\s*$/\n paras.push([ marker, thisPara ])\n thisPara = []\n marker = ''\n end\n end\n paras.push([ marker, thisPara ])\n return paras.reject { |p| p[1].length == 0 }\n end", "def rdoc_paragraphs(rdoc_text)\n paragraphs, current = [], \"\"\n rdoc_text.each_line do |s|\n if s.strip.empty?\n unless current.strip.empty?\n paragraphs << current \n end\n current = \"\"\n else\n current << s\n end\n end\n unless current.strip.empty?\n paragraphs << current \n end\n paragraphs\n end", "def find_all_paragraphs(key)\n find_all(key, paragraphs).map do |string|\n SectionedText.new(\n string.gsub(/\\s+/, ' '),\n SENTENCE_DELIMITER\n )\n end\n end", "def remove_paragraph_tags mytext\n mytext.sub!(/^<p>\\s*<\\/p>/,\"\")\n mytext.sub!(/(<br>)*<p>\\s*<\\/p>$/,\"\")\n mytext.sub!(/^<p>/,'')\n mytext.sub!(/<\\/p>?/,'')\n return mytext\n end", "def clean_paragraphs(doc)\n out = Nokogiri::HTML.fragment('<p></p>')\n doc.children.each do |node|\n next out.add_child('<p></p>') if node.name == 'br'\n parent = out.last_element_child || out.children.select(&:element?).last\n parent.add_child(node)\n end\n out.css('p').each do |node|\n node.remove if node.content.blank?\n end\n out\n end", "def paragraphs(\n word_count: rand(DEFAULT_WORD_COUNT_RANGE),\n sentence_count: rand(DEFAULT_SENTENCE_COUNT_RANGE),\n paragraph_count: rand(DEFAULT_PARAGRAPH_COUNT_RANGE),\n fillers: dictionnary.fillers,\n seperator: DEFAULT_PARAGRAPH_SEPARATOR\n )\n paragraph_count = 0 if paragraph_count.negative?\n paragraphs = []\n paragraph_count.times do\n p = paragraph(word_count: word_count, sentence_count: sentence_count, fillers: fillers)\n paragraphs << p unless p.empty?\n end\n paragraphs.join(seperator)\n end", "def add_paragraphs_to_text(text)\n\n # get rid of spaces and newlines-before/after-paragraphs and linebreaks\n # this enables us to avoid converting newlines into paras/breaks where we already have them\n source = text.gsub(/\\s*(<p[^>]*>)\\s*/, '\\1') # replace all whitespace before/after <p>\n source.gsub!(/\\s*(<\\/p>)\\s*/, '\\1') # replace all whitespace before/after </p>\n source.gsub!(/\\s*(<br\\s*?\\/?>)\\s*/, '<br />') # replace all whitespace before/after <br> \n\n # do we have a paragraph to start and end\n source = '<p>' + source unless source.match(/^<p/)\n source = source + \"</p>\" unless source.match(/<\\/p>$/)\n \n # If we have three newlines, assume user wants a blank line\n source.gsub!(/\\n\\s*?\\n\\s*?\\n/, \"\\n\\n&nbsp;\\n\\n\")\n\n # Convert double newlines into single paragraph break\n source.gsub!(/\\n+\\s*?\\n+/, '</p><p>')\n\n # Convert single newlines into br tags\n source.gsub!(/\\n/, '<br />')\n \n # convert double br tags into p tags\n source.gsub!(/<br\\s*?\\/?>\\s*<br\\s*?\\/?>/, '</p><p>')\n \n # if we have closed inline tags that cross a <p> tag, reopen them \n # at the start of each paragraph before the end\n HTML_TAGS_TO_REOPEN.each do |tag| \n source.gsub!(/(<#{tag}>)(.*?)(<\\/#{tag}>)/) { $1 + reopen_tags($2, tag) + $3 }\n end\n \n # reopen paragraph tags that cross a <div> tag\n source.gsub!(/(<p[^>]*>)(.*?)(<\\/p>)/) { $1 + reopen_tags($2, \"p\", \"div\") + $3 }\n \n # swap order of paragraphs around divs\n source.gsub!(/(<p[^>]*>)(<div[^>]*>)/, '\\2\\1')\n\n # Parse in Nokogiri\n parsed = Nokogiri::HTML.parse(source)\n parsed.encoding = 'UTF-8'\n \n # Get out the nice well-formed XHTML\n source = parsed.css(\"body\").to_xhtml\n \n # trash empty paragraphs and leading spaces\n source.gsub!(/\\s*<p[^>]*>\\s*<\\/p>\\s*/, \"\")\n source.gsub!(/^\\s*/, '')\n \n # get rid of the newlines-before/after-paragraphs inserted by to_xhtml,\n # so that when this is loaded up by strip_html_breaks in textarea fields,\n # \n source.gsub!(/\\s*(<p[^>]*>)\\s*/, '\\1')\n source.gsub!(/\\s*(<\\/p>)\\s*/, '\\1')\n \n # trash the body tag\n source.gsub!(/<\\/?body>\\s*/, '')\n \n # return the text\n source\n end", "def cleanup_paragraph_tags(text)\n # Now we want to replace any cases where these have been doubled -- ie, \n # where a new paragraph tag is opened before an old one is closed\n text.gsub!(/<p>\\s*<p>/im, \"<p>\")\n text.gsub!(/<\\/p>\\s*<\\/p>/im, \"</p>\")\n while text.gsub!(/<br\\s*\\/>\\s*<p>/im, \"<p>\")\n end\n\n while text.gsub!(/<p>\\s*<br\\s*\\/>/im, \"<p>\")\n end\n\n #<pre> blocks shouldn't contain any linebreak markup\n a = text.scan(/<pre>.*?<\\/pre>/im) \n a.each do |pre|\n text = text.sub(pre.to_s(), pre.to_s().gsub(/<(\\/)?(br|p)(\\s)?(\\/)?>/, \"\")) \n end\n\n # and where there are empty paragraphs\n text.gsub!(/<p>\\s*<\\/p>/im, \"\")\n \n # also get rid of blank paragraphs inserted by tinymce\n text.gsub!(/<p>&nbsp;<\\/p>/, \"\")\n \n return cleanup_break_tags(text)\n end", "def textilize_without_paragraph(text)\n textiled = textilize(text)\n if textiled[0..2] == \"<p>\" then textiled = textiled[3..-1] end\n if textiled[-4..-1] == \"</p>\" then textiled = textiled[0..-5] end\n return textiled\n end", "def cell_paragraphs(cell)\n cell.paragraphs\n .map(&:text) # Extract the text from each paragraph\n .map(&:strip) # Remove leading/trailing spaces from text\n .reject(&:empty?) # Throw away blank paragraphs\n end", "def strip_paragraph_formatting(text)\n text = text.gsub(/^(<p>)/, '')\n\t text = text.gsub(/(<\\/p>)$/, '')\n\t return text\n end", "def paragraphs\n return enum_for(:each) unless block_given?\n\n gathered_lines = '' # collects all lines belonging to a field\n @data.each_line do |line|\n if line.chomp.empty? # empty line found that seperates paragraphs\n unless gathered_lines.empty? # any lines gathered so far?\n #yield gathered_lines # return the paragraph\n yield DebianControlParser.new(gathered_lines)\n gathered_lines = ''\n end\n else\n gathered_lines << line\n end\n end\n\n # Any lines left after the last empty line and the end of the input?\n unless gathered_lines.empty?\n #yield gathered_lines\n yield DebianControlParser.new(gathered_lines)\n end\n end", "def parse_paragraph\n pos = @src.pos\n start_line_number = @src.current_line_number\n result = @src.scan(PARAGRAPH_MATCH)\n until @src.match?(paragraph_end)\n result << @src.scan(PARAGRAPH_MATCH)\n end\n result.rstrip!\n if (last_child = @tree.children.last) && last_child.type == :p\n last_item_in_para = last_child.children.last\n if last_item_in_para && last_item_in_para.type == @text_type\n joiner = (extract_string((pos - 3)...pos, @src) == \" \\n\" ? \" \\n\" : \"\\n\")\n last_item_in_para.value << joiner << result\n else\n add_text(result, last_child)\n end\n else\n @tree.children << new_block_el(:p, nil, nil, location: start_line_number)\n result.lstrip!\n add_text(result, @tree.children.last)\n end\n true\n end", "def paragraphs(options={})\n count = rand_count options[:paragraphs] || (3..5)\n join_str = options[:join]\n\n res = count.times.collect do |i|\n op = options.clone\n op.delete :punctuation unless i==count-1\n op.delete :first_word unless i==0\n paragraph op\n end\n\n join_str!=false ? res.join(join_str || \"\\n\\n\") : res\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the accessPackage property value. Access package containing this policy. Readonly. Supports $expand.
def access_package return @access_package end
[ "def access_package=(value)\n @access_package = value\n end", "def access_package_id\n return @access_package_id\n end", "def access_packages\n return @access_packages\n end", "def access_packages=(value)\n @access_packages = value\n end", "def access_package_assignment_approvals\n return @access_package_assignment_approvals\n end", "def access_package_display_name\n return @access_package_display_name\n end", "def access_package_id=(value)\n @access_package_id = value\n end", "def package\n return @package\n end", "def access_package_assignment_approvals=(value)\n @access_package_assignment_approvals = value\n end", "def access\n return @access\n end", "def access_package_display_name=(value)\n @access_package_display_name = value\n end", "def package\n if !@_package\n #Open the file\n File.open @path do |io|\n io.each do |line|\n #Search for the package name\n if line =~ /^package (.*)/\n @_package = $1.rstrip\n end\n end\n #no package name found, set to empty string\n @_package = \"\" if !@_package\n end\n end\n return @_package\n end", "def package=(value)\n @package = value\n end", "def access_policy\n if @options[:acl].to_s == \"public\"\n \"public-read\"\n else\n \"private\"\n end\n end", "def [](package_name)\n package_rules.find {|rule| rule.package_name == package_name }\n end", "def access_consent\n return @access_consent\n end", "def package_link\n @attributes[:package_link]\n end", "def access_packages()\n return MicrosoftGraph::IdentityGovernance::EntitlementManagement::AccessPackages::AccessPackagesRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def package_settings\n properties[:package_settings]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the accessPackage property value. Access package containing this policy. Readonly. Supports $expand.
def access_package=(value) @access_package = value end
[ "def access_packages=(value)\n @access_packages = value\n end", "def access_package_id=(value)\n @access_package_id = value\n end", "def access_package_assignment_approvals=(value)\n @access_package_assignment_approvals = value\n end", "def package=(value)\n @package = value\n end", "def access_package\n return @access_package\n end", "def incompatible_access_packages=(value)\n @incompatible_access_packages = value\n end", "def access=(value)\n @access = value\n end", "def package_set(ref, val)\n raise ArgumentError.new(ref.inspect) unless ref.package_id\n\n package_table.set(ref, val)\n end", "def set_access_conditions\n\n if package\n access_conditions = package['assetSequences']\n .to_a.first.to_h['rootSection'].to_h['extensions'].to_h['accessCondition']\n else\n access_conditions = nil\n end\n\n write_attribute(:access_conditions, access_conditions)\n end", "def access_package_display_name=(value)\n @access_package_display_name = value\n end", "def changepackage(user, package)\n do_request 'changepackage', {:user => user, :pkg => package}\n end", "def access_package_id\n return @access_package_id\n end", "def release_access_node=(new_doc)\n if(new_doc.root.name != 'releaseAccess')\n raise \"Trying to replace releaseAccess with a non-releaseAccess document\"\n end\n\n term_value_delete(:select => '//embargoMetadata/releaseAccess')\n ng_xml.root.add_child(new_doc.root.clone)\n end", "def package_location=(path)\n @package_location = path\n end", "def access_packages_incompatible_with=(value)\n @access_packages_incompatible_with = value\n end", "def package(pkg)\n @pkg = pkg\n end", "def package_set(name)\n @name = name\n end", "def access_package_assignment_approvals\n return @access_package_assignment_approvals\n end", "def set_PrivateAccess(value)\n set_input(\"PrivateAccess\", value)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the allowedTargetScope property value. Principals that can be assigned the access package through this policy. The possible values are: notSpecified, specificDirectoryUsers, specificConnectedOrganizationUsers, specificDirectoryServicePrincipals, allMemberUsers, allDirectoryUsers, allDirectoryServicePrincipals, allConfiguredConnectedOrganizationUsers, allExternalUsers, unknownFutureValue.
def allowed_target_scope return @allowed_target_scope end
[ "def allowed_target_scope=(value)\n @allowed_target_scope = value\n end", "def policy_scope(target, options={})\n @_policy_scoped = true\n\n policy(target, options).scope\n end", "def policy_scope(target, options={})\n policy(target, options).scope\n end", "def request_access_for_allowed_targets\n return @request_access_for_allowed_targets\n end", "def allowed_target_trackers\n Issue.allowed_target_trackers(project, user)\n end", "def request_access_for_allowed_targets=(value)\n @request_access_for_allowed_targets = value\n end", "def allowed_users\n return @allowed_users\n end", "def specific_allowed_targets\n return @specific_allowed_targets\n end", "def enforced_grant_controls\n return @enforced_grant_controls\n end", "def authorization_scope_type_for(policy, target)\n policy.resolve_scope_type(target)\n end", "def allowed_target_projects\n Project.allowed_to(user, :import_issues)\n end", "def apply_scopes_if_available(target_object) #:nodoc:\n respond_to?(:apply_scopes, true) ? apply_scopes(target_object) : target_object\n end", "def apply_scope_to(target_object) #:nodoc:\n target_object\n end", "def users_authorized_through_parents_of(target)\n models_which_authorize(target).map do |authorizing_model|\n users_with_access_to(authorizing_model) # recurse\n end.flatten\n end", "def grantable_privileges\n return [] if !self.is_grant?\n return [self.privilege] if self.class_name == 'any'\n klass = self.target_class\n return klass.declared_privileges + [:any] if self.privilege == :any\n return [self.privilege] + klass.sg_priv_to_implied_privs[self.privilege]\n end", "def enforced_grant_controls=(value)\n @enforced_grant_controls = value\n end", "def allowed_users=(value)\n @allowed_users = value\n end", "def application_enforced_restrictions\n return @application_enforced_restrictions\n end", "def scopes\n env['HTTP_X_AUTHENTICATED_SCOPE'].to_s.split(',')\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the allowedTargetScope property value. Principals that can be assigned the access package through this policy. The possible values are: notSpecified, specificDirectoryUsers, specificConnectedOrganizationUsers, specificDirectoryServicePrincipals, allMemberUsers, allDirectoryUsers, allDirectoryServicePrincipals, allConfiguredConnectedOrganizationUsers, allExternalUsers, unknownFutureValue.
def allowed_target_scope=(value) @allowed_target_scope = value end
[ "def allowed_target_scope\n return @allowed_target_scope\n end", "def policy_scope(target, options={})\n @_policy_scoped = true\n\n policy(target, options).scope\n end", "def request_access_for_allowed_targets=(value)\n @request_access_for_allowed_targets = value\n end", "def policy_scope(target, options={})\n policy(target, options).scope\n end", "def apply_scopes_if_available(target_object) #:nodoc:\n respond_to?(:apply_scopes, true) ? apply_scopes(target_object) : target_object\n end", "def specific_allowed_targets=(value)\n @specific_allowed_targets = value\n end", "def apply_scope_to(target_object) #:nodoc:\n target_object\n end", "def enforced_grant_controls=(value)\n @enforced_grant_controls = value\n end", "def allowed_target_trackers\n Issue.allowed_target_trackers(project, user)\n end", "def scope=(value)\n @scope = value\n end", "def call_scope(target, scope, value)\n if boolean?(value)\n target.send(scope)\n else\n target.send(scope, value)\n end\n end", "def allowed_users=(value)\n @allowed_users = value\n end", "def scope=(value)\n @scope = value\n end", "def request_access_for_allowed_targets\n return @request_access_for_allowed_targets\n end", "def authorization_scope_type_for(policy, target)\n policy.resolve_scope_type(target)\n end", "def remove_access_when_target_leaves_allowed_targets=(value)\n @remove_access_when_target_leaves_allowed_targets = value\n end", "def data_source_scopes=(value)\n @data_source_scopes = value\n end", "def directory_scope=(value)\n @directory_scope = value\n end", "def recipient_scope=(value)\n @recipient_scope = value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the automaticRequestSettings property value. This property is only present for an auto assignment policy; if absent, this is a requestbased policy.
def automatic_request_settings return @automatic_request_settings end
[ "def automatic_request_settings=(value)\n @automatic_request_settings = value\n end", "def automatic_user_consent_settings\n return @automatic_user_consent_settings\n end", "def request_approval_settings\n return @request_approval_settings\n end", "def enforced_settings\n return @enforced_settings\n end", "def automatic_replies_setting\n return @automatic_replies_setting\n end", "def requestor_settings\n return @requestor_settings\n end", "def get_request_settings(opts = {})\n data, _status_code, _headers = get_request_settings_with_http_info(opts)\n data\n end", "def request_approval_settings=(value)\n @request_approval_settings = value\n end", "def automatic_user_consent_settings=(value)\n @automatic_user_consent_settings = value\n end", "def admin_consent_request_policy\n return @admin_consent_request_policy\n end", "def get_auto_approve_setting\n service_response = ClientManagement::GetAutoApproveSetting.new(params).perform\n render_api_response(service_response)\n end", "def is_sites_storage_limit_automatic\n return @is_sites_storage_limit_automatic\n end", "def requestor_settings=(value)\n @requestor_settings = value\n end", "def implicit_grant_settings\n return @implicit_grant_settings\n end", "def automatic_replies_setting=(value)\n @automatic_replies_setting = value\n end", "def default_app_management_policy\n return @default_app_management_policy\n end", "def is_sites_storage_limit_automatic=(value)\n @is_sites_storage_limit_automatic = value\n end", "def user_requests_enabled\n @attributes[:user_requests_enabled]\n end", "def default_policy\n @default_policy\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the automaticRequestSettings property value. This property is only present for an auto assignment policy; if absent, this is a requestbased policy.
def automatic_request_settings=(value) @automatic_request_settings = value end
[ "def automatic_request_settings\n return @automatic_request_settings\n end", "def automatic_user_consent_settings=(value)\n @automatic_user_consent_settings = value\n end", "def automatic_replies_setting=(value)\n @automatic_replies_setting = value\n end", "def request_approval_settings=(value)\n @request_approval_settings = value\n end", "def enforced_settings=(value)\n @enforced_settings = value\n end", "def requestor_settings=(value)\n @requestor_settings = value\n end", "def automatic_update_mode=(value)\n @automatic_update_mode = value\n end", "def is_sites_storage_limit_automatic=(value)\n @is_sites_storage_limit_automatic = value\n end", "def set_automatic_scheduling(automatic)\n manager.automatic_scheduling = automatic == 'true'\n end", "def implicit_grant_settings=(value)\n @implicit_grant_settings = value\n end", "def update_request_settings(opts = {})\n data, _status_code, _headers = update_request_settings_with_http_info(opts)\n data\n end", "def create_request_settings(opts = {})\n data, _status_code, _headers = create_request_settings_with_http_info(opts)\n data\n end", "def updates_require_automatic_updates=(value)\n @updates_require_automatic_updates = value\n end", "def automatic_replies=(value)\n @automatic_replies = value\n end", "def is_automatic_reply=(value)\n @is_automatic_reply = value\n end", "def update_auto_approve_setting\n service_response = ClientManagement::UpdateAutoApproveSetting.new(params).perform\n render_api_response(service_response)\n end", "def network_proxy_automatic_configuration_url=(value)\n @network_proxy_automatic_configuration_url = value\n end", "def autoscaling(value)\n set_bool(:autoscaling, value)\n end", "def offer_shift_requests_enabled=(value)\n @offer_shift_requests_enabled = value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the catalog property value. Catalog of the access package containing this policy. Readonly.
def catalog return @catalog end
[ "def catalog=(value)\n @catalog = value\n end", "def catalogs\n return @catalogs\n end", "def catalog_type\n return @catalog_type\n end", "def catalog_number\n self[:CatalogNumber]\n end", "def catalogs=(value)\n @catalogs = value\n end", "def catalog\n return nil unless @raw_series.include?(\"catalog\")\n return @catalog unless @catalog.nil?\n @catalog = OpenStruct.new(@raw_series[\"catalog\"])\n end", "def access_package\n return @access_package\n end", "def catalog_value(key)\n return catalog[key]\n end", "def get_catalog(catalog_id)\n end", "def access_package=(value)\n @access_package = value\n end", "def catalog_type=(value)\n @catalog_type = value\n end", "def catalog?\n @resource_name == \"catalog\" && @actions[0] == \"*\"\n end", "def has_catalog?\n true\n end", "def catalog_info(opts = {})\n data, _status_code, _headers = catalog_info_with_http_info(opts)\n return data\n end", "def get_catalogs\n message = { session_id: @session_id }\n\n @soap_client.call(:get_catalogs, message: message).body[:get_catalogs_response][:return]\n end", "def catalog_location\n case __ub1(OCI_ATTR_CATALOG_LOCATION)\n when 0; :cl_start\n when 1; :cl_end\n end\n end", "def services()\n return @data[\"access\"][\"serviceCatalog\"]\n end", "def get_catalog_information uri, catalog_id\n catalog_uri = URI.parse(uri)\n catalog_uri.merge!(\"/obj/fCatalog/\" + catalog_id)\n catalog_res = Net::HTTP.get(catalog_uri)\n gz = Zlib::GzipReader.new(StringIO.new(catalog_res))\n catalog_info = gz.read\n doc = Nokogiri::XML(catalog_info)\n label = doc.xpath('//s:label')\n description = doc.xpath('//s:comment')\n catalog = Nesstar::Catalog.new\n catalog.nesstar_id = catalog_id\n catalog.nesstar_uri = uri\n catalog.label = label[0].content.strip unless label[0] == nil\n catalog.description = description[0].content.strip unless description[0] == nil\n return catalog\n end", "def access_packages\n return @access_packages\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the catalog property value. Catalog of the access package containing this policy. Readonly.
def catalog=(value) @catalog = value end
[ "def catalogs=(value)\n @catalogs = value\n end", "def catalog_type=(value)\n @catalog_type = value\n end", "def catalog_json=(str)\n @catalog_json = str\n @resource_hash = nil\n end", "def save_catalog(catalog, options)\n if Puppet::Resource::Catalog.indirection.cache?\n terminus = Puppet::Resource::Catalog.indirection.cache\n\n request = Puppet::Indirector::Request.new(terminus.class.name,\n :save,\n options.delete('certname'),\n catalog,\n options)\n\n terminus.save(request)\n end\n end", "def access_package=(value)\n @access_package = value\n end", "def catalog\n return nil unless @raw_series.include?(\"catalog\")\n return @catalog unless @catalog.nil?\n @catalog = OpenStruct.new(@raw_series[\"catalog\"])\n end", "def update_capability_catalog(moid, capability_catalog, opts = {})\n data, _status_code, _headers = update_capability_catalog_with_http_info(moid, capability_catalog, opts)\n data\n end", "def type_catalog=(tc)\n @type_catalog = tc\n end", "def catalog\n return @catalog\n end", "def access_packages=(value)\n @access_packages = value\n end", "def acl=(value)\n @acl = value\n end", "def set_movie_catalog\n @movie_catalog = MovieCatalog.find(params[:id])\n end", "def add_catalog_command\r\n add_command(\"Catalogue\", :catalogue, catalog_enabled)\r\n end", "def update\n return false unless authorize(permissions = [\"administer_catalog\"])\n @catalog = Catalog.find(params[:id])\n\n respond_to do |format|\n if @catalog.update_attributes(params[:catalog])\n flash.now[:notice] = t('admin.catalog.flash.updated')\n format.html { redirect_to(@catalog) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @catalog.errors, :status => :unprocessable_entity }\n end\n end\n end", "def catalog_type\n return @catalog_type\n end", "def catalogs\n return @catalogs\n end", "def catalog_number\n self[:CatalogNumber]\n end", "def catalog(opts = {})\n return nil unless catalog?\n\n opts[:replace] = true unless opts.key?(:replace)\n\n cat = Systemd::Journal.catalog_for(self[:message_id])\n # catalog_for does not do field substitution for us, so we do it here\n # if requested\n opts[:replace] ? field_substitute(cat) : cat\n end", "def acl=(_acl)\n fail Dav::Exception::NotImplemented, 'Updating ACLs is not implemented here'\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the customExtensionStageSettings property value. The collection of stages when to execute one or more custom access package workflow extensions. Supports $expand.
def custom_extension_stage_settings return @custom_extension_stage_settings end
[ "def custom_extension_stage_settings=(value)\n @custom_extension_stage_settings = value\n end", "def stage_settings\n return @stage_settings\n end", "def custom_settings\n return @custom_settings\n end", "def custom_extension\n return @custom_extension\n end", "def custom_workflow_extensions\n return @custom_workflow_extensions\n end", "def custom_extension_stage_instance_detail\n return @custom_extension_stage_instance_detail\n end", "def custom_workflow_extensions=(value)\n @custom_workflow_extensions = value\n end", "def stage_settings=(value)\n @stage_settings = value\n end", "def custom_extension_stage_instance_id\n return @custom_extension_stage_instance_id\n end", "def get_available_extension_properties()\n return MicrosoftGraph::GroupSettingTemplates::GetAvailableExtensionProperties::GetAvailableExtensionPropertiesRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def custom_extension=(value)\n @custom_extension = value\n end", "def custom_field_settings(options: {})\n\n Collection.new(parse(client.get(\"/portfolios/#{gid}/custom_field_settings\", options: options)), type: CustomFieldSetting, client: client)\n end", "def custom_settings=(value)\n @custom_settings = value\n end", "def extension_properties\n return @extension_properties\n end", "def custom_task_extensions\n return @custom_task_extensions\n end", "def getSettingsForDash\n\t\tif(!self.customCode)\n\t\t\treturn {}\n\t\telse\n\t\t\tsettings = Hash.new\n\t\t\tcustomSettings.each do |k,v|\n\t\t\t\tsettings[k] = v[:val]\n\t\t\tend\n\n\t\t\treturn settings\n\t\tend\n\tend", "def stage_enabled(stage)\n return get_stage_data(stage,'enabled')\n end", "def extension_setting(name)\n extension_settings.find{ |setting| setting.key == name.to_s }\n end", "def custom_extension_id\n return @custom_extension_id\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the customExtensionStageSettings property value. The collection of stages when to execute one or more custom access package workflow extensions. Supports $expand.
def custom_extension_stage_settings=(value) @custom_extension_stage_settings = value end
[ "def custom_extension_stage_settings\n return @custom_extension_stage_settings\n end", "def custom_workflow_extensions=(value)\n @custom_workflow_extensions = value\n end", "def custom_extension=(value)\n @custom_extension = value\n end", "def stage_settings=(value)\n @stage_settings = value\n end", "def custom_settings=(value)\n @custom_settings = value\n end", "def custom_task_extensions=(value)\n @custom_task_extensions = value\n end", "def custom_extension_stage_instance_id=(value)\n @custom_extension_stage_instance_id = value\n end", "def set_stage_configuration(config)\n deployment.stage.non_prompt_configurations.each do |effective_conf|\n value = resolve_references(config, effective_conf.value)\n config.set effective_conf.name.to_sym, Deployer.type_cast(value)\n end\n deployment.prompt_config.each do |k, v|\n v = resolve_references(config, v)\n config.set k.to_sym, Deployer.type_cast(v)\n end\n end", "def extensions=(value)\n @extensions = value\n end", "def custom_extension_stage_instance_detail=(value)\n @custom_extension_stage_instance_detail = value\n end", "def extensions=(extensions)\n @extensions = Array extensions\n end", "def custom_extension_id=(value)\n @custom_extension_id = value\n end", "def extensions=(val)\n set_extensions(val)\n val\n end", "def custom_extension\n return @custom_extension\n end", "def extend_options\n options.each do |option|\n klass = Post::Extension.const_get(option.camelize)\n self.extend klass\n end\n end", "def custom_field_settings(options: {})\n\n Collection.new(parse(client.get(\"/portfolios/#{gid}/custom_field_settings\", options: options)), type: CustomFieldSetting, client: client)\n end", "def on_premises_extension_attributes=(value)\n @on_premises_extension_attributes = value\n end", "def extension_properties=(value)\n @extension_properties = value\n end", "def custom_configuration=(value)\n @custom_configuration = value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the expiration property value. The expiration date for assignments created in this policy.
def expiration return @expiration end
[ "def expiration=(value)\n @expiration = value\n end", "def expiration_date_time\n return @expiration_date_time\n end", "def expiration_date\n @plist['ExpirationDate']\n end", "def getExpiration; @expires; end", "def management_certificate_expiration_date\n return @management_certificate_expiration_date\n end", "def expiration_time\n @expiration_time ||= 1.day\n end", "def expiration_date\n @stored_at + Rational(expiration_time.to_i, Utils::SECONDS_PER_DAY)\n end", "def certification_expiration_date_time\n return @certification_expiration_date_time\n end", "def expiration_date\n \"#{expiration_month}/#{expiration_year}\"\n end", "def expiration_date=(value)\n expiration_date_will_change!\n @expiration_date = value\n end", "def expiration_time\n Time.now.to_i + configuration.expiration_time\n end", "def management_certificate_expiration_date=(value)\n @management_certificate_expiration_date = value\n end", "def expiration_date\n @expiration_date ||= extract_warranty_date\n end", "def get_expiry_of_last()\n get_value_of(\"expiry\")\n end", "def expiration_behavior\n return @expiration_behavior\n end", "def expiration\n val = if (max_age = @hash['max-age'].to_s.strip).present?\n Time.zone.now + max_age.to_i\n else\n expire_time\n end\n val&.gmtime\n end", "def expires_at\n get_expires_at\n end", "def expires_at\n raise \"Override and return the metric's expiration time\"\n end", "def expiry=(value)\n @expiry = value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the expiration property value. The expiration date for assignments created in this policy.
def expiration=(value) @expiration = value end
[ "def expiration_date=(value)\n expiration_date_will_change!\n @expiration_date = value\n end", "def expiration=(expiration_date)\n unless self.new_record?\n logger.warn(\"Attempted to set expiration on existing record: access_token id=#{self.id}. Update ignored\")\n return\n end\n super(expiration_date)\n\n self.expired = expiration_date.nil? || (expiration_date == '') || expiration_date.past?\n end", "def expiry=(value)\n @expiry = value\n end", "def set_expiration_date\n self.expiration_date = DateTime.new(self.expiration_year,\n self.expiration_month,\n 28)\n end", "def expiration_date_time=(value)\n @expiration_date_time = value\n end", "def set_ExpirationDate(value)\n set_input(\"ExpirationDate\", value)\n end", "def expires=(value)\n @expires = value\n @expires_in = nil\n end", "def expiry=(v)\n v = v + '-01-01'\n write_attribute(:expiry, v)\n end", "def management_certificate_expiration_date=(value)\n @management_certificate_expiration_date = value\n end", "def terms_expiration=(value)\n @terms_expiration = value\n end", "def set_ExpirationDate(value)\n set_input(\"ExpirationDate\", value)\n end", "def set_expires_at\n self[:expires_at] = case self.expiry_option \n when :in then Time.now.utc + (self.expiry_days || 3).days\n when :on then self[:expires_at]\n else self[:expires_at]\n end\n end", "def set_expires_at\n self[:expires_at] = case self.expiry_option \n when :in then Time.now.utc + (self.expiry_days || DEFAULT_EXPIRY_DAYS).days\n when :on then self[:expires_at]\n else self[:expires_at]\n end\n end", "def set_as_expired(expiration_datetime = DateTime.now)\n self.status = Status::EXPIRED\n self.expired_at = expiration_datetime\n self\n end", "def expires_in=(duration)\n self.expires_at = duration.from_now\n end", "def set_DateOfExpiration(value)\n set_input(\"DateOfExpiration\", value)\n end", "def expiration_behavior=(value)\n @expiration_behavior = value\n end", "def set_ExpirationMonth(value)\n set_input(\"ExpirationMonth\", value)\n end", "def certification_expiration_date_time=(value)\n @certification_expiration_date_time = value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the questions property value. Questions that are posed to the requestor.
def questions return @questions end
[ "def questions\n @data[:questions]\n end", "def questions=(value)\n @questions = value\n end", "def question\n return @question\n end", "def custom_questions\n return @custom_questions\n end", "def question=(value)\n @question = value\n end", "def question\n # get the question for every user\n end", "def questions\n @questions ||= qa_buffer.map{|qq|qq.first}\n end", "def questions\n self.class.get('/2.2/questions', @options)\n end", "def answers\n return @answers\n end", "def questions\n expansions.map(&:questions).flatten\n end", "def custom_question_answers\n return @custom_question_answers\n end", "def custom_questions=(value)\n @custom_questions = value\n end", "def questions\n @_questions ||= input_questions.map do |question|\n text_answers = answers_for(question.ids)\n\n Question.with_response_data(\n question: question,\n answer: typecast_answer(answer: text_answers, type: question.type),\n text: extrapolated_question_text(question),\n original_answer: text_answers\n )\n end\n end", "def question\n answer.question\n end", "def currentQuestion\n @questions[@questionsCompleted]\n end", "def questions\n qs = []\n qs |= self.class.questions if self.class.respond_to? :questions\n qs |= (@_questions||=[])\n qs.map{|q| q.for_instance(self) }\n end", "def questions\n question_settings = self.settings(:export).fields[:questions]\n @questions ||= if question_settings.present?\n if question_settings == :all\n Question.where(section_id: self.plan.sections.collect { |s| s.id }).pluck(:id)\n elsif question_settings.is_a?(Array)\n question_settings\n else\n []\n end\n else\n []\n end\n end", "def questions\n qs = []\n qs |= superclass.questions if superclass.respond_to? :questions\n qs |= (@_questions||=[])\n qs\n end", "def questions\n question_settings = settings(:export).fields[:questions]\n @questions ||= if question_settings.present?\n case question_settings\n when :all\n Question.where(section_id: plan.sections.collect(&:id)).pluck(:id)\n when Array\n question_settings\n else\n []\n end\n else\n []\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the questions property value. Questions that are posed to the requestor.
def questions=(value) @questions = value end
[ "def question=(value)\n @question = value\n end", "def custom_questions=(value)\n @custom_questions = value\n end", "def answers=(value)\n @answers = value\n end", "def custom_question_answers=(value)\n @custom_question_answers = value\n end", "def question=(object)\n case object\n when Array\n if object.all? {|x| x.kind_of? Net::DNS::Question}\n @question = object\n else\n raise ArgumentError, \"Some of the elements is not an Net::DNS::Question object\"\n end\n when Net::DNS::Question\n @question = [object]\n else\n raise ArgumentError, \"Invalid argument, not a Question object nor an array of objects\"\n end\n end", "def answer_options=(value)\n @answer_options = value\n end", "def questions\n @_questions ||= input_questions.map do |question|\n text_answers = answers_for(question.ids)\n\n Question.with_response_data(\n question: question,\n answer: typecast_answer(answer: text_answers, type: question.type),\n text: extrapolated_question_text(question),\n original_answer: text_answers\n )\n end\n end", "def replies=(value)\n @replies = value\n end", "def questions\n self.class.get('/2.2/questions', @options)\n end", "def set_QuestionType(value)\n set_input(\"QuestionType\", value)\n end", "def set_questionnaire\n questionnaire_reference.reference = \"Questionnaire/#{DEFAULT_QUESTIONNAIRE_ID}\"\n end", "def questions\n @data[:questions]\n end", "def answer=(value)\n @answer = value\n end", "def question_id=(value)\n @question_id = value\n end", "def response_to_questions\n opts[:questions].each do |response|\n @obj.response_questions.build(\n question_id: response[:id],\n question: response[:question],\n answer: response[:answer],\n default_question: response[:default_question]\n )\n end\n end", "def prompts=(value)\n @prompts = value\n end", "def value=(val)\n # Deal with nil values, generated by empty checkbox questions\n val = {} if val.nil?\n\n if locked?\n logger.warn \"Attempting to change value of locked answer: survey: #{answer_session.survey.slug} | question: #{question.slug} | user: #{answer_session.user.email} | encounter: #{answer_session.encounter}\"\n return nil\n end\n\n self[:preferred_not_to_answer] = (val.delete('preferred_not_to_answer') ? true : false)\n\n answer_values.clear\n template_completions = []\n template_values = []\n\n question.answer_templates.each do |template|\n target_field = template.data_type\n\n if val.kind_of?(Hash)\n val_for_template = val[template.id.to_s]\n else\n # Temporary - remove this option! Always set with hash\n raise StandardError\n #val_for_template = val\n end\n\n if template.preprocess.present?\n val_for_template = template.preprocess_value(val_for_template)\n end\n\n template_values << val_for_template\n\n # Test for nested inputs. There is a dependency: all conditionals are one-level, and the first answer template in questions with nested inputs is a categorical question that spawns the nesting.\n # TODO: Add Testing\n if template.target_answer_option.present? and template_completions.first\n answer_option_ids = template_values.first.kind_of?(Array) ? template_values.first : [template_values.first]\n answer_options = answer_option_ids.map{ |ao_id| AnswerOption.find(ao_id) }\n answer_option_values = answer_options.map(&:value)\n\n template_completion = answer_option_values.include?(template.target_answer_option) ? val_for_template.present? : true\n else\n template_completion = val_for_template.present?\n end\n\n template_completions << template_completion\n\n if template.allow_multiple and val_for_template.kind_of?(Array)\n val_for_template.each {|v| answer_values.build(target_field => v, 'answer_template_id' => template.id) }\n else\n answer_values.build(target_field => val_for_template, 'answer_template_id' => template.id)\n end\n end\n\n set_completion_state(template_completions)\n\n if self.persisted?\n self.save\n end\n end", "def questions\n return @questions\n end", "def update_questions_correct_answers\n self.questions.each {|question| question.update_correct_answers}\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the requestApprovalSettings property value. Specifies the settings for approval of requests for an access package assignment through this policy. For example, if approval is required for new requests.
def request_approval_settings return @request_approval_settings end
[ "def request_approval_settings=(value)\n @request_approval_settings = value\n end", "def get_access_approval_settings request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_get_access_approval_settings_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::AccessApproval::V1::AccessApprovalSettings.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def is_approval_request=(value)\n @is_approval_request = value\n end", "def update_access_approval_settings request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_update_access_approval_settings_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::AccessApproval::V1::AccessApprovalSettings.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def is_approval_request\n return @is_approval_request\n end", "def approval_mode\n return @approval_mode\n end", "def access_package_assignment_approvals=(value)\n @access_package_assignment_approvals = value\n end", "def automatic_request_settings\n return @automatic_request_settings\n end", "def requestor_settings\n return @requestor_settings\n end", "def requestor_settings=(value)\n @requestor_settings = value\n end", "def approval_mode=(value)\n @approval_mode = value\n end", "def access_package_assignment_approvals\n return @access_package_assignment_approvals\n end", "def automatic_request_settings=(value)\n @automatic_request_settings = value\n end", "def is_approval_required=(value)\n @is_approval_required = value\n end", "def implicit_grant_settings=(value)\n @implicit_grant_settings = value\n end", "def content_approval_status\n return @content_approval_status\n end", "def is_approval_required\n return @is_approval_required\n end", "def approver_requests\n @approver_requests ||= approver_request_ids\n end", "def get_request_settings(opts = {})\n data, _status_code, _headers = get_request_settings_with_http_info(opts)\n data\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the requestApprovalSettings property value. Specifies the settings for approval of requests for an access package assignment through this policy. For example, if approval is required for new requests.
def request_approval_settings=(value) @request_approval_settings = value end
[ "def update_access_approval_settings request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_update_access_approval_settings_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::AccessApproval::V1::AccessApprovalSettings.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def is_approval_request=(value)\n @is_approval_request = value\n end", "def request_approval_settings\n return @request_approval_settings\n end", "def access_package_assignment_approvals=(value)\n @access_package_assignment_approvals = value\n end", "def requestor_settings=(value)\n @requestor_settings = value\n end", "def get_access_approval_settings request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_get_access_approval_settings_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::AccessApproval::V1::AccessApprovalSettings.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def automatic_request_settings=(value)\n @automatic_request_settings = value\n end", "def approval_mode=(value)\n @approval_mode = value\n end", "def implicit_grant_settings=(value)\n @implicit_grant_settings = value\n end", "def is_approval_required=(value)\n @is_approval_required = value\n end", "def update_request_settings(opts = {})\n data, _status_code, _headers = update_request_settings_with_http_info(opts)\n data\n end", "def admin_consent_request_policy=(value)\n @admin_consent_request_policy = value\n end", "def delete_access_approval_settings 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_delete_access_approval_settings_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::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def approve_approval_request 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_approve_approval_request_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::AccessApproval::V1::ApprovalRequest.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def assignment_requests=(value)\n @assignment_requests = value\n end", "def pre_approval=(pre_approval)\n @pre_approval = ensure_type(PreApproval, pre_approval)\n end", "def content_approval_status=(value)\n @content_approval_status = value\n end", "def enforced_settings=(value)\n @enforced_settings = value\n end", "def edit_merge_request_approvals(project, merge_request, options = {})\n post(\"/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals\", body: options)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the requestorSettings property value. Provides additional settings to select who can create a request for an access package assignment through this policy, and what they can include in their request.
def requestor_settings return @requestor_settings end
[ "def requestor_settings=(value)\n @requestor_settings = value\n end", "def request_approval_settings\n return @request_approval_settings\n end", "def request_approval_settings=(value)\n @request_approval_settings = value\n end", "def requestor=(value)\n @requestor = value\n end", "def automatic_request_settings\n return @automatic_request_settings\n end", "def requestor\n return @requestor\n end", "def conditional_access_settings\n return @conditional_access_settings\n end", "def get_settings\n settings = {}\n settings['sharing_scope'] = self.sharing_scope\n settings['access_type'] = self.access_type\n settings['use_custom_sharing'] = self.use_custom_sharing\n settings['use_whitelist'] = self.use_whitelist\n settings['use_blacklist'] = self.use_blacklist\n return settings\n end", "def assignment_settings\n return @assignment_settings\n end", "def implicit_grant_settings\n return @implicit_grant_settings\n end", "def settings()\n return MicrosoftGraph::IdentityGovernance::EntitlementManagement::Settings::SettingsRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def automatic_request_settings=(value)\n @automatic_request_settings = value\n end", "def get_request_settings(opts = {})\n data, _status_code, _headers = get_request_settings_with_http_info(opts)\n data\n end", "def settings\n return @settings\n end", "def requestor\n @requestor ||= requestor_class.new(self)\n end", "def implicit_grant_settings=(value)\n @implicit_grant_settings = value\n end", "def settings\n Buildr.application.settings\n end", "def user_account_control_settings\n return @user_account_control_settings\n end", "def member_settings\n return @member_settings\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the requestorSettings property value. Provides additional settings to select who can create a request for an access package assignment through this policy, and what they can include in their request.
def requestor_settings=(value) @requestor_settings = value end
[ "def requestor=(value)\n @requestor = value\n end", "def requestor_settings\n return @requestor_settings\n end", "def request_approval_settings=(value)\n @request_approval_settings = value\n end", "def automatic_request_settings=(value)\n @automatic_request_settings = value\n end", "def implicit_grant_settings=(value)\n @implicit_grant_settings = value\n end", "def enable_on_behalf_requestors_to_update_access=(value)\n @enable_on_behalf_requestors_to_update_access = value\n end", "def requestor\n @requestor ||= requestor_class.new(self)\n end", "def on_behalf_requestors=(value)\n @on_behalf_requestors = value\n end", "def assignment_settings=(value)\n @assignment_settings = value\n end", "def requestor()\n return MicrosoftGraph::IdentityGovernance::EntitlementManagement::AssignmentRequests::Item::Requestor::RequestorRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def assignment_requests=(value)\n @assignment_requests = value\n end", "def set_request_specific_data!(settings, domain, protocol)\n settings[:domain] = domain\n settings[:protocol] = protocol\n settings\n end", "def conditional_access_settings=(value)\n @conditional_access_settings = value\n end", "def permission_grant_policies=(value)\n @permission_grant_policies = value\n end", "def update_request_settings(opts = {})\n data, _status_code, _headers = update_request_settings_with_http_info(opts)\n data\n end", "def settings=(value)\n @settings = value\n end", "def request_approval_settings\n return @request_approval_settings\n end", "def enable_on_behalf_requestors_to_add_access=(value)\n @enable_on_behalf_requestors_to_add_access = value\n end", "def requestor\n return @requestor\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the reviewSettings property value. Settings for access reviews of assignments through this policy.
def review_settings return @review_settings end
[ "def review_settings=(value)\n @review_settings = value\n end", "def assignment_settings\n return @assignment_settings\n end", "def assignment_settings=(value)\n @assignment_settings = value\n end", "def access_reviews\n return @access_reviews\n end", "def get_review_generation_settings(account_id, v, opts = {})\n data, _status_code, _headers = get_review_generation_settings_with_http_info(account_id, v, opts)\n return data\n end", "def settings\n return @settings\n end", "def recommendation_insight_settings\n return @recommendation_insight_settings\n end", "def conditional_access_settings\n return @conditional_access_settings\n end", "def request_approval_settings\n return @request_approval_settings\n end", "def enforced_settings\n return @enforced_settings\n end", "def get_settings\n settings = {}\n settings['sharing_scope'] = self.sharing_scope\n settings['access_type'] = self.access_type\n settings['use_custom_sharing'] = self.use_custom_sharing\n settings['use_whitelist'] = self.use_whitelist\n settings['use_blacklist'] = self.use_blacklist\n return settings\n end", "def review_set\n return @review_set\n end", "def access_review_id\n return @access_review_id\n end", "def implicit_grant_settings\n return @implicit_grant_settings\n end", "def review_sets\n return @review_sets\n end", "def settings\n @settings ||= (parent&.settings || Settings).for(self)\n end", "def member_settings\n return @member_settings\n end", "def custom_settings\n return @custom_settings\n end", "def requestor_settings\n return @requestor_settings\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the reviewSettings property value. Settings for access reviews of assignments through this policy.
def review_settings=(value) @review_settings = value end
[ "def assignment_settings=(value)\n @assignment_settings = value\n end", "def review_set=(value)\n @review_set = value\n end", "def update_review_generation_settings(account_id, v, review_generation_settings_request, opts = {})\n data, _status_code, _headers = update_review_generation_settings_with_http_info(account_id, v, review_generation_settings_request, opts)\n return data\n end", "def review_settings\n return @review_settings\n end", "def set(settings)\n @settings.merge!(settings)\n end", "def access_reviews=(value)\n @access_reviews = value\n end", "def recommendation_insight_settings=(value)\n @recommendation_insight_settings = value\n end", "def review_sets=(value)\n @review_sets = value\n end", "def settings=(value)\n @settings = value\n end", "def review=(r)\r\n # don't have to reset, because the product method does it\r\n self.product = r.product\r\n # add the review stuff\r\n self.page_name = \"Read Review: #{r.sound_bite} (#{r.id})\"\r\n # TODO LTC - is it odd that the page name isn't the same what we put on the hier stack?\r\n self.hierarchy << \"#{r.sound_bite} (#{r.id})\"\r\n self.page_type = \"Review Page\"\r\n self.reviewer = ((r.user != nil) && (r.user.screen_name != nil)) ? r.user.screen_name : '[not logged in]'\r\n end", "def request_approval_settings=(value)\n @request_approval_settings = value\n end", "def settings=(new_settings)\n settings.merge!(new_settings)\n end", "def reviewers=(value)\n @reviewers = value\n end", "def access_review_id=(value)\n @access_review_id = value\n end", "def enforced_settings=(value)\n @enforced_settings = value\n end", "def implicit_grant_settings=(value)\n @implicit_grant_settings = value\n end", "def requestor_settings=(value)\n @requestor_settings = value\n end", "def conditional_access_settings=(value)\n @conditional_access_settings = value\n end", "def assignment_policy=(value)\n @assignment_policy = value\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the specificAllowedTargets property value. The principals that can be assigned access from an access package through this policy.
def specific_allowed_targets return @specific_allowed_targets end
[ "def request_access_for_allowed_targets\n return @request_access_for_allowed_targets\n end", "def specific_allowed_targets=(value)\n @specific_allowed_targets = value\n end", "def allowed_target_scope\n return @allowed_target_scope\n end", "def request_access_for_allowed_targets=(value)\n @request_access_for_allowed_targets = value\n end", "def granted_to_identities\n return @granted_to_identities\n end", "def allowed_permissions\n if self[:joinable_type]\n self[:joinable_type].constantize.permissions\n else\n raise \"Cannot get allowed access levels because permission is not attached to a permissable yet: #{inspect}\"\n end\n end", "def granted_to\n return @granted_to\n end", "def grantable_privileges\n return [] if !self.is_grant?\n return [self.privilege] if self.class_name == 'any'\n klass = self.target_class\n return klass.declared_privileges + [:any] if self.privilege == :any\n return [self.privilege] + klass.sg_priv_to_implied_privs[self.privilege]\n end", "def can?(user, action, target)\n @permissions.select { |cls, _| target.is_a?(cls) || target == cls }\n .collect { |_, perms| perms }\n .flatten\n .select { |perm| perm.has_action? action }\n .any? { |perm| perm.allow? user, target }\n end", "def allowed_target_projects\n Project.allowed_to(user, :import_issues)\n end", "def get_targets method, action\n permission.static_rules.send(method).send(:[], action.to_s)\n end", "def target_resources\n return @target_resources\n end", "def target_types\n return @target_types\n end", "def is_direct_collaborator?\n permission_sources = data.fetch(\"permissionSources\")\n permission_sources.size == 1 && permission_sources.first.fetch(\"source\").has_key?(\"nameWithOwner\") # nameWithOwner means this is a Repository permission\n end", "def project_permissions\n user.project_permissions(rule.project)\n end", "def allowed_target_trackers\n Issue.allowed_target_trackers(project, user)\n end", "def target_in_privileges?\n @privileges.key?(@target)\n end", "def target_group_arns\n data[:target_group_arns]\n end", "def alternate_implied_privileges\n if self.class_name == 'any'\n return [self.privilege] \n end\n klass = self.target_class\n return [self.privilege] + klass.sg_priv_to_implied_privs[self.privilege] + klass.sg_implied_priv_to_privs[self.privilege]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the specificAllowedTargets property value. The principals that can be assigned access from an access package through this policy.
def specific_allowed_targets=(value) @specific_allowed_targets = value end
[ "def request_access_for_allowed_targets=(value)\n @request_access_for_allowed_targets = value\n end", "def specific_allowed_targets\n return @specific_allowed_targets\n end", "def allowed_target_scope=(value)\n @allowed_target_scope = value\n end", "def granted_to_identities=(value)\n @granted_to_identities = value\n end", "def target_objects=(value)\n @target_objects = value\n end", "def groups(*target_groups)\n target_groups.each do |target_group_name|\n grant_rights_on_group(target_group_name)\n end\n end", "def request_access_for_allowed_targets\n return @request_access_for_allowed_targets\n end", "def set_protected_access(*perms)\n perms.each do |perm_symbol|\n perm = find_permission_object(perm_symbol)\n if perm\n perm.set_as_protected_access \n else\n msg = \"Permission not found: #{perm_symbol}\"\n raise Lockdown::InvalidRuleAssignment, msg\n end\n end\n end", "def granted_to=(value)\n @granted_to = value\n end", "def targets=(value)\n @targets = value\n end", "def limit_targets=(limit)\n unless limit\n @limit_targets = nil\n return\n end\n\n if limit.is_a?(String)\n raise \"Invalid limit specified: #{limit} valid limits are /^\\d+%*$/\" unless limit =~ /^\\d+%*$/\n\n begin\n @limit_targets = Integer(limit)\n rescue\n @limit_targets = limit\n end\n else\n @limit_targets = Integer(limit)\n end\n end", "def set_permissions(*args)\n self.permissions = {}\n args.each do | permission |\n raise InvalidPermissionError.new(\"Permission #{permission} is invalid.\") unless ALLOWED_PERMISSIONS.include?(permission)\n self.permissions[permission] = true\n end\n end", "def remove_access_when_target_leaves_allowed_targets=(value)\n @remove_access_when_target_leaves_allowed_targets = value\n end", "def acts_as_configurable_target(options = {})\n return if self.included_modules.include?(Nkryptic::ActsAsConfigurable::TargetInstanceMethods)\n send :include, Nkryptic::ActsAsConfigurable::TargetInstanceMethods\n \n has_many :_targetable_settings,\n :as => :targetable,\n :class_name => 'ConfigurableSetting',\n :dependent => :destroy\n \n end", "def allowed_target_scope\n return @allowed_target_scope\n end", "def consented_permission_set=(value)\n @consented_permission_set = value\n end", "def set_public_access(*perms)\n perms.each do |perm_symbol|\n perm = find_permission_object(perm_symbol)\n if perm\n perm.set_as_public_access \n else\n msg = \"Permission not found: #{perm_symbol}\"\n raise Lockdown::InvalidRuleAssignment, msg\n end\n end\n end", "def target_types=(value)\n @target_types = value\n end", "def update_target_permissions(all_permissions:, permissions_params:, targets_to_add_group: [], targets_to_update_perms: [], targets_to_remove_group: [], type:, group_id:, successes: [], fails: [], overwrite_fails: [], revision_ids: {})\n identity_type = \"#{type}_identity\"\n\n all_permissions.each do |full_perm|\n concept_id = full_perm['concept_id']\n acl_object = full_perm.fetch('acl', {})\n target = acl_object.fetch(identity_type, {}).fetch('target', nil)\n new_perms = permissions_params[target] || []\n if targets_to_add_group.include?(target)\n new_perm_obj = edit_permission_object(\n permission_object: acl_object,\n action: 'add',\n new_permissions: new_perms,\n group_id: group_id\n )\n elsif targets_to_remove_group.include?(target)\n new_perm_obj = edit_permission_object(\n permission_object: acl_object,\n action: 'remove',\n new_permissions: new_perms,\n group_id: group_id\n )\n elsif targets_to_update_perms.include?(target)\n new_perm_obj = edit_permission_object(\n permission_object: acl_object,\n action: 'replace',\n new_permissions: new_perms,\n group_id: group_id\n )\n end\n\n next unless new_perm_obj\n\n update_permission(\n acl_object: new_perm_obj,\n concept_id: concept_id,\n identity_type: identity_type,\n target: target,\n successes: successes,\n fails: fails,\n overwrite_fails: overwrite_fails,\n revision_id: revision_ids[target]\n )\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
pins that are dropped
def dropped_pins location = Location.new location.name = params[:locations][:name] location.description = "" location.user_id = @current_user.id location.trip_id = params[:locations][:trip_id] location.coordinates = [params[:locations][:pin][1].to_f, params[:locations][:pin][0].to_f] location.save! @redirect = "/trips/#{params[:locations][:trip_id]}" end
[ "def drops\n @drops\n end", "def custom_drops; @extra_drop; end", "def unpin\n @pinned = false\n end", "def cleanup_pins\n pin(:resetb).drive(0)\n pin(:tclk).drive(0)\n pin(:tdi).drive(0)\n pin(:tms).drive(0)\n pin(:tdo).dont_care\n end", "def on_tile_drop(dropped_tile)\n layout_tiles\n end", "def pin_clear\n @pinmap.each { |pin_name, pin| pin.destroy }\n @pinmap.clear\n @patternpinindex.clear\n @patternorder.delete_if { true }\n @cycletiming.clear\n 'P:'\n end", "def file_dropped(*files); end", "def drop(e)\n plyr = get_object(e.from)\n place = get_object(plyr.location)\n # remove it\n plyr.delete_contents(id)\n # add it\n place.add_contents(id)\n self.location = place.id\n add_event(id,e.from,:show,\"You drop the #{name}\")\n end", "def turn_off\n @output_pins.each do |pin|\n set_low(pin)\n end\n end", "def remove_tip_pools\n #remove the tip values from the shift and then destroy it\n self.tip_pools.each do |tip|\n tip.destroy\n end\n end", "def touch_pins_if_necessary\n return true unless %w(avatar avatar_x avatar_y avatar_w avatar_h username).any? {|attrib| changes[attrib]}\n pins.map(&:touch)\n end", "def waypoints_minus_removed\n points = []\n waypoints.each do |waypoint|\n points << waypoint if !waypoint.marked_for_destruction?\n end\n points\n end", "def border_points_minus_removed\n points = []\n border_points.each do |point|\n points << point if !point.marked_for_destruction?\n end\n points\n end", "def inhibited_pins\n @inhibited_pins ||= []\n end", "def missed_destinations(chosen_road)\n # An array of all the roads left behind\n roads_left_behind = roads_available.reject {|road| road == chosen_road }\n # collect the destination left behind with those roads \n roads_left_behind.map { |road| road.the_city_opposite(@current_city)}\n\n end", "def drops\n jerrycan.drops\n end", "def drop\n prev = nil\n sand = @source.dup\n\n while sand != prev\n sand, prev = drop_step(sand), sand\n return false if sand.y > @maxy\n end\n\n set(sand, \"o\")\n true\n end", "def contained_pins\n pins = []\n @pin_id.each do |a|\n a.each do |p|\n pins << p\n end\n end\n pins.uniq\n end", "def drop_to(container, bikes)\n bikes.each do |bike|\n container.dock(bike)\n release(bike) \n end \n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
TL;DR: adds data layers between existing base layers. Stacks data layer on top of the last data layer and/or the first base layer found, and keeps any existing "top" base layers on top.
def copy_data_layers(origin_map, destination_map, user) last_data = destination_map.layers.reverse.find(&:data_layer?) order = if last_data last_data.order + 1 else first_base = destination_map.layers.find(&:base_layer?) first_base ? (first_base.order + 1) : 0 end modified_layers = [] data_layer_copies_from(origin_map, user).map do |layer| # Push layers on top if needed if(destination_map.layers.map(&:order).include?(order)) destination_map.layers.select { |l| l.order >= order }.each do |layer| layer.order += 1 # layer must be saved later modified_layers << layer end end layer.order = order link(destination_map, layer) # link saves modified_layers -= [layer] order += 1 end # this avoid extra saving (including validation) overhead modified_layers.uniq.map(&:save) end
[ "def add_layers\n add_top_layers if pushing_top_3d_boundary?\n add_bottom_layers if pushing_bot_3d_boundary?\n end", "def add_bottom_layers\n @hypercube.each do |grid|\n new_layer = Array.new(@y_dim) { Array.new(@x_dim) { '.' } }\n grid.unshift(new_layer)\n end\n @z_origin += 1\n @z_dim += 1\n end", "def add_layers\n bottom_layer = @grid.first\n top_layer = @grid.last\n add_top_layer if top_layer.flatten.count('#').positive?\n add_bottom_layer if bottom_layer.flatten.count('#').positive?\n end", "def add_bottom_layer\n new_layer = Array.new(@y_length) { Array.new(@x_width) { '.' } }\n @grid.unshift(new_layer)\n @z_origin += 1\n @z_height += 1\n end", "def _add_layer(layer)\n\t\t\t@layers << layer\n\t\tend", "def add_layer(new_layer, context)\n current_layer = expand_context(context)\n current_layer[new_layer] ||= layers_factory\n end", "def add_layer(new_layer)\n #first determine if the layer already exists.\n @layers.each do |current_layer|\n if new_layer == current_layer\n return current_layer\n end\n end\n @layers.push(new_layer)\n return @layers.last()\n end", "def unshift_layer!(layer)\n raise Exception::OptionShouldBeRecursive.new(layer) unless Utils.recursive?(layer)\n\n if layer.is_a?(self.class)\n layer.structures.dup.concat(structures)\n else\n structures.unshift(layer)\n end\n\n dirty!\n end", "def add_layer(layer)\r\n @layers.push(layer)\r\n end", "def add_layer_at(layer_name, location)\n if location.kind_of? Numeric\n @layer_order.delete_at(location) if @layer_order[location].nil?\n @layer_order.insert(location, layer_name)\n else # string/symbol\n case location.to_s\n when FRONT_LAYER\n @layer_order << layer_name\n when BACK_LAYER\n @layer_order.unshift(layer_name)\n end\n end\n @layers[layer_name] = []\n end", "def merge(*data)\n merged = data.compact.inject(@input) do |acc, layer|\n assert_hash_or_config(layer)\n layer_data = layer.is_a?(self.class) ? layer.input : layer\n Bolt::Util.deep_merge(acc, layer_data)\n end\n\n self.class.new(merged, @project)\n end", "def initialize_layers(config_layers = nil) #:doc:\n @config_layers = []\n\n config_layers.each do |layer|\n next unless layer.is_a?(Hash) && layer.key?(:config) &&\n layer[:config].is_a?(BaseConfig)\n next unless layer[:name].is_a?(String)\n @config_layers << _initialize_layer(layer)\n end\n @config_layers.reverse!\n end", "def overlay(base, layer)\n return base.each_with_index.map{|row,r|\n row.each_with_index.map{|e,c|\n e.nil? ? layer[r][c] : e\n }\n }\n end", "def makeLayersGroups\n @resLayerName = getLayerName('results') ## get unique layer name for results layer\n @resLayer = @model.layers.add(@resLayerName)\n @resLayer.set_attribute(\"layerData\", \"results\", true)\n @resultsGroup = @entities.add_group\n @resultsGroup.layer = @resLayerName\n end", "def setup_layers\n x = self.x - 12\n y = self.y - 12\n create_layer(0, \"SAM-storage-background\", 0, x, y, self.openness)\n\tend", "def add_layer\n Layer.create(:name => @new_table_name, :table_name => @new_table_name, :geometric_column_name => \"the_geom\")\n end", "def << layer\n unload!\n source << layer\n self\n end", "def add_layer(thickness, conductivity, density, specific_heat)\n layer = Layer.new()\n # Make sure all the values are > 0.\n layer.set(thickness, conductivity, density, specific_heat)\n @layers.push(layer)\n end", "def setup_layers\n\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Getter. Gets all activities for a given board.
def activities return @activities if @activities != nil && @activities.length > 0 @activities = [] self.board.cards.each do |card| card.actions.each do |action| member = Trello::Member.find(action.member_creator_id) action_record = {action: action, member: member} activity = (Parser.new(action_record, @prefix)).parse @activities.push(activity) unless activity == nil end end @activities end
[ "def activities\n return @activities if !@activities.nil? && @activities.length > 0\n \n @activities = []\n self.board.cards.each do |card|\n card.actions.each do |action|\n member = self.members.select { |member| member.id == action.member_creator_id }.first\n action_record = {action: action, member: member}\n activity = self.parser.parse(action_record)\n @activities.push(activity) unless activity.nil?\n end\n end\n \n @activities\n end", "def activities\n return @activities\n end", "def activities\n return @activities\n end", "def all_activities\n get('activities.json')\n end", "def all_activities\n t = PublicActivity::Activity.arel_table\n PublicActivity::Activity.where(\n t[:trackable_id].eq(id).and(t[:trackable_type].eq(Classroom.to_s)).or(\n t[:recipient_id].eq(id).and(t[:recipient_type].eq(Classroom.to_s))\n )\n ).reverse_order\n end", "def activities\n\t activity_feed.activities\n\tend", "def activities\n @grouped_activities.flatten\n end", "def activities\n url = \"http://nikeplus.nike.com/plus/activity/running/#{ @screenname }/lifetime/activities?indexStart=0&indexEnd=9999\"\n data = get(url)\n activity_list = data.activities.any? ? data.activities.collect { |a| NikePlus::ActivitySummary.new( a.activity ) } : []\n end", "def get_space_activities(params = {})\n get('space/activities', params)\n end", "def all_activities\n if user.present?\n Activity.where('(activity_owner_id = :activity_owner_id and activity_owner_type = :activity_owner_type) or user_id = :user_id',\n activity_owner_id: id, activity_owner_type: self.class.name, user_id: user.id).order(created_at: :desc)\n else\n activities\n end\n end", "def activity_ids\n self.activities.collect(&:activityId)\n end", "def find_recent_activities\n @recent_activities = RecentActivity.all\n end", "def bioactivities\n BioChEMBL::Bioactivity.parse_list_xml(REST.new.assays(@chemblId, 'bioactivities'))\n end", "def bioactivities\n BioChEMBL::Bioactivity.parse_list_xml(REST.new.targets(chemblId, 'bioactivities'))\n end", "def activities_for_event(event)\n return @all_activities if event.nil?\n @all_activities.select{ |sa| event.matches_activity(sa) }\n end", "def getMEELeadActivities\n users = User.all.pluck(:id)\n activities = []\n users.each do |id|\n username = User.find(id).display_name\n #create list of [[user, [their activities...]]...]\n activities.push([username, Activity.where(user_id: id)]) \n end\n return activities \n end", "def board\n client.get(\"/actions/#{id}/board\").json_into(Board)\n end", "def board\n return @board if @board\n @board = Client.get(\"/actions/#{id}/board\").json_into(Board)\n end", "def activities(per_page: nil, page: nil)\n if page || per_page\n get_activities(per_page: per_page, page: page)\n else\n get_activities if @activities.empty?\n @activities.values\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /role_funcions POST /role_funcions.json
def create @role_funcion = RoleFuncion.new(role_funcion_params) respond_to do |format| if @role_funcion.save format.html { redirect_to @role_funcion } format.json { render action: 'show', status: :created, location: @role_funcion } else format.html { render action: 'new' } format.json { render json: @role_funcion.errors, status: :unprocessable_entity } end end end
[ "def update\n respond_to do |format|\n if @role_funcion.update(role_funcion_params)\n format.html { redirect_to @role_funcion }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @role_funcion.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @role_funcion.destroy\n respond_to do |format|\n format.html { redirect_to role_funcions_url }\n format.json { head :no_content }\n end\n end", "def create\n @funcion = Funcion.new(funcion_params)\n\n respond_to do |format|\n if @funcion.save\n format.html { redirect_to @funcion, notice: 'Funcion was successfully created.' }\n format.json { render :show, status: :created, location: @funcion }\n else\n format.html { render :new }\n format.json { render json: @funcion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ums_function = Ums::Function.new(ums_function_params)\n\n respond_to do |format|\n if @ums_function.save\n format.html { redirect_to ums.functions_url, notice: '功能创建创建成功.' }\n format.json { render action: 'show', status: :created, location: @ums_function }\n else\n format.html { render action: 'new' , status: :unprocessable_entity}\n format.json { render json: @ums_function.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @member_function = MemberFunction.new(member_function_params)\n\n respond_to do |format|\n if @member_function.save\n format.html { redirect_to @member_function, notice: 'Member function was successfully created.' }\n format.json { render :show, status: :created, location: @member_function }\n else\n format.html { render :new }\n format.json { render json: @member_function.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_function = Admin::Function.new(admin_function_params)\n\n respond_to do |format|\n if @admin_function.save\n format.html { redirect_to @admin_function, notice: 'Function was successfully created.' }\n format.json { render :show, status: :created, location: @admin_function }\n else\n format.html { render :new }\n format.json { render json: @admin_function.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @func = Func.new(func_params)\n\n respond_to do |format|\n if @func.save\n format.html { redirect_to @func, notice: 'Func was successfully created.' }\n format.json { render :show, status: :created, location: @func }\n else\n format.html { render :new }\n format.json { render json: @func.errors, status: :unprocessable_entity }\n end\n end\n end", "def role_add(name)\n request.handle(:auth, 'role_add', [name])\n end", "def create\n @roles_privilege = RolesPrivilege.new(roles_privilege_params)\n\n respond_to do |format|\n if @roles_privilege.save\n format.html { redirect_to @roles_privilege, notice: 'Roles privilege was successfully created.' }\n format.json { render :show, status: :created, location: @roles_privilege }\n else\n format.html { render :new }\n format.json { render json: @roles_privilege.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_function = UserFunction.new(params[:user_function])\n\n respond_to do |format|\n if @user_function.save\n flash[:notice] = 'UserFunction was successfully created.'\n format.html { redirect_to([:admin,@user_function]) }\n format.xml { render :xml => @user_function, :status => :created, :location => @user_function }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_function.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_mode_role\n authorize @event_configuration\n role = params[:role]\n\n if User.changable_user_roles.include?(role.to_sym)\n if current_user.has_role? role\n current_user.remove_role role\n else\n current_user.add_role role\n end\n\n flash[:notice] = 'User Permissions successfully updated.'\n else\n flash[:alert] = \"Unable to set role\"\n end\n redirect_back(fallback_location: root_path)\n end", "def create\n @funcao = Funcao.new(funcao_params)\n\n respond_to do |format|\n if @funcao.save\n format.html { redirect_to @funcao, notice: 'Funcao was successfully created.' }\n format.json { render :show, status: :created, location: @funcao }\n else\n format.html { render :new }\n format.json { render json: @funcao.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @administrative_function = AdministrativeFunction.new(administrative_function_params)\n\n respond_to do |format|\n if @administrative_function.save\n format.html { redirect_to @administrative_function, notice: 'Função administrativa criada com sucesso.' }\n format.json { render :show, status: :created, location: @administrative_function }\n else\n format.html { render :new }\n format.json { render json: @administrative_function.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event_role = EventRole.new(event_role_params)\n\n respond_to do |format|\n if @event_role.save\n format.html { redirect_to @event_role, notice: 'Event role was successfully created.' }\n format.json { render :show, status: :created, location: @event_role }\n else\n format.html { render :new }\n format.json { render json: @event_role.errors, status: :unprocessable_entity }\n end\n end\n end", "def change_role\n authorize @user\n @user.update!(role_params)\n json_response({message: \"Role changed successfully\"})\n end", "def facility_operator_roles\n # Translates helper roles to User factory traits\n facility_operators.map do |role|\n case role\n when :admin\n :facility_administrator\n when :senior_staff, :staff\n role\n else\n \"facility_#{role}\".to_sym\n end\n end\nend", "def create\n @function = Function.new(function_params)\n\n respond_to do |format|\n if @function.save\n format.html { redirect_to @function, notice: 'Function was successfully created.' }\n format.json { render :show, status: :created, location: @function }\n else\n format.html { render :new }\n format.json { render json: @function.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_role\n\t\t@roles = Role.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\tend\n\tend", "def create_roles_tool\n #TODO: Have to make sure if they have changed the devise_for :users that we account for it here.\n rep_str = load_file_string('partials/_role_permission.rb')\n insert_into_file \"app/helpers/roles_helper.rb\", rep_str, :after => \"module RolesHelper\\n\" \n #most of this is done in the scaffold above\n gsub_file \"app/views/roles/index.html.erb\" , \"<td><%= link_to 'Edit', edit_role_path(role) %></td>\", \"<td><%= link_to_if(can?(:edit, Role), 'Edit', edit_role_path(role)) %></td>\"\n rep_str = load_erb_string('partials/_roles_index_delete.erb')\n gsub_file \"app/views/roles/index.html.erb\" , \"<td><%= link_to 'Destroy', role, :confirm => 'Are you sure?', :method => :delete %></td>\", rep_str\n \n gsub_file \"app/views/roles/show.html.erb\" , \"<%= link_to 'Edit', edit_role_path(@role) %>\", \"<%= link_to_if(can?(:edit, Role), 'Edit', edit_role_path(@role)) %>\"\n gsub_file \"app/views/roles/show.html.erb\" , \"<p id=\\\"notice\\\"><%= notice %></p>\", \"\"\n gsub_file \"app/views/roles/_form.html.erb\" , /^[\\s]*(<div class=\"actions\">)[\\s]+(<%= f.submit %>)[\\s]+(<\\/div>)/m, \"<p><%= f.label :permission %></p>\\n <ul class=\\\"no-pad no-bullets\\\">\\n <%= permissions_checkboxes(@role, :permission_ids, @accessible_permissions, @role.id) %>\\n </ul>\\n <div class=\\\"actions\\\">\\n <%= f.submit %>\\n </div>\"\n \n \n rep_str = load_erb_string('partials/_accessible_permissions_model.rb')\n gsub_file \"app/models/role.rb\", /^(\\s)*end\\Z/m, rep_str\n rep_str = load_erb_string('partials/_accessible_permissions_controller.rb')\n gsub_file \"app/controllers/roles_controller.rb\" , /^(\\s)*end\\Z/m, rep_str\n gsub_file \"app/controllers/roles_controller.rb\" , \"format.html { redirect_to(roles_url) }\", \"format.html { redirect_to(roles_url, :notice => 'Role was successfully deleted.') }\"\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /role_funcions/1 PATCH/PUT /role_funcions/1.json
def update respond_to do |format| if @role_funcion.update(role_funcion_params) format.html { redirect_to @role_funcion } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @role_funcion.errors, status: :unprocessable_entity } end end end
[ "def change_role\n authorize @user\n @user.update!(role_params)\n json_response({message: \"Role changed successfully\"})\n end", "def update\n authorize @role, :edit?\n respond_to do |format|\n if @role.update(api_v2_role_params)\n format.html { render :show, notice: \"Role was successfully updated.\" }\n format.json { render json: @role, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end", "def modify_guild_role(guild_id, role_id, name: :undef, permissions: :undef, color: :undef, hoist: :undef,\n mentionable: :undef, reason: nil)\n json = filter_undef({ name: name, permissions: permissions, color: color,\n hoist: hoist, mentionable: mentionable })\n route = Route.new(:PATCH, '/guilds/%{guild_id}/roles/%{role_id}', guild_id: guild_id, role_id: role_id)\n request(route, json: json, reason: reason)\n end", "def update\n respond_to do |format|\n if @cms_fortress_role.update_attributes(role_params)\n flash[:success] = \"Role was successfully updated.\"\n format.html { redirect_to @cms_fortress_role }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cms_fortress_role.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # this action is not provided for partyroles\n end", "def update_application_role(application_id, role_id, request)\n start.uri('/api/application')\n .url_segment(application_id)\n .url_segment(\"role\")\n .url_segment(role_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .put()\n .go()\n end", "def update_role\n auth_token = params[:id]\n change_role(auth_token, params[:role])\n current_user.refresh!\n redirect_to root_path\n end", "def changeRoleForShift\n # NOTE: required params[:role_id]\n @role = EventRole.find_by_id(params[:role_id])\n\n if @role.update(role_params)\n data = {\n role: @role,\n role_type:RoleType.find_by_id(@role.role_type_id),\n status: RoleStatus.find_by(:status => @role.role_status)\n }\n render json: {message: \"Role Updated!\", data: data}, status:200\n else\n render json: {errors: @role.errors.full_messages}\n end\n end", "def update\n respond_to do |format|\n if @required_role.update(required_role_params)\n format.html { redirect_to @required_role, notice: 'Required role was successfully updated.' }\n format.json { render :show, status: :ok, location: @required_role }\n else\n format.html { render :edit }\n format.json { render json: @required_role.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_application_role(application_id, role_id, request)\n start.uri('/api/application')\n .url_segment(application_id)\n .url_segment(\"role\")\n .url_segment(role_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .put()\n .go()\n end", "def edit_role(id, *roles)\n request(:put, \"/users/#{id}.json\", default_params(:role_ids => roles))\n end", "def update\n respond_to do |format|\n if @funcion.update(funcion_params)\n format.html { redirect_to @funcion, notice: 'Funcion was successfully updated.' }\n format.json { render :show, status: :ok, location: @funcion }\n else\n format.html { render :edit }\n format.json { render json: @funcion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @func.update(func_params)\n format.html { redirect_to @func, notice: 'Func was successfully updated.' }\n format.json { render :show, status: :ok, location: @func }\n else\n format.html { render :edit }\n format.json { render json: @func.errors, status: :unprocessable_entity }\n end\n end\n end", "def change_user_role(user_id, role)\n params = { role: role }\n\n request :patch,\n \"/v3/team/users/#{user_id}.json\",\n params\n end", "def update\n authorize RoleCutoff\n respond_to do |format|\n if @role_cutoff.update(role_cutoff_params)\n format.html { redirect_to @role_cutoff, notice: \"Role cutoff #{@role_cutoff.description} was successfully updated.\" }\n format.json { render :show, status: :ok, location: @role_cutoff }\n else\n format.html { render :edit }\n format.json { render json: @role_cutoff.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event_role.update(event_role_params)\n format.html { redirect_to @event_role, notice: 'Event role was successfully updated.' }\n format.json { render :show, status: :ok, location: @event_role }\n else\n format.html { render :edit }\n format.json { render json: @event_role.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_role(role_id, data = {})\n raise Auth0::MissingParameter, 'Must supply a valid role_id' if role_id.to_s.empty?\n\n patch \"#{roles_path}/#{role_id}\", data\n end", "def update\n @role = @client.roles.find(params[:id])\n\n respond_to do |format|\n if @role.update_attributes(params[:role])\n flash[:notice] = 'Role was successfully updated.'\n format.html { redirect_to client_role_url(@client, @role) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @role.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @role_id_and_permission_id = RoleIdAndPermissionId.find(params[:id])\n respond_to do |format|\n if @role_id_and_permission_id.update_attributes(params[:role_id_and_permission_id])\n format.html { redirect_to @role_id_and_permission_id, notice: 'Role id and permission was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @role_id_and_permission_id.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /role_funcions/1 DELETE /role_funcions/1.json
def destroy @role_funcion.destroy respond_to do |format| format.html { redirect_to role_funcions_url } format.json { head :no_content } end end
[ "def destroy\n @role = Role.find(params[:id])\n @role.destroy\n \n respond_to do |format|\n format.html { redirect_to roles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @role = Role.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_roles_url }\n format.json { head :no_content }\n end\n end", "def delete(id)\n request(:delete, \"/roles/#{id}.json\")\n end", "def destroy\n @core_user_role.destroy\n respond_to do |format|\n format.html { redirect_to core_user_roles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @role = Role.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n format.html { redirect_to roles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @core_role.destroy\n respond_to do |format|\n format.html { redirect_to core_roles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n role.destroy\n respond_to do |format|\n format.html { redirect_to admin_roles_url, notice: 'Role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cms_fortress_role.destroy\n\n respond_to do |format|\n format.html { redirect_to cms_fortress_roles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_role = UserRole.find(params[:id])\n @user_role.destroy\n\n respond_to do |format|\n format.html { redirect_to user_roles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_user_role.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_user_roles_url, notice: 'User role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_roles\n delete(roles_path)\n end", "def destroy\n @ministerial_role.destroy\n respond_to do |format|\n format.html { redirect_to ministerial_roles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @role.destroy\n respond_to do |format|\n format.html { redirect_to company_roles_url(@company), notice: 'Role was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mod_actions_role.destroy\n respond_to do |format|\n format.html { redirect_to mod_actions_roles_url, notice: 'Mod actions role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event_role.destroy\n respond_to do |format|\n format.html { redirect_to event_roles_url, notice: 'Event role was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :manage, Role\n @member = Member.find params[:member_id]\n @role = @member.roles.find params[:id]\n if @member.roles.delete @role\n render text: {success: true}.to_json\n else\n render text: {success: false, error_message: \"Couldn't take role from user (#{@member.name})\"}.to_json\n end\n end", "def destroy\n @admin_role = Role.find(params[:id])\n @admin_role.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_roles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @role = @client.roles.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n flash[:notice] = 'Role was successfully removed.' \n format.html { redirect_to(client_roles_url(@client)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @master_role.destroy\n respond_to do |format|\n format.html { redirect_to master_roles_url }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /trials/1 GET /trials/1.xml
def show @trial = Trial.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @trial } end end
[ "def show\n @trial = Trial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trial }\n format.json { render :json => @trial }\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n end\n end", "def index\n @trials = Trial.all\n end", "def show\n @trial = Trial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trial }\n end\n end", "def show\n @trial = Trial.find(params[:id])\n \n respond_to do |format|\n format.html { render :layout => false }\n format.json { render json: @trial }\n end\n end", "def create\n @trial = Trial.new(params[:trial])\n\n respond_to do |format|\n if @trial.save\n flash[:notice] = 'Trial was successfully created.'\n format.html { redirect_to(@trial) }\n format.xml { render :xml => @trial, :status => :created, :location => @trial }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trial.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @trial = Trial.new(params[:trial])\n\n respond_to do |format|\n if @trial.save\n format.html { redirect_to(@trial, :notice => 'Trial was successfully created.') }\n format.xml { render :xml => @trial, :status => :created, :location => @trial }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trial.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n format.json { render :json => @trial }\n end\n end", "def get_trial(url)\n page_content = open(url).read()\n doc = Hpricot(page_content)\n tds = doc.search(\"//td[@id='WhiteText']\")\n trial_links = (tds/\"a\")\n for trial_link in trial_links do\n individual_trial = @base_path + trial_link['href']\n scrape_trial(individual_trial)\n end\n # if there is a 'next' page, go there\n begin\n next_page = doc.at(\"//a[@title='Next Page of Results']\")['href']\n if next_page\n next_link = \"http://www.controlled-trials.com\" + next_page\n get_trial(next_link)\n end\n rescue\n puts \"last page\"\n end\n end", "def show\n @my_time_trial = MyTimeTrial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @my_time_trial }\n end\n end", "def show\n respond_to do |format|\n format.html { redirect_to :controller => 'testcases', :action => 'index' }\n format.xml { render :xml => @testcase_result }\n end\n end", "def show\n @testcase = Testcase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @testcase }\n end\n end", "def index\n @testcase_results = TestcaseResult.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @testcase_results }\n end\n end", "def show\n @smalltrial = Smalltrial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @smalltrial }\n end\n end", "def index\n # @trails = Trail.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trails }\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trial }\n end\n end", "def index\n @tests = TkdTest.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tests }\n end\n end", "def new\n @trial = Trial.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trial }\n end\n end", "def index\n @lab_tests = @test_subject.lab_tests\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @lab_tests }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /trials/new GET /trials/new.xml
def new @trial = Trial.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @trial } end end
[ "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n format.json { render :json => @trial }\n end\n end", "def new\n @trial = Trial.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trial }\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trial }\n end\n end", "def create\n @trial = Trial.new(params[:trial])\n\n respond_to do |format|\n if @trial.save\n flash[:notice] = 'Trial was successfully created.'\n format.html { redirect_to(@trial) }\n format.xml { render :xml => @trial, :status => :created, :location => @trial }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trial.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @trial = Trial.new(params[:trial])\n\n respond_to do |format|\n if @trial.save\n format.html { redirect_to(@trial, :notice => 'Trial was successfully created.') }\n format.xml { render :xml => @trial, :status => :created, :location => @trial }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trial.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n val = Digest::SHA2.hexdigest(Time.now.utc.to_s)\n @trip = Trip.new(:sum => val.slice(0..9))\n @title = \"New Trip\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trip }\n end\n end", "def new_stories\n get('/newstories.json')\n end", "def new\n @testcase = Testcase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @testcase }\n end\n end", "def shownew\n @trial = Trial.find_by_customeremail(params[:id])\n\n respond_to do |format|\n format.html # show_name.html.erb\n format.xml { render :xml => @trial }\n format.json { render :json => @trial }\n end\n end", "def new\n @roundtrip = Roundtrip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @roundtrip }\n end\n end", "def create\n @trial = Trial.new(trial_params)\n\n respond_to do |format|\n if @trial.save\n format.html { redirect_to @trial, notice: 'Trial was successfully created.' }\n format.json { render action: 'show', status: :created, location: @trial }\n else\n format.html { render action: 'new' }\n format.json { render json: @trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @my_time_trial = MyTimeTrial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @my_time_trial }\n end\n end", "def new\n @testing = Testing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @testing }\n end\n end", "def new\n @trail = Trail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trail }\n end\n end", "def show\n @trial = Trial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trial }\n end\n end", "def new\n @goals = Goals.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @goals }\n end\n end", "def new\n @trial_day = TrialDay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trial_day }\n end\n end", "def new\n @tst1 = Tst1.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tst1 }\n end\n end", "def new\n @old_twit = OldTwit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @old_twit }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /trials POST /trials.xml
def create @trial = Trial.new(params[:trial]) respond_to do |format| if @trial.save flash[:notice] = 'Trial was successfully created.' format.html { redirect_to(@trial) } format.xml { render :xml => @trial, :status => :created, :location => @trial } else format.html { render :action => "new" } format.xml { render :xml => @trial.errors, :status => :unprocessable_entity } end end end
[ "def create\n @trial = Trial.new(params[:trial])\n\n respond_to do |format|\n if @trial.save\n format.html { redirect_to(@trial, :notice => 'Trial was successfully created.') }\n format.xml { render :xml => @trial, :status => :created, :location => @trial }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trial.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @trial = Trial.new(trial_params)\n\n respond_to do |format|\n if @trial.save\n format.html { redirect_to @trial, notice: 'Trial was successfully created.' }\n format.json { render action: 'show', status: :created, location: @trial }\n else\n format.html { render action: 'new' }\n format.json { render json: @trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @trial = Trial.new(trial_params)\n\n respond_to do |format|\n if @trial.save\n format.html { redirect_to @trial, notice: \"Juicio creado con éxito.\" }\n format.json { render :show, status: :created, location: @trial }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_trial = TimeTrial.new(time_trial_params)\n @time_trial.save\n end", "def create\n @associated_trial = AssociatedTrial.new(associated_trial_params)\n\n respond_to do |format|\n if @associated_trial.save\n format.html { redirect_to @associated_trial, notice: 'Associated trial was successfully created.' }\n format.json { render :show, status: :created, location: @associated_trial }\n else\n format.html { render :new }\n format.json { render json: @associated_trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @smalltrial = Smalltrial.new(params[:smalltrial])\n\n respond_to do |format|\n if @smalltrial.save\n format.html { redirect_to @smalltrial, notice: 'Smalltrial was successfully created.' }\n format.json { render json: @smalltrial, status: :created, location: @smalltrial }\n else\n format.html { render action: \"new\" }\n format.json { render json: @smalltrial.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @my_time_trial = MyTimeTrial.new(params[:my_time_trial])\n\n respond_to do |format|\n if @my_time_trial.save\n format.html { redirect_to @my_time_trial, :notice => 'My time trial was successfully created.' }\n format.json { render :json => @my_time_trial, :status => :created, :location => @my_time_trial }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @my_time_trial.errors, :status => :unprocessable_entity }\n end\n end\n end", "def posttestrail(runId, caseId, statusId, versionId, elapsedseconds)\r\n\r\n uri = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_result_for_case&run_id=#{runId}&case_id=#{caseId}&status_id=#{statusId}&version=#{versionId}&elapsed_seconds=#{elapsedseconds}&sharedSecret=thI5iSourSHAREDsecret\"\r\n #uri = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_result_for_case&run_id=110324&case_id=665022&status_id=1&version=Test&elapsed_seconds=12&sharedSecret=thI5iSourSHAREDsecret\"\r\n\r\n uri = uri.gsub(\" \", \"%20\")\r\n xml_data = open(uri).read\r\n if(xml_data.include? '\"test_id\":')\r\n recorded = xml_data.split('\"test_id\":')[1]\r\n testID = recorded.split(',\"status_id\"')[0]\r\n puts \"TestID:\"+testID\r\n else\r\n puts xml_data\r\n fail \"Cannot Post result to Testrail, check Webservice\"\r\n end\r\n\r\n timeStamp = Time.now.strftime (\"posted at %H:%M %d/%m/%Y\")\r\n files = \"//zgbwcfs3005.jupiter.bbc.co.uk/QA/Jenkins/Jupiter/ICETEAresultupdatelog.txt\"\r\n f = File.open(files,'a')\r\n f.write \"#{testID} #{timeStamp}\"\r\n f.close\r\nend", "def create\n @trial = Trial.new(params[:trial])\n @trial.datum_id = params[:trial_datum_id]\n @trial.classifier_id = params[:trial_classifier_id]\n @trial.selected_features = params[:sf] && params[:sf].map(&:to_i)\n \n project_id = params[:project_id]\n if project_id\n number = Project.find_by_id(project_id).max_trial_number + 1\n @trial.name = \"Trial-#{number}\"\n @trial.project_id = project_id\n @trial.number = number\n end \n \n valid = @trial.run\n \n respond_to do |format|\n if project_id\n if @trial.save\n format.html { render :action => 'show', :layout => false }\n format.json { render json: @trial, status: :created }\n else \n # TODO(ushadow): Handle or display error.\n format.html { render :action => 'show', :layout => false, \n :error => 'Trial run is unsuccessful.'} \n format.json { render json: @trial.errors, \n status: :unprecessable_entity }\n end\n else\n if valid\n format.html { render :show, layout: false }\n format.json { render json: @trial, status: :ok }\n else\n format.html { render :nothing => true, \n :status => :unprocessable_entity }\n end\n end\n end\n end", "def create\n @trial_model = TrialModel.new(trial_model_params)\n\n respond_to do |format|\n if @trial_model.save\n format.html { redirect_to @trial_model, notice: 'Trial model was successfully created.' }\n format.json { render :show, status: :created, location: @trial_model }\n else\n format.html { render :new }\n format.json { render json: @trial_model.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n end\n end", "def create\n @medium_trial = MediumTrial.new(params[:medium_trial])\n\n respond_to do |format|\n if @medium_trial.save\n format.html { redirect_to @medium_trial, notice: 'Medium trial was successfully created.' }\n format.json { render json: @medium_trial, status: :created, location: @medium_trial }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium_trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n format.json { render :json => @trial }\n end\n end", "def create\n @trial_site = TrialSite.new(trial_site_params)\n\n respond_to do |format|\n if @trial_site.save\n format.html { redirect_to @trial_site, notice: 'Trial site was successfully created.' }\n format.json { render :show, status: :created, location: @trial_site }\n else\n format.html { render :new }\n format.json { render json: @trial_site.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @trials = Trial.all\n end", "def create\n @mosttinytrial = Mosttinytrial.new(params[:mosttinytrial])\n\n respond_to do |format|\n if @mosttinytrial.save\n format.html { redirect_to @mosttinytrial, notice: 'Mosttinytrial was successfully created.' }\n format.json { render json: @mosttinytrial, status: :created, location: @mosttinytrial }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mosttinytrial.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @trial = Trial.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trial }\n end\n end", "def create\n @trial_day = TrialDay.new(trial_day_params)\n\n respond_to do |format|\n if @trial_day.save\n format.html { redirect_to @trial_day, notice: 'Trial day was successfully created.' }\n format.json { render :show, status: :created, location: @trial_day }\n else\n format.html { render :new }\n format.json { render json: @trial_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @trial_day = TrialDay.new(params[:trial_day])\n\n respond_to do |format|\n if @trial_day.save\n format.html { redirect_to @trial_day, notice: 'Trial day was successfully created.' }\n format.json { render json: @trial_day, status: :created, location: @trial_day }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trial_day.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /trials/1 PUT /trials/1.xml
def update @trial = Trial.find(params[:id]) respond_to do |format| if @trial.update_attributes(params[:trial]) flash[:notice] = 'Trial was successfully updated.' format.html { redirect_to(@trial) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @trial.errors, :status => :unprocessable_entity } end end end
[ "def update\n @trial = Trial.find(params[:id])\n\n respond_to do |format|\n if @trial.update_attributes(params[:trial])\n format.html { redirect_to(@trial, :notice => 'Trial 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 => @trial.errors, :status => :unprocessable_entity }\n format.json { render :json => @trial.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @trial = Trial.find(params[:id])\n\n respond_to do |format|\n if @trial.update_attributes(params[:trial])\n format.html { redirect_to trials_url, notice: 'Trial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n p = trial_params.clone\n if p[\"question_ids\"].nil?\n p[\"question_ids\"] = []\n end\n\n respond_to do |format|\n if @trial.update(p)\n format.html { redirect_to @trial, notice: 'Trial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @trial.update(trial_params)\n format.html { redirect_to @trial, notice: 'Trial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post opts.fetch(:path, update_path), opts\n end", "def update\n @smalltrial = Smalltrial.find(params[:id])\n\n respond_to do |format|\n if @smalltrial.update_attributes(params[:smalltrial])\n format.html { redirect_to @smalltrial, notice: 'Smalltrial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @smalltrial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @my_time_trial = MyTimeTrial.find(params[:id])\n\n respond_to do |format|\n if @my_time_trial.update_attributes(params[:my_time_trial])\n format.html { redirect_to @my_time_trial, :notice => 'My time trial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @my_time_trial.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @trial = Trial.new(params[:trial])\n\n respond_to do |format|\n if @trial.save\n flash[:notice] = 'Trial was successfully created.'\n format.html { redirect_to(@trial) }\n format.xml { render :xml => @trial, :status => :created, :location => @trial }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trial.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @trial = Trial.new(params[:trial])\n\n respond_to do |format|\n if @trial.save\n format.html { redirect_to(@trial, :notice => 'Trial was successfully created.') }\n format.xml { render :xml => @trial, :status => :created, :location => @trial }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trial.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @trial_document.update(trial_document_params)\n format.html { redirect_to @trial_document, notice: 'Trial document was successfully updated.' }\n format.json { render :show, status: :ok, location: @trial_document }\n else\n format.html { render :edit }\n format.json { render json: @trial_document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @associated_trial.update(associated_trial_params)\n format.html { redirect_to @associated_trial, notice: 'Associated trial was successfully updated.' }\n format.json { render :show, status: :ok, location: @associated_trial }\n else\n format.html { render :edit }\n format.json { render json: @associated_trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @trial_model.update(trial_model_params)\n format.html { redirect_to @trial_model, notice: 'Trial model was successfully updated.' }\n format.json { render :show, status: :ok, location: @trial_model }\n else\n format.html { render :edit }\n format.json { render json: @trial_model.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @time_trial.update(time_trial_params)\n format.html { redirect_to @time_trial, notice: 'Time trial was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_trial }\n else\n format.html { render :edit }\n format.json { render json: @time_trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @mosttinytrial = Mosttinytrial.find(params[:id])\n\n respond_to do |format|\n if @mosttinytrial.update_attributes(params[:mosttinytrial])\n format.html { redirect_to @mosttinytrial, notice: 'Mosttinytrial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mosttinytrial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @rest_test = RestTest.find(params[:id])\n\n respond_to do |format|\n if @rest_test.update_attributes(params[:rest_test])\n format.html { redirect_to(@rest_test, :notice => 'RestTest was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @rest_test.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @train = Train.find(params[:id])\n\n respond_to do |format|\n if @train.update_attributes(params[:train])\n format.html { redirect_to(@train, :notice => 'Train was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @train.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @stepsix = Stepsix.find(params[:id])\n\n respond_to do |format|\n if @stepsix.update_attributes(params[:stepsix])\n format.html { redirect_to(root_path, :notice => 'Stepsix was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @stepsix.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @smalltrialstatus = Smalltrialstatus.find(params[:id])\n\n respond_to do |format|\n if @smalltrialstatus.update_attributes(params[:smalltrialstatus])\n format.html { redirect_to @smalltrialstatus, notice: 'Smalltrialstatus was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @smalltrialstatus.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /trials/1 DELETE /trials/1.xml
def destroy @trial = Trial.find(params[:id]) @trial.destroy respond_to do |format| format.html { redirect_to(trials_url) } format.xml { head :ok } end end
[ "def destroy\n @assertion = Assertion.find(params[:id])\n @assertion.destroy\n\n respond_to do |format|\n format.html { redirect_to(assertions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @trial.destroy\n respond_to do |format|\n format.html { redirect_to trials_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @testcase.destroy\n\n respond_to do |format|\n format.html { redirect_to(testcases_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @testcase = Testcase.find(params[:id])\n @testcase.destroy\n\n respond_to do |format|\n format.html { redirect_to(testcases_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @testcase = Testcase.find(params[:id])\n TestcaseXref.delete_all(\"from_testcase_id=\"+params[:id]+\" || to_testcase_id=\"+params[:id])\n UserTestcaseXref.delete_all(\"testcase_id=\"+params[:id])\n TestcaseBugXref.delete_all(\"testcase_id=\"+params[:id])\n @testcase.destroy\n\n respond_to do |format|\n format.html { redirect_to(testcases_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tst1 = Tst1.find(params[:id])\n @tst1.destroy\n\n respond_to do |format|\n format.html { redirect_to(tst1s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expectation = RiGse::Expectation.find(params[:id])\n @expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to(expectations_url) }\n format.xml { head :ok }\n end\n end", "def test_delete_not_exist_experiment\n not_exist_id = '10000'\n output = `curl -X DELETE http://localhost:8080/metrics/experiments/#{not_exist_id}`\n assert_match \"<html>\", output, \"TEST 3: delete not existing experiment - FAILED\"\n end", "def destroy\n @mytest = Mytest.find(params[:id])\n @mytest.destroy\n\n respond_to do |format|\n format.html { redirect_to(mytests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @atest = Atest.find(params[:id])\n @atest.destroy\n\n respond_to do |format|\n format.html { redirect_to(atests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @smalltrial = Smalltrial.find(params[:id])\n @smalltrial.destroy\n\n respond_to do |format|\n format.html { redirect_to smalltrials_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_suite = TestSuite.find(params[:id])\n @test_suite.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_suites_url) }\n format.xml { head :ok }\n end\n end", "def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end", "def destroy\n @expectation = Expectation.find(params[:id])\n @expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to(expectations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @test = Test.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to(tests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @test = Mg::Test.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to(mg_tests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @test_test = TestTest.find(params[:id])\n @test_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_tests_url) }\n format.xml { head :ok }\n end\n end", "def delete_retry_test id\n uri = URI(HOST + \"/retry_test/#{id}\")\n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Delete.new(uri.path)\n http.request(req)\n end", "def destroy\n @scrap_xml = ScrapXml.find(params[:id])\n @scrap_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(scrap_xmls_url) }\n format.xml { head :ok }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the query property value. Represents unique identification for the query. 'Asset ID' for SharePoint Online and OneDrive for Business, 'keywords' for Exchange Online.
def query=(value) @query = value end
[ "def query=(v); self[:query]=v end", "def setQuery(query) \n\t\tself.queryString = query\n end", "def set_Query(value)\n set_input(\"Query\", value)\n end", "def query_string=(value)\n @query_string = value\n end", "def set_query(query); end", "def set_QueryKeywords(value)\n set_input(\"QueryKeywords\", value)\n end", "def altered_query_string=(value)\n @altered_query_string = value\n end", "def filter_query=(value)\n @filter_query = value\n end", "def original_query_string=(value)\n @original_query_string = value\n end", "def query=(query); end", "def review_set_query=(value)\n @review_set_query = value\n end", "def set_QueryUserID(value)\n set_input(\"QueryUserID\", value)\n end", "def query=(newquery)\n delete_elements(newquery.name)\n add(newquery)\n end", "def query_type=(value)\n @query_type = value\n end", "def altered_highlighted_query_string=(value)\n @altered_highlighted_query_string = value\n end", "def query=(v)\n return @query = nil unless v\n raise InvalidURIError, \"query conflicts with opaque\" if @opaque\n\n x = v.to_str\n v = x.dup if x.equal? v\n v.encode!(Encoding::UTF_8) rescue nil\n v.delete!(\"\\t\\r\\n\")\n v.force_encoding(Encoding::ASCII_8BIT)\n raise InvalidURIError, \"invalid percent escape: #{$1}\" if /(%\\H\\H)/n.match(v)\n v.gsub!(/(?!%\\h\\h|[!$-&(-;=?-_a-~])./n.freeze){'%%%02X' % $&.ord}\n v.force_encoding(Encoding::US_ASCII)\n @query = v\n end", "def cache= value\n @gapi.configuration.query.use_query_cache = value\n end", "def query_alteration=(value)\n @query_alteration = value\n end", "def update_query( hash )\n \n # Convert symbols to strings to avoid duplicate entries\n hash = Hash[hash.map {|k, v| [ k.to_s, v] }] if hash.keys.any? { |k| k.is_a?(Symbol) }\n \n # Merge the changes with the existing query\n query.query_values = query.query_values.merge!( hash )\n \n self\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the queryType property value. Represents the type of query associated with an event. 'files' for SPO and ODB and 'messages' for EXO.The possible values are: files, messages, unknownFutureValue.
def query_type return @query_type end
[ "def query_type=(value)\n @query_type = value\n end", "def query_type_str\n query_type_enum[query_type]\n end", "def get_event_type\n if @event_type\n @event_type\n else\n @local_result ? @local_result.event_type : '?'\n end\n end", "def query_class\n Query.get_subclass(params[:type] || 'IssueQuery')\n end", "def query_type_enum\n return {\n 0=>'empty',\n 1=>'iso',\n 2=>'multi'\n }\n end", "def data_type\n ns_definition(:query_spec_datatypes)\n end", "def query_alteration_type=(value)\n @query_alteration_type = value\n end", "def event_type\n metadata[:event_type] || self.class.name\n end", "def get_q_type(item)\n if item.is_a? Exception\n Q_TYPE_EXCEPTION\n elsif item.is_a?(TrueClass) || item.is_a?(FalseClass)\n Q_TYPE_BOOLEAN\n elsif item.is_a? Bignum\n Q_TYPE_LONG\n elsif item.is_a? Fixnum\n Q_TYPE_INT\n elsif item.is_a? Float\n Q_TYPE_FLOAT\n elsif item.is_a? String\n Q_TYPE_CHAR_VECTOR\n elsif item.is_a? Symbol\n Q_TYPE_SYMBOL\n # not yet supported\n# elsif item.is_a? Date\n# Q_TYPE_DATE\n# elsif item.is_a? DateTime\n# Q_TYPE_DATETIME\n# elsif item.is_a? Time\n# Q_TYPE_TIME\n elsif item.is_a? Array\n get_q_array_type(item)\n elsif item.is_a? Hash\n Q_TYPE_FLIP\n else\n raise QIOException.new(\"Cannot infer Q type from #{item.class.to_s}\")\n end\n end", "def query_alteration_type\n return @query_alteration_type\n end", "def action_type\n node_text(node_tagged(:queryflagname))\n end", "def query_type\n search_string = @current_query.to_s\n if search_string =~ /centrexticketreport\\.php/\n #return 'serial' if search_string =~ /reptype=serial/\n \n res = @menu_items.find(&:active?).label\n res.nil? ? 'barcode' : WorkshopReportKeys[ res ]\n \n else\n 'num'\n end\n end", "def event_type\n return @event_type\n end", "def query_failure_type\n @attributes[:query_failure_type]\n end", "def get_query_type_from_result( json_data )\n retval = nil\n object_class_name = json_data[ \"objectClassName\" ]\n if object_class_name != nil\n case object_class_name\n when \"domain\"\n retval = QueryType::BY_DOMAIN\n when \"ip network\"\n retval = QueryType::BY_IP\n when \"entity\"\n retval = QueryType::BY_ENTITY_HANDLE\n when \"autnum\"\n retval = QueryType::BY_AS_NUMBER\n when \"nameserver\"\n retval = QueryType::BY_NAMESERVER\n end\n end\n if json_data[ \"domainSearchResults\" ]\n retval = QueryType::SRCH_DOMAINS\n elsif json_data[ \"nameserverSearchResults\" ]\n retval = QueryType::SRCH_NS\n elsif json_data[ \"entitySearchResults\" ]\n retval = QueryType::SRCH_ENTITY_BY_NAME\n end\n return retval\n end", "def get_event_type(event)\n # Set the 'type' value for the index.\n type = if @document_type\n event.sprintf(@document_type)\n else\n event[\"type\"] || \"logs\"\n end\n\n if !(type.is_a?(String) || type.is_a?(Numeric))\n @logger.warn(\"Bad event type! Non-string/integer type value set!\", :type_class => type.class, :type_value => type.to_s, :event => event)\n end\n\n type.to_s\n end", "def document_type\n @document_type ||= @options[:document_type] ||\n __get_class_value(:document_type)\n end", "def type\n event_type.name\n end", "def document_type\n DocumentTypes[@document_type]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the queryType property value. Represents the type of query associated with an event. 'files' for SPO and ODB and 'messages' for EXO.The possible values are: files, messages, unknownFutureValue.
def query_type=(value) @query_type = value end
[ "def query_alteration_type=(value)\n @query_alteration_type = value\n end", "def query_type\n return @query_type\n end", "def query_type_str\n query_type_enum[query_type]\n end", "def query_type=(sym) #:nodoc:\n @query_type = sym\n @query_type = :select if @query_type.to_s =~ /select/\n end", "def event_type=(value)\n @event_type = value\n end", "def request_type=(value)\n @request_type = value\n end", "def document_type=(name)\n @document_type = name\n end", "def query_class\n Query.get_subclass(params[:type] || 'IssueQuery')\n end", "def type=(type)\n if TYPE_MAPPING[type]\n type = TYPE_MAPPING[type]\n end\n\n @type = type\n @event = type\n end", "def set_Query(value)\n set_input(\"Query\", value)\n end", "def type=(value)\n @type = value\n end", "def query=(value)\n @query = value\n end", "def call_event_type=(value)\n @call_event_type = value\n end", "def message_type=(value)\n @message_type = value\n end", "def set_Type(value)\n set_input(\"Type\", value)\n end", "def operation_type=(value)\n @operation_type = value\n end", "def value_type=(value)\n @value_type = value\n end", "def set_ReportType(value)\n set_input(\"ReportType\", value)\n end", "def set_SearchType(value)\n set_input(\"SearchType\", value)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Builds billing, shipping and origin addresses
def build_addresses(options={}) raise "override in purchase_order or sales_order" end
[ "def build_addresses(options={})\n raise ArgumentError.new(\"No address declared for buyer (#{buyer.class.name} ##{buyer.id}), use acts_as_addressable :billing\") \\\n unless buyer.respond_to?(:find_default_address)\n \n # buyer's billing or default address\n unless default_billing_address\n if buyer.respond_to?(:billing_address) && buyer.default_billing_address\n self.build_billing_address(buyer.default_billing_address.content_attributes)\n else\n if buyer_default_address = buyer.find_default_address\n self.build_billing_address(buyer_default_address.content_attributes)\n else\n raise ArgumentError.new(\n \"No billing or default address for buyer (#{buyer.class.name} ##{buyer.id}) use acts_as_addressable\")\n end\n end\n end\n\n # buyer's shipping address\n if buyer.respond_to?(:shipping_address)\n self.build_shipping_address(buyer.find_shipping_address_or_clone_from(\n self.billing_address\n ).content_attributes) unless self.default_shipping_address\n end\n\n # seller's billing or default address\n if seller\n raise ArgumentError.new(\"No address for seller (#{seller.class.name} ##{seller.id}), use acts_as_addressable\") \\\n unless seller.respond_to?(:find_default_address)\n \n unless default_origin_address\n if seller.respond_to?(:billing_address) && seller.find_billing_address\n self.build_origin_address(seller.find_billing_address.content_attributes)\n else\n if seller_default_address = seller.find_default_address\n self.build_origin_address(seller_default_address.content_attributes)\n end\n end\n end\n end\n end", "def build_addresses(options={})\n raise ArgumentError.new(\"No address declared for buyer (#{buyer.class.name} ##{buyer.id}), use acts_as_addressable :billing\") \\\n unless buyer.respond_to?(:find_default_address)\n \n # buyer's billing or default address\n unless default_billing_address\n if buyer.respond_to?(:billing_address) && buyer.default_billing_address\n self.build_billing_address(buyer.default_billing_address.content_attributes)\n else\n if buyer_default_address = buyer.find_default_address\n self.build_billing_address(buyer_default_address.content_attributes)\n else\n raise ArgumentError.new(\n \"No billing or default address for buyer (#{buyer.class.name} ##{buyer.id}) use acts_as_addressable\")\n end\n end\n end\n\n # buyer's shipping address\n if buyer.respond_to?(:shipping_address)\n self.build_shipping_address(buyer.find_shipping_address_or_clone_from(\n self.billing_address\n ).content_attributes) unless self.default_shipping_address\n end\n\n self.billing_address.street = \"#{Merchant::Sidekick::Version::NAME}\" if self.billing_address && self.billing_address.street.to_s =~ /^backend$/\n self.shipping_address.street = \"#{Merchant::Sidekick::Version::NAME}\" if self.shipping_address && self.shipping_address.street.to_s =~ /^backend$/\n\n # seller's billing or default address\n if seller\n raise ArgumentError.new(\"No address for seller (#{seller.class.name} ##{seller.id}), use acts_as_addressable\") \\\n unless seller.respond_to?(:find_default_address)\n \n unless default_origin_address\n if seller.respond_to?(:billing_address) && seller.find_billing_address\n self.build_origin_address(seller.find_billing_address.content_attributes)\n else\n if seller_default_address = seller.find_default_address\n self.build_origin_address(seller_default_address.content_attributes)\n end\n end\n end\n end\n end", "def billing_address\n address.merge('name' => \"#{first_name} #{last_name}\")\n end", "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 build_billing_address_with_copy(attributes={})\n build_billing_address_without_copy({\n :first_name => self.first_name,\n :middle_name => self.first_name,\n :last_name => self.last_name,\n :gender => self.gender,\n :academic_title => self.academic_title\n }.merge(attributes))\n end", "def build_address(b, type)\n b.Address do\n send(\"#{type}_streets\").split(\"\\n\").each { |l| b.StreetLines l } if send(\"#{type}_streets\")\n b.City send(\"#{type}_city\") if send(\"#{type}_city\")\n b.StateOrProvinceCode state_code(send(\"#{type}_state\")) if send(\"#{type}_state\")\n b.PostalCode send(\"#{type}_postal_code\") if send(\"#{type}_postal_code\")\n b.CountryCode country_code(send(\"#{type}_country\")) if send(\"#{type}_country\")\n b.Residential send(\"#{type}_residential\")\n end\n end", "def shipping_address\n address.merge(\n 'first_name' => first_name,\n 'last_name' => last_name,\n )\n end", "def billing_address\n default_billing_address ? default_billing_address : shipping_address\n end", "def sales_invoice_billing_address(order)\n components = [\n order.billing_company,\n vat_number_description(order),\n order.billing_address_line_1,\n order.billing_address_line_2,\n order.billing_address_line_3,\n order.billing_town_city,\n order.billing_county,\n order.billing_postcode,\n order.billing_country\n ]\n order_document_address(components)\n end", "def ship_to_address(options)\n for setting in [:first_name, :last_name, :company, :city, :state, :zip, :country] do\n if options[setting] then\n add_field 'x_ship_to_' + setting.to_s, options[setting]\n end\n end\n raise 'must use :address1 and/or :address2' if options[:address]\n add_field 'x_ship_to_address', (options[:address1].to_s + ' ' + options[:address2].to_s).strip\n end", "def add_address(params, options)\n address = options[:billing_address] || options[:address]\n\n if address\n params[:address] = address[:address1] unless address[:address1].blank?\n params[:city] = address[:city] unless address[:city].blank?\n params[:state] = address[:state] unless address[:state].blank?\n params[:zipcode] = address[:zip] unless address[:zip].blank?\n params[:country] = address[:country] unless address[:country].blank?\n end\n end", "def ship_to_address(options)\n for setting in [:first_name, :last_name, :company, :city, :state, :zip, :country] do\n if options[setting] then\n add_field 'x_ship_to_' + setting.to_s, options[setting]\n end\n end\n raise 'must use :address1 and/or :address2' if options[:address]\n add_field 'x_ship_to_address', (options[:address1].to_s + ' ' + options[:address2].to_s).strip\n end", "def billing_address= address\n address = Address.new if address.nil?\n self.billing_first_name = address.first_name\n self.billing_last_name = address.last_name\n self.billing_email = address.email\n self.billing_work_phone = address.work_phone\n self.billing_line1 = address.line1\n self.billing_line2 = address.line2\n self.billing_city = address.city\n self.billing_region = address.region\n self.billing_postcode = address.postcode\n self.billing_country = address.country\n address \n end", "def fill_in_address_fields(values)\n uncheck 'order_use_billing' if page.has_css?('#order_use_billing')\n\n if page.has_css?('#order_bill_address_id_0, #order_ship_address_id_0')\n choose I18n.t(:other_address, scope: :address_book)\n end\n\n if values.is_a?(Spree::Address)\n fill_in Spree.t(:first_name), with: values.firstname\n fill_in Spree.t(:last_name), with: values.lastname\n fill_in Spree.t(:company), with: values.company if Spree::Config[:company]\n\n if page.has_content?(/#{Regexp.escape(Spree.t(:street_address_2))}/i)\n fill_in Spree.t(:street_address), with: values.address1\n fill_in Spree.t(:street_address_2), with: values.address2\n else\n fill_in Spree.t(:address1), with: values.address1\n fill_in Spree.t(:address2), with: values.address2\n end\n\n select values.country.name, from: Spree.t(:country) if values.country\n fill_in Spree.t(:city), with: values.city\n fill_in Spree.t(:zipcode), with: values.zipcode\n select values.state.name, from: Spree.t(:state)\n fill_in Spree.t(:phone), with: values.phone\n fill_in Spree.t(:alternative_phone), with: values.alternative_phone if Spree::Config[:alternative_shipping_phone]\n elsif values.is_a?(Hash)\n values.each do |k, v|\n if k == Spree.t(:country) || k == Spree.t(:state)\n select v, from: k\n else\n fill_in k, with: v\n end\n end\n else\n raise \"Invalid class #{values.class.name} for values\"\n end\n end", "def full_order_to_address\n ship_address.address1 + ' ' + ship_address.address2\n end", "def mailing\n out = address1.to_s\n out += \"<br />\" unless out.strip.empty? || address2.to_s.empty?\n out += address2.to_s\n out += \"<br />\" unless out.strip.empty?\n out += city.to_s\n out += \", \" if city.present? && state.present?\n out += state if state.present?\n out += \"<br />\" + zip.to_s if zip.present?\n out += \"<br />\" unless out.strip.empty? || !country.present?\n out += country_ref.name if country.present?\n out\n end", "def assign_addresses\n self.billing_address ||= Address.default(store)\n self.shipping_address ||= Address.default(store)\n\n if billing_group && billing_group.billing_address.present?\n billing_address.copy_from(billing_group.billing_address)\n end\n if shipping_group && shipping_group.shipping_address.present?\n shipping_address.copy_from(shipping_group.shipping_address)\n end\n check_separate_shipping_address\n end", "def add_address(post, options)\n address = options[:billing_address] || options[:address]\n post['address1'] = truncate(address[:address1], 50) if address[:address1]\n post['address2'] = truncate(address[:address2], 50) if address[:address2]\n post['address3'] = truncate(address[:address3], 50) if address[:address3]\n post['town'] = truncate(address[:city], 50) if address[:city]\n post['county'] = truncate(address[:county], 50) if address[:county]\n post['postcode'] = truncate(address[:postcode], 50) if address[:postcode]\n end", "def get_billing_address\n str = \"\"\n if self.billing_address\n str << self.billing_address.address1 + \" \"\n str << self.billing_address.address2 + \" \" if self.billing_address.address2.present?\n str << self.billing_address.city + \", \"\n str << self.billing_address.state_abbr + \" \"\n str << self.billing_address.zipcode\n str = \"Same as shipping address\" if str == self.get_shipping_address\n else\n str = \"No billing address found\"\n end\n str\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates tax and sets the tax_amount attribute It adds tax_amount across all line_items
def tax_total self.tax_amount = line_items.inject(0.to_money) {|sum,l| sum + l.tax_amount } self.tax_amount end
[ "def tax_total\n self.tax_amount = line_items.inject(Money.new(0, self.currency || Money.default_currency)) {|sum,l| sum + l.tax_amount }\n self.tax_rate # calculates average rate, leave for compatibility reasons\n self.tax_amount\n end", "def add_tax_as_line_item\n raise unless @fields['x_tax']\n add_line_item :name => 'Total Tax', :quantity => 1, :unit_price => @fields['x_tax'], :tax => 0, :line_title => 'Tax'\n end", "def add_tax_as_line_item\n raise unless @fields['x_tax']\n add_line_item :name => 'Total Tax', :quantity => 1, :unit_price => @fields['x_tax'], :tax => 0, :line_title => 'Tax'\n end", "def apply_taxes(tax_class)\n @cart_lines.each do |line|\n product = line[:product]\n tax_amount = tax_class.calculate_tax product\n product.attributes[:tax] = tax_amount\n end\n end", "def total_tax\n line_items.reduce(Money.zero) { |a, e| a + e.total_tax }\n end", "def total_tax\n @total_tax || line_items.inject(BigDecimal.new('0')) { | sum, line_item | sum + BigDecimal.new(line_item.tax_amount.to_s) }\n end", "def line_tax_total\n order_lines.inject(0) { |sum, l| sum + l.tax_amount }\n end", "def tax_rate\n self[:tax_rate] ||= Float(line_items.inject(0) {|sum, l| sum + l.tax_rate}) / line_items.size\n end", "def calculate\n Spree::Tax::OrderTax.new(\n order_id: order.id,\n line_item_taxes: line_item_rates,\n shipment_taxes: shipment_rates\n )\n end", "def tax\n self.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.tax_amount }\n end", "def tax_rate\n write_attribute( :tax_rate, Float(line_items.inject(0) {|sum, l| sum + l.tax_rate}) / line_items.size)\n end", "def tax\n order.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.tax_amount }\n end", "def add_tax_and_tip\n self.purchases.each do |purchase|\n purchase.items.each do |item|\n amnt = item.amount*(1.08)\n item.update(amount: (amnt + amnt/1.08*(self.tip.to_f*0.01)).round(2))\n end\n end\n end", "def calculate_tax\n if self.vendor.net_prices\n # this is for the US tax system\n self.tax_amount = self.total * self.tax / 100.0\n self.total += tax_amount\n else\n # this is for the Europe tax system. Note that self.total already includes taxes, so we don't have to modify it here.\n self.tax_amount = self.total * ( 1 - 1 / ( 1 + self.tax / 100.0))\n end\n end", "def tax_amount\n return 0 if tax.nil? || tax <= 0\n amount = 0\n items.each { |item| amount += item.total if item.taxable? }\n amount * ( tax / 100 )\n end", "def pre_tax_amount_from_line_item line_item\n amount = (line_item.discounted_amount - line_item.included_tax_total) / line_item.quantity\n\n Spree::Money.new(\n BigDecimal.new(amount.to_s).round(2, BigDecimal::ROUND_HALF_DOWN),\n currency: line_item.currency\n ).cents\n end", "def update_amounts\n @items = @items.each do |item|\n item[:good_tax] = set_tax(item[:good], item[:total], @good_tax_rate)\n item[:import_tax] = set_tax(item[:import], item[:total], @import_tax_rate)\n item[:sales_tax] = add_taxes(item[:sales_tax], item[:good_tax], item[:import_tax])\n item[:total] = add_taxes(item[:total], item[:good_tax], item[:import_tax])\n end\n end", "def calculate_tax\n if self.vendor.net_prices\n # this is for the US tax system. At this point, total is still net.\n self.tax_amount = self.total * self.tax / 100.0\n # here, total becomes gross\n self.total += tax_amount\n else\n # this is for the Europe tax system. self.total is already gross, so we don't have to modify it here.\n self.tax_amount = self.total * ( 1 - 1 / ( 1 + self.tax / 100.0 ) )\n end\n end", "def tax_total\n included_tax_total + additional_tax_total\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gross amount including tax
def gross_total self.gross_amount = self.net_total + self.tax_total end
[ "def total_tax\n (doc/\"total-tax\").to_money\n end", "def gross_total\n gross_total_base.round(2)\n end", "def gross_price\n if @vat_included\n @price\n else\n net_price + vat_sum\n end\n end", "def gross_amount\n get_awards[:gross_amt]\n end", "def gross\n BigDecimal.new(params['payload']['base_price'], 8)\n end", "def grand_total_sans_tax\n (subtotal_sans_tax || 0.to_money) + adjustments_sans_tax\n end", "def calculate_tax\n if self.vendor.net_prices\n # this is for the US tax system. At this point, total is still net.\n self.tax_amount = self.total * self.tax / 100.0\n # here, total becomes gross\n self.total += tax_amount\n else\n # this is for the Europe tax system. self.total is already gross, so we don't have to modify it here.\n self.tax_amount = self.total * ( 1 - 1 / ( 1 + self.tax / 100.0 ) )\n end\n end", "def gross_price\n price = 0\n logistics_order_items.each do |i|\n price += i.total_price\n end\n end", "def tax_total\n conv_tax.round(2)\n end", "def gross_price\n @gross_price = @net_price *(100 +VAT_RATE)/100\n end", "def tax_amount\n self.taxes.values.reduce(0, :+)\n end", "def tax_amount\n return 0 if tax.nil? || tax <= 0\n amount = 0\n items.each { |item| amount += item.total if item.taxable? }\n amount * ( tax / 100 )\n end", "def rrp_inc_sales_tax\n price_get(2).try(:price_amount)\n end", "def calc_total\n (@total_after_tax * @gratuity) + @total_after_tax\n end", "def tax_amount(amount)\n return ((amount * 8.9)/100).round(2)\nend", "def tax\n price * 0.09\n end", "def taxrate\n 0.10\n end", "def net_tax\n net_amount() * self.vat_tax.to_f\n end", "def shipping_amount_gross\n shipping_amount + shipping_tax_amount\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
is the number of line items stored in the order, though not to be confused by the items_count
def line_items_count self.line_items.count end
[ "def line_items_count\n self.line_items.size\n end", "def items_count\n counter = 0\n self.line_items.each do |item|\n counter += item.quantity\n end\n counter\n end", "def items_count\n counter = 0\n self.line_items.each do |item|\n counter += item.quantity\n end\n counter\n end", "def item_count\n self.line_items.inject(0) { |total, line_item| total + line_item.quantity }\n end", "def item_count\n items.size\n end", "def item_count\n items.size\n end", "def nitems() end", "def item_count\n @items.length\n end", "def total_items\n order_items.inject(0) { |t, _i| t + 1 }\n end", "def line_count\n prog_order.length\n end", "def line_items_total\n\t\ttotal = 0\n\t\tfor item in self.order_line_items\n\t\t\ttotal += item.total\n\t\tend\n\t\treturn total\n\tend", "def count\r\n items.size\r\n end", "def items_count\n carrousel_items.count\n end", "def nb_items\n return @contained.length\n end", "def item_count\n @items.values.inject(0) do |count, item|\n count + item.count\n end\n end", "def item_count\n collection.length\n end", "def item_count\n @collection.size\n end", "def size\n items.size\n end", "def item_count\n @collection.size\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a commaseparated list of all errors found during the last attempt to create or update this +User+, as a String.
def get_all_errors @user.errors.full_messages.compact.join(',') end
[ "def get_all_errors\n\t\t@user.errors.full_messages.compact.join(', ')\n\tend", "def to_s\n @errors.to_a.join(', ')\n end", "def errors\n return @errors || []\n end", "def get_all_errors\n\t\t@interest_point.errors.full_messages.compact.join(',')\n\tend", "def error_messages\n errors ? errors.map { |prop, msg| \"#{prop} : #{msg}\" } : []\n end", "def errors\n return fetch('errors') || []\n end", "def errors_for row\n ie = insert_error_for row\n return ie.errors if ie\n []\n end", "def getErrorRecepientEmailList()\n return @errorRecepients\n end", "def errors\n \" \" + @results.scan(self.errors_regexp).join(\"\\n \")\n end", "def get_all_errors\n\t\t@category.errors.full_messages.compact.join(',')\n\tend", "def errors\n @fields.flat_map(&:errors)\n end", "def error_messages\n if errors?\n errors = Array(parsed_body['errors'])\n errors << parsed_body['error']\n errors.compact\n else\n []\n end\n end", "def errors\n @checks ||= []\n all_errors = @checks.collect {|check| check.errors}\n all_errors.flatten\n end", "def error_messages\n escaped = entry.errors.full_messages.map { |m| ERB::Util.html_escape(m) }\n escaped.join('<br/>').html_safe\n end", "def errors\n @errors.clone\n end", "def inspect_errors\n valid?\n errors.full_messages.join(\"; \") + \" \" + inspect\n end", "def error_list(obj)\n\t\tcontent_tag :ul do\n\t\t\tobj.errors.full_messages.collect {|err| concat(content_tag(:li, err))}\n\t\tend\n\tend", "def report_errors\n if !@latest.nil? and !@latest[:report_errors].nil?\n return @latest[:report_errors]\n else\n return []\n end\n end", "def errors\n self.messages.select { |error| error[:type] == :error }\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }