idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
11,900 | def link_child_to_parent ( operation ) child_collection = operation . klass . send ( "#{operation.klass_name}" ) || [ ] child_collection << operation . child_klass operation . klass . send ( "#{operation.klass_name}=" , child_collection ) parent_meta = @class_metadata [ operation . klass . class . to_s ] [ operation . ... | Used to link a child object to its parent and vice - versa after a add_link operation |
11,901 | def fill_complex_type_properties ( complex_type_xml , klass ) properties = complex_type_xml . xpath ( ".//*" ) properties . each do | prop | klass . send "#{prop.name}=" , parse_value_xml ( prop ) end end | Helper method for complex_type_to_class |
11,902 | def parse_date ( sdate ) sdate = sdate + "Z" unless sdate . match ( / \d \d / ) begin result = Time . parse ( sdate ) rescue ArgumentError result = DateTime . parse ( sdate ) end return result end | Field Converters Handles parsing datetimes from a string |
11,903 | def parse_value_xml ( property_xml ) property_type = Helpers . get_namespaced_attribute ( property_xml , 'type' , 'm' ) property_null = Helpers . get_namespaced_attribute ( property_xml , 'null' , 'm' ) if property_type . nil? || ( property_type && property_type . match ( / / ) ) return parse_value ( property_xml . con... | Parses a value into the proper type based on an xml property element |
11,904 | def parse_primative_type ( value , return_type ) return value . to_i if return_type == Fixnum return value . to_d if return_type == Float return parse_date ( value . to_s ) if return_type == Time return value . to_s end | Parses a value into the proper type based on a specified return type |
11,905 | def execute_import_function ( name , * args ) func = @function_imports [ name ] param_count = func [ :parameters ] . nil? ? 0 : func [ :parameters ] . count arg_count = args . nil? ? 0 : args [ 0 ] . count if arg_count > param_count raise ArgumentError , "wrong number of arguments (#{arg_count} for #{param_count})" end... | Method Missing Handlers Executes an import function |
11,906 | def model_with_associations ( name ) model = created_model ( name ) return nil unless model OData :: PickleAdapter . get_model ( model . class , model . id , true ) end | return a newly selected model with the navigation properties expanded |
11,907 | def build return @klass unless @klass . nil? return nil if @klass_name . nil? already_defined = eval ( "defined?(#{@klass_name}) == 'constant' and #{@klass_name}.class == Class" ) if already_defined @klass = @klass_name . constantize return @klass end if @namespace namespaces = @namespace . split ( / \. / ) namespaces ... | Creates a new instance of the ClassBuilder class |
11,908 | def links ( navigation_property ) raise OData :: NotSupportedError . new ( "You cannot call both the `links` method and the `count` method in the same query." ) if @count raise OData :: NotSupportedError . new ( "You cannot call both the `links` method and the `select` method in the same query." ) unless @select . empt... | Used to return links instead of actual objects |
11,909 | def count raise OData :: NotSupportedError . new ( "You cannot call both the `links` method and the `count` method in the same query." ) if @links_navigation_property raise OData :: NotSupportedError . new ( "You cannot call both the `select` method and the `count` method in the same query." ) unless @select . empty? @... | Used to return a count of objects instead of the objects themselves |
11,910 | def select ( * fields ) raise OData :: NotSupportedError . new ( "You cannot call both the `links` method and the `select` method in the same query." ) if @links_navigation_property raise OData :: NotSupportedError . new ( "You cannot call both the `count` method and the `select` method in the same query." ) if @count ... | Used to customize the properties that are returned for ad - hoc queries |
11,911 | def sanitize_request_parameters ( parameters ) parameters . reduce ( { } ) do | result , ( key , value ) | if value . is_a? ( Array ) && value . none? { | entry | entry . is_a? ( Enumerable ) && ! entry . is_a? ( String ) } value = value . join ( "," ) end value = value . to_time if value . is_a? DateTime value = value... | Sanitizes Ruby objects into Strava - compatible string values . |
11,912 | def list_activity_photos ( id , args = { } , options = { } , & block ) args [ 'photo_sources' ] = 'true' api_call ( "activities/#{id}/photos" , args , 'get' , options , & block ) end | Fetch list of photos from a specific activity only if it is your activity |
11,913 | def retrieve_activity_streams ( id , types , args = { } , options = { } , & block ) api_call ( "activities/#{id}/streams/#{types}" , args , 'get' , options , & block ) end | Fetch information about a stream for a specific activity |
11,914 | def retrieve_effort_streams ( id , types , args = { } , options = { } , & block ) api_call ( "segment_efforts/#{id}/streams/#{types}" , args , 'get' , options , & block ) end | Fetch information about a subset of the activity streams that correspond to that effort |
11,915 | def retrieve_segment_streams ( id , types , args = { } , options = { } , & block ) api_call ( "segments/#{id}/streams/#{types}" , args , 'get' , options , & block ) end | Fetch information about a stream for a specific segment |
11,916 | def set_value ( value , format = CFDate :: TIMESTAMP_UNIX ) if ( format == CFDate :: TIMESTAMP_UNIX ) then @value = Time . at ( value ) else @value = Time . at ( value + CFDate :: DATE_DIFF_APPLE_UNIX ) end end | set value to defined state set value with timestamp either Apple or UNIX |
11,917 | def get_value ( format = CFDate :: TIMESTAMP_UNIX ) if ( format == CFDate :: TIMESTAMP_UNIX ) then @value . to_i else @value . to_f - CFDate :: DATE_DIFF_APPLE_UNIX end end | get timestamp either UNIX or Apple timestamp |
11,918 | def to_xml ( parser ) n = parser . new_node ( 'array' ) @value . each do | v | n = parser . append_node ( n , v . to_xml ( parser ) ) end n end | create a new array CFType convert to XML |
11,919 | def to_xml ( parser ) n = parser . new_node ( 'dict' ) @value . each_pair do | key , value | k = parser . append_node ( parser . new_node ( 'key' ) , parser . new_text ( key . to_s ) ) n = parser . append_node ( n , k ) n = parser . append_node ( n , value . to_xml ( parser ) ) end n end | Create new CFDictonary type . convert to XML |
11,920 | def load ( opts ) @unique_table = { } @count_objects = 0 @object_refs = 0 @written_object_count = 0 @object_table = [ ] @object_ref_size = 0 @offsets = [ ] fd = nil if ( opts . has_key? ( :file ) ) fd = File . open ( opts [ :file ] , "rb" ) file = opts [ :file ] else fd = StringIO . new ( opts [ :data ] , "rb" ) file =... | Read a binary plist file |
11,921 | def to_str ( opts = { } ) @unique_table = { } @count_objects = 0 @object_refs = 0 @written_object_count = 0 @object_table = [ ] @offsets = [ ] binary_str = "bplist00" @object_refs = count_object_refs ( opts [ :root ] ) opts [ :root ] . to_binary ( self ) next_offset = 8 offsets = @object_table . map do | object | offse... | Convert CFPropertyList to binary format ; since we have to count our objects we simply unique CFDictionary and CFArray |
11,922 | def read_binary_int ( fname , fd , length ) if length > 4 raise CFFormatError . new ( "Integer greater than 16 bytes: #{length}" ) end nbytes = 1 << length buff = fd . read ( nbytes ) CFInteger . new ( case length when 0 then buff . unpack ( "C" ) [ 0 ] when 1 then buff . unpack ( "n" ) [ 0 ] when 2 then buff . unpack ... | read a binary int value |
11,923 | def read_binary_real ( fname , fd , length ) raise CFFormatError . new ( "Real greater than 8 bytes: #{length}" ) if length > 3 nbytes = 1 << length buff = fd . read ( nbytes ) CFReal . new ( case length when 0 raise CFFormatError . new ( "got #{length+1} byte float, must be an error!" ) when 1 raise CFFormatError . ne... | read a binary real value |
11,924 | def read_binary_date ( fname , fd , length ) raise CFFormatError . new ( "Date greater than 8 bytes: #{length}" ) if length > 3 nbytes = 1 << length buff = fd . read ( nbytes ) CFDate . new ( case length when 0 then raise CFFormatError . new ( "#{length+1} byte CFDate, error" ) when 1 then raise CFFormatError . new ( "... | read a binary date value |
11,925 | def read_binary_data ( fname , fd , length ) CFData . new ( read_fd ( fd , length ) , CFData :: DATA_RAW ) end | Read a binary data value |
11,926 | def read_binary_string ( fname , fd , length ) buff = read_fd fd , length @unique_table [ buff ] = true unless @unique_table . has_key? ( buff ) CFString . new ( buff ) end | Read a binary string value |
11,927 | def read_binary_unicode_string ( fname , fd , length ) buff = fd . read ( 2 * length ) @unique_table [ buff ] = true unless @unique_table . has_key? ( buff ) CFString . new ( Binary . charset_convert ( buff , "UTF-16BE" , "UTF-8" ) ) end | Read a unicode string value coded as UTF - 16BE |
11,928 | def read_binary_array ( fname , fd , length ) ary = [ ] if ( length != 0 ) buff = fd . read ( length * @object_ref_size ) objects = unpack_with_size ( @object_ref_size , buff ) 0 . upto ( length - 1 ) do | i | object = read_binary_object_at ( fname , fd , objects [ i ] ) ary . push object end end CFArray . new ( ary ) ... | Read an binary array value including contained objects |
11,929 | def read_binary_dict ( fname , fd , length ) dict = { } if ( length != 0 ) then buff = fd . read ( length * @object_ref_size ) keys = unpack_with_size ( @object_ref_size , buff ) buff = fd . read ( length * @object_ref_size ) objects = unpack_with_size ( @object_ref_size , buff ) 0 . upto ( length - 1 ) do | i | key = ... | Read a dictionary value including contained objects |
11,930 | def read_binary_object ( fname , fd ) buff = fd . read ( 1 ) object_length = buff . unpack ( "C*" ) object_length = object_length [ 0 ] & 0xF buff = buff . unpack ( "H*" ) object_type = buff [ 0 ] [ 0 ] . chr if ( object_type != "0" && object_length == 15 ) then object_length = read_binary_object ( fname , fd ) object_... | Read an object type byte decode it and delegate to the correct reader function |
11,931 | def string_to_binary ( val ) val = val . to_s @unique_table [ val ] ||= begin if ! Binary . ascii_string? ( val ) val = Binary . charset_convert ( val , "UTF-8" , "UTF-16BE" ) bdata = Binary . type_bytes ( 0b0110 , Binary . charset_strlen ( val , "UTF-16BE" ) ) val . force_encoding ( "ASCII-8BIT" ) if val . respond_to?... | Uniques and transforms a string value to binary format and adds it to the object table |
11,932 | def int_to_binary ( value ) nbytes = 0 nbytes = 1 if value > 0xFF nbytes += 1 if value > 0xFFFF nbytes += 1 if value > 0xFFFFFFFF nbytes += 1 if value > 0x7FFFFFFFFFFFFFFF nbytes = 3 if value < 0 Binary . type_bytes ( 0b0001 , nbytes ) << if nbytes < 4 [ value ] . pack ( [ "C" , "n" , "N" , "q>" ] [ nbytes ] ) else [ 0... | Codes an integer to binary format |
11,933 | def num_to_binary ( value ) @object_table [ @written_object_count ] = if value . is_a? ( CFInteger ) int_to_binary ( value . value ) else real_to_binary ( value . value ) end @written_object_count += 1 @written_object_count - 1 end | Converts a numeric value to binary and adds it to the object table |
11,934 | def array_to_binary ( val ) saved_object_count = @written_object_count @written_object_count += 1 values = val . value . map { | v | v . to_binary ( self ) } bdata = Binary . type_bytes ( 0b1010 , val . value . size ) << Binary . pack_int_array_with_size ( object_ref_size ( @object_refs ) , values ) @object_table [ sav... | Convert array to binary format and add it to the object table |
11,935 | def dict_to_binary ( val ) saved_object_count = @written_object_count @written_object_count += 1 keys_and_values = val . value . keys . map { | k | CFString . new ( k ) . to_binary ( self ) } keys_and_values . concat ( val . value . values . map { | v | v . to_binary ( self ) } ) bdata = Binary . type_bytes ( 0b1101 , ... | Convert dictionary to binary format and add it to the object table |
11,936 | def request ( method , options ) host = options . fetch ( :host , S3 . host ) path = options . fetch ( :path ) body = options . fetch ( :body , nil ) params = options . fetch ( :params , { } ) headers = options . fetch ( :headers , { } ) path = Addressable :: URI . escape ( path ) if params params = params . is_a? ( St... | Creates new connection object . |
11,937 | def parse_acl ( xml ) grants = { } rexml_document ( xml ) . elements . each ( "AccessControlPolicy/AccessControlList/Grant" ) do | grant | grants . merge! ( extract_grantee ( grant ) ) end grants end | Parse acl response and return hash with grantee and their permissions |
11,938 | def temporary_url ( expires_at = Time . now + 3600 ) signature = Signature . generate_temporary_url_signature ( :bucket => name , :resource => key , :expires_at => expires_at , :secret_access_key => secret_access_key ) "#{url}?AWSAccessKeyId=#{self.bucket.service.access_key_id}&Expires=#{expires_at.to_i.to_s}&Signature... | Returns a temporary url to the object that expires on the timestamp given . Defaults to one hour expire time . |
11,939 | def save ( options = { } ) options = { :location => options } unless options . is_a? ( Hash ) create_bucket_configuration ( options ) true end | Saves the newly built bucket . |
11,940 | def translation_for ( locale ) success = true tries ||= 3 translation = self . translations . detect { | t | t . locale == locale } return translation if translation return nil if self . new_record request = Net :: HTTP :: Get . new ( "/api/projects/#{Connection.api_key}/strings/#{self.id}/locales/#{locale}/translation... | Gets a Translation for a String |
11,941 | def fetch ( http_connection , force = false ) success = true tries ||= 3 display = [ ] display . push ( self . file_path ) display . push "#{StringUtil.checksumify(self.local_checksum.to_s)}..#{StringUtil.checksumify(self.remote_checksum.to_s)}" if ! File . exist? ( self . file_path ) or force or self . remote_checksum... | Fetch a language file . By default it will make a conditional GET Request using the If - Modified - Since tag . You can force the method to re - download your file by passing true as a second argument |
11,942 | def upload ( http_connection , merge = false , ignore_missing = false , label = nil , low_priority = false , minor_changes = false , force = false ) success = true tries ||= 3 display = [ ] display . push ( self . file_path ) display . push "#{StringUtil.checksumify(self.local_checksum.to_s)}..#{StringUtil.checksumify(... | Update a language file to Web Translate It by performing a PUT Request . |
11,943 | def create ( http_connection , low_priority = false ) success = true tries ||= 3 display = [ ] display . push file_path display . push "#{StringUtil.checksumify(self.local_checksum.to_s)}..[ ]" if File . exists? ( self . file_path ) File . open ( self . file_path ) do | file | begin request = Net :: HTTP :: Post ::... | Create a master language file to Web Translate It by performing a POST Request . |
11,944 | def delete ( http_connection ) success = true tries ||= 3 display = [ ] display . push file_path if File . exists? ( self . file_path ) File . open ( self . file_path ) do | file | begin request = Net :: HTTP :: Delete . new ( api_url_for_delete ) WebTranslateIt :: Util . add_fields ( request ) display . push Util . ha... | Delete a master language file from Web Translate It by performing a DELETE Request . |
11,945 | def sendgrid_enable ( * options ) self . default_sg_options = Array . new unless self . default_sg_options options . each { | option | self . default_sg_options << option if VALID_OPTIONS . include? ( option ) } end | Enables a default option for all emails . See documentation for details . |
11,946 | def clear return self unless current_table = table current_table_size = current_table . size deleted_count = i = 0 while i < current_table_size if ! ( node = current_table . volatile_get ( i ) ) i += 1 elsif ( node_hash = node . hash ) == MOVED current_table = node . key current_table_size = current_table . size elsif ... | Implementation for clear . Steps through each bin removing all nodes . |
11,947 | def initialize_table until current_table ||= table if ( size_ctrl = size_control ) == NOW_RESIZING Thread . pass else try_in_resize_lock ( current_table , size_ctrl ) do initial_size = size_ctrl > 0 ? size_ctrl : DEFAULT_CAPACITY current_table = self . table = Table . new ( initial_size ) initial_size - ( initial_size ... | Initializes table using the size recorded in + size_control + . |
11,948 | def check_for_resize while ( current_table = table ) && MAX_CAPACITY > ( table_size = current_table . size ) && NOW_RESIZING != ( size_ctrl = size_control ) && size_ctrl < @counter . sum try_in_resize_lock ( current_table , size_ctrl ) do self . table = rebuild ( current_table ) ( table_size << 1 ) - ( table_size >> 1 ... | If table is too small and not already resizing creates next table and transfers bins . Rechecks occupancy after a transfer to see if another resize is already needed because resizings are lagging additions . |
11,949 | def split_old_bin ( table , new_table , i , node , node_hash , forwarder ) table . try_lock_via_hash ( i , node , node_hash ) do split_bin ( new_table , i , node , node_hash ) table . volatile_set ( i , forwarder ) end end | Splits a normal bin with list headed by e into lo and hi parts ; installs in given table . |
11,950 | def run GreenAndSecure :: check_block_setup puts "The available chef servers are:" servers . each do | server | if server == current_server then puts "\t* #{server} [ Currently Selected ]" else puts "\t* #{server}" end end end | list the available environments |
11,951 | def valid? ( request ) begin valid! ( request ) rescue AlexaVerifier :: BaseError => e puts e return false end true end | Validate a request object from Rack . Return a boolean . |
11,952 | def check_that_request_is_timely ( raw_body ) request_json = JSON . parse ( raw_body ) raise AlexaVerifier :: InvalidRequestError , 'Timestamp field not present in request' if request_json . fetch ( 'request' , { } ) . fetch ( 'timestamp' , nil ) . nil? request_is_timely = ( Time . parse ( request_json [ 'request' ] [ ... | Prevent replays of requests by checking that they are timely . |
11,953 | def check_that_request_is_valid ( signature_certificate_url , request , raw_body ) certificate , chain = AlexaVerifier :: CertificateStore . fetch ( signature_certificate_url ) if @configuration . verify_certificate? || @configuration . verify_signature? begin AlexaVerifier :: Verifier :: CertificateVerifier . valid! (... | Check that our request is valid . |
11,954 | def check_that_request_was_signed ( certificate_public_key , request , raw_body ) signed_by_certificate = certificate_public_key . verify ( OpenSSL :: Digest :: SHA1 . new , Base64 . decode64 ( request . env [ 'HTTP_SIGNATURE' ] ) , raw_body ) raise AlexaVerifier :: InvalidRequestError , 'Signature does not match certi... | Check that our request was signed by a given public key . |
11,955 | def before_feature_element ( cuke_feature_element ) if cuke_feature_element . is_a? ( Cucumber :: Core :: Ast :: Scenario ) before_scenario ( cuke_feature_element ) elsif cuke_feature_element . is_a? ( Cucumber :: Core :: Ast :: ScenarioOutline ) before_scenario_outline ( cuke_feature_element ) else raise ( "unsupporte... | this method gets called before a scenario or scenario outline we dispatch to our own more specific methods |
11,956 | def after_feature_element ( cuke_feature_element ) if cuke_feature_element . is_a? ( Cucumber :: Formatter :: LegacyApi :: Ast :: Scenario ) after_scenario ( cuke_feature_element ) elsif cuke_feature_element . is_a? ( Cucumber :: Formatter :: LegacyApi :: Ast :: ScenarioOutline ) after_scenario_outline ( cuke_feature_e... | this method gets called after a scenario or scenario outline we dispatch to our own more specific methods |
11,957 | def before_table_row ( cuke_table_row ) if cuke_table_row . is_a? ( Cucumber :: Formatter :: LegacyApi :: ExampleTableRow ) is_not_header_row = ( @scenario_outline . example_column_names != cuke_table_row . values ) if is_not_header_row example = @scenario_outline . examples . find { | example | example . column_values... | this method is called before a scenario outline row OR step data table row |
11,958 | def after_table_row ( cuke_table_row ) if cuke_table_row . is_a? ( Cucumber :: Formatter :: LegacyApi :: Ast :: ExampleTableRow ) is_not_header_row = ( @scenario_outline . example_column_names != cuke_table_row . cells ) if is_not_header_row exception = ( @exception || cuke_table_row . exception ) example = @scenario_o... | this method is called after a scenario outline row OR step data table row |
11,959 | def render ( & block ) raise LocalJumpError , "no block given" unless block_given? options = @options . dup open_tabs_options = options . delete ( :open_tabs ) || { } close_tabs_options = options . delete ( :close_tabs ) || { } "" . tap do | html | html << open_tabs ( open_tabs_options ) . to_s html << @context . captu... | Renders the tab stack using the current builder . |
11,960 | def download ( key , & block ) source = cloudinary_url_for_key ( key ) if block_given? instrument :streaming_download , key : key do stream_download ( source , & block ) end else instrument :download , key : key do Cloudinary :: Downloader . download ( source ) end end end | Return the content of the file at the + key + . |
11,961 | def download_chunk ( key , range ) instrument :download_chunk , key : key , range : range do source = cloudinary_url_for_key ( key ) download_range ( source , range ) end end | Return the partial content in the byte + range + of the file at the + key + . |
11,962 | def url_for_direct_upload ( key , expires_in : , content_type : , content_length : , checksum : ) instrument :url_for_direct_upload , key : key do options = { expires_in : expires_in , content_type : content_type , content_length : content_length , checksum : checksum , resource_type : 'auto' } signed_download_url_for_... | Returns a signed temporary URL that a direct upload file can be PUT to on the + key + . The URL will be valid for the amount of seconds specified in + expires_in + . You must also provide the + content_type + + content_length + and + checksum + of the file that will be uploaded . All these attributes will be validated ... |
11,963 | def parse_json ( response ) data = JSON . parse ( response ) fail OptaSD :: Error . new ( data ) , ErrorMessage . get_message ( data [ 'errorCode' ] . to_i ) if data [ 'errorCode' ] data end | Parse JSON Response |
11,964 | def parse_xml ( response ) data = Nokogiri :: XML ( response ) do | config | config . strict . noblanks end fail OptaSD :: Error . new ( xml_error_to_hast ( data ) ) , ErrorMessage . get_message ( data . children . first . content . to_i ) if data . css ( 'errorCode' ) . first . present? data end | Parse XML Response |
11,965 | def push ( value , opts = { } ) topic = opts [ :topic ] || @topic result = nil if value . kind_of? Array return value . map { | e | self . push ( e , opts ) } end if Hermann . jruby? result = @internal . push_single ( value , topic , opts [ :partition_key ] , nil ) unless result . nil? @children << result end reap_chil... | Push a value onto the Kafka topic passed to this + Producer + |
11,966 | def tick_reactor ( timeout = 0 ) begin execute_tick ( rounded_timeout ( timeout ) ) rescue StandardError => ex @children . each do | child | next if ( Hermann . jruby? ? child . fulfilled? : child . completed? ) child . internal_set_error ( ex ) end end return reap_children end | Tick the underlying librdkafka reacter and clean up any unreaped but reapable children results |
11,967 | def execute_tick ( timeout ) if timeout == 0 @internal . tick ( 0 ) else ( timeout * 2 ) . times do events = @internal . tick ( 0 ) break if events > 0 sleep 0.5 end end end | Perform the actual reactor tick |
11,968 | def change_content_type ( key , content_type ) client . post_object ( container , key , 'Content-Type' => content_type ) true rescue Fog :: OpenStack :: Storage :: NotFound false end | Non - standard method to change the content type of an existing object |
11,969 | def create_connection ( * args ) if args . length == 2 @username = args [ 0 ] @password = args [ 1 ] end cf = AQjmsFactory . getConnectionFactory ( @url , java . util . Properties . new ) if username cf . createConnection ( @username , @password ) else cf . createConnection ( ) end end | Creates a connection per standard JMS 1 . 1 techniques from the Oracle AQ JMS Interface |
11,970 | def session ( & block ) s = nil begin s = @pool . checkout block . call ( s ) rescue javax . jms . JMSException => e s . close rescue nil @pool . remove ( s ) s = nil raise e ensure @pool . checkin ( s ) if s end end | Obtain a session from the pool and pass it to the supplied block The session is automatically returned to the pool once the block completes |
11,971 | def consumer ( params , & block ) session do | s | begin consumer = s . consumer ( params ) block . call ( s , consumer ) ensure consumer . close if consumer end end end | Obtain a session from the pool and create a MessageConsumer . Pass both into the supplied block . Once the block is complete the consumer is closed and the session is returned to the pool . |
11,972 | def producer ( params , & block ) session do | s | begin producer = s . producer ( params ) block . call ( s , producer ) ensure producer . close if producer end end end | Obtain a session from the pool and create a MessageProducer . Pass both into the supplied block . Once the block is complete the producer is closed and the session is returned to the pool . |
11,973 | def fetch_dependencies ( jar_list ) jar_list . each do | jar | logger . debug "Loading Jar File:#{jar}" begin require jar rescue Exception => exc logger . error "Failed to Load Jar File:#{jar}" , exc end end if jar_list require 'jms/mq_workaround' require 'jms/imports' require 'jms/message_listener_impl' require 'jms/m... | Load the required jar files for this JMS Provider and load JRuby extensions for those classes |
11,974 | def session ( params = { } , & block ) raise ( ArgumentError , 'Missing mandatory Block when calling JMS::Connection#session' ) unless block session = self . create_session ( params ) begin block . call ( session ) ensure session . close end end | Create a session over this connection . It is recommended to create separate sessions for each thread If a block of code is passed in it will be called and then the session is automatically closed on completion of the code block |
11,975 | def create_session ( params = { } ) transacted = params [ :transacted ] || false options = params [ :options ] || JMS :: Session :: AUTO_ACKNOWLEDGE @jms_connection . create_session ( transacted , options ) end | Create a session over this connection . It is recommended to create separate sessions for each thread |
11,976 | def on_message ( params , & block ) raise 'JMS::Connection must be connected prior to calling JMS::Connection::on_message' unless @sessions && @consumers consumer_count = params [ :session_count ] || 1 consumer_count . times do session = self . create_session ( params ) consumer = session . consumer ( params ) if sessi... | Receive messages in a separate thread when they arrive |
11,977 | def statistics raise ( ArgumentError , 'First call MessageConsumer::on_message with statistics: true before calling MessageConsumer::statistics()' ) unless @message_count duration = ( @last_time || Time . now ) - @start_time { messages : @message_count , duration : duration , messages_per_second : ( @message_count / du... | Return Statistics gathered for this listener |
11,978 | def override ( config , option , escape = false , & blk ) if opt = input [ option ] opt = CFMicro . escape_path ( opt ) if escape config [ option ] = opt end config [ option ] = yield unless config [ option ] end | override with command line arguments and yield the block in case the option isn t set |
11,979 | def resolve_lexically ( resolver , val , ctx ) case val when Hash new = { } val . each do | k , v | new [ k ] = resolve_lexically ( resolver , v , [ val ] + ctx ) end new when Array val . collect do | v | resolve_lexically ( resolver , v , ctx ) end when String val . gsub ( / \$ \{ \} \} / ) do resolve_symbol ( resolve... | resolve symbols with hashes introducing new lexical symbols |
11,980 | def resolve_symbol ( resolver , sym , ctx ) if found = find_symbol ( sym . to_sym , ctx ) resolve_lexically ( resolver , found , ctx ) found elsif dynamic = resolver . resolve_symbol ( sym ) dynamic else fail ( "Unknown symbol in manifest: #{sym}" ) end end | resolve a symbol to its value and then resolve that value |
11,981 | def find_symbol ( sym , ctx ) ctx . each do | h | if val = resolve_in ( h , sym ) return val end end nil end | search for a symbol introduced in the lexical context |
11,982 | def find_in_hash ( hash , where ) what = hash where . each do | x | return nil unless what . is_a? ( Hash ) what = what [ x ] end what end | helper for following a path of values in a hash |
11,983 | def build ( file ) manifest = YAML . load_file file raise CFManifests :: InvalidManifest . new ( file ) unless manifest Array ( manifest [ "inherit" ] ) . each do | path | manifest = merge_parent ( path , manifest ) end manifest . delete ( "inherit" ) manifest end | parse a manifest and merge with its inherited manifests |
11,984 | def merge_manifest ( parent , child ) merge = proc do | _ , old , new | if new . is_a? ( Hash ) && old . is_a? ( Hash ) old . merge ( new , & merge ) else new end end parent . merge ( child , & merge ) end | deep hash merge |
11,985 | def where ( filter ) return self if filter . nil? select do | item | matches = true filter . each do | key , value | matches &= case value when Regexp item . send ( key ) =~ value else item . send ( key ) == value end end matches end end | Filters an array of objects by a given hash . The keys of the hash must be methods implemented by the objects . The values of the hash are compared to the values the object returns when calling the methods . |
11,986 | def reload device = SimCtl . device ( udid : udid ) device . instance_variables . each do | ivar | instance_variable_set ( ivar , device . instance_variable_get ( ivar ) ) end end | Reloads the device information |
11,987 | def wait ( timeout = SimCtl . default_timeout ) Timeout . timeout ( timeout ) do loop do break if yield SimCtl . device ( udid : udid ) end end reload end | Reloads the device until the given block returns true |
11,988 | def disable_keyboard_helpers edit_plist ( path . preferences_plist ) do | plist | %w[ KeyboardAllowPaddle KeyboardAssistant KeyboardAutocapitalization KeyboardAutocorrection KeyboardCapsLock KeyboardCheckSpelling KeyboardPeriodShortcut KeyboardPrediction KeyboardShowPredictionBar ] . each do | key | plist [ key ] = fal... | Disables the keyboard helpers |
11,989 | def set_language ( language ) edit_plist ( path . global_preferences_plist ) do | plist | key = 'AppleLanguages' plist [ key ] = [ ] unless plist . key? ( key ) plist [ key ] . unshift ( language ) . uniq! end end | Sets the device language |
11,990 | def count_all total_count = count @tags . each_value do | value | total_count += value . count_all if value . children? end return total_count end | Gives the total number of elements connected to this parent . |
11,991 | def delete ( tag_or_index , options = { } ) check_key ( tag_or_index , :delete ) element = self [ tag_or_index ] if element element . parent = nil unless options [ :no_follow ] @tags . delete ( tag_or_index ) end end | Deletes the specified element from this parent . |
11,992 | def delete_group ( group_string ) group_elements = group ( group_string ) group_elements . each do | element | delete ( element . tag ) end end | Deletes all elements of the specified group from this parent . |
11,993 | def encode_children ( old_endian ) children . each do | element | if element . children? element . encode_children ( old_endian ) elsif element . is_a? ( Element ) encode_child ( element , old_endian ) end end end | Re - encodes the binary data strings of all child Element instances . This also includes all the elements contained in any possible child elements . |
11,994 | def group ( group_string ) raise ArgumentError , "Expected String, got #{group_string.class}." unless group_string . is_a? ( String ) found = Array . new children . each do | child | found << child if child . tag . group == group_string . upcase end return found end | Returns an array of all child elements that belongs to the specified group . |
11,995 | def handle_print ( index , max_digits , max_name , max_length , max_generations , visualization , options = { } ) elements = Array . new s = " " hook_symbol = "|_" last_item_symbol = " " nonlast_item_symbol = "| " children . each_with_index do | element , i | n_parents = element . parents . length i_s = s * ( max_digi... | Gathers the desired information from the selected data elements and processes this information to make a text output which is nicely formatted . |
11,996 | def max_lengths max_name = 0 max_length = 0 max_generations = 0 children . each do | element | if element . children? max_nc , max_lc , max_gc = element . max_lengths max_name = max_nc if max_nc > max_name max_length = max_lc if max_lc > max_length max_generations = max_gc if max_gc > max_generations end n_length = ele... | Finds and returns the maximum character lengths of name and length which occurs for any child element as well as the maximum number of generations of elements . |
11,997 | def method_missing ( sym , * args , & block ) s = sym . to_s action = s [ - 1 ] tag = LIBRARY . as_tag ( s ) || LIBRARY . as_tag ( s [ 0 .. - 2 ] ) if tag if action == '?' return self . exists? ( tag ) elsif action == '=' unless args . length == 0 || args [ 0 ] . nil? if tag == 'FFFE,E000' return self . add_item elsif ... | Handles missing methods which in our case is intended to be dynamic method names matching DICOM elements in the dictionary . |
11,998 | def print ( options = { } ) elements = Array . new if count > 0 max_name , max_length , max_generations = max_lengths max_digits = count_all . to_s . length visualization = Array . new elements , index = handle_print ( start_index = 1 , max_digits , max_name , max_length , max_generations , visualization , options ) if... | Prints all child elementals of this particular parent . Information such as tag parent - child relationship name vr length and value is gathered for each element and processed to produce a nicely formatted output . |
11,999 | def to_hash as_hash = Hash . new unless children? if self . is_a? ( DObject ) as_hash = { } else as_hash [ ( self . tag . private? ) ? self . tag : self . send ( DICOM . key_representation ) ] = nil end else children . each do | child | if child . tag . private? hash_key = child . tag elsif child . is_a? ( Item ) hash_... | Builds a nested hash containing all children of this parent . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.