idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
13,900 | def library_combined_document ( library_document_id , file_path = nil , auditReport = false ) response = Echochamber :: Request . library_combined_document ( token , library_document_id , auditReport ) unless file_path . nil? file = File . new ( file_path , 'wb' ) file . write ( response ) file . close end response end | Retrieves library combined document file |
13,901 | def enter_into_queue? current_limit = queue_constraints [ :capacity ] . to_i current_usage = queue_constraints [ :taken ] . to_i + UserQ :: UserQueue . count_unexpired ( queue_constraints [ :context ] ) current_usage < current_limit end | Beautiful syntax . |
13,902 | def gallery_list_all request = Typhoeus :: Request . new ( "#{Kairos::Configuration::GALLERY_LIST_ALL}" , method : :post , headers : { "Content-Type" => "application/x-www-form-urlencoded" , "app_id" => "#{@app_id}" , "app_key" => "#{@app_key}" } ) response = request . run JSON . parse ( response . body ) rescue "INVAL... | List all Galleries |
13,903 | def method_missing ( name , * args ) if self [ 0 ] . respond_to? ( name ) self . inject ( QueryResult . new ) do | memo , node | ret = node . send ( name , * args ) memo << ret if ret memo end else super end end | To facilitate the management of what could be many nodes found by a single query we forward off any unknown methods to each node in the results query . We assume that if one node accepts the method then all of them will . |
13,904 | def sync_attr_sync ( attribute , & block ) mutex_var_name = "@sync_attr_#{attribute}" . to_sym instance_variable_set ( mutex_var_name , Mutex . new ) unless instance_variable_defined? ( mutex_var_name ) instance_variable_get ( mutex_var_name ) . synchronize ( & block ) end | Thread safe way of creating the instance sync |
13,905 | def wait_for_instance_death ( instance , opts = { } ) wait_for_instance_status ( :terminated , instance , opts ) if instance . exists? rescue AWS :: EC2 :: Errors :: InvalidInstanceID :: NotFound end | Being serial shouldn t be much slower as we are blocked by the slowest stopper anyway |
13,906 | def get_widget_documents ( widget_id , version_id = nil , participant_email = nil ) Echochamber :: Request . get_widget_documents ( token , widget_id , version_id , participant_email ) end | Retrieves the IDs of the documents associated with widget . |
13,907 | def get_widget_document_file ( widget_id , document_id , file_path = nil ) response = Echochamber :: Request . get_widget_document_file ( token , widget_id , document_id ) unless file_path . nil? file = File . new ( file_path , 'wb' ) file . write ( response ) file . close end response end | Retrieves the file stream of a document of a widget |
13,908 | def redirect_notice ( record = nil ) { notice : I18n . t ( "crud.notices.#{action_name}" , model : helpers . t_model , record : record . present? ? "#{record} " : '' ) } end | returns a redirect notice for create update and destroy actions |
13,909 | def initialize_with_i18n_routing ( name , app , path , constraints , defaults = { } ) @locale = if constraints . key? ( :i18n_locale ) c = constraints . delete ( :i18n_locale ) ( c . respond_to? ( :source ) ? c . source : c ) . to_sym else nil end initialize_without_i18n_routing ( name , app , path , constraints , defa... | During route initialization if a condition i18n_locale is present Delete it store it in |
13,910 | def raw_response ( json , status ) json . empty? ? { } : JSON . parse ( json , symbolize_names : true ) rescue StandardError { message : json , code : status } end | Turn the API s JSON response and HTTP status code into a Ruby object . |
13,911 | def do_migration migration_exists = Dir [ "db/migrate/*_create_user_queues.rb" ] . count > 0 if migration_exists and installing? puts "UserQ is already installed. Maybe a 'rake db:migrate' command might help?" return end create_migration puts "Success! UserQ is installed. You can now use it in your application." if ins... | Setup and create the migration |
13,912 | def create_user ( user ) user_response = Echochamber :: Request . create_user ( user , token ) user_response . fetch ( "userId" ) end | Initializes the Client object |
13,913 | def create_transient_document ( file_name , mime_type , file_handle ) transient_document_response = Echochamber :: Request . create_transient_document ( token , file_name , file_handle , mime_type ) transient_document_response . fetch ( "transientDocumentId" ) end | Creates a transient document for later referral |
13,914 | def ask_run_new_file ( new_file_path , source_path , tmp ) return if tmp && IRT . rails_server original_ask_run_new_file ( new_file_path , source_path , tmp ) end | skips asking to run the save file if it is a tmp file in a server session because the server is exiting so no rerun is possible |
13,915 | def response_shim ( body , status ) items = JSON . parse ( body , symbolize_names : true ) { response : { items : items , offset : 0 , limit : items . size , totalItems : items . size , modeItems : false } , status : { result : status == 200 ? 'OK' : 'ERROR' , message : extract_api_message ( status , items ) , code : s... | Fake a response which looks like we get from all the other paths . I m expecting the user response model to be made consistent with others in the future . |
13,916 | def parse_opts ( opts_in , opts_defaults ) diff_id = opts_in . keys - opts_defaults . keys raise ArgumentError , "Unrecognised argument(s): #{diff_id.join(", ")}" if diff_id . any? ( opts_in . keys & opts_defaults . keys ) . each do | k | raise ArgumentError , "Argument #{k.to_s} must not be nil" if opts_defaults [ k ]... | Setting value of a key to nil in opts_defaults forces non - nil value of key in opts_in |
13,917 | def determine_remotely lv_uri = URI :: Generic . build ( :scheme => @connection_uri . scheme , :userinfo => @connection_uri . user , :host => @connection_uri . host , :path => @connection_uri . path , :query => @connection_uri . query ) conn = Libvirt :: open_auth ( lv_uri . to_s , [ Libvirt :: CRED_AUTHNAME , Libvirt ... | Interact with a libvirtd attempt to determine optimal settings where possible . Register the appliance as a new domain . |
13,918 | def determine_locally domain = @libvirt_capabilities . get_plugin ( @previous_plugin_info ) . domain_rank . last generate_xml ( OpenStruct . new ( { :domain_type => domain . name , :os_type => domain . virt_rank . last , :bus => domain . bus } ) ) end | Make no external connections just dump a basic XML skeleton and provide sensible defaults where user provided values are not given . |
13,919 | def upload_image uploader = SFTPHelper . new ( :log => @log ) uploader . connect ( @image_delivery_uri . host , ( @image_delivery_uri . user || Etc . getlogin ) , :password => @image_delivery_uri . password ) uploader . upload_files ( @image_delivery_uri . path , @default_permissions , @overwrite , File . basename ( @p... | Upload an image via SFTP |
13,920 | def build_xml ( opts = { } ) opts = { :bus => @bus , :os_type => :hvm } . merge! ( opts ) builder = Builder :: XmlMarkup . new ( :indent => 2 ) xml = builder . domain ( :type => opts [ :domain_type ] . to_s ) do | domain | domain . name ( @appliance_name ) domain . description ( @appliance_config . summary ) domain . m... | Build the XML domain definition . If the user provides a script it will be called after the basic definition has been constructed with the XML as the sole parameter . The output from stdout of the script will be used as the new domain definition . |
13,921 | def get_existing_domain ( conn , name ) return conn . lookup_domain_by_name ( name ) rescue Libvirt :: Error => e return nil if e . libvirt_code == 42 raise end | Look up a domain by name |
13,922 | def undefine_domain ( dom ) case dom . info . state when Libvirt :: Domain :: RUNNING , Libvirt :: Domain :: PAUSED , Libvirt :: Domain :: BLOCKED dom . destroy end dom . undefine end | Undefine a domain . The domain will be destroyed first if required . |
13,923 | def write_xml ( xml ) fname = "#{@appliance_name}.xml" File . open ( "#{@dir.tmp}/#{fname}" , 'w' ) { | f | f . write ( xml ) } register_deliverable ( :xml => fname ) end | Write domain XML to file |
13,924 | def with_temp_file filename = original_filename || content . default_file_name basename = [ File . basename ( filename , ".*" ) , File . extname ( filename ) ] infile = Tempfile . open ( basename , Ddr :: Models . tempdir , encoding : 'ascii-8bit' ) begin infile . write ( content . content ) infile . close verify_check... | Yields path of tempfile containing content to block |
13,925 | def member_of? ( group ) if group . is_a? Group groups . include? group else member_of? Group . new ( group ) end end | Is the user associated with the auth context a member of the group? |
13,926 | def post ( path , body = nil , ctype = 'text/plain' ) body = body . to_json unless body . is_a? ( String ) make_call ( mk_conn ( path , 'Content-Type' : ctype , 'Accept' : 'application/json' ) , :post , nil , body ) end | Make a POST call to the Wavefront API and return the result as a Ruby hash . |
13,927 | def put ( path , body = nil , ctype = 'application/json' ) make_call ( mk_conn ( path , 'Content-Type' : ctype , 'Accept' : 'application/json' ) , :put , nil , body . to_json ) end | Make a PUT call to the Wavefront API and return the result as a Ruby hash . |
13,928 | def verbosity ( conn , method , * args ) return unless noop || verbose log format ( 'uri: %s %s' , method . upcase , conn . url_prefix ) return unless args . last && ! args . last . empty? log method == :get ? "params: #{args.last}" : "body: #{args.last}" end | Try to describe the actual HTTP calls we make . There s a bit of clumsy guesswork here |
13,929 | def to_s text = '' text << tag_output_string + "\n" unless tags . empty? text << "Scenario Outline:#{name_output_string}" text << "\n" + description_output_string unless description_text . empty? text << "\n" unless steps . empty? || description_text . empty? text << "\n" + steps_output_string unless steps . empty? tex... | Returns a gherkin representation of the outline . |
13,930 | def dist ( path , interval , value , tags = nil ) key = [ path , interval , tags ] @buf [ :dists ] [ key ] += [ value ] . flatten end | These distributions are stored in memory and sent to Wavefront as native distibutions when the buffer is flushed . |
13,931 | def flush_gauges ( gauges ) return if gauges . empty? to_flush = gauges . dup @buf [ :gauges ] = empty_gauges writer . write ( gauges_to_wf ( gauges ) ) . tap do | resp | @buf [ :gauges ] += to_flush unless resp . ok? end end | When we are asked to flush the buffers duplicate the current one hand it off to the writer class and clear . If writer tells us there was an error dump the old buffer into the the new one for the next flush . |
13,932 | def replay_counters ( buffer ) buffer . each { | k , v | counter ( k [ 0 ] , v , k [ 1 ] ) } end | Play a failed flush full of counters back into the system |
13,933 | def + ( offset ) if offset > @size raise "Offset must not be more than #{@size} (but was #{offset})" end mark , size = self , @size - offset retval = orig_plus offset retval . instance_eval { @mark , @size = mark , size } retval end | Operator for doing pointer arithmetic |
13,934 | def write ( data ) if data . is_a? Malloc if data . size > @size raise "Must not write more than #{@size} bytes of memory " + "(illegal attempt to write #{data.size} bytes)" end orig_write data , data . size else if data . bytesize > @size raise "Must not write more than #{@size} bytes of memory " + "(illegal attempt t... | Write data to memory |
13,935 | def to_s text = '' text << tag_output_string + "\n" unless tags . empty? text << "Examples:#{name_output_string}" text << "\n" + description_output_string unless description_text . empty? text << "\n" unless description_text . empty? text << "\n" + parameters_output_string text << "\n" + rows_output_string unless rows ... | Returns a gherkin representation of the example . |
13,936 | def time_to_ms ( time ) return false unless time . is_a? ( Integer ) return time if time . to_s . size == 13 ( time . to_f * 1000 ) . round end | Convert an epoch timestamp into epoch milliseconds . If the timestamp looks like it s already epoch milliseconds return it as - is . |
13,937 | def capture ( * observers , & block ) @lock_a . synchronize do add_observers ( observers ) _capture ( & block ) if block_given? yield _stop end end end | Start capturing paths . Providing a block automatically stops the capture process upon termination of the scope . |
13,938 | def alias_and_capture ( klazz , m_sym , flag , & blk ) alias_m_sym = "__alias_#{m_sym}" klazz . class_eval do alias_method alias_m_sym , m_sym define_method ( m_sym ) do | * args , & blx | response = send ( alias_m_sym , * args , & blx ) blk . call ( self , * args ) if flag . get_set response end end end | Cracks open the target class and injects a wrapper to enable monitoring . By aliasing the original method the wrapper intercepts the call which it forwards onto the real method before executing the hook . |
13,939 | def newest ( versions ) versions . sort { | x , y | compare ( x , y ) } . last end | Returns newest version from the array |
13,940 | def partition_mount_points ( partitions ) partitions . keys . sort do | a , b | a_count = a . count ( '/' ) b_count = b . count ( '/' ) if a_count > b_count v = 1 else if a_count < b_count v = - 1 else if a . length == b . length v = a <=> b else v = a . length <=> b . length end end end v = 1 if a_count == 0 v = - 1 i... | Returns valid array of sorted mount points |
13,941 | def process! windows = @termfile [ :windows ] default = windows . delete ( 'default' ) execute_window ( default , :default => true ) unless default [ :tabs ] . empty? windows . each_pair { | _ , cont | execute_window ( cont ) } end | Method called by runner to execute Termfile . |
13,942 | def url_for_trolley ( options = { } ) return url_for_dc_identifier ( @purchasable_item ) if @purchasable_item && params [ :action ] == 'create' user = options . delete ( :user ) trolley = options [ :trolley ] || @trolley || user . trolley if trolley . blank? user = @user else user = trolley . user end options [ :user_i... | expects user in options or |
13,943 | def url_for_order ( options = { } ) trolley = options . delete ( :trolley ) || @trolley trolley = @order . trolley if @order order = options . delete ( :order ) || @order || trolley . selected_order options [ :id ] = order options [ :controller ] = 'orders' options [ :action ] = 'show' options [ :urlified_name ] = Bask... | expects order either as instance variables or in options |
13,944 | def sign_in_url ( ruparams = { } ) url = [ ] url << EbayTrader . configuration . production? ? 'https://signin.ebay.com' : 'https://signin.sandbox.ebay.com' url << '/ws/eBayISAPI.dll?SignIn' url << "&runame=#{url_encode ru_name}" url << "&SessID=#{url_encode id}" if ruparams && ruparams . is_a? ( Hash ) && ! ruparams .... | Get the URL through which a user must sign in using this session ID . |
13,945 | def method_missing ( method , * args , & block ) method_in_snake_case = method . to_s . snake_case if @operations . keys . include? ( method_in_snake_case ) op_name , param_types = @operations [ method_in_snake_case ] @connection . invoke @object_name , op_name , args . to_java ( :Object ) , param_types . to_java ( :St... | Creates a new MBean . |
13,946 | def create ( base , head , title , body ) logger . info { "Creating a pull request asking for '#{head}' to be merged into '#{base}' on #{repo}." } begin return sym_hash_JSON ( client . create_pull_request ( repo , base , head , title , body ) ) rescue Octokit :: UnprocessableEntity => exp pull = pull_requests . find { ... | Create a pull request |
13,947 | def remove_title ( lyric ) lines = lyric . lines lines . shift lines = remove_empty_lines_from_beginning ( lines ) lines . join end | This is necessary because for translations the song title comes with the lyric text . Also the format is not always the same sometimes it s just one line for the title sometimes it s the title followed by some empty lines . Here we remove the first line and any following empty lines so we have a consident API . |
13,948 | def set_some_flags @flag_not_accessible_through_html = true @flag_create_migration = true @flag_create_model = true @create_id = true for attribute in attributes @flag_not_accessible_through_html = false if attribute . name == '_enabled' @flag_create_migration = false if attribute . name == '_no_migration' @flag_create... | using flags . |
13,949 | def login_url ( service_url = request . url ) url = URI ( Rails . application . cas_server_url ) url . path = "/login" url . query = "service=#{service_url || request.url}" url . to_s end | Renders the CAS login URL with re - direct back to some URL . |
13,950 | def format_key ( key ) key = key . to_s key = key . gsub ( 'PayPal' , 'Paypal' ) key = key . gsub ( 'eBay' , 'Ebay' ) key = key . gsub ( 'EBay' , 'Ebay' ) key . underscore . to_sym end | Ensure the key is an underscored Symbol . |
13,951 | def push_to_server ( local_branch , remote_branch , opts = { } ) if opts [ :local ] logger . debug ( 'Not pushing to the server because the user selected local-only.' ) elsif not has_a_remote? logger . debug ( 'Not pushing to the server because there is no remote.' ) elsif local_branch == config . master_branch logger ... | Push the repository to the server . |
13,952 | def branch ( branch_name , opts = { } ) if branch_name if opts [ :delete ] return delete_branch ( branch_name , opts [ :force ] ) elsif opts [ :rename ] return rename_branch ( branch_name , opts [ :rename ] ) elsif opts [ :upstream ] return set_upstream_branch ( branch_name , opts [ :upstream ] ) else base_branch = opt... | Does branch manipulation . |
13,953 | def remove ( files , opts = { } ) args = [ ] args << '-f' if opts [ :force ] args << [ * files ] command ( :rm , args ) end | Remove the files from the Index |
13,954 | def write_sync_control_file ( branch_name ) latest_sha = rev_parse ( branch_name ) filename = sync_control_filename ( branch_name ) logger . debug { "Writing sync control file, #{filename}, with #{latest_sha}" } File . open ( filename , 'w' ) { | f | f . puts latest_sha } end | Writes the current SHA - 1 for the tip of the branch to the sync control file |
13,955 | def delete_sync_control_file! ( branch_name ) filename = sync_control_filename ( branch_name ) logger . debug { "Deleting sync control file, #{filename}" } counter = 10 while counter > 0 begin File . delete ( filename ) counter = 0 rescue counter = counter - 1 sleep ( 0.25 ) end end end | Delete the sync control file for the branch |
13,956 | def create_git_command ( cmd , opts , redirect ) opts = [ opts ] . flatten . map { | s | escape ( s ) } . join ( ' ' ) return "git #{cmd} #{opts} #{redirect} 2>&1" end | Create the CLI for the git command |
13,957 | def search_with ( operator_class , options = { } ) merged_operations = options . merge ( :klass => self ) operator = operator_class . new ( merged_operations ) operator . valid! search_with_operator_by_name [ operator . name ] = operator end | Declares that this class should be search with an instance of the given operator_class . |
13,958 | def to_s_append ( ds , s ) s << '$' << name . to_s s << ':' << sql_field . to_s if sql_field s << '/*' << small_source << '*/' end | this is inserted into the generated SQL from a dataset that contains PlaceHolder instances . |
13,959 | def call ( dataset ) dataset = dataset . dataset if dataset . respond_to? :dataset dataset = expressions . inject ( dataset . clone ) do | dataset , filter_expr | dataset . filter ( filter_expr ) end if order_clause . empty? dataset else dataset . order * order_clause end end | return a modified dataset containing all the predicates |
13,960 | def valued_parameters @valued_parameters ||= filter_parameters . select do | key , value | key . to_sym != :order && valued_parameter? ( key , value ) end end | Values in the parameter list which are not blank and not an ordering . That is parameters which will be used to generate the filter expression . |
13,961 | def to_h ( all = false ) filter_parameters . select { | k , v | all || ! v . blank? } end | for use in forms |
13,962 | def expr_hash vary = valued_parameters . map do | key , value | [ key , to_expr ( key , value ) ] end Hash [ vary ] end | hash of keys to expressions but only where there are values . |
13,963 | def serializable_hash return serializable_collection if collection? self . class . _attributes . each_with_object ( { } ) do | ( name , option ) , hash | if _include_from_options? ( name ) && public_send ( option [ :include_method ] ) hash [ option [ :key ] || name ] = _set_value ( name , option ) end end end | Returns a hash representation without the root |
13,964 | def delete! ( force = false ) if local? @lib . branch ( @name , :force => force , :delete => true ) else @lib . push ( Process . server_name , nil , nil , :delete => @name ) end end | Delete this branch |
13,965 | def search_operator_by_name unless instance_variable_defined? :@search_operator_by_name @search_operator_by_name = { } search_with_operator_by_name . each_value do | operator | @search_operator_by_name [ operator . name ] = operator end search_association_operators . each do | operator | @search_operator_by_name [ oper... | Collects all search attributes from search associations and all attributes from this class to show the valid search operators to search . |
13,966 | def root ( name , * args , & block ) set_context ( & block ) node ( name , args , & block ) end | Begin creating an XML string by specifying the root node . This also sets the context scope allowing methods and variables outside the block to be accessed . |
13,967 | def node ( name , args , & block ) content = get_node_content ( args ) options = format_node_attributes ( get_node_attributes ( args ) ) @_segments ||= [ ] @_segments << "#{indent_new_line}<#{name}#{options}>#{content}" if block_given? @depth += 1 instance_eval ( & block ) @depth -= 1 @_segments << indent_new_line end ... | Create an XML node |
13,968 | def get_node_content ( args ) return nil if block_given? content = nil args . each do | arg | case arg when Hash next when Time content = arg . strftime ( '%Y-%m-%dT%H:%M:%S.%Z' ) when DateTime content = arg . strftime ( '%Y-%m-%dT%H:%M:%S.%Z' ) break else content = arg . to_s break end end content end | Return the node content as a String unless a block is given . |
13,969 | def format_node_attributes ( options ) options . collect { | key , value | value = value . to_s . gsub ( '"' , '\"' ) " #{key}=\"#{value}\"" } . join ( '' ) end | Convert the given Hash of options into a string of XML element attributes . |
13,970 | def call method , params = { } url = "#{api_url}&method=#{method}" params = { apikey : self . api_key } . merge params resp = post_api ( url , params ) begin return JSON . parse ( resp ) rescue return resp . tr ( '"' , '' ) end end | Initialize API wrapper . |
13,971 | def post_api url , params uri = URI . parse ( url ) http = Net :: HTTP . new ( uri . host , uri . port ) http . use_ssl = self . secure form_params = params . to_query res = http . post ( uri . request_uri , form_params ) res . body end | All api calls throught POST method . |
13,972 | def read_file json_string = '' if ApiExplorer :: use_file json_path = ApiExplorer :: json_path json_string = File . read ( json_path ) else json_string = ApiExplorer :: json_string end @methods = JSON . parse ( json_string ) [ "methods" ] end | Read file with methods |
13,973 | def format ( input , pattern , options = { } ) fill = options [ :fill ] intl_prefix = options [ :intl_prefix ] || '' trunk_prefix = options [ :trunk_prefix ] || '' slots = pattern . count ( PLACEHOLDER_CHAR ) return input if ( fill . nil? && input . length > slots ) source = ( fill . nil? || fill . empty? ) ? input : i... | Returns the string formatted according to a pattern . |
13,974 | def configure_octokit ( opts = { } ) base_url = opts [ :base_url ] || base_github_api_url_for_remote Octokit . configure do | c | c . api_endpoint = api_endpoint ( base_url ) c . web_endpoint = web_endpoint ( base_url ) end if logger . level < :: GitProc :: GitLogger :: INFO Octokit . middleware = Faraday :: RackBuilde... | Configures Octokit to use the appropriate URLs for GitHub server . |
13,975 | def create_pw_client ( opts = { } ) usr = opts [ :user ] || user ( ) pw = opts [ :password ] || password ( ) remote = opts [ :remote_name ] || self . remote_name logger . info ( "Authorizing #{usr} to work with #{remote}." ) configure_octokit ( opts ) Octokit :: Client . new ( :login => usr , :password => pw ) end | Create a GitHub client using username and password specifically . Meant to be used to get an OAuth token for regular client calls . |
13,976 | def unprocessable_authorization ( exp ) errors = exp . errors if not ( errors . nil? or errors . empty? ) error_hash = errors [ 0 ] if error_hash [ :resource ] == 'OauthAccess' return ask_about_resetting_authorization else raise exp end else raise exp end end | Tries to more gracefully handle the token already existing . See |
13,977 | def association ( name , options = { } ) association = Metasploit :: Model :: Association :: Reflection . new ( :model => self , :name => name . to_sym , :class_name => options [ :class_name ] ) association . valid! association_by_name [ association . name ] = association end | Registers an association . |
13,978 | def annex_block ( identifier , opts = { } ) opts [ :route ] ||= current_route case Annex :: config [ :adapter ] when :activerecord doc = Annex :: Block . where ( route : "#{opts[:route]}_#{identifier}" ) . first_or_create content = doc . content when :mongoid doc = Annex :: Block . where ( route : opts [ :route ] ) . f... | annex_block is a universal helper to render content from the database and display it on the page |
13,979 | def repo_name unless @repo_name url = config [ "remote.#{name}.url" ] raise GitProcessError . new ( "There is no #{name} url set up." ) if url . nil? or url . empty? uri = Addressable :: URI . parse ( url ) @repo_name = uri . path . sub ( / \. / , '' ) . sub ( / \/ / , '' ) end @repo_name end | The name of the repository |
13,980 | def remote_name unless @remote_name @remote_name = config [ 'gitProcess.remoteName' ] if @remote_name . nil? or @remote_name . empty? remotes = self . remote_names if remotes . empty? @remote_name = nil else @remote_name = remotes [ 0 ] raise "remote name is not a String: #{@remote_name.inspect}" unless @remote_name . ... | Returns the remote name to use . By convention the most common name is origin . |
13,981 | def expanded_url ( server_name = 'origin' , raw_url = nil , opts = { } ) if raw_url . nil? raise ArgumentError . new ( 'Need server_name' ) unless server_name conf_key = "remote.#{server_name}.url" url = config [ conf_key ] raise GitHubService :: NoRemoteRepository . new ( "There is no value set for '#{conf_key}'" ) if... | Expands the git configuration server name to a url . |
13,982 | def to_s ( indent = xml_tab_width ) xml = '' if defined? Ox ox_doc = Ox . parse ( xml_response ) xml = Ox . dump ( ox_doc , indent : indent ) else rexml_doc = REXML :: Document . new ( xml_response ) rexml_doc . write ( xml , indent ) end xml end | Get a String representation of the response XML with indentation . |
13,983 | def submit raise EbayTraderError , 'Cannot post an eBay API request before application keys have been set' unless EbayTrader . configuration . has_keys_set? uri = EbayTrader . configuration . uri http = Net :: HTTP . new ( uri . host , uri . port ) http . read_timeout = http_timeout if uri . port == 443 http . use_ssl ... | Post the xml_request to eBay and record the xml_response . |
13,984 | def add_to_blacklist ( word , deep_search = 0 ) params = { :method => WebPurify :: Constants . methods [ :add_to_blacklist ] , :word => word , :ds => deep_search } parsed = WebPurify :: Request . query ( text_request_base , @query_base , params ) return parsed [ :success ] == '1' end | Add a word to the blacklist |
13,985 | def remove_from_blacklist ( word ) params = { :method => WebPurify :: Constants . methods [ :remove_from_blacklist ] , :word => word } parsed = WebPurify :: Request . query ( text_request_base , @query_base , params ) return parsed [ :success ] == '1' end | Remove a word from the blacklist |
13,986 | def get_blacklist params = { :method => WebPurify :: Constants . methods [ :get_blacklist ] } parsed = WebPurify :: Request . query ( text_request_base , @query_base , params ) if parsed [ :word ] return [ ] << parsed [ :word ] else return [ ] end end | Get the blacklist |
13,987 | def write_and_logging ( message , command , secret = false ) logging_message = secret ? message : message + command @logger . info logging_message if @writer . closed? @logger . error "Try to write #{command}, but writer closed" @commands . clear else @writer . puts command end end | Send string to process and logging the string |
13,988 | def default_io_logger ( logger_io , progname ) logger = Logger . new ( logger_io ) logger . progname = progname logger . datetime_format = '%Y-%m-%d %H:%M:%D %Z' logger end | Setup default IO logger |
13,989 | def load_yaml_file ( file_type , file_name ) YAML . load_file file_name rescue StandardError => error @logger . error "Cannot load #{file_type}: #{file_name}" raise error end | YAML file loader |
13,990 | def nil_instance_vars ( object , vars ) vars = Array ( vars ) vars . select { | var | object . instance_variable_get ( var ) . nil? } end | Returns an array containing each symbol in vars for which the corresponding instance variable in the specified object is nil . |
13,991 | def raise_on_nil_instance_vars ( object , vars ) nil_vars = nil_instance_vars ( object , vars ) unless nil_vars . empty? raise ObjectValidationError . new ( "The following instance variables were nil: #{nil_vars.join(', ')}." ) end end | For each symbol in vars checks to see that the corresponding instance variable in the specified object is not nil . If any are nil raises an error listing the nils . |
13,992 | def print_header Rudy :: Huxtable . update_global @global li Rudy :: CLI . generate_header ( @@global , @@config ) if @@global . print_header unless @@global . quiet if @@global . environment == "prod" msg = "YOU ARE PLAYING WITH PRODUCTION" li Rudy :: Utils . banner ( msg , :normal ) , $/ end end end | Print a default header to the screen for every command . |
13,993 | def bell ( chimes = 1 , logger = nil ) chimes ||= 0 return unless logger chimed = chimes . to_i logger . print "\a" * chimes if chimes > 0 && logger true end | Make a terminal bell chime |
13,994 | def bug ( bugid , logger = STDERR ) logger . puts "You have found a bug! If you want, you can email" . color ( :red ) logger . puts 'rudy@solutious.com' . color ( :red ) . bright << " about it. It's bug ##{bugid}." . color ( :red ) logger . puts "Continuing..." . color ( :red ) true end | Have you seen that episode of The Cosby Show where Dizzy Gillespie ... ah nevermind . |
13,995 | def known_type? ( key ) return false unless key key &&= key . to_s . to_sym Rudy :: ID_MAP . has_key? ( key ) end | Is the given + key + a known type of object? |
13,996 | def identifier ( key ) key &&= key . to_sym return unless Rudy :: ID_MAP . has_key? ( key ) Rudy :: ID_MAP [ key ] end | Returns the string identifier associated to this + key + |
13,997 | def capture ( stream ) begin stream = stream . to_s eval "$#{stream} = StringIO.new" yield result = eval ( "$#{stream}" ) . read ensure eval ( "$#{stream} = #{stream.upcase}" ) end result end | Capture STDOUT or STDERR to prevent it from being printed . |
13,998 | def write_to_file ( filename , content , mode , chmod = 600 ) mode = ( mode == :append ) ? 'a' : 'w' f = File . open ( filename , mode ) f . puts content f . close return unless Rudy . sysinfo . os == :unix raise "Provided chmod is not a Fixnum (#{chmod})" unless chmod . is_a? ( Fixnum ) File . chmod ( chmod , filename... | A basic file writer |
13,999 | def refresh! raise UnknownObject , self . name unless self . exists? h = Rudy :: Metadata . get self . name return false if h . nil? || h . empty? obj = self . from_hash ( h ) obj . postprocess obj end | Refresh the metadata object from SimpleDB . If the record doesn t exist it will raise an UnknownObject error |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.