idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
17,300 | def convert_response ( response ) HttpResponse . new ( response . status , response . headers , response . body ) end | Method overridden from HttpClient . |
17,301 | def clone_object ( old_object ) object = build_from ( old_object ) assign_attributes_for ( object , get_model_attributes_from ( old_object ) ) object end | clone object without associations |
17,302 | def clone_has_one ( old_object , new_object ) old_object . class . reflect_on_all_associations ( :has_one ) . each do | association | old_association = old_object . send ( association . name ) build_has_one ( new_object , association , old_association ) if build_has_one? ( old_object , association ) end new_object end | clone has_one associations |
17,303 | def clone_has_many ( old_object , new_object ) associations = old_object . class . reflect_on_all_associations ( :has_many ) . select { | a | ! a . options . keys . include? ( :through ) } associations . each do | association | old_object . send ( association . name ) . each do | old_association | new_object . send ( a... | clone has_many associations |
17,304 | def text assert_exists tn = @element . node_name . downcase case tn when 'input' @element . get_attribute ( :value ) when 'button' @element . text else raise Exception :: Error , "unknown tag name for button: #{tn}" end end | Returns the text of the button . |
17,305 | def intraday_activity_time_series ( resource : nil , start_date : nil , end_date : nil , detail_level : nil , start_time : nil , end_time : nil ) resource = resource . to_sym unless %i[ calories steps distance floors elevation ] . include? ( resource ) raise FitgemOauth2 :: InvalidArgumentError , 'Must specify resource... | retrieves intraday activity time series . |
17,306 | def activity_list ( date , sort , limit ) date_param = format_date ( date ) if sort == "asc" date_param = "afterDate=#{date_param}" elsif sort == "desc" date_param = "beforeDate=#{date_param}" else raise FitgemOauth2 :: InvalidArgumentError , "sort can either be asc or desc" end get_call ( "user/#{user_id}/activities/l... | retrieves activity list for the user |
17,307 | def update_activity_goals ( period , params ) unless period && %w( daily weekly ) . include? ( period ) raise FitgemOauth2 :: InvalidArgumentError , "Goal period should either be 'daily' or 'weekly'" end post_call ( "user/#{user_id}/activities/goals/#{period}.json" , params ) end | update activity goals |
17,308 | def sleep_time_series ( resource : nil , start_date : nil , end_date : nil , period : nil ) unless start_date raise FitgemOauth2 :: InvalidArgumentError , 'Start date not provided.' end unless resource && SLEEP_RESOURCES . include? ( resource ) raise FitgemOauth2 :: InvalidArgumentError , "Invalid resource: #{resource}... | retrieve time series data for sleep |
17,309 | def text assert_exists attribute = [ :label , :text ] . find { | a | attribute? a } if attribute @element . get_attribute ( attribute ) else @element . text end end | Returns the text of option . |
17,310 | def style ( property = nil ) assert_exists styles = attribute_value ( 'style' ) . to_s . strip if property properties = Hash [ styles . downcase . split ( ";" ) . map { | p | p . split ( ":" ) . map ( & :strip ) } ] properties [ property ] else styles end end | Returns given style property of this element . |
17,311 | def parent assert_exists e = @element . parent if e . kind_of? ( Nokogiri :: XML :: Element ) WatirNokogiri . element_class_for ( e . node_name . downcase ) . new ( @parent , :element => e ) end end | Returns parent element of current element . |
17,312 | def to_hash ( val ) if @options [ :humidity ] then return { "humidity" => val . humidity } end if @options [ :unit ] == :c then if @options [ :temperature ] then return { "temperature" => val . temp } else return { "temperature" => val . temp , "humidity" => val . humidity } end else if @options [ :temperature ] then r... | Convert to sensor reading to hash |
17,313 | def print ( val ) if @options [ :humidity ] then puts sprintf ( "Humidity: %.2f%%" , val . humidity ) return end if @options [ :unit ] == :c then if @options [ :temperature ] then puts sprintf ( "Temperature: %.2f C" , val . temp ) else puts sprintf ( "Temperature: %.2f C Humidity: %.2f%%" , val . temp , val . humidity... | Print to stdout taking the various output options into account |
17,314 | def cell ( * args ) cell = TableCell . new ( self , extract_selector ( args ) . merge ( :tag_name => / / ) ) cell . locator_class = ChildCellLocator cell end | Returns table cell . |
17,315 | def cells ( * args ) cells = TableCellCollection . new ( self , extract_selector ( args ) . merge ( :tag_name => / / ) ) cells . locator_class = ChildCellLocator cells end | Returns table cells collection . |
17,316 | def to_hash hash = { } instance_variables . each do | name | value = instance_variable_get ( name ) next if value . nil? name = name [ 1 .. - 1 ] key = self . class . names . key? ( name ) ? self . class . names [ name ] : name if value . instance_of? Array hash [ key ] = value . map { | v | v . is_a? ( BaseModel ) ? v... | Returns a Hash representation of the current object . |
17,317 | def goto ( file_path ) html = File . read ( file_path ) @driver = Nokogiri :: HTML . parse ( html ) end | Reads the given file as HTML . |
17,318 | def run @wants . each do | want | @haves . each do | have | import ( have ) retime ( have , want ) cull ( have ) group ( have ) want . subtitles += have . subtitles . clone end polish ( want ) export ( want ) end return true rescue AbortJob return false end | Starts a new job . |
17,319 | def cull ( have ) have . subtitles . reject! { | subtitle | subtitle [ :end ] < 0 } have . subtitles . each do | subtitle | subtitle [ :start ] = 0 if subtitle [ :start ] < 0 end end | Cleans out subtitles that fell out of the usable time range |
17,320 | def retime_by_framerate ( have , want ) ratio = want . fps . to_f / have . fps . to_f have . subtitles . each do | subtitle | subtitle [ :start ] *= ratio subtitle [ :end ] *= ratio end end | Rescales timecodes based on two differing framerates . |
17,321 | def get ( query_url , headers : { } ) HttpRequest . new ( HttpMethodEnum :: GET , query_url , headers : headers ) end | Get a GET HttpRequest object . |
17,322 | def head ( query_url , headers : { } ) HttpRequest . new ( HttpMethodEnum :: HEAD , query_url , headers : headers ) end | Get a HEAD HttpRequest object . |
17,323 | def post ( query_url , headers : { } , parameters : { } ) HttpRequest . new ( HttpMethodEnum :: POST , query_url , headers : headers , parameters : parameters ) end | Get a POST HttpRequest object . |
17,324 | def put ( query_url , headers : { } , parameters : { } ) HttpRequest . new ( HttpMethodEnum :: PUT , query_url , headers : headers , parameters : parameters ) end | Get a PUT HttpRequest object . |
17,325 | def patch ( query_url , headers : { } , parameters : { } ) HttpRequest . new ( HttpMethodEnum :: PATCH , query_url , headers : headers , parameters : parameters ) end | Get a PATCH HttpRequest object . |
17,326 | def delete ( query_url , headers : { } , parameters : { } ) HttpRequest . new ( HttpMethodEnum :: DELETE , query_url , headers : headers , parameters : parameters ) end | Get a DELETE HttpRequest object . |
17,327 | def log ( level , message , line_prefix = nil ) if level <= self . level indent = "%*s" % [ Capistrano :: Logger :: MAX_LEVEL , "*" * ( Capistrano :: Logger :: MAX_LEVEL - level ) ] ( RUBY_VERSION >= "1.9" ? message . lines : message ) . each do | line | if line_prefix self . class . log_with_awesome "#{indent} [#{line... | Log and do awesome things I wish there was a nicer way to do this . Hax on device . puts maybe? |
17,328 | def records_for_rebuild ( batch_size = 1000 ) transaction do if use_fast_batches? offset = 0 while ( rows = where ( [ "#{table_name}.id > ?" , offset ] ) . limit ( batch_size ) . all ) . any? offset = rows . last . id yield rows , offset end else order = "#{primary_key} ASC" 0 . step ( self . count , batch_size ) do | ... | runs across all records yielding those to be indexed when the index is rebuilt |
17,329 | def records_for_bulk_index ( ids , batch_size = 1000 ) transaction do offset = 0 ids . each_slice ( batch_size ) do | id_slice | records = where ( :id => id_slice ) . all yield where ( :id => id_slice ) . all , offset offset += batch_size end end end | yields the records with the given ids in batches of batch_size |
17,330 | def within_method_sexp ( sexp ) case sexp . first when :call recur ( sexp [ 1 ] ) when :method_add_block within_method_sexp ( sexp [ 1 ] ) when :method_add_arg recur ( sexp [ 2 ] ) within_method_sexp ( sexp [ 1 ] ) else recur ( sexp ) end end | When already handling a method call we don t need to recur on some items . |
17,331 | def enable_irb IRB :: Inspector . class_eval { unless method_defined? ( :inspect_value_with_colour ) alias_method :inspect_value_without_colour , :inspect_value def inspect_value_with_colour ( value ) Colours . colourize ( inspect_value_without_colour ( value ) ) end end alias_method :inspect_value , :inspect_value_wit... | Enable colourized IRb results . |
17,332 | def colourize ( str ) '' . tap { | res | Tokenizer . tokenize ( str . to_s ) { | token , value | res << colourize_string ( value , colours [ token ] ) } } rescue => err Brice . error ( self , __method__ , err ) str end | Colourize the results of inspect |
17,333 | def each_page ( indices ) unless block_given? enum_for ( :each_page , indices ) else indices . map { | index | yield page_cache [ index ] } end end | Iterates over the pages at the specified indices . |
17,334 | def each return enum_for ( :each ) unless block_given? index = 1 until ( ( next_page = page_cache [ index ] ) . empty? ) do yield next_page index = index + 1 end return self end | Iterates over all the pages of the query until an empty page is encountered . |
17,335 | def page_cache @page_cache ||= Hash . new { | hash , key | hash [ key ] = page ( key . to_i ) } end | The cache of previously requested pages . |
17,336 | def change_index_dir ( new_dir ) logger . debug "[#{index_name}] changing index dir to #{new_dir}" index_definition [ :index_dir ] = index_definition [ :ferret ] [ :path ] = new_dir reopen! logger . debug "[#{index_name}] index dir is now #{new_dir}" end | Switches the index to a new index directory . Used by the DRb server when switching to a new index version . |
17,337 | def read @resource_paths = Dir . chdir ( path ) do Dir [ '**/Contents.json' ] . map { | p | Pathname ( p ) + '..' } end @resources = @resource_paths . map do | path | Resource . new ( self , path ) end self end | Initialize a new file with given path |
17,338 | def build_section selected_file_refs = selected_strings_file_refs file_paths = filter_exclusions ( selected_file_refs . map ( & :path ) ) filtered_file_refs = selected_file_refs . select { | file_ref | file_paths . include? file_ref . path } rel_file_paths = filtered_file_refs . map { | p | p . real_path . relative_pat... | Build the section |
17,339 | def info_plist_paths @info_plist_paths ||= target . build_configurations . map do | config | config . build_settings [ 'INFOPLIST_FILE' ] end . compact . map { | file | Pathname ( file ) } . flatten . to_set end | Discover Info . plist files by build settings of the application target |
17,340 | def native_dev_languages @native_dev_languages ||= absolute_info_plist_paths . map do | path | begin read_plist_key ( path , :CFBundleDevelopmentRegion ) rescue ArgumentError => e warn e end end . compact . to_set end | Find the native development languages by trying to use the Localization native development region from Info . plist |
17,341 | def keys_by_file ( path ) begin strings = read_strings_file ( path ) strings . reject! { | key , _ | / / . match ( key ) } keys = Hash [ strings . map do | key , value | [ key , { value : key , comment : value . gsub ( / \r \n / , ' ' ) } ] end ] log 'Found %s keys in file %s' , keys . count , path keys rescue Argument... | Read a file and collect all its keys |
17,342 | def ferret_enabled? ( is_bulk_index = false ) @ferret_disabled . nil? && ( is_bulk_index || self . class . ferret_enabled? ) && ( aaf_configuration [ :if ] . nil? || aaf_configuration [ :if ] . call ( self ) ) end | compatibility returns true if ferret indexing is enabled for this record . |
17,343 | def removeNotificationListener ( listener , filter = nil , handback = nil ) found = false listeners . delete_if do | clistener , ( cfilter , chandback ) | v = listener == clistener && filter == cfilter && handback == chandback found = true if v v end raise javax . management . ListenerNotFoundException . new unless fou... | NotificationListener listener NotificationFilter filter Object handback |
17,344 | def [] ( name ) attribute = @server . getAttribute ( @object_name , name . to_s ) return attribute . value if attribute . kind_of? javax . management . Attribute attribute end | Get MBean attribute specified by name . If it is just a plain attribute then unwrap the attribute and just return the value . |
17,345 | def []= ( name , value ) @server . setAttribute @object_name , javax . management . Attribute . new ( name . to_s , value ) end | Set MBean attribute specified by name to value |
17,346 | def invoke ( name , * params ) op = @info . operations . find { | o | o . name == name . to_s } raise NoMethodError . new ( "No such operation #{name}" ) unless op jargs , jtypes = java_args ( op . signature , params ) @server . invoke @object_name , op . name , jargs , jtypes end | Invoke an operation . A NoMethodError will be thrown if this MBean cannot respond to the operation . |
17,347 | def java_types ( params ) return nil if params . nil? params . map { | e | e . class . java_class . name } . to_java ( :string ) end | Convert a collection of java objects to their Java class name equivalents |
17,348 | def compare_with ( apk_filepath , other_apk_filepath ) base = Apkstats :: Entity :: ApkInfo . new ( self , apk_filepath ) other = Apkstats :: Entity :: ApkInfo . new ( self , other_apk_filepath ) Apkstats :: Entity :: ApkInfoDiff . new ( base , other ) . to_h end | Compare two apk files and return results . |
17,349 | def new_section ( name , data , options = { } ) XCRes :: Section . new ( name , data , self . options . merge ( options ) ) end | Create a new + Section + . |
17,350 | def filter_exclusions file_paths file_paths . reject do | path | exclude_file_patterns . any? { | pattern | File . fnmatch ( "#{pattern}" , path ) || File . fnmatch ( "**/#{pattern}" , path ) } end end | Apply the configured exclude file patterns to a list of files |
17,351 | def find_file_refs_by_extname ( extname ) project . files . select do | file_ref | File . extname ( file_ref . path ) == extname && is_file_ref_included_in_application_target? ( file_ref ) end end | Discover all references to files with a specific extension in project which belong to a resources build phase of an application target . |
17,352 | def resources_files target . resources_build_phase . files . map do | build_file | if build_file . file_ref . is_a? ( Xcodeproj :: Project :: Object :: PBXGroup ) build_file . file_ref . recursive_children else [ build_file . file_ref ] end end . flatten . compact end | Find files in resources build phases of application targets |
17,353 | def translate sl = ShortenedUrl . where ( :unique_key => params [ :unique_key ] [ 1 .. - 1 ] ) . first if sl sl . inc ( :use_count , 1 ) head :moved_permanently , :location => sl . url else head :moved_permanently , :location => MongoidShortener . root_url end end | find the real link for the shortened link key and redirect |
17,354 | def acts_as_ferret ( options = { } ) extend ClassMethods include InstanceMethods include MoreLikeThis :: InstanceMethods if options [ :rdig ] cattr_accessor :rdig_configuration self . rdig_configuration = options [ :rdig ] require 'rdig_adapter' include ActsAsFerret :: RdigAdapter end unless included_modules . include?... | declares a class as ferret - searchable . |
17,355 | def define_to_field_method ( field , options = { } ) method_name = "#{field}_to_ferret" return if instance_methods . include? ( method_name ) aaf_configuration [ :defined_fields ] ||= { } aaf_configuration [ :defined_fields ] [ field ] = options dynamic_boost = options [ :boost ] if options [ :boost ] . is_a? ( Symbol ... | helper to defines a method which adds the given field to a ferret document instance |
17,356 | def create_dependencies task project_name = "minke#{SecureRandom.urlsafe_base64(12)}" . downcase . gsub ( / /i , '' ) network_name = ENV [ 'DOCKER_NETWORK' ] ||= "#{project_name}_default" ENV [ 'DOCKER_PROJECT' ] = project_name ENV [ 'DOCKER_NETWORK' ] = network_name logger = Minke :: Logging . create_logger ( STDOUT ,... | Creates dependencies for minke |
17,357 | def write_preview_to_file ( path ) FileUtils . mkdir_p ( File . dirname ( path ) ) File . open ( path , 'wb' ) do | out | out . write ( preview_data ) end end | Writes the preview for this slide to disk . |
17,358 | def is_valid? site_option_valid = ! site . nil? && ! site . empty? api_key_option_valid = ! api_key . nil? && ! api_key . empty? use_ssl_option_valid = ! use_ssl . nil? && ! ! use_ssl == use_ssl api_version_option_valid = ! api_version . nil? && ! api_version . empty? project_name_option_valid = ! project_name . nil? &... | Check that mandatory parameters are not nil and contain valid values |
17,359 | def ads_with_title ( title ) return enum_for ( :ads_with_title , title ) unless block_given? comparitor = if title . kind_of? ( Regexp ) lambda { | ad | ad . title =~ title } else lambda { | ad | ad . title == title } end return ads_with do | ad | if comparitor . call ( ad ) yield ad true end end end | Selects the ads with the matching title . |
17,360 | def ads_with_url ( url ) return enum_for ( :ads_with_url , url ) unless block_given? comparitor = if url . kind_of? ( Regexp ) lambda { | ad | ad . url =~ url } else lambda { | ad | ad . url == url } end return ads_with do | ad | if comparitor . call ( ad ) yield ad true end end end | Selects the ads with the matching URL . |
17,361 | def ads_with_direct_url ( direct_url ) return enum_for ( :ads_with_direct_url , direct_url ) unless block_given? comparitor = if direct_url . kind_of? ( Regexp ) lambda { | ad | ad . direct_url =~ direct_url } else lambda { | ad | ad . direct_url == direct_url } end return ads_with do | ad | if comparitor . call ( ad )... | Selects the ads with the matching direct URL . |
17,362 | def aspect_ratio path = "/tmp/rapinoe-aspect" write_preview_to_file ( path ) dimensions = FastImage . size ( path ) widescreen = ( 16 / 9.0 ) if widescreen == ( dimensions [ 0 ] / dimensions [ 1 ] . to_f ) :widescreen else :standard end end | The aspect ratio of the deck . |
17,363 | def colors return @colors if @colors path = "/tmp/rapinoe-aspect" write_preview_to_file ( path ) colors = Miro :: DominantColors . new ( path ) by_percentage = colors . by_percentage hash = { } colors . to_rgb . each_with_index do | hex , i | hash [ hex ] = by_percentage [ i ] end @colors = hash end | The top colors present in the title slide . |
17,364 | def read ( hash ) self . scale = hash . delete ( 'scale' ) . sub ( / / , '' ) . to_i unless hash [ 'scale' ] . nil? KNOWN_KEYS . each do | key | value = hash . delete ( key . to_s . dasherize ) next if value . nil? self . send "#{key}=" . to_sym , value end self . attributes = hash return self end | Initialize a new ResourceImage |
17,365 | def to_hash hash = { } hash [ 'scale' ] = "#{scale}x" unless scale . nil? ( KNOWN_KEYS - [ :scale ] ) . each do | key | value = self . send ( key ) hash [ key . to_s . dasherize ] = value . to_s unless value . nil? end attributes . each do | key , value | hash [ key . to_s ] = value end hash end | Serialize to hash |
17,366 | def add_with_class ( analyzer_class , options = { } ) analyzer = analyzer_class . new ( target , self . options . merge ( options ) ) analyzer . exclude_file_patterns = exclude_file_patterns analyzer . logger = logger self . analyzers << analyzer analyzer end | Instantiate and add an analyzer by its class . All properties will be copied to the child analyzer . |
17,367 | def post ( path , options = { } ) response = request ( :post , path , options ) response . delete ( :status ) if response . respond_to? ( :status ) response end | Make a HTTP POST request . |
17,368 | def shortened_url ( url ) raise "Only String accepted: #{url}" unless url . class == String short_url = MongoidShortener :: ShortenedUrl . generate ( url ) short_url end | generate a url from either a url string or a shortened url object |
17,369 | def ferret_index ensure_index_exists ( @ferret_index ||= Ferret :: Index :: Index . new ( index_definition [ :ferret ] ) ) . tap do | idx | idx . batch_size = index_definition [ :reindex_batch_size ] idx . logger = logger end end | The real Ferret Index instance |
17,370 | def rebuild_index models = index_definition [ :registered_models ] logger . debug "rebuild index with models: #{models.inspect}" close index = Ferret :: Index :: Index . new ( index_definition [ :ferret ] . dup . update ( :auto_flush => false , :field_infos => ActsAsFerret :: field_infos ( index_definition ) , :create ... | rebuilds the index from all records of the model classes associated with this index |
17,371 | def process_query ( query , options = { } ) return query unless String === query ferret_index . synchronize do if options [ :analyzer ] qp = Ferret :: QueryParser . new ferret_index . instance_variable_get ( '@options' ) . merge ( options ) reader = ferret_index . reader qp . fields = reader . fields unless options [ :... | Parses the given query string into a Ferret Query object . |
17,372 | def total_hits ( query , options = { } ) ferret_index . search ( process_query ( query , options ) , options ) . total_hits end | Total number of hits for the given query . |
17,373 | def highlight ( key , query , options = { } ) logger . debug ( "highlight: #{key} query: #{query}" ) options . reverse_merge! :num_excerpts => 2 , :pre_tag => '<em>' , :post_tag => '</em>' highlights = [ ] ferret_index . synchronize do doc_num = document_number ( key ) if options [ :field ] highlights << ferret_index .... | highlight search terms for the record with the given id . |
17,374 | def document_number ( key ) docnum = ferret_index . doc_number ( key ) raise "cannot determine document number for record #{key}" if docnum . nil? docnum end | retrieves the ferret document number of the record with the given key . |
17,375 | def get_app_access_token return connection_params [ :app_access_token ] if connection_params . has_key? :app_access_token @oauth = Koala :: Facebook :: OAuth . new ( connection_params [ :app_id ] , connection_params [ :app_secret ] , callback_url ) connection_params [ :app_access_token ] = @oauth . get_app_access_token... | A long - term app_access_token might be supplied on connection parameters If not we fetch a short - term one here . |
17,376 | def regions return attributes [ 'regions' ] if attributes [ 'regions' ] . present? return [ ] unless respond_to? :region_ids ESP :: Region . where ( id_in : region_ids ) end | The regions affected by this suppression . |
17,377 | def external_accounts return attributes [ 'external_accounts' ] if attributes [ 'external_accounts' ] . present? return [ ] unless respond_to? :external_account_ids ESP :: ExternalAccount . where ( id_in : external_account_ids ) end | The external accounts affected by this suppression . |
17,378 | def signatures return attributes [ 'signatures' ] if attributes [ 'signatures' ] . present? return [ ] unless respond_to? :signature_ids ESP :: Signature . where ( id_in : signature_ids ) end | The signatures being suppressed . |
17,379 | def custom_signatures return attributes [ 'custom_signatures' ] if attributes [ 'custom_signatures' ] . present? return [ ] unless respond_to? :custom_signature_ids ESP :: CustomSignature . where ( id_in : custom_signature_ids ) end | The custom signatures being suppressed . |
17,380 | def suppress ( arguments = { } ) arguments = arguments . with_indifferent_access ESP :: Suppression :: Region . create ( regions : [ code ] , external_account_ids : Array ( arguments [ :external_account_ids ] ) , reason : arguments [ :reason ] ) end | Create a suppression for this region . |
17,381 | def validate! if title . blank? raise RuntimeError , "HelpLinks must provide a string title" end file_configured = ( slug . present? && markdown_file . present? ) link_configured = link_to . present? unless file_configured || link_configured raise RuntimeError , "Incomplete HelpLink config. You must provide link_to, or... | Raises RuntimeError if this HelpLink is incorrectly configured . |
17,382 | def presence ( presence = nil , status = nil , priority = nil ) @config [ :presence ] = presence @config [ :status ] = status @config [ :priority ] = priority status_message = Presence . new ( presence , status , priority ) @jabber . send! ( status_message ) if @jabber . connected? end | Sets the bot presence status message and priority . |
17,383 | def add_command_alias ( command_name , alias_command , callback ) original_command = @commands [ :meta ] [ command_name ] original_command [ :syntax ] << alias_command [ :syntax ] alias_name = command_name ( alias_command [ :syntax ] ) alias_command [ :is_public ] = original_command [ :is_public ] add_command_meta ( al... | Add a command alias for the given original + command_name + |
17,384 | def add_command_meta ( name , command , is_alias = false ) syntax = command [ :syntax ] @commands [ :meta ] [ name ] = { :syntax => syntax . is_a? ( Array ) ? syntax : [ syntax ] , :description => command [ :description ] , :is_public => command [ :is_public ] || false , :is_alias => is_alias } end | Add a command meta |
17,385 | def help_message ( sender , command_name ) if command_name . nil? || command_name . length == 0 help_message = "I understand the following commands:\n\n" @commands [ :meta ] . sort . each do | command | command = command [ 1 ] if ! command [ :is_alias ] && ( command [ :is_public ] || master? ( sender ) ) command [ :syn... | Returns the default help message describing the bot s command repertoire . Commands are sorted alphabetically by name and are displayed according to the bot s and the commands s _public_ attribute . |
17,386 | def start_listener_thread listener_thread = Thread . new do loop do if @jabber . received_messages? @jabber . received_messages do | message | sender = message . from . to_s . sub ( / \/ / , '' ) if message . type == :chat parse_thread = Thread . new do parse_command ( sender , message . body ) end parse_thread . join ... | Creates a new Thread dedicated to listening for incoming chat messages . When a chat message is received the bot checks if the sender is its master . If so it is tested for the presence commands and processed accordingly . If the bot itself or the command issued is not made public a message sent by anyone other than th... |
17,387 | def prepare_request ( command , extension = nil ) cmd = EPP :: Requests :: Command . new ( req_tid , command , extension ) EPP :: Request . new ( cmd ) end | Send request to server |
17,388 | def connection @connection_errors = [ ] addrinfo . each do | _ , port , _ , addr , _ , _ , _ | retried = false begin @conn = TCPSocket . new ( addr , port ) rescue Errno :: EINVAL => e if retried message = e . message . split ( " - " ) [ 1 ] @connection_errors << Errno :: EINVAL . new ( "#{message}: TCPSocket.new(#{add... | EPP Server Connection |
17,389 | def send_frame ( xml ) xml = xml . to_s if xml . kind_of? ( Request ) @sock . write ( [ xml . size + HEADER_LEN ] . pack ( "N" ) + xml ) end | Send XML frame |
17,390 | def recv_frame header = @sock . read ( HEADER_LEN ) if header . nil? && @sock . eof? raise ServerError , "Connection terminated by remote host" elsif header . nil? raise ServerError , "Failed to read header from remote host" else len = header . unpack ( 'N' ) [ 0 ] raise ServerError , "Bad frame header from server, sho... | Receive XML frame |
17,391 | def render ( document ) if Tolaria . config . markdown_renderer . nil? return simple_format ( document ) else @markdown_renderer ||= Tolaria . config . markdown_renderer . constantize return @markdown_renderer . render ( document ) end end | Calls the configured Markdown renderer if none exists then uses simple_format to return more than nothing . |
17,392 | def base_sha default_branch = client . repo ( repo ) [ :default_branch ] branches . find { | branch | branch [ :name ] == default_branch } [ :commit ] [ :sha ] end | Head SHA of default branch used for creating new branches |
17,393 | def patch_branch num = 1 branch_name = form_data [ 'title' ] . parameterize return branch_name unless branch_exists? ( branch_name ) branch = "#{branch_name}-#{num}" while branch_exists? ( branch ) num += 1 branch = "#{branch_name}-#{num}" end branch end | Name of branch to submit pull request from Starts with patch - 1 and keeps going until it finds one not taken |
17,394 | def create_pull_request unless uploads . empty? branch = patch_branch create_branch ( branch ) uploads . each do | key , upload | client . create_contents ( repo , upload [ :filename ] , "Create #{upload[:filename]}" , branch : branch , file : upload [ :tempfile ] ) session [ "file_#{key}" ] = nil end end pr = client .... | Create a pull request with the form contents |
17,395 | def run ( cmd ) cmd = @before_run_block . call ( cmd ) if @before_run_block return false unless cmd say "!txtgrn!> #{cmd}" unless Runfile . quiet system cmd @after_run_block . call ( cmd ) if @after_run_block end | Run a command wait until it is done and continue |
17,396 | def run! ( cmd ) cmd = @before_run_block . call ( cmd ) if @before_run_block return false unless cmd say "!txtgrn!> #{cmd}" unless Runfile . quiet exec cmd end | Run a command wait until it is done then exit |
17,397 | def run_bg ( cmd , pid : nil , log : '/dev/null' ) cmd = @before_run_block . call ( cmd ) if @before_run_block return false unless cmd full_cmd = "exec #{cmd} >#{log} 2>&1" say "!txtgrn!> #{full_cmd}" unless Runfile . quiet process = IO . popen "exec #{cmd} >#{log} 2>&1" File . write pidfile ( pid ) , process . pid if ... | Run a command in the background optionally log to a log file and save the process ID in a pid file |
17,398 | def stop_bg ( pid ) file = pidfile ( pid ) if File . exist? file pid = File . read file File . delete file run "kill -s TERM #{pid}" else say "!txtred!PID file not found." unless Runfile . quiet end end | Stop a command started with run_bg . Provide the name of he pid file you used in run_bg |
17,399 | def start ARGV . clear IRB . setup nil IRB . conf [ :PROMPT ] = { } IRB . conf [ :IRB_NAME ] = 'espsdk' IRB . conf [ :PROMPT ] [ :ESPSDK ] = { PROMPT_I : '%N:%03n:%i> ' , PROMPT_N : '%N:%03n:%i> ' , PROMPT_S : '%N:%03n:%i%l ' , PROMPT_C : '%N:%03n:%i* ' , RETURN : "# => %s\n" } IRB . conf [ :PROMPT_MODE ] = :ESPSDK IRB... | Start a console |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.