idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
8,800 | def position_object ( col_start , row_start , x1 , y1 , width , height ) x1 , col_start = adjust_col_position ( x1 , col_start ) y1 , row_start = adjust_row_position ( y1 , row_start ) col_end = col_start row_end = row_start width += x1 height += y1 width , col_end = adjust_col_position ( width , col_end ) height , row... | Calculate the vertices that define the position of a graphical object within the worksheet . |
8,801 | def store_mso_sp_container ( length ) type = 0xF004 version = 15 instance = 0 data = '' add_mso_generic ( type , version , instance , data , length ) end | Write the Escher SpContainer record that is part of MSODRAWING . |
8,802 | def store_mso_sp ( instance , spid , options ) type = 0xF00A version = 2 data = '' length = 8 data = [ spid , options ] . pack ( 'VV' ) add_mso_generic ( type , version , instance , data , length ) end | Write the Escher Sp record that is part of MSODRAWING . |
8,803 | def store_mso_client_data type = 0xF011 version = 0 instance = 0 data = '' length = 0 add_mso_generic ( type , version , instance , data , length ) end | Write the Escher ClientData record that is part of MSODRAWING . |
8,804 | def boundsheet hidden = self . hidden? ? 1 : 0 encoding = self . is_name_utf16be? ? 1 : 0 record = 0x0085 length = 0x08 + @name . bytesize cch = @name . bytesize cch /= 2 if is_name_utf16be? sheetname = is_name_utf16be? ? @name . unpack ( 'v*' ) . pack ( 'n*' ) : @name grbit = @type | hidden header = [ record , length ... | Excel BIFF BOUNDSHEET record . |
8,805 | def parse_filter_expression ( expression , tokens ) if ( tokens . size == 7 ) conditional = tokens [ 3 ] if conditional =~ / / conditional = 0 elsif conditional =~ / \| \| / conditional = 1 else raise "Token '#{conditional}' is not a valid conditional " + "in filter expression '#{expression}'" end expression_1 = parse_... | Converts the tokens of a possibly conditional expression into 1 or 2 sub expressions for further parsing . |
8,806 | def xf_record_index ( row , col , xf = nil ) if xf . respond_to? ( :xf_index ) xf . xf_index elsif @row_formats . has_key? ( row ) @row_formats [ row ] . xf_index elsif @col_formats . has_key? ( col ) @col_formats [ col ] . xf_index else 0x0F end end | Returns an index to the XF record in the workbook . |
8,807 | def encode_password ( password ) i = 0 chars = password . split ( / / ) count = chars . size chars . collect! do | char | i += 1 char = char . ord << i low_15 = char & 0x7fff high_15 = char & 0x7fff << 15 high_15 = high_15 >> 15 char = low_15 | high_15 end encoded_password = 0x0000 chars . each { | c | encoded_password... | Based on the algorithm provided by Daniel Rentz of OpenOffice . |
8,808 | def get_formula_string ( string ) ruby_19 { string = convert_to_ascii_if_ascii ( string ) } record = 0x0207 length = 0x00 strlen = string . bytesize encoding = 0 if is_utf8? ( string ) string = utf8_to_16be ( string ) encoding = 1 end length = 0x03 + string . bytesize header = [ record , length ] . pack ( "vv" ) data =... | Pack the string value when a formula evaluates to a string . The value cannot be calculated by the module and thus must be supplied by the user . |
8,809 | def store_dimensions record = 0x0200 length = 0x000E reserved = 0x0000 @dimension . increment_row_max @dimension . increment_col_max header = [ record , length ] . pack ( "vv" ) fields = [ @dimension . row_min , @dimension . row_max , @dimension . col_min , @dimension . col_max , reserved ] data = fields . pack ( "VVvv... | Writes Excel DIMENSIONS to define the area in which there is cell data . |
8,810 | def store_window2 record = 0x023E length = 0x0012 grbit = 0x00B6 rwTop = @first_row colLeft = @first_col rgbHdr = 0x00000040 wScaleSLV = 0x0000 wScaleNormal = 0x0000 reserved = 0x00000000 fDspFmla = @display_formulas fDspGrid = @screen_gridlines fDspRwCol = @display_headers fFrozen = frozen? ? 1 : 0 fDspZeros = display... | Write BIFF record Window2 . |
8,811 | def store_tab_color color = @tab_color return if color == 0 record = 0x0862 length = 0x0014 zero = 0x0000 unknown = 0x0014 store_simple ( record , length , record , zero , zero , zero , zero , zero , unknown , zero , color , zero ) end | Write the Tab Color BIFF record . |
8,812 | def store_defrow record = 0x0225 length = 0x0004 grbit = 0x0000 height = 0x00FF header = [ record , length ] . pack ( "vv" ) data = [ grbit , height ] . pack ( "vv" ) prepend ( header , data ) end | Write BIFF record DEFROWHEIGHT . |
8,813 | def store_defcol record = 0x0055 length = 0x0002 colwidth = 0x0008 header = [ record , length ] . pack ( "vv" ) data = [ colwidth ] . pack ( "v" ) prepend ( header , data ) end | Write BIFF record DEFCOLWIDTH . |
8,814 | def store_autofilterinfo return '' if @filter_area . count == 0 record = 0x009D length = 0x0002 num_filters = @filter_area . count header = [ record , length ] . pack ( 'vv' ) data = [ num_filters ] . pack ( 'v' ) prepend ( header , data ) end | Write BIFF record AUTOFILTERINFO . |
8,815 | def store_selection ( first_row = 0 , first_col = 0 , last_row = nil , last_col = nil ) record = 0x001D length = 0x000F pane_position = @active_pane row_active = first_row col_active = first_col irefAct = 0 cref = 1 row_first = first_row col_first = first_col row_last = last_row || row_first col_last = last_col || col_... | Write BIFF record SELECTION . |
8,816 | def store_externcount ( count ) record = 0x0016 length = 0x0002 cxals = count header = [ record , length ] . pack ( 'vv' ) data = [ cxals ] . pack ( 'v' ) prepend ( header , data ) end | Write BIFF record EXTERNCOUNT to indicate the number of external sheet references in a worksheet . |
8,817 | def store_setup record = 0x00A1 length = 0x0022 iPaperSize = @paper_size iScale = @print_scale iPageStart = @page_start iFitWidth = @fit_width iFitHeight = @fit_height grbit = 0x00 iRes = 0x0258 iVRes = 0x0258 numHdr = @margin_header numFtr = @margin_footer iCopies = 0x01 fLeftToRight = @page_order fLandscape = @orient... | Store the page setup SETUP BIFF record . |
8,818 | def store_gridset record = 0x0082 length = 0x0002 fGridSet = @print_gridlines == 0 ? 1 : 0 header = [ record , length ] . pack ( "vv" ) data = [ fGridSet ] . pack ( "v" ) prepend ( header , data ) end | Write the GRIDSET BIFF record . Must be used in conjunction with the PRINTGRIDLINES record . |
8,819 | def store_wsbool record = 0x0081 length = 0x0002 grbit = 0x0000 grbit |= 0x0001 grbit |= 0x0020 if @outline . style != 0 grbit |= 0x0040 if @outline . below != 0 grbit |= 0x0080 if @outline . right != 0 grbit |= 0x0100 if @fit_page != 0 grbit |= 0x0400 if @outline . visible? header = [ record , length ] . pack ( "vv" )... | Write the WSBOOL BIFF record mainly for fit - to - page . Used in conjunction with the SETUP record . |
8,820 | def store_password return unless protect? && @password record = 0x0013 length = 0x0002 wPassword = @password header = [ record , length ] . pack ( "vv" ) data = [ wPassword ] . pack ( "v" ) prepend ( header , data ) end | Write the worksheet PASSWORD record . |
8,821 | def store_table return unless compatibility? row_offset = 0 written_rows = [ ] ( 0 .. @dimension . row_max - 1 ) . each do | row | next unless @table [ row ] or @row_data [ row ] written_rows . push ( row ) row_offset += 20 col_min = @dimension . col_min col_max = @dimension . col_max if @row_data [ row ] packed_row = ... | Note about compatibility mode . |
8,822 | def size_col ( col ) if @col_sizes [ col ] width = @col_sizes [ col ] if width < 1 ( width * 12 ) . to_i else ( width * 7 + 5 ) . to_i end else 64 end end | Convert the width of a cell from user s units to pixels . Excel rounds the column width to the nearest pixel . If the width hasn t been set by the user we use the default value . If the column is hidden we use a value of zero . |
8,823 | def store_autofilter ( index , operator_1 , token_1 , join = nil , operator_2 = nil , token_2 = nil ) record = 0x009E length = 0x0000 top10_active = 0 top10_direction = 0 top10_percent = 0 top10_value = 101 grbit = join || 0 optimised_1 = 0 optimised_2 = 0 doper_1 = '' doper_2 = '' string_1 = '' string_2 = '' optimised... | Function to write worksheet AUTOFILTER records . These contain 2 Biff Doper structures to represent the 2 possible filter conditions . |
8,824 | def pack_doper ( operator , token ) doper = '' string = '' unless operator return pack_unused_doper , string end if token . to_s =~ / /i doper = pack_blanks_doper ( operator , token ) elsif operator == 2 or ! ( token . to_s =~ / \d \. \d \d \. \d \d / ) string = token . to_s ruby_19 { string = convert_to_ascii_if_ascii... | Create a Biff Doper structure that represents a filter expression . Depending on the type of the token we pack an Empty String or Number doper . |
8,825 | def pack_number_doper ( operator , number ) number = [ number ] . pack ( 'd' ) number . reverse! if @byte_order [ 0x04 , operator ] . pack ( 'CC' ) + number end | Pack an IEEE double number Doper structure . |
8,826 | def store_images return if @images . array . empty? spid = @object_ids . spid @images . array . each_index do | i | @images . array [ i ] . store_image_record ( i , @images . array . size , charts_size , @filter_area . count , comments_size , spid ) store_obj_image ( i + 1 ) end @object_ids . spid = spid end | Store the collections of records that make up images . |
8,827 | def store_charts return if charts_size == 0 record = 0x00EC charts = @charts . array charts . each_index do | i | data = '' if i == 0 && images_size == 0 dg_length = 192 + 120 * ( charts_size - 1 ) + 96 * filter_count + 128 * comments_size spgr_length = dg_length - 24 data += store_parent_mso_record ( dg_length , spgr_... | Store the collections of records that make up charts . |
8,828 | def store_comments return if @comments . array . empty? spid = @object_ids . spid num_comments = comments_size num_objects = images_size + @filter_area . count + charts_size @comments . array . each_index { | i | spid = @comments . array [ i ] . store_comment_record ( i , num_objects , num_comments , spid ) } @comments... | Store the collections of records that make up cell comments . |
8,829 | def store_mso_dg_container ( length ) type = 0xF002 version = 15 instance = 0 data = '' add_mso_generic ( type , version , instance , data , length ) end | Write the Escher DgContainer record that is part of MSODRAWING . |
8,830 | def store_mso_dg type = 0xF008 version = 0 length = 8 data = [ @object_ids . num_shapes , @object_ids . max_spid ] . pack ( "VV" ) add_mso_generic ( type , version , @object_ids . drawings_saved , data , length ) end | Write the Escher Dg record that is part of MSODRAWING . |
8,831 | def store_mso_spgr_container ( length ) type = 0xF003 version = 15 instance = 0 data = '' add_mso_generic ( type , version , instance , data , length ) end | Write the Escher SpgrContainer record that is part of MSODRAWING . |
8,832 | def store_mso_spgr type = 0xF009 version = 1 instance = 0 data = [ 0 , 0 , 0 , 0 ] . pack ( "VVVV" ) length = 16 add_mso_generic ( type , version , instance , data , length ) end | Write the Escher Spgr record that is part of MSODRAWING . |
8,833 | def get_font dyHeight = @size * 20 icv = @color bls = @bold sss = @font_script uls = @underline bFamily = @font_family bCharSet = @font_charset rgch = @font encoding = @font_encoding ruby_19 { rgch = convert_to_ascii_if_ascii ( rgch ) } if is_utf8? ( rgch ) rgch = utf8_to_16be ( rgch ) encoding = 1 end cch = rgch . byt... | Generate an Excel BIFF FONT record . |
8,834 | def set_border ( style ) set_bottom ( style ) set_top ( style ) set_left ( style ) set_right ( style ) end | Set cells borders to the same style |
8,835 | def set_border_color ( color ) set_bottom_color ( color ) set_top_color ( color ) set_left_color ( color ) set_right_color ( color ) end | Set cells border to the same color |
8,836 | def method_missing ( name , * args ) method = "#{name}" method =~ / \w / or raise "Unknown method: #{method}\n" attribute = "@#{$1}" if method =~ / \w / value = get_color ( args [ 0 ] ) else value = args [ 0 ] . nil? ? 1 : args [ 0 ] end if value . respond_to? ( :to_str ) || ! value . respond_to? ( :+ ) s = %Q!#{attrib... | Dynamically create set methods that aren t already defined . |
8,837 | def process_jpg ( data ) @type = 5 offset = 2 data_length = data . bytesize while offset < data_length marker = data [ offset , 2 ] . unpack ( "n" ) marker = marker [ 0 ] length = data [ offset + 2 , 2 ] . unpack ( "n" ) length = length [ 0 ] if marker == 0xFFC0 || marker == 0xFFC2 height = data [ offset + 5 , 2 ] . un... | Extract width and height information from a JPEG file . |
8,838 | def value unless @processed @processed = true until ( nested = constants_from_value ) . empty? nested . each { | n | @value . gsub! ( value_regex ( n ) , find_value_for_constant ( n ) ) } end end @value end | When requesting a step tranformer object value process it if it hasn t alredy been processed replacing any constants that may be lurking within the value . |
8,839 | def constants_from_value ( data = @value ) data . scan ( escape_pattern ) . flatten . collect { | value | value . strip } end | Look through the specified data for the escape pattern and return an array of those constants found . This defaults to the |
8,840 | def find_value_for_constant ( name ) constant = YARD :: Registry . all ( :constant ) . find { | c | c . name == name . to_sym } log . warn "StepTransformer#find_value_for_constant : Could not find the CONSTANT [#{name}] using the string value." unless constant constant ? strip_regex_from ( constant . value ) : name end | Looking through all the constants in the registry and returning the value with the regex items replaced from the constnat if present |
8,841 | def parse begin @parser . parse ( @source ) @feature = @builder . ast return nil if @feature . nil? rescue Gherkin :: ParserError => e e . message . insert ( 0 , "#{@file}: " ) warn e end self end | Each found feature found is creates a new FeatureParser |
8,842 | def has json_path , json = nil if json . nil? json = JSON . parse body end not JsonPath . new ( json_path ) . on ( json ) . empty? end | Check if given JSON path exists |
8,843 | def get json_path , json = nil if json . nil? json = JSON . parse body end results = JsonPath . new ( json_path ) . on ( json ) if results . empty? raise %/Expected json path '#{json_path}' not found\n#{to_json_s}/ end results . first end | Retrieve value of the first JSON element with given JSON path |
8,844 | def get_as_type json_path , type , json = nil value = get json_path , json case type when 'numeric' valid = value . is_a? Numeric when 'array' valid = value . is_a? Array when 'string' valid = value . is_a? String when 'boolean' valid = ! ! value == value when 'numeric_string' valid = value . is_a? ( Numeric ) or value... | Retrieve value of the first JSON element with given JSON path as given type |
8,845 | def get_as_type_or_null json_path , type , json = nil value = get json_path , json value . nil? ? value : get_as_type ( json_path , type , json ) end | Retrieve value of the first JSON element with given JSON path as given type with nil value allowed |
8,846 | def get_as_type_and_check_value json_path , type , value , json = nil v = get_as_type json_path , type , json if value != v . to_s raise %/Expect '#{json_path}' to be '#{value}' but was '#{v}'\n#{to_json_s}/ end end | Retrieve value of the first JSON element with given JSON path as given type and check for a given value |
8,847 | def authorized! ( rack_env , allowed_by ) Env . new ( rack_env ) . tap do | env | env . authorize ( allowed_by ) end . to_rack end | Mark a request as externally authorized . Causes ACL checks to be skipped . |
8,848 | def set_allowed_by ( rack_env , allowed_by ) Env . new ( rack_env ) . tap do | env | env . allowed_by = allowed_by end . to_rack end | Mark what authorized the request in the Rack environment |
8,849 | def add_credential ( rack_env , type , credential ) Env . new ( rack_env ) . tap do | env | env . credentials [ type ] = credential end . to_rack end | Add a credential to the Rack environment |
8,850 | def write_db new_db = { } @db . keys . sort . each do | key | new_db [ key ] = { } Braid :: Mirror :: ATTRIBUTES . each do | k | new_db [ key ] [ k ] = @db [ key ] [ k ] if @db [ key ] . has_key? ( k ) end end new_data = { 'config_version' => CURRENT_CONFIG_VERSION , 'mirrors' => new_db } File . open ( @config_file , '... | Public for upgrade - config command only . |
8,851 | def memory ( quiet : false ) raise ConfigurationError unless block_given? job = Job . new ( quiet : quiet ) yield job job . run job . run_comparison job . full_report end | Measure memory usage in report blocks . |
8,852 | def populate ( amount , options = { } , & block ) self . class . remember_depth do build_records ( Populator . interpret_value ( amount ) , options [ :per_query ] || DEFAULT_RECORDS_PER_QUERY , & block ) end end | Use for_model instead of instatiating a record directly . Entry method for building records . Delegates to build_records after remember_depth . |
8,853 | def save_records unless @records . empty? @model_class . connection . populate ( @model_class . quoted_table_name , columns_sql , rows_sql_arr , "#{@model_class.name} Populate" ) @last_id_in_database = @records . last . id @records . clear end end | Saves the records to the database by calling populate on the current database adapter . |
8,854 | def populate ( amount , options = { } , & block ) Factory . for_model ( self ) . populate ( amount , options , & block ) end | Call populate on any ActiveRecord model to fill it with data . Pass the number of records you want to create and a block to set the attributes . You can nest calls to handle associations and use ranges or arrays to randomize the values . |
8,855 | def value_in_range ( range ) case range . first when Integer then number_in_range ( range ) when Time then time_in_range ( range ) when Date then date_in_range ( range ) else range . to_a [ rand ( range . to_a . size ) ] end end | Pick a random value out of a given range . |
8,856 | def scan ( options = { } , exec_options = { } , & block ) run_task ( Task . new ( options , & block ) , exec_options ) end | Performs a scan . |
8,857 | def sudo_scan ( options = { } , exec_options = { } , & block ) sudo_task ( Task . new ( options , & block ) , exec_options ) end | Performs a scan and runs nmap under sudo . |
8,858 | def scanner @scanner ||= Scanner . new ( @doc . root [ 'scanner' ] , @doc . root [ 'version' ] , @doc . root [ 'args' ] , Time . at ( @doc . root [ 'start' ] . to_i ) ) end | Parses the scanner information . |
8,859 | def scan_info @doc . xpath ( '/nmaprun/scaninfo' ) . map do | scaninfo | Scan . new ( scaninfo [ 'type' ] . to_sym , scaninfo [ 'protocol' ] . to_sym , scaninfo [ 'services' ] . split ( ',' ) . map { | ports | if ports . include? ( '-' ) Range . new ( * ( ports . split ( '-' , 2 ) ) ) else ports . to_i end } ) end end | Parses the scan information . |
8,860 | def each_run_stat return enum_for ( __method__ ) unless block_given? @doc . xpath ( '/nmaprun/runstats/finished' ) . each do | run_stat | yield RunStat . new ( Time . at ( run_stat [ 'time' ] . to_i ) , run_stat [ 'elapsed' ] , run_stat [ 'summary' ] , run_stat [ 'exit' ] ) end return self end | Parses the essential runstats information . |
8,861 | def each_task return enum_for ( __method__ ) unless block_given? @doc . xpath ( '/nmaprun/taskbegin' ) . each do | task_begin | task_end = task_begin . xpath ( 'following-sibling::taskend' ) . first yield ScanTask . new ( task_begin [ 'task' ] , Time . at ( task_begin [ 'time' ] . to_i ) , Time . at ( task_end [ 'time'... | Parses the tasks of the scan . |
8,862 | def each_up_host return enum_for ( __method__ ) unless block_given? @doc . xpath ( "/nmaprun/host[status[@state='up']]" ) . each do | host | yield Host . new ( host ) end return self end | Parses the hosts that were found to be up during the scan . |
8,863 | def each_address return enum_for ( __method__ ) unless block_given? @node . xpath ( "address[@addr]" ) . each do | addr | address = Address . new ( addr [ 'addrtype' ] . to_sym , addr [ 'addr' ] , addr [ 'vendor' ] ) yield address end return self end | Parses each address of the host . |
8,864 | def each_hostname return enum_for ( __method__ ) unless block_given? @node . xpath ( "hostnames/hostname[@name]" ) . each do | host | yield Hostname . new ( host [ 'type' ] , host [ 'name' ] ) end return self end | Parses the hostnames of the host . |
8,865 | def uptime @uptime ||= if ( uptime = @node . at_xpath ( 'uptime' ) ) Uptime . new ( uptime [ 'seconds' ] . to_i , Time . parse ( uptime [ 'lastboot' ] ) ) end yield @uptime if ( @uptime && block_given? ) return @uptime end | Parses the Uptime analysis of the host . |
8,866 | def each_tcp_port return enum_for ( __method__ ) unless block_given? @node . xpath ( "ports/port[@protocol='tcp']" ) . each do | port | yield Port . new ( port ) end return self end | Parses the TCP ports of the host . |
8,867 | def script_data unless @script_data @script_data = { } traverse = lambda do | node | case node . name when 'script' , 'table' unless node . xpath ( '*[@key]' ) . empty? hash = { } node . elements . each do | element | hash [ element [ 'key' ] ] = traverse . call ( element ) end hash else array = [ ] node . elements . e... | The structured output of the NSE scripts . |
8,868 | def each return enum_for ( __method__ ) unless block_given? @node . xpath ( 'hop' ) . each do | hop | yield Hop . new ( hop [ 'ipaddr' ] , hop [ 'host' ] , hop [ 'ttl' ] , hop [ 'rtt' ] ) end return self end | Parses the traceroute information for the host . |
8,869 | def each_class return enum_for ( __method__ ) unless block_given? @node . xpath ( "osmatch/osclass" ) . each do | osclass | yield OSClass . new ( osclass ) end return self end | Creates a new OS object . |
8,870 | def each_match return enum_for ( __method__ ) unless block_given? @node . xpath ( "osmatch" ) . map do | osclass | os_match = OSMatch . new ( osclass [ 'name' ] , osclass [ 'accuracy' ] . to_i ) yield os_match end return self end | Parses the OS match information . |
8,871 | def retrogress_bbtree if @tags_list [ - 1 ] . definition [ :self_closable ] @tags_list [ - 1 ] [ :nodes ] [ 0 ] [ :text ] . chomp! unless @tags_list [ - 1 ] [ :nodes ] [ 0 ] [ :text ] . nil? @tags_list [ - 2 ] [ :nodes ] [ 0 ] [ :text ] . chomp! unless @tags_list . length < 2 or @tags_list [ - 2 ] [ :nodes ] [ 0 ] [ :t... | Step down the bbtree a notch because we ve reached a closing tag |
8,872 | def get_formatted_between between = @ti [ :text ] between = match_url_id ( between , @bbtree . current_node . definition [ :url_matches ] ) if @bbtree . current_node . definition [ :url_matches ] return between end | Get between tag for tag |
8,873 | def up ( * services , abort_on_container_exit : false , detached : false , timeout : 10 , build : false , exit_code_from : nil , no_build : false , no_deps : false , no_start : false ) o = opts ( abort_on_container_exit : [ abort_on_container_exit , false ] , d : [ detached , false ] , timeout : [ timeout , 10 ] , buil... | Idempotently up the given services in the project . |
8,874 | def scale ( container_count , timeout : 10 ) args = container_count . map { | service , count | "#{service}=#{count}" } o = opts ( timeout : [ timeout , 10 ] ) run! ( 'scale' , o , * args ) end | Idempotently scales the number of containers for given services in the project . |
8,875 | def run ( service , * cmd , detached : false , no_deps : false , volumes : [ ] , env : [ ] , rm : false , no_tty : false , user : nil , service_ports : false ) o = opts ( d : [ detached , false ] , no_deps : [ no_deps , false ] , rm : [ rm , false ] , T : [ no_tty , false ] , u : [ user , nil ] , service_ports : [ serv... | Idempotently run an arbitrary command with a service container . |
8,876 | def stop ( * services , timeout : 10 ) o = opts ( timeout : [ timeout , 10 ] ) run! ( 'stop' , o , services ) end | Stop running services . |
8,877 | def kill ( * services , signal : 'KILL' ) o = opts ( signal : [ signal , 'KILL' ] ) run! ( 'kill' , o , services ) end | Forcibly stop running services . |
8,878 | def version ( short : false ) o = opts ( short : [ short , false ] ) result = run! ( 'version' , o , file : false , dir : false ) if short result . strip else lines = result . split ( / \r \n / ) lines . inject ( { } ) do | h , line | kv = line . split ( / / , 2 ) h [ kv . first ] = kv . last h end end end | Determine the installed version of docker - compose . |
8,879 | def run! ( * args ) file_args = case @file when 'docker-compose.yml' [ ] when Array file_args = @file . map { | filepath | { :file => filepath } } else [ { file : @file . to_s } ] end @shell . chdir = dir @last_command = @shell . run ( 'docker-compose' , * file_args , * args ) . join status = @last_command . status out... | Run a docker - compose command without validating that the CLI parameters make sense . Prepend project and file options if suitable . |
8,880 | def parse ( str ) fields = [ ] nest = 0 field = '' str . each_char do | ch | got = false if nest == 0 if ch == '(' nest += 1 end else if ch == '(' nest += 1 field << ch elsif ch == ')' nest -= 1 if nest == 0 got = true else field << ch end else field << ch end end if got fields << field field = '' end end fields end | Parse a string that consists of a sequence of values enclosed within parentheses . Ignore any bytes that are outside of parentheses . Values may include nested parentheses . |
8,881 | def export_env ( print : ) Docker :: Compose :: Mapper . map ( host_env , session : @session , net_info : @net_info ) do | k , v | ENV [ k ] = serialize_for_env ( v ) print_env ( k , ENV [ k ] ) if print end extra_host_env . each do | k , v | ENV [ k ] = serialize_for_env ( v ) print_env ( k , ENV [ k ] ) if print end ... | Substitute and set environment variables that point to network ports published by docker - compose services . Optionally also print bash export statements so this information can be made available to a user s shell . |
8,882 | def serialize_for_env ( v ) case v when String v when NilClass nil when Array JSON . dump ( v ) else fail ArgumentError , "Can't represent a #{v.class} in the environment" end end | Transform a Ruby value into a String that can be stored in the environment . This accepts nil String or Array and returns nil String or JSON - serialized Array . |
8,883 | def print_env ( k , v ) if v puts @shell_printer . export ( k , v ) else puts @shell_printer . unset ( k ) end end | Print an export or unset statement suitable for user s shell |
8,884 | def docker_routable_ip case @docker_url . scheme when 'tcp' , 'http' , 'https' docker_dns = @docker_url . host docker_port = @docker_url . port || 2376 else docker_dns = 'localhost' docker_port = 2376 end addr = Addrinfo . getaddrinfo ( docker_dns , docker_port , Socket :: AF_INET , Socket :: SOCK_STREAM ) . first addr... | Figure out the likely IP address of the host pointed to by self . docker_url . |
8,885 | def map ( value ) if value . respond_to? ( :map ) value . map { | e | map_scalar ( e ) } else map_scalar ( value ) end end | Create an instance of Mapper |
8,886 | def map_scalar ( value ) uri = begin URI . parse ( value ) rescue nil end pair = value . split ( ':' ) if uri && uri . scheme && uri . host uri . host , uri . port = host_and_port ( uri . host , uri . port ) return uri . to_s elsif pair . size == 2 if pair . first =~ ELIDED service = pair . first . gsub ( REMOVE_ELIDED... | Map a single string replacing service names with IPs and container ports with the host ports that they have been mapped to . |
8,887 | def birthday? ( date = Date . today ) return false unless have_birthday? month , day = birthday . split ( "/" ) birthday_date = Date . new ( date . year , month . to_i , day . to_i ) birthday_date == date end | Whether date is her birthday |
8,888 | def all_stars ( arg = Time . current ) extra_girls = [ ] date = to_date ( arg ) if date last_all_stars_date = Rubicure :: Movie . find ( :stmm ) . started_date if date > last_all_stars_date date = last_all_stars_date end else movie = Rubicure :: Movie . find ( arg . to_sym ) date = movie . started_date if movie . has_k... | Get precure all stars |
8,889 | def all_girls ( arg = Time . current ) date = to_date ( arg ) unless @all_girls @all_girls = [ ] Rubicure :: Girl . names . each do | girl_name | @all_girls << Rubicure :: Girl . find ( girl_name ) end @all_girls . uniq! ( & :human_name ) end @all_girls . select { | girl | girl . created_date && girl . created_date <= ... | Get all precures |
8,890 | def dream_stars return @dream_stars if @dream_stars girls = Precure . go_princess . girls + Precure . maho_girls . girls + Precure . a_la_mode . girls dream_stars_date = Rubicure :: Movie . find ( :dream_stars ) . started_date @dream_stars = girls . select { | girl | girl . created_date && girl . created_date <= dream_... | Get precure dream stars |
8,891 | def super_stars return @super_stars if @super_stars girls = Precure . maho_girls . girls + Precure . a_la_mode . girls + Precure . hugtto . girls super_stars_date = Rubicure :: Movie . find ( :super_stars ) . started_date @super_stars = girls . select { | girl | girl . created_date && girl . created_date <= super_stars... | Get precure super stars |
8,892 | def set_column_comment ( table_name , column_name , comment_text ) execute comment_sql ( CommentDefinition . new ( table_name , column_name , comment_text ) ) end | Set a comment on a column |
8,893 | def imply_dates return unless ! @properties [ 'end' ] . nil? && ! @properties [ 'start' ] . nil? start_date = nil @properties [ 'start' ] . each do | start_val | if start_val =~ / \d \d \d / start_date = Regexp . last_match ( 1 ) if start_date . nil? elsif start_val =~ / \d \d \d / start_date = Regexp . last_match ( 1 ... | imply date for dt - end if dt - start is defined with a date |
8,894 | def get_sentences ( n ) sentences = [ ] n . times do sentence = @dict . get_start_words while nw = @dict . get ( sentence [ - @dict . order , @dict . order ] ) sentence << nw end sentences << ( sentence [ 0 ... - 1 ] . join ( " " ) . gsub ( / \s / , '\1' ) << sentence . last ) end sentences end | Initializes the generator |
8,895 | def parents @parents ||= Array ( nesting ) . map do | p | if p . is_a? ( Class ) && p < ActiveRecord :: Base parent_entry ( p ) else p end end end | Returns the parent entries of the current request if any . These are ActiveRecords or namespace symbols corresponding to the defined nesting attribute . |
8,896 | def headers super . merge ( { size : @raw . length , summary : @message . summary . force_encoding ( 'UTF-8' ) . scrub , message_class : @message_class . to_s , } ) end | The next two methods are the last stop before JSON encoding so all strings in the returned hash must be UTF - 8 compatible . |
8,897 | def parse ( raw_buffer , peer ) start_pos = nil loop do break if raw_buffer . eof? start_pos = raw_buffer . pos log . debug "at #{start_pos} of #{raw_buffer.length} in buffer" read_fn = lambda { message_class . new ( src : peer . to_s , protocol_state : @protocol_state ) . read ( raw_buffer ) } message = if log . debug... | Try to parse one or more messages from the buffer and yield them |
8,898 | def connect ( host = nil , port = nil , & cb ) host ||= opts [ :upstream_host ] || raise ( 'no upstream host' ) port ||= opts [ :upstream_port ] || raise ( 'no upstream port' ) cb ||= lambda { | conn | opts [ :session_callback ] . call ( self , conn ) } log . debug "Making upstream connection to #{host}:#{port}" EM . c... | Used by filters to initiate upstream connection in response to inbound connection |
8,899 | def send_message ( pm ) log . error "OOPS! message going the wrong way (to #{peer})" if pm . dest != peer data = pm . to_binary_s @filters . each do | f | data = f . write data return if data . nil? or data == '' end send_data ( data ) end | called with a ProxyMessage |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.