input
stringlengths
109
5.2k
output
stringlengths
7
509
Summarize the following code: def dispatch_create_item!(msg) if msg.has_attachments? draft = msg.draft msg.draft = true resp = validate_created_item(ews.create_item(msg.to_ews)) msg.file_attachments.each do |f| next unless f.kind_of?(File) resp.add_file_attachme...
Handles the CreateItem call for Forward ReplyTo and ReplyAllTo It will handle the neccessary actions for adding attachments .
Summarize the following code: def validate_created_item(response) msg = response.response_messages[0] if(msg.status == 'Success') msg.items.empty? ? true : parse_created_item(msg.items.first) else raise EwsCreateItemError, "#{msg.code}: #{msg.message_text}" end end
validate the CreateItem response .
Summarize the following code: def items_since(date_time, opts = {}) opts = opts.clone unless date_time.kind_of?(Date) raise EwsBadArgumentError, "First argument must be a Date or DateTime" end restr = {:restriction => {:is_greater_than_or_equal_to => [{:field_uRI => {:f...
Fetch items since a give DateTime
Summarize the following code: def items_between(start_date, end_date, opts={}) items do |obj| obj.restriction = { :and => [ {:is_greater_than_or_equal_to => [ {:field_uRI => {:field_uRI=>'item:DateTimeReceived'}}, {:field_uRI_or_constant=...
Fetch items between a given time period
Summarize the following code: def search_by_subject(match_str, exclude_str = nil) items do |obj| match = {:contains => { :containment_mode => 'Substring', :containment_comparison => 'IgnoreCase', :field_uRI => {:field_uRI=>'item:Subject'}, :constant => {:value =>mat...
Search on the item subject
Summarize the following code: def sync_items!(sync_state = nil, sync_amount = 256, sync_all = false, opts = {}) item_shape = opts.has_key?(:item_shape) ? opts.delete(:item_shape) : {:base_shape => :default} sync_state ||= @sync_state resp = ews.sync_folder_items item_shape: item_shape, sync_f...
Syncronize Items in this folder . If this method is issued multiple times it will continue where the last sync completed .
Summarize the following code: def subscribe(evtypes = [:all], watermark = nil, timeout = 240) # Refresh the subscription if already subscribed unsubscribe if subscribed? event_types = normalize_event_names(evtypes) folder = {id: self.id, change_key: self.change_key} resp = ews.pull_subscr...
Subscribe this folder to events . This method initiates an Exchange pull type subscription .
Summarize the following code: def unsubscribe return true if @subscription_id.nil? resp = ews.unsubscribe(@subscription_id) rmsg = resp.response_messages.first if rmsg.success? @subscription_id, @watermark = nil, nil true else raise EwsSubscriptionError, "Could not...
Unsubscribe this folder from further Exchange events .
Summarize the following code: def get_events begin if subscribed? resp = ews.get_events(@subscription_id, @watermark) rmsg = resp.response_messages[0] @watermark = rmsg.new_watermark # @todo if parms[:more_events] # get more events rmsg.events.collect{|ev|...
Checks a subscribed folder for events
Summarize the following code: def get_folder(opts = {}) args = get_folder_args(opts) resp = ews.get_folder(args) get_folder_parser(resp) end
Get a specific folder by its ID .
Summarize the following code: def get_time_zones(full = false, ids = nil) req = build_soap! do |type, builder| unless type == :header builder.get_server_time_zones!(full: full, ids: ids) end end result = do_soap_request req, response_class: EwsSoapResponse if result.su...
Request list of server known time zones
Summarize the following code: def copy_folder(to_folder_id, *sources) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.CopyFolder { builder.nbuild.parent.default_namespace = @default_ns builder.to_folder_id!(to_folder_id) bu...
Defines a request to copy folders in the Exchange store
Summarize the following code: def move_folder(to_folder_id, *sources) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.MoveFolder { builder.nbuild.parent.default_namespace = @default_ns builder.to_folder_id!(to_folder_id) bu...
Defines a request to move folders in the Exchange store
Summarize the following code: def update_folder(folder_changes) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.UpdateFolder { builder.nbuild.parent.default_namespace = @default_ns builder.nbuild.FolderChanges { folder_ch...
Update properties for a specified folder There is a lot more building in this method because most of the builders are only used for this operation so there was no need to externalize them for re - use .
Summarize the following code: def empty_folder(opts) validate_version(VERSION_2010_SP1) ef_opts = {} [:delete_type, :delete_sub_folders].each do |k| ef_opts[camel_case(k)] = validate_param(opts, k, true) end fids = validate_param opts, :folder_ids, true req = build_soap! do ...
Empties folders in a mailbox .
Summarize the following code: def create_attachment(opts) opts = opts.clone [:parent_id].each do |k| validate_param(opts, k, true) end validate_param(opts, :files, false, []) validate_param(opts, :items, false, []) req = build_soap! do |type, builder| if(type == :hea...
Creates either an item or file attachment and attaches it to the specified item .
Summarize the following code: def resolve_names(opts) opts = opts.clone fcd = opts.has_key?(:full_contact_data) ? opts[:full_contact_data] : true req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.ResolveNames {|x| x.parent['ReturnFullContact...
Resolve ambiguous e - mail addresses and display names
Summarize the following code: def convert_id(opts) opts = opts.clone [:id, :format, :destination_format, :mailbox ].each do |k| validate_param(opts, k, true) end req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.ConvertId {|x| ...
Converts item and folder identifiers between formats .
Summarize the following code: def create_item(attributes, to_ews_create_opts = {}) template = Viewpoint::EWS::Template::CalendarItem.new attributes template.saved_item_folder_id = {id: self.id, change_key: self.change_key} rm = ews.create_item(template.to_ews_create(to_ews_create_opts)).response_messa...
Creates a new appointment
Summarize the following code: def get_user_availability(opts) opts = opts.clone req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.GetUserAvailabilityRequest {|x| x.parent.default_namespace = @default_ns builder.time_zone!(opts[:time_zone...
Provides detailed information about the availability of a set of users rooms and resources within a specified time window .
Summarize the following code: def get_rooms(roomDistributionList) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.GetRooms {|x| x.parent.default_namespace = @default_ns builder.room_list!(roomDistributionList) } end ...
Gets the rooms that are in the specified room distribution list
Summarize the following code: def get_room_lists req = build_soap! do |type, builder| if(type == :header) else builder.room_lists! end end do_soap_request(req, response_class: EwsSoapRoomlistResponse) end
Gets the room lists that are available within the Exchange organization .
Summarize the following code: def validate_version(exchange_version) if server_version < exchange_version msg = 'The operation you are attempting to use is not compatible with' msg << " your configured Exchange Server version(#{server_version})." msg << " You must be running at least versi...
Some operations only exist for certain versions of Exchange Server . This method should be called with the required version and we ll throw an exception of the currently set
Summarize the following code: def build_soap!(&block) opts = { :server_version => server_version, :impersonation_type => impersonation_type, :impersonation_mail => impersonation_address } opts[:time_zone_context] = @time_zone_context if @time_zone_context EwsBuilder.new.build!(opts, &block) end
Build the common elements in the SOAP message and yield to any custom elements .
Summarize the following code: def camel_case(input) input.to_s.split(/_/).map { |i| i.sub(/^./) { |s| s.upcase } }.join end
Change a ruby_cased string to CamelCased
Summarize the following code: def iso8601_duration_to_seconds(input) return nil if input.nil? || input.empty? match_data = DURATION_RE.match(input) raise(StringFormatException, "Invalid duration given") if match_data.nil? duration = 0 duration += match_data[:weeks].to_i * 604800 du...
Convert an ISO8601 Duration format to seconds
Summarize the following code: def subscribe(subscriptions) req = build_soap! do |type, builder| if(type == :header) else builder.nbuild.Subscribe { builder.nbuild.parent.default_namespace = @default_ns subscriptions.each do |sub| subtype = sub.keys.f...
Used to subscribe client applications to either push pull or stream notifications .
Summarize the following code: def push_subscribe_folder(folder, evtypes, url, status_frequency = nil, watermark = nil) status_frequency ||= 30 psr = { :subscribe_to_all_folders => false, :folder_ids => [ {:id => folder[:id], :change_key => folder[:change_key]} ], :event_types=> evtyp...
Create a push subscription to a single folder
Summarize the following code: def coerce(*) return nil if value.nil? return value if value.is_a?(Date) DateTime.parse(value) end
Coerces value to DateTime
Summarize the following code: def incoming_references(client = nil, query = {}) return false unless client query = is_a?(Contentful::Entry) ? query.merge(links_to_entry: id) : query.merge(links_to_asset: id) client.entries(query) end
Gets a collection of entries which links to current entry
Summarize the following code: def entry(id, query = {}) normalize_select!(query) query['sys.id'] = id entries = Request.new(self, environment_url('/entries'), query).get return entries if configuration[:raw_mode] entries.first end
Gets a specific entry
Summarize the following code: def os_info os_name = case ::RbConfig::CONFIG['host_os'] when /(cygwin|mingw|mswin|windows)/i then 'Windows' when /(darwin|macruby|mac os)/i then 'macOS' when /(linux|bsd|aix|solarix)/i then 'Linux' end {...
Returns the X - Contentful - User - Agent os data
Summarize the following code: def contentful_user_agent header = { 'sdk' => sdk_info, 'app' => app_info, 'integration' => integration_info, 'platform' => platform_info, 'os' => os_info } result = [] header.each do |key, values| next unless values[...
Returns the X - Contentful - User - Agent
Summarize the following code: def request_headers headers = { 'X-Contentful-User-Agent' => contentful_user_agent } headers['Authorization'] = "Bearer #{configuration[:access_token]}" if configuration[:authentication_mechanism] == :header headers['Content-Type'] = "application/vnd.contentful.delivery.v...
Returns the headers used for the HTTP requests
Summarize the following code: def run_request(request) url = request.absolute? ? request.url : base_url + request.url logger.info(request: { url: url, query: request.query, header: request_headers }) if logger Response.new( self.class.get_http( url, request_query(request.qu...
Runs request and parses Response
Summarize the following code: def do_build_resource(response) logger.debug(response: response) if logger configuration[:resource_builder].new( response.object, configuration.merge(endpoint: response.request.endpoint), (response.request.query || {}).fetch(:locale, nil) == '*', ...
Runs Resource Builder
Summarize the following code: def resolve(client, query = {}) id_and_query = [(id unless link_type == 'Space')].compact + [query] client.public_send( Contentful::Support.snakify(link_type).to_sym, *id_and_query ) end
Queries contentful for the Resource the Link is refering to Takes an optional query hash
Summarize the following code: def fields_with_locales remapped_fields = {} locales.each do |locale| fields(locale).each do |name, value| remapped_fields[name] ||= {} remapped_fields[name][locale.to_sym] = value end end remapped_fields end
Returns all fields of the asset with locales nested by field
Summarize the following code: def reload(client = nil) return client.send(Support.snakify(self.class.name.split('::').last), id) unless client.nil? false end
Issues the request that was made to fetch this response again . Only works for Entry Asset ContentType and Space
Summarize the following code: def field_for(field_id) fields.detect { |f| Support.snakify(f.id) == Support.snakify(field_id) } end
Field definition for field
Summarize the following code: def each_page page = first_page yield page if block_given? until completed? page = page.next_page yield page if block_given? end end
Iterates over all pages of the current sync
Summarize the following code: def coerce(value, configuration) return value if type.nil? return value if value.nil? options = {} options[:coercion_class] = KNOWN_TYPES[items.type] unless items.nil? KNOWN_TYPES[type].new(value, options).coerce(configuration) end
Coerces value to proper type
Summarize the following code: def set_ext_params(ext_key, ext_params) raise ArgumentError unless ext_params.is_a?(Hash) @extensions[ext_key] = ext_params end
Set the extension parameters for a specific vendor
Summarize the following code: def process_xml(xml) doc = REXML::Document.new xml if root = REXML::XPath.first(doc, 'xmlns:cartridge_basiclti_link') @title = get_node_text(root, 'blti:title') @description = get_node_text(root, 'blti:description') @launch_url = get_node_text(root, 'blt...
Parse tool configuration data out of the Common Cartridge LTI link XML
Summarize the following code: def to_xml(opts = {}) builder = Builder::XmlMarkup.new(:indent => opts[:indent] || 0) builder.instruct! builder.cartridge_basiclti_link("xmlns" => "http://www.imsglobal.org/xsd/imslticc_v1p0", "xmlns:blti" => 'http://www.imsglobal.org...
Generate XML from the current settings
Summarize the following code: def seed(*args, &block) SeedFu::Seeder.new(self, *parse_seed_fu_args(args, block)).seed end
Load some seed data . There are two ways to do this .
Summarize the following code: def call(save: true) if save == false call_processor elsif destination handle_destination do call_processor(destination: destination) end else create_tempfile do |tempfile| call_processor(destination: tempfile.path) ...
Initializes the pipeline with all the processing options . Determines the destination and calls the processor .
Summarize the following code: def destination_format format = File.extname(destination)[1..-1] if destination format ||= self.format format ||= File.extname(source_path)[1..-1] if source_path format || DEFAULT_FORMAT end
Determines the appropriate destination image format .
Summarize the following code: def create_tempfile tempfile = Tempfile.new(["image_processing", ".#{destination_format}"], binmode: true) yield tempfile tempfile.open tempfile rescue tempfile.close! if tempfile raise end
Creates a new tempfile for the destination file yields it and refreshes the file descriptor to get the updated file .
Summarize the following code: def handle_destination destination_existed = File.exist?(destination) yield rescue File.delete(destination) if File.exist?(destination) && !destination_existed raise end
In case of processing errors both libvips and imagemagick will leave the empty destination file they created so this method makes sure it is deleted in case an exception is raised on saving the image .
Summarize the following code: def apply(operations) operations.inject(self) do |builder, (name, argument)| if argument == true || argument == nil builder.send(name) elsif argument.is_a?(Array) builder.send(name, *argument) else builder.send(name, argument) ...
Add multiple operations as a hash or an array .
Summarize the following code: def call(file = nil, destination: nil, **call_options) options = {} options = options.merge(source: file) if file options = options.merge(destination: destination) if destination branch(options).call!(**call_options) end
Call the defined processing and get the result . Allows specifying the source file and destination .
Summarize the following code: def branch(loader: nil, saver: nil, operations: nil, **other_options) options = respond_to?(:options) ? self.options : DEFAULT_OPTIONS options = options.merge(loader: options[:loader].merge(loader)) if loader options = options.merge(saver: options[:saver].merge(saver)) i...
Creates a new builder object merging current options with new options .
Summarize the following code: def cookie_params params = {} cookies.each do |value| value.split(';').each do |param| param.strip! name, value = param.split('=',2) unless name =~ RESERVED_COOKIE_NAMES params[name] = (value || '') end end ...
The Cookie key - > value pairs returned with the response .
Summarize the following code: def active?(url) # normalize the url url = URI(url) # session key key = key_for(url) return @sessions.has_key?(key) end
Creates a new session cache .
Summarize the following code: def [](url) # normalize the url url = URI(url) # session key key = key_for(url) unless @sessions[key] session = Net::HTTP::Proxy( @proxy.host, @proxy.port, @proxy.user, @proxy.password ).new(url.host,ur...
Provides an active HTTP session for a given URL .
Summarize the following code: def kill!(url) # normalize the url url = URI(url) # session key key = key_for(url) if (sess = @sessions[key]) begin sess.finish rescue IOError end @sessions.delete(key) end end
Destroys an HTTP session for the given scheme host and port .
Summarize the following code: def sanitize_url(url) url = URI(url) url.fragment = nil if @strip_fragments url.query = nil if @strip_query return url end
Sanitizes a URL based on filtering options .
Summarize the following code: def doc unless body.empty? doc_class = if html? Nokogiri::HTML::Document elsif rss? || atom? || xml? || xsl? Nokogiri::XML::Document end if doc_class begin @doc ...
Returns a parsed document object for HTML XML RSS and Atom pages .
Summarize the following code: def content_charset content_types.each do |value| if value.include?(';') value.split(';').each do |param| param.strip! if param.start_with?('charset=') return param.split('=',2).last end end end ...
The charset included in the Content - Type .
Summarize the following code: def is_content_type?(type) if type.include?('/') # otherwise only match the first param content_types.any? do |value| value = value.split(';',2).first value == type end else # otherwise only match the sub-type content...
Determines if any of the content - types of the page include a given type .
Summarize the following code: def []=(host,cookies) collected = self[host] cookies.each do |key,value| if collected[key] != value collected.merge!(cookies) @dirty << host break end end return cookies end
Add a cookie to the jar for a particular domain .
Summarize the following code: def from_page(page) cookies = page.cookie_params unless cookies.empty? self[page.url.host] = cookies return true end return false end
Retrieve cookies for a domain from a page response header .
Summarize the following code: def for_host(host) if @dirty.include?(host) values = [] cookies_for_host(host).each do |name,value| values << "#{name}=#{value}" end @cookies[host] = values.join('; ') @dirty.delete(host) end return @cookies[host] e...
Returns the pre - encoded Cookie for a given host .
Summarize the following code: def [](url) # normalize the url url = URI(url) key = [url.scheme, url.host, url.port] paths = @credentials[key] return nil unless paths # longest path first ordered_paths = paths.keys.sort_by { |path_key| -path_key.length } # directories ...
Creates a new auth store .
Summarize the following code: def []=(url,auth) # normalize the url url = URI(url) # normalize the URL path path = URI.expand_path(url.path) key = [url.scheme, url.host, url.port] @credentials[key] ||= {} @credentials[key][path.split('/')] = auth return auth end
Add an auth credential to the store for supplied base URL .
Summarize the following code: def run(&block) @running = true until (@queue.empty? || paused? || limit_reached?) begin visit_page(dequeue,&block) rescue Actions::Paused return self rescue Actions::Action end end @running = false @sessio...
Start spidering until the queue becomes empty or the agent is paused .
Summarize the following code: def enqueue(url,level=0) url = sanitize_url(url) if (!(queued?(url)) && visit?(url)) link = url.to_s begin @every_url_blocks.each { |url_block| url_block.call(url) } @every_url_like_blocks.each do |pattern,url_blocks| match = c...
Enqueues a given URL for visiting only if it passes all of the agent s rules for visiting a given URL .
Summarize the following code: def get_page(url) url = URI(url) prepare_request(url) do |session,path,headers| new_page = Page.new(url,session.get(path,headers)) # save any new cookies @cookies.from_page(new_page) yield new_page if block_given? return new_page ...
Requests and creates a new Page object from a given URL .
Summarize the following code: def post_page(url,post_data='') url = URI(url) prepare_request(url) do |session,path,headers| new_page = Page.new(url,session.post(path,post_data,headers)) # save any new cookies @cookies.from_page(new_page) yield new_page if block_given? ...
Posts supplied form data and creates a new Page object from a given URL .
Summarize the following code: def visit_page(url) url = sanitize_url(url) get_page(url) do |page| @history << page.url begin @every_page_blocks.each { |page_block| page_block.call(page) } yield page if block_given? rescue Actions::Paused => action rai...
Visits a given URL and enqueus the links recovered from the URL to be visited later .
Summarize the following code: def prepare_request_headers(url) # set any additional HTTP headers headers = @default_headers.dup unless @host_headers.empty? @host_headers.each do |name,header| if url.host.match(name) headers['Host'] = header break en...
Prepares request headers for the given URL .
Summarize the following code: def prepare_request(url,&block) path = unless url.path.empty? url.path else '/' end # append the URL query to the path path += "?#{url.query}" if url.query headers = prepare_request_headers(url) begin ...
Normalizes the request path and grabs a session to handle page get and post requests .
Summarize the following code: def visit?(url) !visited?(url) && visit_scheme?(url.scheme) && visit_host?(url.host) && visit_port?(url.port) && visit_link?(url.to_s) && visit_url?(url) && visit_ext?(url.path) && robot_allowed?(url.to_s) end
Determines if a given URL should be visited .
Summarize the following code: def accept?(data) unless @accept.empty? @accept.any? { |rule| test_data(data,rule) } else !@reject.any? { |rule| test_data(data,rule) } end end
Creates a new Rules object .
Summarize the following code: def every_html_doc every_page do |page| if (block_given? && page.html?) if (doc = page.doc) yield doc end end end end
Pass every HTML document that the agent parses to a given block .
Summarize the following code: def every_xml_doc every_page do |page| if (block_given? && page.xml?) if (doc = page.doc) yield doc end end end end
Pass every XML document that the agent parses to a given block .
Summarize the following code: def every_rss_doc every_page do |page| if (block_given? && page.rss?) if (doc = page.doc) yield doc end end end end
Pass every RSS document that the agent parses to a given block .
Summarize the following code: def every_atom_doc every_page do |page| if (block_given? && page.atom?) if (doc = page.doc) yield doc end end end end
Pass every Atom document that the agent parses to a given block .
Summarize the following code: def initialize_filters(options={}) @schemes = [] if options[:schemes] self.schemes = options[:schemes] else @schemes << 'http' begin require 'net/https' @schemes << 'https' rescue Gem::LoadError => e raise(e...
Initializes filtering rules .
Summarize the following code: def each_meta_redirect return enum_for(__method__) unless block_given? if (html? && doc) search('//meta[@http-equiv and @content]').each do |node| if node.get_attribute('http-equiv') =~ /refresh/i content = node.get_attribute('content') ...
Enumerates over the meta - redirect links in the page .
Summarize the following code: def each_redirect(&block) return enum_for(__method__) unless block if (locations = @response.get_fields('Location')) # Location headers override any meta-refresh redirects in the HTML locations.each(&block) else # check page-level meta redirects i...
Enumerates over every HTTP or meta - redirect link in the page .
Summarize the following code: def each_link return enum_for(__method__) unless block_given? filter = lambda { |url| yield url unless (url.nil? || url.empty?) } each_redirect(&filter) if is_redirect? if (html? && doc) doc.search('//a[@href]').each do |a| filter....
Enumerates over every link in the page .
Summarize the following code: def each_url return enum_for(__method__) unless block_given? each_link do |link| if (url = to_absolute(link)) yield url end end end
Enumerates over every absolute URL in the page .
Summarize the following code: def to_absolute(link) link = link.to_s new_url = begin url.merge(link) rescue Exception return end if (!new_url.opaque) && (path = new_url.path) # ensure that paths begin with a leading '/' fo...
Normalizes and expands a given link into a proper URI .
Summarize the following code: def post(options={}, &block) response = http.post_uri(options.merge(:body => serialize), &block) handle_response(response) end
Serializes the object POSTs it to + url + with + format + deserializes the returned document and updates properties accordingly .
Summarize the following code: def get(options={}, &block) response = http.get_uri(options, &block) handle_response(response) end
GETs + url + with + format + deserializes the returned document and updates properties accordingly .
Summarize the following code: def put(options={}, &block) response = http.put_uri(options.merge(:body => serialize), &block) handle_response(response) self end
Serializes the object PUTs it to + url + with + format + deserializes the returned document and updates properties accordingly .
Summarize the following code: def each page = fetch(@first_query) loop do if page['items'].empty? # we consume this array as we iterate break if page['last_page'] page = fetch(page['next']) # The second predicate (empty?) *should* be redundant, but we check it ...
Iterate through objects in response fetching the next page of results from the API as needed .
Summarize the following code: def sign(tx_template) return tx_template if @xpubs_by_signer.empty? @xpubs_by_signer.each do |signer_conn, xpubs| tx_template = signer_conn.singleton_batch_request( '/sign-transaction', transactions: [tx_template], xpubs: xpubs, ) ...
Sign a single transaction
Summarize the following code: def sign_batch(tx_templates) if @xpubs_by_signer.empty? # Treat all templates as if signed successfully. successes = tx_templates.each_with_index.reduce({}) do |memo, (t, i)| memo[i] = t memo end BatchResponse.new(successes: success...
Sign a batch of transactions
Summarize the following code: def set_no_auth FHIR.logger.info 'Configuring the client to use no authentication.' @use_oauth2_auth = false @use_basic_auth = false @security_headers = {} @client = RestClient @client.proxy = proxy unless proxy.nil? @client end
Set the client to use no authentication mechanisms
Summarize the following code: def set_basic_auth(client, secret) FHIR.logger.info 'Configuring the client to use HTTP Basic authentication.' token = Base64.encode64("#{client}:#{secret}") value = "Basic #{token}" @security_headers = { 'Authorization' => value } @use_oauth2_auth = false ...
Set the client to use HTTP Basic Authentication
Summarize the following code: def set_bearer_token(token) FHIR.logger.info 'Configuring the client to use Bearer Token authentication.' value = "Bearer #{token}" @security_headers = { 'Authorization' => value } @use_oauth2_auth = false @use_basic_auth = true @client = RestClient ...
Set the client to use Bearer Token Authentication
Summarize the following code: def request_payload(resource, headers) if headers format_specified = headers['Content-Type'] if format_specified.nil? resource.to_xml elsif format_specified.downcase.include?('xml') resource.to_xml elsif format_specified.downcase.in...
Extract the request payload in the specified format defaults to XML
Summarize the following code: def split(subnets=2) unless (1..(2**@prefix.host_prefix)).include? subnets raise ArgumentError, "Value #{subnets} out of range" end networks = subnet(newprefix(subnets)) until networks.size == subnets networks = sum_first_found(networks) end ...
Splits a network into different subnets
Summarize the following code: def supernet(new_prefix) raise ArgumentError, "New prefix must be smaller than existing prefix" if new_prefix >= @prefix.to_i return self.class.new("0.0.0.0/0") if new_prefix < 1 return self.class.new(@address+"/#{new_prefix}").network end
Returns a new IPv4 object from the supernetting of the instance network .
Summarize the following code: def subnet(subprefix) unless ((@prefix.to_i)..32).include? subprefix raise ArgumentError, "New prefix must be between #@prefix and 32" end Array.new(2**(subprefix-@prefix.to_i)) do |i| self.class.parse_u32(network_u32+(i*(2**(32-subprefix))), subprefix) ...
This method implements the subnetting function similar to the one described in RFC3531 .
Summarize the following code: def -(oth) if oth.is_a? Integer self.prefix - oth else (self.prefix - oth.prefix).abs end end
Returns the difference between two prefixes or a prefix and a number as a Integer
Summarize the following code: def bot return @bot unless @bot.nil? @bot_command = nil # # parse any command-line options and use them to initialize the bot # params = {} #:nocov: opts = OptionParser.new opts.banner = "Usage: #{File.basename($0)} [options]"...
generate a Bot object . if the DSL is being called from a Bot object just return it otherwise create a bot and return that