idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
18,600 | def load_and_verify ( verify_element , url_hash = nil ) result = true @metrics . start_time if url_hash . nil? load else load ( url_hash ) end if verify_element result = wait_till_element_visible ( verify_element , 3 ) end @metrics . log_metric ( @page_name , 'load' , verify_element ) result end | Page loads typically takes longer . |
18,601 | def load_ab_person @attributes ||= { } Person . single_value_property_map . each do | ab_property , attr_key | if attributes [ attr_key ] set_field ( ab_property , attributes [ attr_key ] ) else remove_field ( ab_property ) end end if attributes [ :is_org ] set_field ( KABPersonKindProperty , KABPersonKindOrganization ... | instantiates ABPerson record from attributes |
18,602 | def tags = ( tags ) tags = tags . split ( ',' ) if tags . is_a? ( String ) @tags = TagArray . new ( list_id , tags ) queue_operation ( 'setTasks' , tags . join ( ',' ) ) end | Sets the tags for the task . |
18,603 | def on_chunk ( & block ) raise "Body already read" if @on_chunk raise ArgumentError , "block must be given" unless block_given? @on_chunk = block unless @body . empty? @body . each ( & block ) @body . clear end self end | Set callback that will be called when received a chunk of response body . |
18,604 | def create_bug ( product , component , summary , version , ** kwargs ) params = { } params = params . merge ( kwargs ) params [ :product ] = product params [ :component ] = component params [ :summary ] = summary params [ :version ] = version ret = @client . call ( 'Bug.create' , params ) handle_faults ( ret ) ret [ 'i... | Create a bug |
18,605 | def search_bugs ( query ) query = Query . new . summary ( query ) if query . is_a? ( String ) ret = @client . call ( 'Bug.search' , query . query_map ) handle_faults ( ret ) bugs = [ ] ret [ 'bugs' ] . each do | bug_data | bugs << Bug . new ( self , bug_data ) end bugs end | Search for a bug |
18,606 | def expand_named_query ( what ) url = @api_url . clone url . path = '/buglist.cgi' url . query = "cmdtype=runnamed&namedcmd=#{URI.escape(what)}&ctype=atom" logger . info ( "Expanding named query: '#{what}' to #{url.request_uri}" ) fetch_named_query_url ( url , 5 ) end | Given a named query s name runs it on the server |
18,607 | def fetch_named_query_url ( url , redirects_left ) raise 'You need to be authenticated to use named queries' unless @userid http = Net :: HTTP . new ( @api_url . host , @api_url . port ) http . set_debug_output ( Bicho :: LoggerIODevice . new ) http . verify_mode = OpenSSL :: SSL :: VERIFY_NONE http . use_ssl = ( @api_... | Fetches a named query by its full url |
18,608 | def get_bugs ( * ids ) params = { } params [ :ids ] = normalize_ids ids bugs = [ ] ret = @client . call ( 'Bug.get' , params ) handle_faults ( ret ) ret [ 'bugs' ] . each do | bug_data | bugs << Bug . new ( self , bug_data ) end bugs end | Retrieves one or more bugs by id |
18,609 | def add_attachment ( summary , file , * ids , ** kwargs ) params = { } params [ :ids ] = ids params [ :summary ] = summary params [ :content_type ] = kwargs . fetch ( :content_type , 'application/octet-stream' ) params [ :file_name ] = kwargs . fetch ( :file_name , File . basename ( file ) ) params [ :is_patch ] = kwar... | Add an attachment to bugs with given ids |
18,610 | def connect ( alias_name , options ) file = File . open ( FILE_PATH , 'r' ) servers = all_hosts_in ( file ) if servers . include? alias_name PRINTER . verbose_print "Connecting to #{alias_name}" exec "ssh #{alias_name}" else PRINTER . print "Could not find host `#{alias_name}`" end end | connects to host using alias |
18,611 | def add ( alias_name , user , host , options ) begin PRINTER . verbose_print "Adding\n" config_append = form ( alias_name , user , host , options ) PRINTER . verbose_print config_append unless options . test file = File . open ( FILE_PATH , 'a+' ) file . write ( config_append ) file . close File . chmod ( 0600 , FILE_P... | append an alias for the given user |
18,612 | def all_hosts_in ( file ) servers = [ ] file . each do | line | if line . include? ( 'Host ' ) servers << line . sub ( 'Host ' , '' ) . strip end end servers end | Returns all the alias names of in the file |
18,613 | def options! @options = { } @option_parser = OptionParser . new ( BANNER ) do | opts | opts . on ( "-b" , "--batch_length BATCH" , "Number of urls to purge at once" ) do | b | @options [ :batch_length ] = b . to_i end opts . on ( "-t" , "--sleep_time SLEEP" , "Time to wait in between batches" ) do | t | @options [ :sle... | Parse the command line options using OptionParser . |
18,614 | def licenses * names names . to_strings . each do | name | begin module_name = "#{name.camelize}License" clazz = module_name . constantize rescue raise "License #{module_name} is not defined" end begin clazz . new ( self ) . enforce! rescue raise "License #{clazz} could not be enforced using #{self.inspect}" end end en... | where and how is this used??? |
18,615 | def executor ( user_account , options = { } ) @executor ||= case self . class . name when / / then Permit :: Executor :: System . new self , user_account , options else Permit :: Executor :: Base . new self , user_account , options end end | return the executor used to execute the permit |
18,616 | def update file solr_doc = om_document ( File . new ( file ) ) . to_solr delete solr_doc [ "id" ] solr . add solr_doc add_components ( file ) unless options [ :simple ] solr . commit end | Updates your ead from a given file by first deleting the existing ead document and any component documents then creating a new index from the supplied file . This method will also commit the results to your solr server when complete . |
18,617 | def om_document file options [ :document ] ? options [ :document ] . from_xml ( File . new ( file ) ) : SolrEad :: Document . from_xml ( File . new ( file ) ) end | Returns an OM document from a given file . |
18,618 | def om_component_from_node node options [ :component ] ? options [ :component ] . from_xml ( prep ( node ) ) : SolrEad :: Component . from_xml ( prep ( node ) ) end | Returns an OM document from a given Nokogiri node |
18,619 | def solr_url if defined? ( Rails . root ) :: YAML . load ( ERB . new ( File . read ( File . join ( Rails . root , "config" , "solr.yml" ) ) ) . result ) [ Rails . env ] [ 'url' ] elsif ENV [ 'RAILS_ENV' ] :: YAML . load ( ERB . new ( File . read ( "config/solr.yml" ) ) . result ) [ ENV [ 'RAILS_ENV' ] ] [ 'url' ] else ... | Determines the url to our solr service by consulting yaml files |
18,620 | def purge_urls @current_job . each do | url | begin @varnish . start if @varnish . stopped? while ( ! @varnish . running? ) do sleep 0.1 end if @varnish . purge :url , url @logger . info "Purged url: #{url}" @purged_urls << url else @logger . warn "Could not purge: #{url}" end rescue * ERRORS => e @logger . warn "Error... | Once a batch is ready the Client fires off purge requests on the list of urls . |
18,621 | def handle_errors trap ( 'HUP' ) { } trap ( 'TERM' ) { close_log ; Process . exit! } trap ( 'KILL' ) { close_log ; Process . exit! } trap ( 'INT' ) { close_log ; Process . exit! } end | Trap certain signals so the Client can report back the progress of the job and close the log . |
18,622 | def logger if ! @log_file . respond_to? ( :write ) STDOUT . reopen ( File . open ( @log_file , ( File :: WRONLY | File :: APPEND | File :: CREAT ) ) ) end @logger = Logger . new ( STDOUT ) end | The logger redirects all STDOUT writes to a logger instance . |
18,623 | def time_filter ( id , name , value ) html = "<select id=\"#{id}\" name=\"#{name}\">" html += "<option value=\"\">-</option>" [ 1 , 3 , 6 , 12 , 24 ] . each do | h | selected = h . to_s == value ? 'selected="selected"' : '' html += "<option #{selected} value=\"#{h}\">#{h} #{h==1 ? "hour" : "hours"} ago</option>" end [ ... | resque - cleaner helpers |
18,624 | def receive_frame ( frame ) validate_received_frame ( frame ) consume_recv_window ( frame ) case frame when Frame :: Data then receive_data ( frame ) when Frame :: Headers then receive_headers ( frame ) when Frame :: Priority then receive_priority ( frame ) when Frame :: RstStream then receive_rst_stream ( frame ) when... | Processes received frames for this stream . Internal use . |
18,625 | def promise ( headers ) stream = @connection . reserve_stream ( weight : self . weight + 1 , parent : self ) encoded = @connection . hpack_encoder . encode ( headers ) frame = Frame :: PushPromise . new ( id , stream . id , encoded , end_headers : true ) send frame stream end | Reserves a stream to server push . Sends PUSH_PROMISE and create new stream . |
18,626 | def send_data ( data = "" , end_stream : true ) max = @connection . remote_settings [ :max_frame_size ] if data . is_a? ( IO ) until data . eof? fragment = data . readpartial ( max ) send Frame :: Data . new ( id , fragment , end_stream : end_stream && data . eof? ) end else send Frame :: Data . new ( id , data , end_s... | Sends DATA frame . If the data is larger than MAX_FRAME_SIZE DATA frame will be splitted . |
18,627 | def remove_node_from_topology ( node_name ) node = Chef :: Node . load ( node_name ) if node [ 'topo' ] && node [ 'topo' ] [ 'name' ] == @topo_name node . rm ( 'topo' , 'name' ) ui . info "Removing node #{node.name} from topology" node . save end node rescue Net :: HTTPServerException => e raise unless e . to_s =~ / / ... | Remove the topo name attribute from all nodes so topo search knows they are not in the topology |
18,628 | def caching_jobs ( & blk ) _was_caching = caching_jobs? cache_jobs blk . call flush_jobs self . is_caching_jobs = _was_caching self end | Caches jobs for the duration of the block flushes them at the end . |
18,629 | def flush_jobs while job = self . cached_jobs . shift job_id , args = * job submit! args , job_id end self end | Publish all the cached jobs |
18,630 | def share_dir ( email , path , perm = "r" , repo = self . repo , s_type = "d" ) post_share_dir ( repo , { "email" => email , "path" => path , "s_type" => s_type , "perm" => perm } ) end | You do not have permission to perform this action |
18,631 | def process @rule_files . each do | rule_name , rule | if rule [ :rule ] . deferred @deferred_process << rule else rule [ :files ] . each do | file | full_path = File . join ( @runner . options . root_path , file ) check ( rule [ :rule ] , full_path ) end end end @deferred_process . each do | rule | rule [ :rule ] . ex... | Check syntax in repository directory |
18,632 | def process @deferred_process = [ ] @reader . rules . each do | rule | if rule . deferred @deferred_process << rule else rule . files_list ( @runner . options . root_path ) . each do | file | check ( rule , file ) end end end @deferred_process . each do | rule | rule . exec_rule . run ( @runner . options . root_path , ... | Check syntax in indicated directory |
18,633 | def configure ( jira_url : , jira_username : , jira_api_token : ) warn "danger-jira_sync plugin configuration is missing jira_url" if jira_url . blank? warn "danger-jira_sync plugin configuration is missing jira_username" if jira_username . blank? warn "danger-jira_sync plugin configuration is missing jira_api_token" i... | Configures the Jira REST Client with your credentials |
18,634 | def autolabel_pull_request ( issue_prefixes , project : true , components : true , labels : false ) raise NotConfiguredError unless @jira_client raise ( ArgumentError , "issue_prefixes cannot be empty" ) if issue_prefixes . empty? issue_keys = extract_issue_keys_from_pull_request ( issue_prefixes ) return if issue_keys... | Labels the Pull Request with Jira Project Keys and Component Names |
18,635 | def startup enable_gc_optimizations if Thread . current == Thread . main register_signal_handlers prune_dead_workers end run_hook :before_first_fork register_worker $stdout . sync = true end | Runs all the methods needed when a worker begins its lifecycle . OVERRIDE for multithreaded workers |
18,636 | def reconnect tries = 0 begin redis . synchronize do | client | client . reconnect end rescue Redis :: BaseConnectionError if ( tries += 1 ) <= 3 log "Error reconnecting to Redis; retrying" sleep ( tries ) retry else log "Error reconnecting to Redis; quitting" raise end end end | override so we can synchronize the client on the reconnect for multithreaded workers . |
18,637 | def options_for_add ( opts , options ) opts . on ( '-p' , '--port PORT' , 'Specify a port' ) do | port | options . file_content . port_text = " Port #{port}\n" end opts . on ( '-i' , '--identity_file [key]' , 'Add identity' ) do | key_path | options . file_content . identity_file_text = " IdentityFile #{key_path}\n" ... | Returns the options specifice to the add command only |
18,638 | def common_options ( opts , options ) opts . separator '' opts . separator 'Common options:' opts . on ( '-v' , '--version' , 'Show version' ) do PRINTER . print Sshez . version options . halt = true end opts . on ( '-z' , '--verbose' , 'Verbose Output' ) do PRINTER . verbose! end opts . on_tail ( '-h' , '--help' , 'Sh... | Returns the standard options |
18,639 | def node_export ( node_name ) load_node_data ( node_name , config [ :min_priority ] ) rescue Net :: HTTPServerException => e raise unless e . to_s =~ / / empty_node ( node_name ) end | get actual node properties for export |
18,640 | def update_nodes! ( nodes ) @node_names . each do | node_name | found = nodes . index { | n | n [ 'name' ] == node_name } if found . nil? nodes . push ( node_export ( node_name ) ) else nodes [ found ] = node_export ( node_name ) end end end | put node details in node array overwriting existing details |
18,641 | def download ( bug , supportconfig_only ) bug . attachments . each do | attachment | filename = "bsc#{bug.id}-#{attachment.id}-#{attachment.props['file_name']}" if supportconfig_only next unless attachment . content_type == 'application/x-gzip' || attachment . content_type == 'application/x-bzip-compressed-tar' next un... | check for supportconfigs and download |
18,642 | def load! ( path ) settings = YAML . safe_load ( ERB . new ( File . new ( path ) . read ) . result ) [ 'api' ] from_hash ( settings ) if settings . is_a? Hash end | Load the settings from a compliant Qualys . yml file . This can be used for easy setup with frameworks other than Rails . |
18,643 | def embed_script ( names = nil ) if production? embeds = buildable_svgs ( names ) . map ( & :embed ) else embeds = find_svgs ( names ) . map ( & :embed ) end write_cache if cache_stale? if ! embeds . empty? "<script>#{js(embeds.join("\n"))}</script>" end end | Embed svg symbols |
18,644 | def get ( url , params = { } ) result ( { "ResponseGroup" => "Related,TrafficData,ContentData" , "Url" => url } , params ) do | doc | @document = doc { speed_median_load_time : speed_median_load_time , speed_load_percentile : speed_load_percentile , link_count : link_count , ranking : ranking , ranking_delta : ranking_... | Alexa data for an individual site |
18,645 | def apply_persistence_timestamps self . updated_at = Time . now if self . class . attribute_names . include? ( :updated_at ) self . created_at ||= Time . now if self . class . attribute_names . include? ( :created_at ) end | Update persistence auto - timestamp attributes |
18,646 | def get ( namespace = false , key = false , defaultValue = '' ) if namespace && key value = @config [ namespace ] [ key ] if value return value else return defaultValue end end return @config if ! @config . empty? get_config end | Returns the whole config or a specific value |
18,647 | def attachable ( options = { } ) cattr_accessor :attachment_file_prefix self . attachment_file_prefix = ( options [ :file_prefix ] || :file ) . to_s default_scope { select ( column_names . reject { | n | n == "#{attachment_file_prefix}_data" } . collect { | n | "#{table_name}.#{n}" } . join ( ',' ) ) } include Instance... | Loads the attachable methods scope and config into the model . |
18,648 | def convert ( data ) Open3 . popen3 ( command ) do | stdin , stdout , stderr | stdin . puts ( data ) stdin . close output = stdout . read error = stderr . read raise ConversionError , error unless error . empty? return output . strip end rescue Errno :: ENOENT raise NoExecutableError , "Can't find the '#{executable}' e... | Convert data between formats . |
18,649 | def map ( name , path = nil ) @locations ||= { } if name . to_sym == :root @locations [ :root ] = cleanup_paths ( "/#{path}/" ) self . class . class_eval do define_method "#{name}_path" do | * paths | cleanup_paths ( "/#{@locations[:root]}/?" ) end end else @locations [ name . to_sym ] = cleanup_paths ( path || name . ... | Write URL path method for use in HTTP methods . |
18,650 | def map_path_to ( * args ) script_name = args . shift if args . first . to_s =~ %r{ \w } path_mapped ( script_name , * locations_get_from ( * args ) ) end | Check arguments . If argument is a symbol and exist map path before setted then return path mapped by symbol name . |
18,651 | def path_mapped ( script_name , * args ) return cleanup_paths ( "/#{script_name}/#{@locations[:root]}" ) if args . empty? a = replace_symbols ( script_name , * args ) cleanup_paths ( "/#{script_name}/#{@locations[:root]}/#{a.join('/')}" ) end | Returns all paths mapped by root path in prefix . |
18,652 | def replace_symbols ( script_name , * args ) args_new = [ ] args_copy = args . clone url = args [ 0 ] . clone modifiers = args_copy [ 1 ] if modifiers . class == Hash modifiers . delete_if do | key , value | delete = url . include? ( ":" + key . to_s ) if delete url . sub! ( ( ":" + key . to_s ) , value . to_s ) end de... | Replace simbols in url for |
18,653 | def locations_get_from ( * args ) args . flatten . reject do | path | path == :root end . collect do | path | @locations [ path ] || path end end | Get paths from location maps . |
18,654 | def reserve_stream ( ** args ) next_id = @max_stream_ids [ 0 ] + 2 stream = stream ( next_id ) stream . set_state ( :reserved_local ) stream . update_dependency ( ** args ) stream end | Reserves a new stream to server push . |
18,655 | def process ( args ) parser = Parser . new ( Exec . new ( self ) ) parser . parse ( args ) PRINTER . output end | Main method of the application takes un processed ARGS and pass it to our parser to start our processing |
18,656 | def element ( label = ' ' , value = '' , type = 'text_field' , & block ) value += @template . capture ( & block ) if block_given? %{ <div class='control-group'> <label class='control-label'>#{label}</label> <div class='controls'> #{value} </div> </div> } . h... | generic container for all things form |
18,657 | def render_field ( field_name , method , options = { } , html_options = { } , & block ) case field_name when 'check_box' template = field_name else template = 'default_field' end @template . render ( :partial => "#{BootstrapBuilder.config.template_folder}/#{template}" , :locals => { :builder => self , :method => method... | Main rendering method |
18,658 | def initialize_cmd_args ( args , name_args , new_name_args ) args = args . dup args . shift ( 2 + name_args . length ) new_name_args + args end | initialize args for another knife command |
18,659 | def run_cmd ( command_class , args ) command = command_class . new ( args ) command . config [ :config_file ] = config [ :config_file ] command . configure_chef command_class . load_deps command . run command end | run another knife command |
18,660 | def resource_exists? ( relative_path ) rest . get_rest ( relative_path ) true rescue Net :: HTTPServerException => e raise unless e . response . code == '404' false end | check if resource exists |
18,661 | def check_chef_env ( chef_env_name ) return unless chef_env_name Chef :: Environment . load ( chef_env_name ) if chef_env_name rescue Net :: HTTPServerException => e raise unless e . to_s =~ / / ui . info 'Creating chef environment ' + chef_env_name chef_env = Chef :: Environment . new chef_env . name ( chef_env_name )... | make sure the chef environment exists |
18,662 | def result ( * params , & parser ) Result . new ( @client , host , path , merged_params ( * params ) , & parser ) . result end | a single result value |
18,663 | def collection ( * params , & parser ) LazyCollection . new ( @client , host , path , merged_params ( * params ) , & parser ) end | A lazy collection which fetches records on demand . |
18,664 | def merged_params ( * params ) params . reduce ( default_params ) do | merged , params | merged . merge ( params ) end end | A hash of the provided params hashes merged into the default_params . |
18,665 | def custom_template_path ( name ) config = ShopConfig . new custom_path = config . get ( 'template' , 'path' ) if File . exists? ( "#{custom_path}/#{name}" ) "#{custom_path}/#{name}" else false end end | Returns the path to the custom template if it exists |
18,666 | def template_path ( name = false ) custom_path = custom_template_path ( name ) if custom_path custom_path else path = File . expand_path File . dirname ( __FILE__ ) return "#{path}/../../templates/#{name}" if name "#{path}/../../templates" end end | Returns the path to the templates directory |
18,667 | def template ( name , datas ) file = template_path ( name ) content = File . read ( file ) datas . each do | k , v | k = "<%= #{k} %>" content = content . gsub ( k , v ) end return content end | Replace the placeholders by the variables |
18,668 | def binary = ( path ) raise ( ArgumentError , "binary doesn't exist" ) if ! File . exists? ( path ) raise ( ArgumentError , "binary isn't called \'barman\'" ) if File . basename ( path ) != 'barman' @binary = path end | Creates a new instance of CliCommand |
18,669 | def backup ( server , backup_id , opts = { } ) raise ( ArgumentError , "backup id must not be nil!" ) if backup_id . nil? opts [ :backup_id ] = backup_id return backups ( server , opts ) [ 0 ] end | Instructs barman to get information about a specific backup |
18,670 | def server ( name , opts = { } ) lines = run_barman_command ( "show-server #{name}" ) server = parse_show_server_lines ( name , lines ) lines = run_barman_command ( "check #{name}" , { :abort_on_error => false } ) parse_check_lines ( server , lines ) server . backups = backups ( server . name , opts ) if opts [ :with_b... | Instructs barman to get information about a server |
18,671 | def servers ( opts = { } ) result = Servers . new lines = run_barman_command ( "list-server" ) server_names = parse_list_server_lines ( lines ) server_names . each do | name | result << server ( name , opts ) end return result end | Instructs barman to get information about all servers |
18,672 | def wal_files ( server , backup_id ) lines = run_barman_command ( "list-files --target wal #{server} #{backup_id}" ) wal_files = parse_wal_files_list ( lines ) xlog_db = read_xlog_db ( server ) wal_files . each do | w | wal = "#{w.timeline}#{w.xlog}#{w.segment}" entry = xlog_db [ wal ] w . size = entry [ :size ] w . co... | Instructs barman to list all wal files for a specific backup id |
18,673 | def parse_list_server_lines ( lines ) result = Array . new lines . each do | l | result << l . split ( "-" ) [ 0 ] . strip end return result end | Parses lines reported by barman s list - server |
18,674 | def create_recovery_cmd_args ( opts = { } ) args = Array . new args << "--remote-ssh-command='#{opts[:remote_ssh_cmd]}'" if opts [ :remote_ssh_cmd ] args << "--target-time '#{opts[:target_time].to_s}'" if opts [ :target_time ] args << "--target-xid #{opts[:target_xid]}" if opts [ :target_xid ] args << "--exclusive" if ... | Creates an argument string for barman recovery command based on opts Hash |
18,675 | def update_node ( node_updates , merge = false ) config [ :disable_editing ] = true begin node = Chef :: Node . load ( node_updates [ 'name' ] ) env = node_updates [ 'chef_environment' ] check_chef_env ( env ) unless env == node [ 'chef_environment' ] do_node_updates ( node , node_updates , merge ) rescue Net :: HTTPSe... | Update an existing node |
18,676 | def update_node_with_values ( node , updates , merge = false ) updated = [ ] updated << 'normal' if update_attrs ( node , updates [ 'normal' ] , merge ) updated << 'run_list' if update_runlist ( node , updates [ 'run_list' ] ) if update_chef_env ( node , updates [ 'chef_environment' ] ) updated << 'chef_environment' en... | Update original node return list of updated properties . |
18,677 | def update_attrs ( node , attrs , merge = false ) return false unless attrs attrs [ 'tags' ] = node . normal . tags || [ ] original = Marshal . load ( Marshal . dump ( node . normal ) ) node . normal = if merge Chef :: Mixin :: DeepMerge . merge ( node . normal , attrs ) else attrs end original != node . normal end | Update methods all return true if an actual update is made |
18,678 | def create ( options = { } ) query = { query : { username : options [ :username ] , password : options [ :password ] , attributes : hash_to_base64_json ( options [ :attributes ] ) } } new_options = default_options_to_merge_with . merge ( query ) self . class . post ( "/#{@api_ver}/users" , new_options ) end | USER API Methods |
18,679 | def all ( read_attributes = "01" ) options = default_options_to_merge_with . merge ( { query : { full : read_attributes } } ) self . class . get ( "/#{@api_ver}/users" , options ) end | list all users TVUser . list_users |
18,680 | def load_directory! ( dir ) paths = Dir . glob ( dir ) . grep LeMeme :: IMAGE_EXTENSIONS @memes . merge! ( paths . reduce ( { } ) do | images , path | path = File . expand_path ( path ) name = path . split . last . sub ( LeMeme :: IMAGE_EXTENSIONS , '' ) . to_s images . merge ( name => path ) end ) end | Loads a directory into the MemeLib for template consumption Clobbers any existing templates |
18,681 | def meme ( template : nil , top : nil , bottom : nil , watermark : nil ) path = template . nil? ? @memes . values . sample : @memes [ template ] Meme . new ( path , top : top , bottom : bottom , watermark : watermark ) end | Create a meme from a template |
18,682 | def role_groups groups = [ ] user_account_class . role_groups . map { | k , v | groups << k if user_account . has_any_role? ( v ) } groups end | return list of symbols for role groups the user belongs to |
18,683 | def send ( frame ) if Frame :: Data === frame @send_buffer << frame if @send_remaining_window < frame . length if Stream === self connection . callback ( :send_deferred , self , frame ) else callback ( :send_deferred , self , frame ) end else consume_send_buffer end else send_immediately frame end end | Sends frame respecting inner - stream flow control . |
18,684 | def window_update ( wsi ) @recv_remaining_window += wsi sid = ( Stream === self ) ? self . id : 0 send_immediately Frame :: WindowUpdate . new ( sid , wsi ) end | Increases receiving window size . Sends WINDOW_UPDATE frame to the peer . |
18,685 | def add_attachment ( summary , file , ** kwargs ) @client . add_attachment ( summary , file , id , ** kwargs ) . first end | Add an attachment to the bug For the params description see the Client . add_attachment method . |
18,686 | def show closed! if @debug ary = @leds . map { | value | Rainbow ( @debug ) . color ( * to_rgb ( value ) ) } $stdout . print "\r#{ary.join}" end self end | Update the display with the data from the LED buffer . This is a noop method for the fake LEDs . |
18,687 | def []= ( num , value ) closed! if ( num < 0 || num >= @leds . length ) raise IndexError , "index #{num} is outside of LED range: 0...#{@leds.length-1}" end @leds [ num ] = to_color ( value ) end | Set the LED at position num to the provided 24 - bit RGB color value . |
18,688 | def replace ( ary ) closed! @leds . length . times do | ii | @leds [ ii ] = Integer ( ary [ ii ] ) end self end | Replace the LED colors with the 24 - bit RGB color values found in the ary . If the ary is longer than the LED string then the extra color values will be ignored . If the ary is shorter than the LED string then only the LEDS up to ary . length will be changed . |
18,689 | def fill ( * args ) closed! if block_given? @leds . fill do | ii | value = yield ( ii ) to_color ( value ) end else value = to_color ( args . shift ) @leds . fill ( value , * args ) end self end | Set the selected LEDs to the given color . The color msut be given as a 24 - bit RGB value . You can also supply a block that receives an LED index and returns a 24 - bit RGB color . |
18,690 | def each ret = Bicho . client . search_bugs ( self ) return ret . each unless block_given? ret . each { | bug | yield bug } end | Iterates through the result of the current query . |
18,691 | def method_missing ( method_name , * args ) return super unless Bicho :: SEARCH_FIELDS . map ( & :first ) . include? ( method_name ) args . each do | arg | append_query ( method_name . to_s , arg ) end self end | Create a query . |
18,692 | def append_query ( param , value ) @query_map [ param ] = [ ] unless @query_map . key? ( param ) @query_map [ param ] = [ @query_map [ param ] , value ] . flatten end | Appends a parameter to the query map |
18,693 | def method_missing ( symbol , * args ) if ( @name == 'tasks' && symbol . to_s == 'notes' ) return RTMMethodSpace . new ( "tasks.notes" , @endpoint ) else rtm_method = "rtm.#{@name}.#{symbol.to_s.rtmize}" @endpoint . call_method ( rtm_method , * args ) end end | Create an RTMMethodSpace |
18,694 | def attributes = ( attributes = { } ) attributes . each do | name , value | begin send ( "#{name}=" , value ) rescue NoMethodError => e puts "Unable to assign #{name}. No such method." end end end | Set the attributes based on the given hash |
18,695 | def start ( & block ) raise IOError , "Session already started" if @started _start if block_given? begin ret = yield ( self ) resume return ret ensure close end end self end | Creates a new HTTP client . |
18,696 | def request ( headers , body , options = { } , & block ) raise ArgumentError , ":method and :path headers are required" unless headers [ ":method" ] && headers [ ":path" ] @session . request ( headers , body , @config . merge ( options ) , & block ) end | Creates a new HTTP request . |
18,697 | def open file_name = File . join ( @db_dir , 'database.blobs' ) new_db_created = false begin if File . exist? ( file_name ) @f = File . open ( file_name , 'rb+' ) else PEROBS . log . info "New FlatFile database '#{file_name}' created" @f = File . open ( file_name , 'wb+' ) new_db_created = true end rescue IOError => e ... | Create a new FlatFile object for a database in the given path . |
18,698 | def close @space_list . close if @space_list . is_open? @index . close if @index . is_open? if @marks @marks . erase @marks = nil end if @f @f . flush @f . flock ( File :: LOCK_UN ) @f . fsync @f . close @f = nil end end | Close the flat file . This method must be called to ensure that all data is really written into the filesystem . |
18,699 | def sync begin @f . flush @f . fsync rescue IOError => e PEROBS . log . fatal "Cannot sync flat file database: #{e.message}" end @index . sync @space_list . sync end | Force outstanding data to be written to the filesystem . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.