idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
11,700 | def loop before_loop set_trap start in_loop stop self rescue Exception => e Rib . warn ( "Error while running loop:\n #{format_error(e)}" ) raise ensure release_trap after_loop end | Create a new shell . |
11,701 | def one_screen? str cols , lines = ` ` . to_i , ` ` . to_i ( str . count ( "\n" ) + 2 ) <= lines && str . gsub ( / \e \[ / , '' ) . size <= cols * lines end | less - F can t cat the output so we need to detect by ourselves . less - X would mess up the buffers so it s not desired either . |
11,702 | def daemonize! if JRUBY thread = Thread . new { daemon_execute } thread . join elsif RUBY_VERSION < "1.9" logger . debug "Parent Process: #{Process.pid}" exit! ( 0 ) if fork logger . debug "Child Process: #{Process.pid}" daemon_execute else Process . daemon ( true , true ) daemon_execute end end | Adapted from Rackup |
11,703 | def load_config_file ( config_path ) abort "Can not find config file at #{config_path}" if ! File . readable? ( config_path ) config = File . read ( config_path ) config . sub! ( / \n / , '' ) @app . module_eval ( config ) end | Loads a config file at config_path and evals it in the context of the |
11,704 | def output_grammar ( code ) code << " # :stopdoc:\n" handle_ast ( code ) fg = @grammar . foreign_grammars if fg . empty? if @standalone code << " def setup_foreign_grammar; end\n" end else code << " def setup_foreign_grammar\n" @grammar . foreign_grammars . each do | name , gram | code << " @_grammar_#{name} = #{... | Output of grammar and rules |
11,705 | def output_header ( code ) if header = @grammar . directives [ 'header' ] code << header . action . strip code << "\n" end pre_class = @grammar . directives [ 'pre-class' ] if @standalone if pre_class code << pre_class . action . strip code << "\n" end code << "class #{@name}\n" cp = standalone_region ( "compiled_parse... | Output up to the user - defined setup actions |
11,706 | def create_transaction ( budget_id , data , opts = { } ) data , _status_code , _headers = create_transaction_with_http_info ( budget_id , data , opts ) data end | Create a single transaction or multiple transactions Creates a single transaction or multiple transactions . If you provide a body containing a transaction object a single transaction will be created and if you provide a body containing a transactions array multiple transactions will be created . |
11,707 | def get_transaction_by_id ( budget_id , transaction_id , opts = { } ) data , _status_code , _headers = get_transaction_by_id_with_http_info ( budget_id , transaction_id , opts ) data end | Single transaction Returns a single transaction |
11,708 | def get_transactions ( budget_id , opts = { } ) data , _status_code , _headers = get_transactions_with_http_info ( budget_id , opts ) data end | List transactions Returns budget transactions |
11,709 | def get_transactions_by_account ( budget_id , account_id , opts = { } ) data , _status_code , _headers = get_transactions_by_account_with_http_info ( budget_id , account_id , opts ) data end | List account transactions Returns all transactions for a specified account |
11,710 | def get_transactions_by_category ( budget_id , category_id , opts = { } ) data , _status_code , _headers = get_transactions_by_category_with_http_info ( budget_id , category_id , opts ) data end | List category transactions Returns all transactions for a specified category |
11,711 | def get_transactions_by_payee ( budget_id , payee_id , opts = { } ) data , _status_code , _headers = get_transactions_by_payee_with_http_info ( budget_id , payee_id , opts ) data end | List payee transactions Returns all transactions for a specified payee |
11,712 | def update_transaction ( budget_id , transaction_id , data , opts = { } ) data , _status_code , _headers = update_transaction_with_http_info ( budget_id , transaction_id , data , opts ) data end | Updates an existing transaction Updates a transaction |
11,713 | def update_transactions ( budget_id , data , opts = { } ) data , _status_code , _headers = update_transactions_with_http_info ( budget_id , data , opts ) data end | Update multiple transactions Updates multiple transactions by id or import_id . |
11,714 | def get_account_by_id ( budget_id , account_id , opts = { } ) data , _status_code , _headers = get_account_by_id_with_http_info ( budget_id , account_id , opts ) data end | Single account Returns a single account |
11,715 | def get_accounts ( budget_id , opts = { } ) data , _status_code , _headers = get_accounts_with_http_info ( budget_id , opts ) data end | Account list Returns all accounts |
11,716 | def get_budget_month ( budget_id , month , opts = { } ) data , _status_code , _headers = get_budget_month_with_http_info ( budget_id , month , opts ) data end | Single budget month Returns a single budget month |
11,717 | def get_budget_months ( budget_id , opts = { } ) data , _status_code , _headers = get_budget_months_with_http_info ( budget_id , opts ) data end | List budget months Returns all budget months |
11,718 | def to_s s = '' TAGS . each do | t | tag = instance_variable_get ( "@#{t}" ) s << "[#{t.capitalize} \"#{tag}\"]\n" end s << "\n" m = '' @moves . each_with_index do | move , i | m << "#{i/2+1}. " if i % 2 == 0 m << "#{move} " end m << @result unless @result . nil? s << m . gsub ( / \n / , "\\1\\2\n" ) end | PGN to string . |
11,719 | def pgn pgn = Chess :: Pgn . new pgn . moves = self . moves pgn . result = self . result return pgn end | Returns the PGN rappresenting the game . |
11,720 | def get_payee_location_by_id ( budget_id , payee_location_id , opts = { } ) data , _status_code , _headers = get_payee_location_by_id_with_http_info ( budget_id , payee_location_id , opts ) data end | Single payee location Returns a single payee location |
11,721 | def get_payee_locations ( budget_id , opts = { } ) data , _status_code , _headers = get_payee_locations_with_http_info ( budget_id , opts ) data end | List payee locations Returns all payee locations |
11,722 | def get_payee_locations_by_payee ( budget_id , payee_id , opts = { } ) data , _status_code , _headers = get_payee_locations_by_payee_with_http_info ( budget_id , payee_id , opts ) data end | List locations for a payee Returns all payee locations for the specified payee |
11,723 | def update_month_category ( budget_id , month , category_id , data , opts = { } ) data , _status_code , _headers = update_month_category_with_http_info ( budget_id , month , category_id , data , opts ) data end | Update a category for a specific month Update a category for a specific month |
11,724 | def get_budget_by_id ( budget_id , opts = { } ) data , _status_code , _headers = get_budget_by_id_with_http_info ( budget_id , opts ) data end | Single budget Returns a single budget with all related entities . This resource is effectively a full budget export . |
11,725 | def get_budget_settings_by_id ( budget_id , opts = { } ) data , _status_code , _headers = get_budget_settings_by_id_with_http_info ( budget_id , opts ) data end | Budget Settings Returns settings for a budget |
11,726 | def get_scheduled_transaction_by_id ( budget_id , scheduled_transaction_id , opts = { } ) data , _status_code , _headers = get_scheduled_transaction_by_id_with_http_info ( budget_id , scheduled_transaction_id , opts ) data end | Single scheduled transaction Returns a single scheduled transaction |
11,727 | def get_scheduled_transactions ( budget_id , opts = { } ) data , _status_code , _headers = get_scheduled_transactions_with_http_info ( budget_id , opts ) data end | List scheduled transactions Returns all scheduled transactions |
11,728 | def gnuchess_move pipe = IO . popen ( 'gnuchess -x' , 'r+' ) begin pipe . puts ( 'depth 1' ) pipe . puts ( 'manual' ) self . coord_moves . each do | m | pipe . puts ( m ) end pipe . puts ( 'go' ) while line = pipe . gets raise IllegalMoveError if line . include? ( 'Invalid move' ) match = line . match ( / / ) return ma... | Returns the next move calculated by Gnuchess . |
11,729 | def get_payee_by_id ( budget_id , payee_id , opts = { } ) data , _status_code , _headers = get_payee_by_id_with_http_info ( budget_id , payee_id , opts ) data end | Single payee Returns single payee |
11,730 | def get_payees ( budget_id , opts = { } ) data , _status_code , _headers = get_payees_with_http_info ( budget_id , opts ) data end | List payees Returns all payees |
11,731 | def links @links ||= @schema . links . map do | link | if link . method && link . href Link . new ( link ) end end . compact end | Defined to change uniqueness in Hash key Defined to change uniqueness in Hash key |
11,732 | def hash_default ( _ , key ) if @default != nil value = @default . respond_to? ( :call ) ? @default . call ( key ) : @default @journal << [ key , value ] @table [ key ] = value end end | The block used in |
11,733 | def clear flush with_tmpfile do | path , file | file . write ( @format . header ) file . close with_flock ( File :: LOCK_EX ) do File . rename ( path , @file ) end end open end | Clear the database log and yield |
11,734 | def compact load with_tmpfile do | path , file | return self if @pos == file . write ( dump ( yield , @format . header ) ) with_flock ( File :: LOCK_EX ) do if @pos != nil file . write ( read ) file . close File . rename ( path , @file ) end end end open replay end | Compact the logfile to represent the in - memory state |
11,735 | def open @fd . close if @fd @fd = File . open ( @file , 'ab+' ) @fd . advise ( :sequential ) if @fd . respond_to? :advise stat = @fd . stat @inode = stat . ino write ( @format . header ) if stat . size == 0 @pos = nil end | Open or reopen file |
11,736 | def read with_flock ( File :: LOCK_SH ) do unless @pos @fd . pos = 0 @format . read_header ( @fd ) @size = 0 @emit . call ( nil ) else @fd . pos = @pos end buf = @fd . read @pos = @fd . pos buf end end | Read new file content |
11,737 | def dump ( records , dump = '' ) records . each do | record | record [ 1 ] = @serializer . dump ( record . last ) dump << @format . dump ( record ) end dump end | Return database dump as string |
11,738 | def write ( dump ) with_flock ( File :: LOCK_EX ) do @fd . write ( dump ) @fd . flush end @pos = @fd . pos if @pos && @fd . pos == @pos + dump . bytesize end | Write data to output stream and advance |
11,739 | def with_flock ( mode ) return yield if @locked begin loop do Thread . pass until @fd . flock ( mode ) stat = @fd . stat break if stat . nlink > 0 && stat . ino == @inode open end @locked = true yield ensure @fd . flock ( File :: LOCK_UN ) @locked = false end end | Block with file lock |
11,740 | def with_tmpfile path = [ @file , $$ . to_s ( 36 ) , Thread . current . object_id . to_s ( 36 ) ] . join file = File . open ( path , 'wb' ) yield ( path , file ) ensure file . close unless file . closed? File . unlink ( path ) if File . exists? ( path ) end | Open temporary file and pass it to the block |
11,741 | def read_header ( input ) raise 'Not a Daybreak database' if input . read ( MAGIC . bytesize ) != MAGIC ver = input . read ( 2 ) . unpack ( 'n' ) . first raise "Expected database version #{VERSION}, got #{ver}" if ver != VERSION end | Read database header from input stream |
11,742 | def dump ( record ) data = if record . size == 1 [ record [ 0 ] . bytesize , DELETE ] . pack ( 'NN' ) << record [ 0 ] else [ record [ 0 ] . bytesize , record [ 1 ] . bytesize ] . pack ( 'NN' ) << record [ 0 ] << record [ 1 ] end data << crc32 ( data ) end | Serialize record and return string |
11,743 | def parse ( buf ) n , count = 0 , 0 while n < buf . size key_size , value_size = buf [ n , 8 ] . unpack ( 'NN' ) data_size = key_size + 8 data_size += value_size if value_size != DELETE data = buf [ n , data_size ] n += data_size raise 'CRC mismatch: your data might be corrupted!' unless buf [ n , 4 ] == crc32 ( data )... | Deserialize records from buffer and yield them . |
11,744 | def query_string params = { } self . query_params . each do | param | params [ param . name ] = param . value end return :: URI :: QueryParams . dump ( params ) end | Dumps the URL query params into a URI query string . |
11,745 | def query_string = ( query ) self . query_params . clear :: URI :: QueryParams . parse ( query ) . each do | name , value | self . query_params . new ( :name => URLQueryParamName . first_or_new ( :name => name ) , :value => value ) end return query end | Sets the query params of the URL . |
11,746 | def to_uri url_class = SCHEMES . fetch ( self . scheme . name , :: URI :: Generic ) host = if self . host_name self . host_name . address end port = if self . port self . port . number end query = unless self . query_params . empty? self . query_string end return url_class . build ( :scheme => self . scheme . name , :h... | Builds a URI object from the URL . |
11,747 | def lookup! ( nameserver = nil ) resolver = Resolv . resolver ( nameserver ) ips = begin resolver . getaddresses ( self . address ) rescue [ ] end ips . map! do | addr | IPAddress . first_or_create ( :address => addr , :host_names => [ self ] ) end return ips end | Looks up all IP Addresses for the host name . |
11,748 | def target! ( addr ) unless ( address = Address . first ( :address => addr ) ) raise ( "unknown address #{addr.dump}" ) end return Target . first_or_create ( :campaign => self , :address => address ) end | Adds an address to the campaign . |
11,749 | def lookup! ( nameserver = nil ) resolver = Resolv . resolver ( nameserver ) hosts = begin resolver . getnames ( self . address . to_s ) rescue [ ] end hosts . map! do | name | HostName . first_or_create ( :address => name , :ip_addresses => [ self ] ) end return hosts end | Performs a reverse lookup on the IP address . |
11,750 | def find_script ( sub_path ) paths = @script_dirs . map { | dir | File . join ( dir , sub_path ) } return script_paths . first ( :path => paths ) end | Finds a cached script . |
11,751 | def update! local_repo = Pullr :: LocalRepository . new ( :path => self . path , :scm => self . scm ) local_repo . update ( self . uri ) initialize_metadata if save sync_scripts! end yield self if block_given? return self end | Updates the repository reloads it s metadata and syncs the cached files of the repository . |
11,752 | def uninstall! deactivate! FileUtils . rm_rf ( self . path ) if self . installed? clean_scripts! destroy if saved? yield self if block_given? return self end | Deletes the contents of the repository . |
11,753 | def digest ( algorithm , options = { } ) digest_class = begin Digest . const_get ( algorithm . to_s . upcase ) rescue LoadError raise ( ArgumentError , "Unknown Digest algorithm #{algorithm}" ) end hash = digest_class . new if options [ :prepend_salt ] hash << options [ :prepend_salt ] . to_s end hash << self . clear_t... | Hashes the password . |
11,754 | def to_i self . address . split ( ':' ) . inject ( 0 ) do | bits , char | bits = ( ( bits << 8 ) | char . hex ) end end | Converts the MAC address to an Integer . |
11,755 | def start ( paths , params = { } ) @registry = [ ] paths . each do | path | if path [ - 1 ] == '/' path . chop! end Dir [ "#{path}/*.rb" ] . each do | f | require File . expand_path ( f ) begin instance = Object . const_get ( File . basename ( f , '.rb' ) ) . new if instance . respond_to? ( :before ) instance . send ( ... | Assign a path where plugins should be loaded from |
11,756 | def on ( method , * args , & block ) if [ :initialize , :before , :setup , :after ] . include? method raise "#{method} should not be called directly" end buffer = [ ] threads = [ ] @registry . each do | s | if s . respond_to? ( method . to_sym , false ) threads << Thread . new do responder = DispatchResponder . new ( s... | Initialize the dispatcher instance with a default timeout of 5s |
11,757 | def message_to_slack ( channel : , options : { } ) @caller_method_name = caller [ 0 ] [ / / , 1 ] options = apply_defaults ( options ) message = nil ActiveSupport :: Notifications . instrument ( 'message_to_slack.action_messenger' , channel : channel , body : options [ :text ] ) do message = slack_client . message ( ch... | message to slack |
11,758 | def upload_file_to_slack ( channels : , file : , options : { } ) upload_file = nil ActiveSupport :: Notifications . instrument ( 'upload_file_to_slack.action_messenger' , channels : channels ) do upload_file = slack_client . upload_file ( channels , file , options ) end upload_file ensure self . deliveries << DeliveryL... | upload file to slack |
11,759 | def extract_multiple ( record , field , tag ) a = Array . new record . fields ( field ) . each do | field | a . push field [ tag ] end return a end | Extract Multiple fields for record |
11,760 | def perform body = perform_action parser = parser_class . new ( body ) Conduit :: ApiResponse . new ( raw_response : @raw_response , body : body , parser : parser ) rescue Braintree :: NotFoundError => error report_braintree_exceptions ( error ) rescue ArgumentError => error respond_with_error ( error . message ) rescu... | Performs the request with mocking if requested |
11,761 | def defaults @__defaults = Settingson :: Store :: Default . new ( klass : self ) if block_given? Rails . application . config . after_initialize do yield @__defaults end end @__defaults end | Settings . defaults do |default| default . server . host = host default . server . port = 80 end |
11,762 | def attribute_transitioning? ( attr , options = { } ) options = _transform_options_for_attribute ( attr , options ) attribute_changed? ( attr , options ) end | Returns + true + if + attribute + is currently transitioning but not saved otherwise + false + . |
11,763 | def deliver_now! messenger . handle_exceptions do ActiveSupport :: Notifications . instrument ( 'deliver_now!.action_messenger' , method_name : method_name , args : args ) do if args . present? messenger . public_send ( method_name , * args ) else messenger . public_send ( method_name ) end end end end | send a message now |
11,764 | def deliver_later! ActionMessenger :: MessageDeliveryJob . perform_later ( self . class . name , 'deliver_now!' , messenger_class . to_s , method_name . to_s , * args ) end | send a message asynchronously |
11,765 | def map_functions ( stub_services ) return @function_map unless @function_map . empty? stub_services . keys . each do | service_name | stub = @services [ service_name ] = stub_services [ service_name ] stub . class . to_s . gsub ( '::Stub' , '::Service' ) . constantize . rpc_descs . values . each do | d | next if d . n... | Add to the function_map by inspecting each service for the RPCs it provides . |
11,766 | def arg ( params ) rpc_desc . input . decode_json ( params . reject { | k , _v | k == :selections } . to_json ) end | Build arguments to a func |
11,767 | def whitelist_options @options [ :options ] ||= { } . tap do | h | h [ :verify_card ] = @options . fetch ( :verify_card , true ) @options . delete ( :verify_card ) if @options . key? ( :verification_merchant_account_id ) h [ :verification_merchant_account_id ] = @options . delete ( :verification_merchant_account_id ) e... | Request verification when the card is stored using the merchant account id if one is provided |
11,768 | def add_term ( term , taxonomy , description , count ) if term . respond_to? ( :term_id ) term_id = term . term_id else term_id = term . to_i end term_taxonomy = WPDB :: TermTaxonomy . where ( term_id : term_id , taxonomy : taxonomy ) . first unless term_taxonomy term_taxonomy = WPDB :: TermTaxonomy . create ( term_id ... | For objects that have a relationship with termtaxonomies this module can be mixed in and gives the ability to add a term directly to the model rather than creating the relationship yourself . Used by Post and Link . |
11,769 | def find ( id ) raise ArgumentError . new ( "Missing id/slug" ) unless id result = access_token . get ( "#{API_BASE}#{self.class::API_PATH}#{id}" ) raise ServiceError . new ( result . code , result . body ) unless result . code == "200" self . class :: ITEM_CLASS . new ( result . body ) end | Find an item based on it s id . |
11,770 | def lock retries . times do atomically ( timeout ) do uid = available_uid if uid lock_uid uid return uid . to_i end end sleep ( delay ) end raise PoolTimeoutError . new ( 'No available UIDs in the pool. Please try again later.' ) end | Locks one UID from the pool in a cross - process atomic manner |
11,771 | def parse! unless File . exists? output_file_path @status = 'error' @error = ContainerError . new ( 'User code did not finish properly' ) @error_to_raise = @error return end begin data = File . binread output_file_path @raw_response = Marshal . load ( data ) rescue => e @status = 'error' @error = e @error_to_raise = Co... | Parses the output file and stores the values in the appropriate ivars |
11,772 | def find_repo ( name ) return @index . base_dirs . first unless name match = FuzzyMatch . new ( @index . to_a , :read => :name ) . find ( name ) match [ 1 ] unless match . nil? end | Fuzzy search for a git repository by name Returns the full path to the repository . |
11,773 | def status ( ) max_name = @index . map { | repo | repo . name . length } . max + 1 @index . each do | r | next unless Dir . exists? ( r . path ) status = repo_status ( r . path ) next if status . empty? name = format ( "%-#{max_name}s" , r . name ) . bold puts "#{name} > #{status}" end end | prints a status list showing repos with unpushed commits or uncommitted changes |
11,774 | def repo_status ( path ) messages = [ ] messages << EMPTY_MESSAGE if repo_empty? ( path ) messages << UNCOMMITTED_MESSAGE if commit_pending? ( path ) messages << UNTRACKED_MESSAGE if untracked_files? ( path ) messages << UNPUSHED_MESSAGE if repo_unpushed? ( path ) messages . join ( JOIN_STRING ) end | returns a short status message for the repo |
11,775 | def install_cd puts CD_INFO print "Continue with installation (yN)? " return unless gets . chomp . downcase == "y" print "Name of pro cd command (default 'pd'): " name = gets . strip name = 'pd' if name . empty? func = SHELL_FUNCTION . sub ( "{{name}}" , name ) did_any = false [ '~/.profile' , '~/.bashrc' , '~/.zshrc' ... | Adds a shell function to the shell config files that allows easy directory changing . |
11,776 | def read_cache return nil unless File . readable_real? ( CACHE_PATH ) index = YAML :: load_file ( CACHE_PATH ) return nil unless index . created_version == Pro :: VERSION return nil unless index . base_dirs == @base_dirs index end | unserializes the cache file and returns the index object |
11,777 | def run_index_process readme , writeme = IO . pipe p1 = fork { STDOUT . reopen ( writeme ) readme . close index_process unless File . exists? ( INDEXER_LOCK_PATH ) } Process . detach ( p1 ) end | spins off a background process to update the cache file |
11,778 | def cache_index ( index ) File . open ( CACHE_PATH , 'w' ) do | out | YAML :: dump ( index , out ) end end | serialize the index to a cache file |
11,779 | def index_repos_slow ( base ) STDERR . puts "WARNING: pro is indexing slowly, please install the 'find' command." repos = [ ] Find . find ( base ) do | path | target = path if FileTest . symlink? ( path ) next if File . dirname ( path ) != base target = File . readlink ( path ) end if FileTest . directory? ( target ) &... | recursive walk in ruby |
11,780 | def find_base_dirs ( ) bases = [ ] base = ENV [ 'PRO_BASE' ] bases << base if base path = ENV [ 'HOME' ] + "/.proBase" if File . exists? ( path ) bases += IO . read ( path ) . split ( "\n" ) . map { | p | File . expand_path ( p . strip ) } end bases = bases . select { | b | File . exists? ( b ) } bases << ENV [ 'HOME' ... | Finds the base directory where repos are kept Checks the environment variable PRO_BASE and the file . proBase |
11,781 | def artifact_sign @signature = 'unsigned' signature_cleanup Dir . chdir ( "#{$config['general']['app_cache']}/artifacts/" ) do unless system "gpg --use-agent --detach-sign artifact.#{@checksum}.tar.gz" $logger . error 'Unable to sign the artifact, an unexpected failure occured. No file uploaded.' return false end if Fi... | Sign the artifact and return the signature . Does not validation of the signature . |
11,782 | def signature_extract manifest = YAML . load ( File . open ( $config [ 'general' ] [ 'app_cache' ] + "/artifacts/manifest.#{@checksum}.yaml" ) , safe : true , raise_on_unknown_tag : true ) if manifest [ 'gpgsig' ] @signature = manifest [ 'gpgsig' ] File . write ( "#{$config['general']['app_cache']}/artifacts/artifact.#... | Extract the signature from the manifest file and write it to file in native binary format . |
11,783 | def signature_save manifest = YAML . load ( File . open ( $config [ 'general' ] [ 'app_cache' ] + "/artifacts/manifest.#{@checksum}.yaml" ) , safe : true , raise_on_unknown_tag : true ) manifest [ 'gpgsig' ] = @signature File . open ( "#{$config['general']['app_cache']}/artifacts/manifest.#{@checksum}.yaml" , 'w' ) do ... | Save the signature into the manifest file |
11,784 | def pubkey_upload unless File . exist? ( "#{$config['general']['app_cache']}/artifacts/#{$config['general']['gpg_signing_key']}.publickey" ) $logger . info "Exporting GPG key #{$config['general']['gpg_signing_key']} and uploading to S3 bucket..." unless pubkey_exist? $logger . error "The public key #{$config['general']... | Extract & upload the public key to the s3 bucket for other users |
11,785 | def pubkey_install $logger . warn "Installing GPG key #{$config['general']['gpg_signing_key']}..." s3 = Pupistry :: StorageAWS . new 'agent' unless s3 . download "#{$config['general']['gpg_signing_key']}.publickey" , "#{$config['general']['app_cache']}/artifacts/#{$config['general']['gpg_signing_key']}.publickey" $logg... | Install the public key . This is a potential avenue for exploit if a machine is being built for the first time it has no existing trust of the GPG key other than transit encryption to the S3 bucket . To protect against attacks at the bootstrap time you should pre - load your machine images with the public GPG key . |
11,786 | def wip = ( pr ) label_names = [ ] labels . each do | label | label_names << label . name end puts ( "exist labels:" + label_names . join ( ", " ) ) unless wip? begin add_label ( "WIP" ) rescue Octokit :: UnprocessableEntity => e puts "WIP label is already exists." puts e end end github . api . add_labels_to_an_issue (... | Set WIP label to PR . |
11,787 | def set ( pr , name , color ) message = "" if label? ( name ) message = "Set #{name} label. (Color: #{color})" else message = "Add #{name} new label. (Color: #{color})" add_label ( name , color ) end github . api . add_labels_to_an_issue ( repo , pr , [ name ] ) puts message end | Set any labels to PR by this . |
11,788 | def delete ( name ) begin github . api . delete_label! ( repo , name ) rescue Octokit :: Error => e puts "Error message: \"#{name}\" label is not existing." puts e end end | Delete label from repository . |
11,789 | def remove ( name ) begin github . api . remove_label ( repo , number , name ) rescue Octokit :: Error => e puts "Error message: \"#{name}\" label is not existing." puts e end end | Remove label from PR . |
11,790 | def diff ( cov1 , cov2 ) ncov = { } old_format = true cov1 . each do | path1 , runs1 | if cov2 [ path1 ] runs2 = cov2 [ path1 ] if runs1 . is_a? ( Array ) && runs2 . is_a? ( Array ) && old_format ncov [ path1 ] = diff_lines ( runs1 , runs2 ) next end if runs1 . is_a? ( Array ) runs1 = { :lines => runs1 } end if runs2 .... | Extract the coverage results that is covered by cov1 but not covered by cov2 . |
11,791 | def sanitize ( cov ) ncov = { } cov . each do | path , runs | if runs . is_a? ( Array ) ncov [ path ] = runs next end ncov [ path ] = { } ncov [ path ] [ :lines ] = runs [ :lines ] if runs [ :lines ] ncov [ path ] [ :branches ] = runs [ :branches ] if runs [ :branches ] if runs [ :methods ] ncov [ path ] [ :methods ] =... | Make the covearge result able to marshal . |
11,792 | def save ( path , cov ) File . binwrite ( path , Marshal . dump ( sanitize ( cov ) ) ) end | Save the coverage result to a file . |
11,793 | def to_lcov_info ( cov , out : "" , test_name : nil ) out << "TN:#{ test_name }\n" cov . each do | path , runs | out << "SF:#{ path }\n" if runs . is_a? ( Hash ) && runs [ :methods ] total = covered = 0 runs [ :methods ] . each do | ( klass , name , lineno ) , run | out << "FN:#{ lineno },#{ klass }##{ name }\n" total ... | Translate the result into LCOV info format . |
11,794 | def after_hook ( hook , * methods ) methods . each do | method | origin_method = "#{method}_origin" . to_sym if instance_methods . include? origin_method raise NameError , "#{origin_method} isn't a unique name" end alias_method origin_method , method define_method ( method ) do | * args , & block | result = send ( orig... | Register a hooking method for given methods . The hook method is executed after calling given methods . |
11,795 | def next_feed ( feed = nil ) return Feed . load_xml ( get_collection ( collection_uri ) . body ) if feed . nil? return nil unless feed . has_next? Feed . load_xml ( get_collection ( feed . next_uri ) . body ) end | Get the next feed of the given feed . Return the first feed if no argument is passed . |
11,796 | def get_entry ( entry_id ) response = get ( member_uri ( entry_id ) ) Entry . load_xml ( response . body ) end | Get a blog entry specified by its ID . |
11,797 | def post_entry ( title = '' , content = '' , categories = [ ] , draft = 'no' ) entry_xml = entry_xml ( title , content , categories , draft ) response = post ( entry_xml ) Entry . load_xml ( response . body ) end | Post a blog entry . |
11,798 | def update_entry ( entry_id , title = '' , content = '' , categories = [ ] , draft = 'no' , updated = '' ) entry_xml = entry_xml ( title , content , categories , draft , updated ) response = put ( entry_xml , member_uri ( entry_id ) ) Entry . load_xml ( response . body ) end | Update a blog entry specified by its ID . |
11,799 | def entry_xml ( title = '' , content = '' , categories = [ ] , draft = 'no' , updated = '' , author_name = @user_id ) builder = Nokogiri :: XML :: Builder . new ( encoding : 'utf-8' ) do | xml | xml . entry ( 'xmlns' => 'http://www.w3.org/2005/Atom' , 'xmlns:app' => 'http://www.w3.org/2007/app' ) do xml . title title x... | Build a entry XML from arguments . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.