idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
16,300 | def close! unless @edges . empty? if closed? if @edges . first . parallel? ( @edges . last ) unshift_edge Edge . new ( @edges . last . first , shift_edge . last ) end elsif closing_edge = Edge . new ( @edges . last . last , @edges . first . first ) if @edges . last . parallel? ( closing_edge ) closing_edge = Edge . new... | Close the receiver and return it |
16,301 | def bisector_map winding = 0 tangent_loop . each_cons ( 2 ) . map do | v1 , v2 | k = v1 [ 0 ] * v2 [ 1 ] - v1 [ 1 ] * v2 [ 0 ] winding += k if v1 == v2 bisector = Vector [ - v1 [ 1 ] , v1 [ 0 ] ] block_given? ? ( bisector * yield ( bisector , 1 ) ) : bisector elsif 0 == k nil else bisector_y = ( v2 [ 1 ] - v1 [ 1 ] ) /... | Generate bisectors and k values with an optional mapping block |
16,302 | def tangent_loop edges . map { | e | e . direction } . tap do | tangents | if closed? tangents . unshift tangents . last else tangents . unshift ( tangents . first ) tangents . push ( tangents . last ) end end end | Generate the tangents and fake a circular buffer while accounting for closedness |
16,303 | def find_next_intersection ( edges , i , e ) for j in i .. ( edges . count - 1 ) e2 = edges [ j ] [ :edge ] next if ! e2 || e . connected? ( e2 ) intersection = e . intersection ( e2 ) return [ intersection , j ] if intersection end nil end | Find the next edge that intersects with e starting at index i |
16,304 | def find_last_intersection ( edges , i , e ) intersection , intersection_at = nil , nil for j in i .. ( edges . count - 1 ) e2 = edges [ j ] [ :edge ] next if ! e2 || e . connected? ( e2 ) _intersection = e . intersection ( e2 ) intersection , intersection_at = _intersection , j if _intersection end [ intersection , in... | Find the last edge that intersects with e starting at index i |
16,305 | def [] ( path , default = "" ) ptr = ffi_delegate . get ( path , default ) return nil if ptr . null? ptr . read_string end | Get the value of the current config item . |
16,306 | def methodResponse ( is_ret , * params ) if is_ret resp = params . collect do | param | @writer . ele ( "param" , conv2value ( param ) ) end resp = [ @writer . ele ( "params" , * resp ) ] else if params . size != 1 or params [ 0 ] === XMLRPC :: FaultException raise ArgumentError , "no valid fault-structure given" end r... | generates a XML - RPC methodResponse document |
16,307 | def add_list_start_and_ends level = 0 res = [ ] type_stack = [ ] @fragments . each do | fragment | new_level = fragment . level while ( level < new_level ) level += 1 type = fragment . type res << ListStart . new ( level , fragment . param , type ) if type type_stack . push type end while level > new_level type = type_... | List nesting is implicit given the level of Make it explicit just to make life a tad easier for the output processors |
16,308 | def init ( name , version ) @name = name @version = version @package_files = Rake :: FileList . new @package_dir = 'pkg' @need_tar = false @need_tar_gz = false @need_tar_bz2 = false @need_zip = false @tar_command = 'tar' @zip_command = 'zip' end | Create a Package Task with the given name and version . Initialization that bypasses the yield self and define step . |
16,309 | def create_vm ( specification ) spec = specification spec [ :cpus ] = ( specification [ :cpus ] || 1 ) . to_i spec [ :cpu_cores ] = ( specification [ :cpu_cores ] || 1 ) . to_i spec [ :guest_id ] = specification [ :guest_id ] || 'otherGuest' spec [ :hw_version ] = ( specification [ :hw_version ] || 8 ) . to_i if specif... | Create a Virtual Machine |
16,310 | def host_info [ @_host . summary . config . product . fullName , @_host . summary . config . product . apiType , @_host . summary . config . product . apiVersion , @_host . summary . config . product . osType , @_host . summary . config . product . productLineId , @_host . summary . config . product . vendor , @_host .... | Return product info as an array of strings containing |
16,311 | def remote_command ( cmd ) output = "" Net :: SSH . start ( @address , @user , :password => @password ) do | ssh | output = ssh . exec! cmd end output end | Run a command in the ESX host via SSH |
16,312 | def copy_from_template ( template_disk , destination ) Log . debug "Copying from template #{template_disk} to #{destination}" raise "Template does not exist" if not template_exist? ( template_disk ) source = File . join ( @templates_dir , File . basename ( template_disk ) ) Net :: SSH . start ( @address , @user , :pass... | Expects vmdk source file path and destination path |
16,313 | def import_disk ( source , destination , print_progress = false , params = { } ) use_template = params [ :use_template ] || false if use_template Log . debug "import_disk :use_template => true" if ! template_exist? ( source ) Log . debug "import_disk, template does not exist, importing." import_template ( source , { :p... | Imports a VMDK |
16,314 | def import_disk_convert ( source , destination , print_progress = false ) tmp_dest = destination + ".tmp" Net :: SSH . start ( @address , @user , :password => @password ) do | ssh | if not ( ssh . exec! "ls #{destination} 2>/dev/null" ) . nil? raise Exception . new ( "Destination file #{destination} already exists" ) e... | This method does all the heavy lifting when importing the disk . It also converts the imported VMDK to thin format |
16,315 | def create_disk_spec ( params ) disk_type = params [ :disk_type ] || :flat disk_file = params [ :disk_file ] if disk_type == :sparse and disk_file . nil? raise Exception . new ( "Creating sparse disks in ESX is not supported. Use an existing image." ) end disk_size = params [ :disk_size ] datastore = params [ :datastor... | disk_file datastore disk_size disk_type |
16,316 | def destroy unless host . free_license vm_object . Destroy_Task . wait_for_completion else host . remote_command "vim-cmd vmsvc/power.off #{vmid}" host . remote_command "vim-cmd vmsvc/destroy #{vmid}" end end | Destroy the VirtualMaching removing it from the inventory and deleting the disk files |
16,317 | def write_attribute_text ( prefix , line ) print prefix line . each do | achar | print achar . char end puts end | overridden in specific formatters |
16,318 | def bold_print ( text ) text . split ( / / ) . each do | ch | print ch , BS , ch end end | draw a string in bold |
16,319 | def display_heading ( text , level , indent ) text = strip_attributes ( text ) case level when 1 puts "= " + text . upcase when 2 puts "-- " + text else print indent , text , "\n" end end | Place heading level indicators inline with heading . |
16,320 | def POST if @env [ "rack.request.form_input" ] . eql? @env [ "rack.input" ] @env [ "rack.request.form_hash" ] elsif form_data? || parseable_data? @env [ "rack.request.form_input" ] = @env [ "rack.input" ] unless @env [ "rack.request.form_hash" ] = Utils :: Multipart . parse_multipart ( env ) form_vars = @env [ "rack.in... | Returns the data recieved in the request body . |
16,321 | def url url = scheme + "://" url << host if scheme == "https" && port != 443 || scheme == "http" && port != 80 url << ":#{port}" end url << fullpath url end | Tries to return a remake of the original request URL as a string . |
16,322 | def open ( uri , config , first = true ) @protocol . each do | prot | begin return prot . open ( uri , config ) rescue DRbBadScheme rescue DRbConnError raise ( $! ) rescue raise ( DRbConnError , "#{uri} - #{$!.inspect}" ) end end if first && ( config [ :auto_load ] != false ) auto_load ( uri , config ) return open ( ur... | Open a client connection to + uri + with the configuration + config + . |
16,323 | def open_server ( uri , config , first = true ) @protocol . each do | prot | begin return prot . open_server ( uri , config ) rescue DRbBadScheme end end if first && ( config [ :auto_load ] != false ) auto_load ( uri , config ) return open_server ( uri , config , false ) end raise DRbBadURI , 'can\'t parse uri:' + uri ... | Open a server listening for connections at + uri + with configuration + config + . |
16,324 | def send_request ( ref , msg_id , arg , b ) @msg . send_request ( stream , ref , msg_id , arg , b ) end | On the client side send a request to the server . |
16,325 | def method_missing ( msg_id , * a , & b ) if DRb . here? ( @uri ) obj = DRb . to_obj ( @ref ) DRb . current_server . check_insecure_method ( obj , msg_id ) return obj . __send__ ( msg_id , * a , & b ) end succ , result = self . class . with_friend ( @uri ) do DRbConn . open ( @uri ) do | conn | conn . send_message ( se... | Routes method calls to the referenced object . |
16,326 | def stop_service DRb . remove_server ( self ) if Thread . current [ 'DRb' ] && Thread . current [ 'DRb' ] [ 'server' ] == self Thread . current [ 'DRb' ] [ 'stop_service' ] = true else @thread . kill end end | Stop this server . |
16,327 | def to_obj ( ref ) return front if ref . nil? return front [ ref . to_s ] if DRbURIOption === ref @idconv . to_obj ( ref ) end | Convert a dRuby reference to the local object it refers to . |
16,328 | def check_insecure_method ( obj , msg_id ) return true if Proc === obj && msg_id == :__drb_yield raise ( ArgumentError , "#{any_to_s(msg_id)} is not a symbol" ) unless Symbol == msg_id . class raise ( SecurityError , "insecure method `#{msg_id}'" ) if insecure_method? ( msg_id ) if obj . private_methods . include? ( ms... | Check that a method is callable via dRuby . |
16,329 | def main_loop Thread . start ( @protocol . accept ) do | client | @grp . add Thread . current Thread . current [ 'DRb' ] = { 'client' => client , 'server' => self } loop do begin succ = false invoke_method = InvokeMethod . new ( self , client ) succ , result = invoke_method . perform if ! succ && verbose p result resul... | The main loop performed by a DRbServer s internal thread . |
16,330 | def supports_standard_conforming_strings? client_min_messages_old = client_min_messages self . client_min_messages = 'panic' has_support = select ( 'SHOW standard_conforming_strings' ) . to_a [ 0 ] [ 0 ] rescue false self . client_min_messages = client_min_messages_old has_support end | Does PostgreSQL support standard conforming strings? |
16,331 | def define if rdoc_task_name != "rdoc" desc "Build the RDOC HTML Files" else desc "Build the #{rdoc_task_name} HTML Files" end task rdoc_task_name desc "Force a rebuild of the RDOC files" task rerdoc_task_name => [ clobber_task_name , rdoc_task_name ] desc "Remove rdoc products" task clobber_task_name do rm_r rdoc_dir ... | Create an RDoc task with the given name . See the RDocTask class overview for documentation . Create the tasks defined by this task lib . |
16,332 | def assert_match ( actual_string , expected_re , message = "" ) _wrap_assertion { full_message = build_message ( message , "Expected <?> to match <?>" , actual_string , expected_re ) assert_block ( full_message ) { expected_re =~ actual_string } Regexp . last_match } end | To deal with the fact that RubyUnit does not check that the regular expression is indeed a regular expression if it is not we do our own assertion using the same semantics as RubyUnit |
16,333 | def init ( gem ) super ( gem . name , gem . version ) @gem_spec = gem @package_files += gem_spec . files if gem_spec . files end | Create a GEM Package task library . Automatically define the gem if a block is given . If no block is supplied then + define + needs to be called to define the task . Initialization tasks without the yield self or define operations . |
16,334 | def parse ( string ) require 'rexml/document' unless defined? ( REXML :: Document ) doc = REXML :: Document . new ( string ) merge_element! ( { } , doc . root ) end | Parse an XML Document string into a simple hash |
16,335 | def init_tags @attr_tags = [ InlineTag . new ( SM :: Attribute . bitmap_for ( :BOLD ) , "<b>" , "</b>" ) , InlineTag . new ( SM :: Attribute . bitmap_for ( :TT ) , "<tt>" , "</tt>" ) , InlineTag . new ( SM :: Attribute . bitmap_for ( :EM ) , "<em>" , "</em>" ) , ] end | Set up the standard mapping of attributes to HTML tags |
16,336 | def add_tag ( name , start , stop ) @attr_tags << InlineTag . new ( SM :: Attribute . bitmap_for ( name ) , start , stop ) end | Add a new set of HTML tags for an attribute . We allow separate start and end tags for flexibility |
16,337 | def set_form_data ( params , sep = '&' ) self . body = params . map { | k , v | "#{urlencode(k.to_s)}=#{urlencode(v.to_s)}" } . join ( sep ) self . content_type = 'application/x-www-form-urlencoded' end | Set header fields and a body from HTML form data . + params + should be a Hash containing HTML form data . Optional argument + sep + means data record separator . |
16,338 | def each if Hash === @tuple @tuple . each { | k , v | yield ( k , v ) } else @tuple . each_with_index { | v , k | yield ( k , v ) } end end | Iterate through the tuple yielding the index or key and the value thus ensuring arrays are iterated similarly to hashes . |
16,339 | def init_with_ary ( ary ) @tuple = Array . new ( ary . size ) @tuple . size . times do | i | @tuple [ i ] = ary [ i ] end end | Munges + ary + into a valid Tuple . |
16,340 | def init_with_hash ( hash ) @tuple = Hash . new hash . each do | k , v | raise InvalidHashTupleKey unless String === k @tuple [ k ] = v end end | Ensures + hash + is a valid Tuple . |
16,341 | def narrow32bit ( f ) if f . nan? || f . infinite? f elsif f . abs < MIN_POSITIVE_SINGLE XSDFloat . positive? ( f ) ? POSITIVE_ZERO : NEGATIVE_ZERO else f end end | Convert to single - precision 32 - bit floating point value . |
16,342 | def set_encoded ( value ) if / / !~ value raise ValueSpaceError . new ( "#{ type }: cannot accept '#{ value }'." ) end @data = String . new ( value ) . strip @is_nil = false end | String in Ruby could be a binary . |
16,343 | def rescue_with_handler ( exception ) if handler = handler_for_rescue ( exception ) handler . arity != 0 ? handler . call ( exception ) : handler . call true end end | Tries to rescue the exception by looking up and calling a registered handler . |
16,344 | def handle ( text ) text . gsub! ( / \t \w \s \n / ) do prefix = $1 directive = $2 . downcase param = $3 case directive when "include" filename = param . split [ 0 ] include_file ( filename , prefix ) else yield ( directive , param ) end end end | Look for common options in a chunk of text . Options that we don t handle are passed back to our caller as |directive param| |
16,345 | def include_file ( name , indent ) if ( full_name = find_include_file ( name ) ) content = File . open ( full_name ) { | f | f . read } if content =~ / / content . gsub ( / / , indent ) else content . gsub ( / / , indent ) end else $stderr . puts "Couldn't find file to include: '#{name}'" '' end end | Include a file indenting it correctly |
16,346 | def find_include_file ( name ) to_search = [ File . dirname ( @input_file_name ) ] . concat @include_path to_search . each do | dir | full_name = File . join ( dir , name ) stat = File . stat ( full_name ) rescue next return full_name if stat . readable? end nil end | Look for the given file in the directory containing the current file and then in each of the directories specified in the RDOC_INCLUDE path |
16,347 | def parse_subprogram ( subprogram , params , comment , code , before_contains = nil , function = nil , prefix = nil ) subprogram . singleton = false prefix = "" if ! prefix arguments = params . sub ( / \( / , "" ) . sub ( / \) / , "" ) . split ( "," ) if params args_comment , params_opt = find_arguments ( arguments , c... | End of parse_program_or_module |
16,348 | def collect_first_comment ( body ) comment = "" not_comment = "" comment_start = false comment_end = false body . split ( "\n" ) . each { | line | if comment_end not_comment << line not_comment << "\n" elsif / \s \s /i =~ line comment_start = true comment << $1 comment << "\n" elsif / \s /i =~ line comment_end = true i... | Collect comment for file entity |
16,349 | def find_namelists ( text , before_contains = nil ) return nil if ! text result = "" lines = "#{text}" before_contains = "" if ! before_contains while lines =~ / \s \s \/ \s \w \s \/ \s \w \, /i lines = $~ . post_match nml_comment = COMMENTS_ARE_UPPER ? find_comments ( $~ . pre_match ) : find_comments ( $~ . post_match... | Return comments of definitions of namelists |
16,350 | def find_comments text return "" unless text lines = text . split ( "\n" ) lines . reverse! if COMMENTS_ARE_UPPER comment_block = Array . new lines . each do | line | break if line =~ / \s \w / || line =~ / \s / if COMMENTS_ARE_UPPER comment_block . unshift line . sub ( / \s \s / , "" ) else comment_block . push line .... | Comments just after module or subprogram or arguments are returned . If COMMENTS_ARE_UPPER is true comments just before modules or subprograms are returned |
16,351 | def initialize_public_method ( method , parent ) return if ! method || ! parent new_meth = AnyMethod . new ( "External Alias for module" , method . name ) new_meth . singleton = method . singleton new_meth . params = method . params . clone new_meth . comment = remove_trailing_alias ( method . comment . clone ) new_met... | Create method for internal alias |
16,352 | def initialize_external_method ( new , old , params , file , comment , token = nil , internal = nil , nolink = nil ) return nil unless new || old if internal external_alias_header = "#{INTERNAL_ALIAS_MES} " external_alias_text = external_alias_header + old elsif file external_alias_header = "#{EXTERNAL_ALIAS_MES} " ext... | Create method for external alias |
16,353 | def check_external_aliases ( subname , params , comment , test = nil ) @@external_aliases . each { | alias_item | if subname == alias_item [ "old_name" ] || subname . upcase == alias_item [ "old_name" ] . upcase && @options . ignore_case new_meth = initialize_external_method ( alias_item [ "new_name" ] , subname , para... | Check external aliases |
16,354 | def united_to_one_line ( f90src ) return "" unless f90src lines = f90src . split ( "\n" ) previous_continuing = false now_continuing = false body = "" lines . each { | line | words = line . split ( "" ) next if words . empty? && previous_continuing commentout = false brank_flag = true ; brank_char = "" squote = false ;... | Continuous lines are united . |
16,355 | def continuous_line? ( line ) continuous = false if / \s / =~ line continuous = true if comment_out? ( $~ . pre_match ) continuous = false end end return continuous end | Continuous line checker |
16,356 | def comment_out? ( line ) return nil unless line commentout = false squote = false ; dquote = false line . split ( "" ) . each { | char | if ! ( squote ) && ! ( dquote ) case char when "!" ; commentout = true ; break when "\"" ; dquote = true when "\'" ; squote = true else next end elsif squote case char when "\'" ; sq... | Comment out checker |
16,357 | def semicolon_to_linefeed ( text ) return "" unless text lines = text . split ( "\n" ) lines . collect! { | line | words = line . split ( "" ) commentout = false squote = false ; dquote = false words . collect! { | char | if ! ( squote ) && ! ( dquote ) && ! ( commentout ) case char when "!" ; commentout = true ; next ... | Semicolons are replaced to line feed . |
16,358 | def remove_empty_head_lines ( text ) return "" unless text lines = text . split ( "\n" ) header = true lines . delete_if { | line | header = false if / \S / =~ line header && / \s / =~ line } lines . join ( "\n" ) end | Empty lines in header are removed |
16,359 | def end unless ready? then warn "attempt to close uninitialized stream; ignored." return nil end if in_stream? then warn "attempt to close unfinished zstream; reset forced" reset end reset_input err = Zlib . send @func_end , pointer Zlib . handle_error err , message @flags = 0 @output = nil @next_out . free unless @nex... | Closes the stream . All operations on the closed stream will raise an exception . |
16,360 | def reset err = Zlib . send @func_reset , pointer Zlib . handle_error err , message @flags = READY reset_input end | Resets and initializes the stream . All data in both input and output buffer are discarded . |
16,361 | def do_deflate ( data , flush ) if data . nil? then run '' , Zlib :: FINISH else data = StringValue data if flush != Zlib :: NO_FLUSH or not data . empty? then run data , flush end end end | Performs the deflate operation and leaves the compressed data in the output buffer |
16,362 | def params ( level , strategy ) err = Zlib . deflateParams pointer , level , strategy raise Zlib :: BufError , 'buffer expansion not implemented' if err == Zlib :: BUF_ERROR Zlib . handle_error err , message nil end | Changes the parameters of the deflate stream . See zlib . h for details . The output from the stream by changing the params is preserved in output buffer . |
16,363 | def check_footer @zstream . flags |= Zlib :: GzipFile :: FOOTER_FINISHED footer = @zstream . input . slice! 0 , 8 rest = @io . read 8 - footer . length footer << rest if rest raise NoFooter , 'footer is not found' unless footer . length == 8 crc , length = footer . unpack 'VV' @zstream [ :total_in ] += 8 raise CRCError... | HACK use a buffer class |
16,364 | def make_header flags = 0 extra_flags = 0 flags |= Zlib :: GzipFile :: FLAG_ORIG_NAME if @orig_name flags |= Zlib :: GzipFile :: FLAG_COMMENT if @comment extra_flags |= Zlib :: GzipFile :: EXTRAFLAG_FAST if @level == Zlib :: BEST_SPEED extra_flags |= Zlib :: GzipFile :: EXTRAFLAG_SLOW if @level == Zlib :: BEST_COMPRESS... | Writes out a gzip header |
16,365 | def make_footer footer = [ @crc , @zstream . total_in , ] . pack 'VV' @io . write footer @zstream . flags |= Zlib :: GzipFile :: FOOTER_FINISHED end | Writes out a gzip footer |
16,366 | def write ( data ) make_header unless header_finished? data = String data if data . length > 0 or sync? then @crc = Zlib . crc32_c @crc , data , data . length flush = sync? ? Zlib :: SYNC_FLUSH : Zlib :: NO_FLUSH @zstream . run data , flush end write_raw end | Same as IO . |
16,367 | def << ( string ) string = StringValue string unless string . nil? if finished? then unless string . nil? then @input ||= '' @input << string end else run string , Zlib :: SYNC_FLUSH end end | Creates a new inflate stream for decompression . See zlib . h for details of the argument . If + window_bits + is + nil + the default value is used . |
16,368 | def each_with_something ( test , max = 0 , name = nil ) num = 0 child = nil @elements . each ( name ) { | child | yield child if test . call ( child ) and num += 1 return if max > 0 and num == max } end | A private helper method |
16,369 | def check_arity ( obj , n_args ) ary = obj . arity if ary >= 0 n_args == ary else n_args >= ( ary + 1 ) . abs end end | returns true if the arity of obj matches |
16,370 | def verify_gem ( signature , data , chain , time = Time . now ) Gem . ensure_ssl_available cert_class = OpenSSL :: X509 :: Certificate exc = Gem :: Security :: Exception chain ||= [ ] chain = chain . map { | str | cert_class . new ( str ) } signer , ch_len = chain [ - 1 ] , chain . size if @verify_data dgst = @opt [ :d... | Verify that the gem data with the given signature and signing chain matched this security policy at the specified time . |
16,371 | def transform t = nil if @value . is_a? Hash t = { } @value . each { | k , v | t [ k ] = v [ 1 ] . transform } elsif @value . is_a? Array t = [ ] @value . each { | v | t . push v . transform } else t = @value end YAML . transfer_method ( @type_id , t ) end | Transform this node fully into a native type |
16,372 | def collect_first_comment skip_tkspace res = '' first_line = true tk = get_tk while tk . kind_of? ( TkCOMMENT ) if first_line && / \A / =~ tk . text skip_tkspace tk = get_tk elsif first_line && / \A \s \* / =~ tk . text first_line = false skip_tkspace tk = get_tk else first_line = false res << tk . text << "\n" tk = ge... | Look for the first comment in a file that isn t a shebang line . |
16,373 | def parse_method_parameters ( method ) res = parse_method_or_yield_parameters ( method ) res = "(" + res + ")" unless res [ 0 ] == ?( method . params = res unless method . params if method . block_params . nil? skip_tkspace ( false ) read_documentation_modifiers ( method , METHOD_MODIFIERS ) end end | Capture the method s parameters . Along the way look for a comment containing |
16,374 | def skip_optional_do_after_expression skip_tkspace ( false ) tk = get_tk case tk when TkLPAREN , TkfLPAREN end_token = TkRPAREN else end_token = TkNL end nest = 0 @scanner . instance_eval { @continue = false } loop do puts ( "\nWhile: #{tk}, #{@scanner.continue} " + "#{@scanner.lex_state} #{nest}" ) if $DEBUG case tk w... | while until and for have an optional |
16,375 | def get_class_specification tk = get_tk return "self" if tk . kind_of? ( TkSELF ) res = "" while tk . kind_of? ( TkCOLON2 ) || tk . kind_of? ( TkCOLON3 ) || tk . kind_of? ( TkCONSTANT ) res += tk . text tk = get_tk end unget_tk ( tk ) skip_tkspace ( false ) get_tkread tk = get_tk case tk when TkNL , TkCOMMENT , TkSEMIC... | Return a superclass which can be either a constant of an expression |
16,376 | def get_constant res = "" skip_tkspace ( false ) tk = get_tk while tk . kind_of? ( TkCOLON2 ) || tk . kind_of? ( TkCOLON3 ) || tk . kind_of? ( TkCONSTANT ) res += tk . text tk = get_tk end unget_tk ( tk ) res end | Parse a constant which might be qualified by one or more class or module names |
16,377 | def get_constant_with_optional_parens skip_tkspace ( false ) nest = 0 while ( tk = peek_tk ) . kind_of? ( TkLPAREN ) || tk . kind_of? ( TkfLPAREN ) get_tk skip_tkspace ( true ) nest += 1 end name = get_constant while nest > 0 skip_tkspace ( true ) tk = get_tk nest -= 1 if tk . kind_of? ( TkRPAREN ) end name end | Get a constant that may be surrounded by parens |
16,378 | def read_directive ( allowed ) tk = get_tk puts "directive: #{tk.inspect}" if $DEBUG result = nil if tk . kind_of? ( TkCOMMENT ) if tk . text =~ / \s \w \s / directive = $1 . downcase if allowed . include? ( directive ) result = [ directive , $2 ] end end else unget_tk ( tk ) end result end | Directives are modifier comments that can appear after class module or method names . For example |
16,379 | def create_driver ( servicename = nil , portname = nil ) warn ( "WSDLDriverFactory#create_driver is depricated. Use create_rpc_driver instead." ) port = find_port ( servicename , portname ) WSDLDriver . new ( @wsdl , port , nil ) end | depricated old interface |
16,380 | def markup ( str , remove_para = false ) return '' unless str unless defined? @markup @markup = SM :: SimpleMarkup . new @markup . add_special ( / \w \w \# \w \( \. \w \* \/ \+ \- \= \< \> \) \# \w \( \w \* \/ \+ \- \= \< \> \) \b \w \w \# \w \b \w \w \# \w \b \w \/ \. \w /x , :CROSSREF ) @markup . add_special ( / \. \... | Convert a string in markup format into HTML . We keep a cached SimpleMarkup object lying around after the first time we re called per object . |
16,381 | def build_method_detail_list ( section ) outer = [ ] methods = @methods . sort for singleton in [ true , false ] for vis in [ :public , :protected , :private ] res = [ ] methods . each do | m | if m . section == section and m . document_self and m . visibility == vis and m . singleton == singleton row = { } if m . call... | Build an array of arrays of method details . The outer array has up to six entries public private and protected for both class methods the other for instance methods . The inner arrays contain a hash for each method |
16,382 | def build_class_list ( level , from , section , infile = nil ) res = "" prefix = " ::" * level ; from . modules . sort . each do | mod | next unless mod . section == section next if infile && ! mod . defined_in? ( infile ) if mod . document_self res << prefix << "Module " << href ( url ( mod . viewer . path ... | Build the structured list of classes and modules contained in this context . |
16,383 | def load_html_template template = @options . template unless template =~ %r{ \\ } template = File . join ( "rdoc/generators/template" , @options . generator . key , template ) end require template extend RDoc :: Page rescue LoadError $stderr . puts "Could not find HTML template '#{template}'" exit 99 end | Load up the HTML template specified in the options . If the template name contains a slash use it literally |
16,384 | def write_style_sheet template = TemplatePage . new ( RDoc :: Page :: STYLE ) unless @options . css File . open ( CSS_NAME , "w" ) do | f | values = { "fonts" => RDoc :: Page :: FONTS } template . write_html_on ( f , values ) end end end | Write out the style sheet used by the main frames |
16,385 | def main_url main_page = @options . main_page ref = nil if main_page ref = AllReferences [ main_page ] if ref ref = ref . path else $stderr . puts "Could not find main page #{main_page}" end end unless ref for file in @files if file . document_self ref = file . path break end end end unless ref $stderr . puts "Couldn't... | return the url of the main page |
16,386 | def generate_xml values = { 'charset' => @options . charset , 'files' => gen_into ( @files ) , 'classes' => gen_into ( @classes ) , 'title' => CGI . escapeHTML ( @options . title ) , } write_extra_pages if defined? write_extra_pages template = TemplatePage . new ( RDoc :: Page :: ONE_PAGE ) if @options . op_name opfile... | Generate all the HTML . For the one - file case we generate all the information in to one big hash |
16,387 | def draw unless @options . quiet $stderr . print "Diagrams: " $stderr . flush end @info . each_with_index do | i , file_count | @done_modules = { } @local_names = find_names ( i ) @global_names = [ ] @global_graph = graph = DOT :: Digraph . new ( 'name' => 'TopLevel' , 'fontname' => FONT , 'fontsize' => '8' , 'bgcolor'... | Pass in the set of top level objects . The method also creates the subdirectory to hold the images |
16,388 | def find_symbol ( symbol , method = nil ) result = nil case symbol when / / result = toplevel . find_symbol ( $1 ) when / / modules = symbol . split ( / / ) unless modules . empty? module_name = modules . shift result = find_module_named ( module_name ) if result modules . each do | module_name | result = result . find... | allow us to sort modules by name Look up the given symbol . If method is non - nil then we assume the symbol references a module that contains that method |
16,389 | def secure_compare ( a , b ) if a . length == b . length result = 0 for i in 0 .. ( a . length - 1 ) result |= a [ i ] ^ b [ i ] end result == 0 else false end end | constant - time comparison algorithm to prevent timing attacks |
16,390 | def parse_pi_content ( content ) params = { } content . scan ( CONTENT_PATTERN ) do | name , quote , value | params [ name ] = value end params end | Extract the first name = value pair from content . Works with single quotes according to the constant CONTENT_PATTERN . Return a Hash . |
16,391 | def normalize_rss ( rss ) return rss if maybe_xml? ( rss ) uri = to_uri ( rss ) if uri . respond_to? ( :read ) uri . read elsif ! rss . tainted? and File . readable? ( rss ) File . open ( rss ) { | f | f . read } else rss end end | Try to get the XML associated with + rss + . Return + rss + if it already looks like XML or treat it as a URI or a file to get the XML |
16,392 | def define lib_path = @libs . join ( File :: PATH_SEPARATOR ) actual_name = Hash === name ? name . keys . first : name unless Rake . application . last_comment desc "Analyze code coverage with tests" + ( @name == :rcov ? "" : " for #{actual_name}" ) end task @name do run_code = '' RakeFileUtils . verbose ( @verbose ) d... | Create a testing task . Create the tasks defined by this task lib . |
16,393 | def update_output_dir ( op_dir , time ) File . open ( output_flag_file ( op_dir ) , "w" ) { | f | f . puts time . rfc2822 } end | Update the flag file in an output directory . |
16,394 | def normalized_file_list ( options , relative_files , force_doc = false , exclude_pattern = nil ) file_list = [ ] relative_files . each do | rel_file_name | next if exclude_pattern && exclude_pattern =~ rel_file_name stat = File . stat ( rel_file_name ) case type = stat . ftype when "file" next if @last_created and sta... | Given a list of files and directories create a list of all the Ruby files they contain . |
16,395 | def list_files_in_directory ( dir , options ) files = Dir . glob File . join ( dir , "*" ) normalized_file_list options , files , false , options . exclude end | Return a list of the files to be processed in a directory . We know that this directory doesn t have a . document file so we re looking for real files . However we may well contain subdirectories which must be tested for . document files . |
16,396 | def parse_files ( options ) @stats = Stats . new options . verbosity files = options . files files = [ "." ] if files . empty? file_list = normalized_file_list ( options , files , true , options . exclude ) return [ ] if file_list . empty? file_info = [ ] file_list . each do | filename | @stats . add_file filename cont... | Parse each file on the command line recursively entering directories . |
16,397 | def document ( argv ) TopLevel :: reset @options = Options . new GENERATORS @options . parse argv @last_created = nil unless @options . all_one_file then @last_created = setup_output_dir @options . op_dir , @options . force_update end start_time = Time . now file_info = parse_files @options @options . title = "RDoc Doc... | Format up one or more files according to the given arguments . |
16,398 | def new_with_value_if_need ( klass , value ) if value . is_a? ( klass ) value else klass . new ( value ) end end | If + value + is an instance of class + klass + return it else create a new instance of + klass + with value + value + . |
16,399 | def methods_matching ( methods , singleton = false ) count = 0 @method_list . each do | m | if methods . include? m . name and m . singleton == singleton then yield m count += 1 end end return if count == methods . size || singleton @attributes . each do | a | yield a if methods . include? a . name end end | Yields Method and Attr entries matching the list of names in + methods + . Attributes are only returned when + singleton + is false . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.