idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
24,200 | def each_page_each_resource ( args = { } ) self . each_page ( args ) do | page | page . resources . each do | item | yield ( item ) end end end | Iterate over all resources with pagination |
24,201 | def extract_article api_response = request . get article_endpoint , token : Diffbot . token , url : @url @response = JSON . parse ( api_response . body ) end | Extracts article data through Diffbot API |
24,202 | def find_stat ( opts = { } , & block ) stats = Core :: Stat . all_available stat = if stats . size > 1 [ * opts [ :platform_defaults ] ] . map do | os_pattern , gem_name | if System . check [ :os ] [ os_pattern ] stats . select { | stat | stat . gem_name == gem_name } if stats . size > 1 raise ArgumentError , "multiple... | find s an available handler |
24,203 | def task ( options , & block ) name , params = * options raise "Couldn't create task without a name" if name . nil? raise "Couldn't create task without a block" unless block_given? task = Task . new ( name , params ) task . instance_eval ( & block ) @dag . add_vertex ( name : name , task : task ) end | Tasks and dependencies |
24,204 | def jql_query ( query ) result = adapter . jql ( query , fields : [ :description , :summary , :created , :status , :issuetype , :priority , :resolutiondate ] , max_results : @query_max_results ) JiraIssuesNavigator . new ( result . map { | i | JiraIssueMapper . new . call ( i ) } ) end | Creates new Query object and sets the maximum number of issues returned by Query |
24,205 | def compress ( path , compress_tar_file ) Mongolicious . logger . info ( "Compressing database #{path}" ) system ( "cd #{path} && tar -cpf#{compress_tar_file ? 'j' : ''} #{path}.tar.bz2 ." ) raise "Error while compressing #{path}" if $? . to_i != 0 FileUtils . rm_rf ( path ) return "#{path}.tar.bz2" end | Initialize a ne Filesystem object . |
24,206 | def cleanup_tar_file ( path ) Mongolicious . logger . info ( "Cleaning up local path #{path}" ) begin File . delete ( path ) rescue => exception Mongolicious . logger . error ( "Error trying to delete: #{path}" ) Mongolicious . logger . info ( exception . message ) end end | Remove dump from tmp path . |
24,207 | def cleanup_parts ( file_parts ) Mongolicious . logger . info ( "Cleaning up file parts." ) if file_parts file_parts . each do | part | Mongolicious . logger . info ( "Deleting part: #{part}" ) begin File . delete ( part ) rescue => exception Mongolicious . logger . error ( "Error trying to delete part: #{part}" ) Mong... | Remove all the bzip parts |
24,208 | def validate_code redeem_code = DealRedemptions :: RedeemCode . find_by_code ( params [ :code ] ) if redeem_code @redeem = redeem_code . validate_code ( params ) else @redeem = false end end | Validate valid redemption codes |
24,209 | def define_request_level ( name , & block ) level = RequestLevel . new ( name , self ) level . instance_eval & block @levels ||= { } @levels [ name ] = level end | Define a request level for this class Takes a name and a block which defined the request level |
24,210 | def find_hash ( id , options = { } ) options . assert_valid_keys ( :request_level ) level = find_level ( options [ :request_level ] ) record = self . find ( id , :select => level . select_field . join ( ', ' ) , :include => level . include_field ) level . receive record end | Find a single element and load it at the given request level |
24,211 | def find_level ( name = nil ) @levels ||= { } level = name . nil? ? load_default_request_level : @levels [ name . to_sym ] level = superclass . find_level ( name ) and @levels [ name . to_sym ] = level if level . nil? && superclass . present? raise NoSuchRequestLevelError . new ( name , self . name ) if level . nil? le... | Find a given level by name and return the request level |
24,212 | def use_reaction ( opts = { } ) raise RuntimeError , 'Already using Reaction.' if Reaction . client opts = use_reaction_defaults opts EM . next_tick { faye = Faye :: Client . new ( opts [ :at ] + '/bayeux' ) signer = Reaction :: Client :: Signer . new opts [ :key ] faye . add_extension signer Reaction . client = Reacti... | Uses an external reaction server . |
24,213 | def upload_files files_to_upload = local_compiled_assets . reject { | f | exists_on_remote? ( f ) } files_to_upload . each do | asset | upload_file ( asset ) end end | Upload all new files to the bucket |
24,214 | def upload_file ( f ) full_file_path = File . join ( File . dirname ( @manifest . dir ) , f ) one_year = 31557600 mime = Rack :: Mime . mime_type ( File . extname ( f ) ) file = { :key => f , :public => true , :content_type => mime , :cache_control => "public, max-age=#{one_year}" , :expires => CGI . rfc1123_date ( Tim... | Uploads a file to the bucket . Sets expires header to one year . If a gzipped version of the file exists and is a smaller file size |
24,215 | def __yield return if ( source = @_undies_source_stack . pop ) . nil? if source . file? instance_eval ( source . data , source . source , 1 ) else instance_eval ( & source . data ) end end | Source handling methods call this to render template source use this method in layouts to insert a layout s content source |
24,216 | def apply_options ( options ) return unless options options . each do | key , value | options [ key ] = value . call if value . kind_of? ( Proc ) end @_options ||= { } @_options . merge! options @input = setup_input_method ( options [ :input ] || @input ) @output = setup_output_method ( options [ :output ] || @output )... | Applies a new set of options . Options that are currently unset or nil will not be modified . |
24,217 | def autocomplete ( line ) return [ ] unless @line_processor result = @line_processor . autocomplete ( line , namespace ) case result when String [ result ] when nil [ ] when Array result else result . to_a end end | Runs the autocomplete method from the line processor then reformats its result to be an array . |
24,218 | def perform ( action , workitem ) @action , @workitem = action , workitem send ( action ) write_output ( '' ) run_callbacks rescue MaestroDev :: Plugin :: PluginError => e write_output ( '' ) set_error ( e . message ) rescue Exception => e write_output ( '' ) lowerstack = e . backtrace . find_index ( caller [ 0 ] ) sta... | Perform the specified action with the provided workitem . Invokes the method specified by the action parameter . |
24,219 | def handle_exception ( e ) if self . class . exception_handler_method send ( self . class . exception_handler_method , e ) elsif self . class . exception_handler_block self . class . exception_handler_block . call ( e , self ) end end | Fire supplied exception handlers if supplied otherwise do nothing |
24,220 | def save_output_value ( name , value ) set_field ( CONTEXT_OUTPUTS_META , { } ) if get_field ( CONTEXT_OUTPUTS_META ) . nil? get_field ( CONTEXT_OUTPUTS_META ) [ name ] = value end | Set a value in the context output |
24,221 | def read_output_value ( name ) if get_field ( PREVIOUS_CONTEXT_OUTPUTS_META ) . nil? set_field ( CONTEXT_OUTPUTS_META , { } ) if get_field ( CONTEXT_OUTPUTS_META ) . nil? get_field ( CONTEXT_OUTPUTS_META ) [ name ] else get_field ( PREVIOUS_CONTEXT_OUTPUTS_META ) [ name ] end end | Read a value from the context output |
24,222 | def set_waiting ( should_wait ) workitem [ WAITING_META ] = should_wait send_workitem_message rescue Exception => e Maestro . log . warn "Failed To Send Waiting Message To Server #{e.class} #{e}: #{e.backtrace.join("\n")}" ensure workitem . delete ( WAITING_META ) unless should_wait end | control Sets the current task as waiting |
24,223 | def cancel workitem [ CANCEL_META ] = true send_workitem_message rescue Exception => e Maestro . log . warn "Failed To Send Cancel Message To Server #{e.class} #{e}: #{e.backtrace.join("\n")}" ensure workitem . delete ( CANCEL_META ) end | Send the cancel message to the server |
24,224 | def not_needed workitem [ NOT_NEEDED ] = true send_workitem_message rescue Exception => e Maestro . log . warn "Failed To Send Not Needed Message To Server #{e.class} #{e}: #{e.backtrace.join("\n")}" ensure workitem . delete ( NOT_NEEDED ) end | Send the not needed message to the server . |
24,225 | def update_fields_in_record ( model , name_or_id , record_field , record_value ) workitem [ PERSIST_META ] = true workitem [ UPDATE_META ] = true workitem [ MODEL_META ] = model workitem [ RECORD_ID_META ] = name_or_id . to_s workitem [ RECORD_FIELD_META ] = record_field workitem [ RECORD_VALUE_META ] = record_value se... | end control persistence |
24,226 | def get_field ( field , default = nil ) value = fields [ field ] value = default if ! default . nil? && ( value . nil? || ( value . respond_to? ( :empty? ) && value . empty? ) ) value end | end persistence Get a field from workitem supporting default value |
24,227 | def add_link ( name , url ) set_field ( LINKS_META , [ ] ) if fields [ LINKS_META ] . nil? fields [ LINKS_META ] << { 'name' => name , 'url' => url } end | Adds a link to be displayed in the Maestro UI . |
24,228 | def as_int ( value , default = 0 ) res = default if value if value . is_a? ( Fixnum ) res = value elsif value . respond_to? ( :to_i ) res = value . to_i end end res end | Field Utility methods Return numeric version of value |
24,229 | def as_boolean ( value ) res = false if value if value . is_a? ( TrueClass ) || value . is_a? ( FalseClass ) res = value elsif value . is_a? ( Fixnum ) res = value != 0 elsif value . respond_to? ( :to_s ) value = value . to_s . downcase res = ( value == 't' || value == 'true' ) end end res end | Return boolean version of a value |
24,230 | def parse ( args = { } ) string_block = args . fetch ( :text , nil ) string_block = sample_string_block if ! string_block . present? result_hash = { results : count_strings ( string_block ) , text : string_block } end | AlgoService . new . parse |
24,231 | def instance_thread_local ( name , value = nil ) sc = class << self extend DSLKit :: ThreadLocal self end sc . thread_local name , value self end | Define a thread local variable for the current instance with name _name_ . If the value _value_ is given it is used to initialize the variable . |
24,232 | def instance_thread_global ( name , value = nil ) sc = class << self extend DSLKit :: ThreadGlobal self end sc . thread_global name , value self end | Define a thread global variable for the current instance with name _name_ . If the value _value_ is given it is used to initialize the variable . |
24,233 | def deflect_start ( from , id , deflector ) @@sync . synchronize do Deflect . deflecting ||= DeflectorCollection . new Deflect . deflecting . member? ( from , id ) and raise DeflectError , "#{from}##{id} is already deflected" Deflect . deflecting . add ( from , id , deflector ) from . class_eval do define_method ( id )... | Start deflecting method calls named _id_ to the _from_ class using the Deflector instance deflector . |
24,234 | def deflect ( from , id , deflector ) @@sync . synchronize do begin deflect_start ( from , id , deflector ) yield ensure deflect_stop ( from , id ) end end end | Start deflecting method calls named _id_ to the _from_ class using the Deflector instance deflector . After that yield to the given block and stop deflecting again . |
24,235 | def deflect_stop ( from , id ) @@sync . synchronize do Deflect . deflecting . delete ( from , id ) or raise DeflectError , "#{from}##{id} is not deflected from" from . instance_eval { remove_method id } end end | Stop deflection method calls named _id_ to class _from_ . |
24,236 | def method_missing ( id , * a , & b ) unless method_missing_delegator . nil? method_missing_delegator . __send__ ( id , * a , & b ) else super end end | Delegates all missing method calls to _method_missing_delegator_ if this attribute has been set . Otherwise it will call super . |
24,237 | def subject if instance_variable_defined? ( :@subject ) @subject else rdf_node = Redland . librdf_statement_get_subject ( rdf_statement ) @subject = rdf_node . null? ? nil : Node . new ( rdf_node ) end end | Create an RDF statement . |
24,238 | def predicate if instance_variable_defined? ( :@predicate ) @predicate else rdf_node = Redland . librdf_statement_get_predicate ( rdf_statement ) @predicate = rdf_node . null? ? nil : Node . new ( rdf_node ) end end | Predicate of the statement . |
24,239 | def object if instance_variable_defined? ( :@object ) @object else rdf_node = Redland . librdf_statement_get_object ( rdf_statement ) @object = rdf_node . null? ? nil : Node . new ( rdf_node ) end end | Object of the statement . |
24,240 | def rdf_node_from ( source ) case source when NilClass nil when Node Redland . librdf_new_node_from_node ( source . rdf_node ) else Redland . librdf_new_node_from_node ( Node . new ( source ) . rdf_node ) end end | Create a Node from the source and get its rdf_node or return nil |
24,241 | def run ( instruction ) @inst = instruction measurements = [ ] if @inst . respond_to? :pre_hooks measurements << Benchmark . measure ( 'pre build:' ) do @inst . pre_hooks . each ( & :call ) end end measurements << Benchmark . measure ( 'process rows:' ) do @inst . options [ :parallel ] ? pprocess_rows : process_rows en... | run the instruction |
24,242 | def report ( measurements ) width = measurements . max_by { | m | m . label . size } . label . size + 1 puts "#{' ' * width}#{Benchmark::CAPTION}" measurements . each do | m | puts "#{m.label.to_s.ljust width} #{m}" end end | output benchmark results |
24,243 | def process ( row ) @inst . tweakers . each do | tweaker | row = tweaker . tweak row return nil unless row end @inst . consumers . each do | consumer | consumer << row end end | tweak & consume one row |
24,244 | def pprocess_rows thread_number = [ @inst . sources . size , @inst . options [ :n_threads ] ] . min queue = Queue . new @inst . sources . each { | p | queue << p } threads = thread_number . times . map do Thread . new do begin while p = queue . pop ( true ) p . each { | row | process row } end rescue ThreadError end en... | process rows in parallel |
24,245 | def build ( consumers ) consumers . each do | consumer | consumer . build if consumer . respond_to? :build consumer . close if consumer . respond_to? :close end end | build and close consumers |
24,246 | def campaigns ( options = { } ) response = connection . get do | req | req . url "campaigns" , options end return_error_or_body ( response ) end | Get a list of all campaigns for the authenticating client . |
24,247 | def get_sender_alias puts "What is your name?" while @from_alias = gets . chomp catch :badalias do puts "Are you sure your name is #{@from_alias}? [y/n]:" while alias_confirmation = gets . chomp case alias_confirmation when 'y' return else puts "Please re-enter your name:" throw :badalias end end end end end | Get user s alias and confirm |
24,248 | def get_sender_gmail puts "Enter your gmail address:" while @from_address = gets . chomp catch :badfrom do if ValidateEmail . validate ( @from_address ) == true puts "Is your email address #{@from_address}? [y/n]:" while address_confirmation = gets . chomp case address_confirmation when 'y' return else puts "Please re-... | Get validate and confirm user s email address |
24,249 | def get_sender_password puts "Enter your password:" while @password = gets . chomp catch :badpass do puts "Are you sure your password is #{@password}? [y/n]:" while pass_confirmation = gets . chomp case pass_confirmation when 'y' return else puts "Please re-enter your password:" throw :badpass end end end end end | Get and confirm user s password |
24,250 | def get_recipient_data puts "Enter the recipient's email address:" while @to_address = gets . chomp catch :badto do if ValidateEmail . validate ( @to_address ) == true puts "Is the recipient's email address #{@to_address}? [y/n]:" while to_address_confirmation = gets . chomp case to_address_confirmation when 'y' return... | Get validate and confirm the recipient s email address . This data does not persist . |
24,251 | def send_message stored_password = @sender_info . transaction { @sender_info [ :password ] } smtp = Net :: SMTP . new ( 'smtp.gmail.com' , 587 ) smtp . enable_starttls smtp . start ( 'gmail.com' , @stored_from_address , stored_password , :login ) do smtp . send_message ( @msg , @_stored_from_address , @to_address ) end... | Open SMTP connection pass user info as arguments send message and close connection |
24,252 | def set_response ( item_class_name ) if @api_response . success? @total_count = @api_response [ "totalCount" ] @total_pages = @api_response [ "totalPages" ] @count = @api_response [ "count" ] @timestamp = @api_response [ "timestamp" ] @items = [ ] unless @api_response [ "collection" ] . nil? @api_response [ "collection... | Assuming type is json |
24,253 | def poll ( method , * args ) authorities . select { | a | a . respond_to? ( method ) } . collect { | a | [ a . send ( method , * args ) , a ] } end | Invokes the specified method with the specified arguments on all the authorities which will respond to it . |
24,254 | def publish! ( topic , subtopic , schema , partition_key , payload ) event = Event . new ( topic , subtopic , origin , schema , partition_key , payload ) raise MegaphoneInvalidEventError . new ( event . errors . join ( ', ' ) ) unless event . valid? unless logger . post ( topic , event . to_hash ) if transient_error? (... | Main entry point for apps using this library . Will default to environment for host and port settings if not passed . Note that a missing callback_handler will result in a default handler being assigned if the FluentLogger is used . |
24,255 | def run @client = JsonApiClient . new ( uri ) @client . log = log @client . header = header @client . param = parameters if param [ :concurrency ] @client . concurrency = param [ :concurrency ] . to_i end if param [ :slice ] @client . slice = param [ :slice ] . to_i end if uri =~ / \w \w / username , password = URI . p... | Execute npolar - api command |
24,256 | def enumerate ( args = { } , & block ) passed , failed = [ ] , [ ] hook = self super do | callback | if hook . condition . call ( * callback . options [ :condition_args ] ) hook . passed << callback callback . evaluate ( args [ :context ] , * args [ :args ] , & args [ :block ] ) else hook . failed << callback end end e... | enumerate over the callbacks |
24,257 | def add_image_from_rspec ( argument , example , url_path ) blob = caller . find { | i | i [ example . file_path . gsub ( / \d \. / , "" ) ] } file_with_line = blob . split ( ":" ) [ 0 , 2 ] . join ( ":" ) filename = [ example . description , argument , file_with_line , SecureRandom . hex ( 6 ) ] . join ( " " ) . gsub (... | adds image_path and metadata to our list returns a full path where the Engine should put the screenshot in |
24,258 | def get ( path , params = { } ) connection . get do | request | request . url path request . params = params end end | Get a response from the AudioVision API . Returns a Faraday Response object . |
24,259 | def read_config_file ( file ) @config_hash = YAML . load_file ( file ) @starting_path = File . expand_path ( File . split ( file ) . first ) @config_options = { } load_tags load_file_exclusions load_extension_inclusions config_options end | Parses the config file and loads the options |
24,260 | def load_file_exclusions return unless config_hash [ "Exclude Files" ] config_options [ :excluded_files ] = [ ] config_hash [ "Exclude Files" ] . each do | short_file | config_options [ :excluded_files ] << File . join ( starting_path , short_file ) end end | Adds the exclude file options to the config_options hash |
24,261 | def load_tags config_options [ :tags ] = { } return unless config_hash [ "Tags" ] config_hash [ "Tags" ] . each do | tag , due_date | unless due_date . is_a? Date raise ArgumentError , "#{due_date} is not a date" end config_options [ :tags ] [ "##{tag}" ] = DueDate . new ( due_date ) end end | Load the tags from the configuration file as DueDates |
24,262 | def columns ( table_name ) table_name = table_name . to_s @columns ||= { } @columns [ table_name ] ||= if @registration [ :columns ] . present? @registration [ :columns ] . call ( @connection , table_name ) else @connection . columns ( table_name ) end end | Returns a list of columns for the given table . |
24,263 | def primary_key ( table_name ) table_name = table_name . to_s @primary_keys ||= { } @primary_keys [ table_name ] ||= if @registration [ :primary_key ] . present? @registration [ :primary_key ] . call ( @connection , table_name ) else @connection . primary_key ( table_name ) end end | Returns the primary key for the given table . |
24,264 | def foreign_keys ( table_name ) table_name = table_name . to_s @foreign_keys ||= { } @foreign_keys [ table_name ] ||= begin if @registration [ :foreign_keys ] . present? @registration [ :foreign_keys ] . call ( @connection , table_name ) else begin @connection . foreign_keys ( table_name ) rescue :: NoMethodError , :: ... | Returns a list of foreign keys for the given table . |
24,265 | def others ( array ) array . select { | elt | not ( any? { | name | elt . kind_of? ( name ) } ) } end | Collect objects from the array excluding named objects which have the name in the set . |
24,266 | def spec_as_json json = { :name => spec . name , :version => spec . version , :manifest_version => calculate_manifest_version } json [ :description ] = spec . description if spec . description json [ :icons ] = spec . icons json [ :default_locale ] = spec . default_locale if spec . default_locale json [ :browser_action... | Return the JSON representation of the specification |
24,267 | def action_as_json ( action ) json = { } json [ :default_title ] = action . title if action . title json [ :default_icon ] = action . icon if action . icon json [ :default_popup ] = action . popup if action . popup json end | Return the manifest representation of a page or browser action |
24,268 | def packaged_app_as_json app = spec . packaged_app json = { :local_path => app . page } unless app . container . nil? json [ :container ] = app . container if app . container == 'panel' json [ :width ] = app . width json [ :height ] = app . height end end { :launch => json } end | Return the manifest representation of a packaged app |
24,269 | def content_scripts_as_json spec . content_scripts . map do | cs | cs_json = { :matches => cs . include_patterns } cs_json [ :exclude_matches ] = cs . exclude_patterns unless cs . exclude_patterns . empty? cs_json [ :run_at ] = cs . run_at if cs . run_at cs_json [ :all_frames ] = cs . all_frames unless cs . all_frames ... | Return the manifest representation of the content scripts if any |
24,270 | def web_intents_as_json spec . web_intents . map do | wi | { :action => wi . action , :title => wi . title , :href => wi . href , :types => wi . types , :disposition => wi . disposition } end end | Return the manifest representation of handled web intents if any |
24,271 | def canonical_write ( str ) rfc822msg = "From: #{@from}\n" rfc822msg << "To: #{@to.join(",")}\n" rfc822msg << "Subject: #{@subject}\n" rfc822msg << "Date: #{Time.new.rfc822}\n" rfc822msg << "Message-Id: <#{"%.8f" % Time.now.to_f}@#{@domain}>\n\n" rfc822msg = rfc822msg . force_encoding ( encoding ) if encoding and rfc82... | This method is called by the buffering code when messages need to be sent out as an email . |
24,272 | def click ( selector , find_by : :link_text ) sleep Random . new . rand ( 1 .. 2 ) with_frame do @driver . find_element ( find_by , selector ) . click end sleep Random . new . rand ( 1 .. 2 ) end | The following methods are utility methods for SeleniumStandaloneDsl - DSL . You can easily handle driver with this DSL . |
24,273 | def replace_blog_image_tags @resaving = true self . body . gsub! ( / / ) do | image_tag | random_id , size = image_tag . scan ( / / ) . flatten new_id = random_id matching_image = self . blog_images . reject { | bi | ! bi . random_id || bi . random_id != random_id } . first if matching_image new_id = matching_image . i... | For images that haven t been uploaded yet they get a random image id with upload infront of it . We replace those with their new image id |
24,274 | def incomplete_tasks incomplete = [ ] categories . each { | c | incomplete << c if c . incomplete? } incomplete . sort_by { | c | [ - c . percent_incomplete , - c . total_min_incomplete ] } end | Returns an array of incomplete tasks . This array is sorted first by percentage incomplete then by total number of minutes incomplete . |
24,275 | def category_ids ( entries ) category_ids = [ ] entries . each do | day , tasks | category_ids += tasks . keys end category_ids . uniq end | Finds all unique category ids in a log or a schedule |
24,276 | def combine_diffs ( diff_one , diff_two ) Hash . new { | hash , key | hash [ key ] = [ [ ] , [ ] ] } . tap do | combined_diff | diff_one . each do | change | combined_diff [ change . old_position ] . first << change end diff_two . each do | change | combined_diff [ change . old_position ] . last << change end end end | Group changes by their old index . |
24,277 | def children_values ( name = nil ) children_values = [ ] each_child ( false , name ) { | child | case child . values . size when 0 children_values << nil when 1 children_values << child . value else children_values << child . values end } return children_values end | Returns the values of all the children with the given + name + . If the child has more than one value all the values will be added as an array . If the child has no value + nil + will be added . The search is not recursive . |
24,278 | def each_child ( recursive = false , namespace = nil , name = :DEFAULT , & block ) if name == :DEFAULT name = namespace namespace = nil end @children . each do | child | if ( name . nil? or child . name == name ) and ( namespace . nil? or child . namespace == namespace ) yield child end child . children ( recursive , n... | Enumerates the children + Tag + s of this Tag and calls the given block providing it the child as parameter . |
24,279 | def remove_value ( v ) index = @values . index ( v ) if index return ! @values . delete_at ( index ) . nil? else return false end end | Removes the first occurence of the specified value from this Tag . |
24,280 | def has_attribute? ( namespace = nil , key = nil ) namespace , key = to_nns namespace , key if namespace or key attributes = @attributesByNamespace [ namespace ] return attributes . nil? ? false : attributes . has_key? ( key ) else attributes { return true } return false end end | Indicates whether there is at least an attribute in this Tag . has_attribute? |
24,281 | def each_attribute ( namespace = nil , & block ) if namespace . nil? @attributesByNamespace . each_key { | a_namespace | each_attribute ( a_namespace , & block ) } else attributes = @attributesByNamespace [ namespace ] unless attributes . nil? attributes . each_pair do | key , value | yield namespace , key , value end ... | Enumerates the attributes for the specified + namespace + . Enumerates all the attributes by default . |
24,282 | def namespace = ( a_namespace ) a_namespace = a_namespace . to_s SDL4R . validate_identifier ( a_namespace ) unless a_namespace . empty? @namespace = a_namespace end | The namespace to set . + nil + will be coerced to the empty string . |
24,283 | def read ( input ) if input . is_a? String read_from_io ( true ) { StringIO . new ( input ) } elsif input . is_a? Pathname read_from_io ( true ) { input . open ( "r:UTF-8" ) } elsif input . is_a? URI read_from_io ( true ) { input . open } else read_from_io ( false ) { input } end return self end | Adds all the tags specified in the given IO String Pathname or URI to this Tag . |
24,284 | def read_from_io ( close_io ) io = yield begin Parser . new ( io ) . parse . each do | tag | add_child ( tag ) end ensure if close_io io . close rescue IOError end end end | Reads and parses the + io + returned by the specified block and closes this + io + if + close_io + is true . |
24,285 | def children_to_string ( line_prefix = "" , s = "" ) @children . each do | child | s << child . to_string ( line_prefix ) << $/ end return s end | Returns a string representation of the children tags . |
24,286 | def list_occurrences ( from , direction = :forward , & block ) raise ArgumentError , "From #{from} not matching the rule #{@rule} and start time #{@start_time}" unless @rule . match? ( from , @start_time ) results = [ ] n , current = init_loop ( from , direction ) loop do return results unless ( current >= @start_time ... | yields valid occurrences return false from the block to stop |
24,287 | def add_member ( number ) pnum = number . to_i raise "'#{number}' is not a valid as a team member player number" if pnum == 0 && ! number . to_s . match ( / \d / ) raise "can't add duplicate player number #{pnum} to team '#{@name}'" if @members . include? ( pnum ) @members . push ( pnum ) end | Add a team member referenced by any integer . |
24,288 | def renumber ( map ) @members . each_with_index do | pnum , index | raise "player number #{pnum} not found in renumbering hash" unless map [ pnum ] @members [ index ] = map [ pnum ] end self end | Renumber the players according to the supplied hash . Return self . |
24,289 | def define_on_distro_release ( distro , release , name , version = nil ) distro_releases [ [ distro , release ] ] << [ name , version ] end | Define the package name and an optional version constraint for a distribution release |
24,290 | def set_httparty_options ( options = { } ) if options [ :ssl_ca_file ] ssl_ca_file opts [ :ssl_ca_file ] if options [ :pem_cert_pass ] pem File . read ( options [ :pem_cert ] ) , options [ :pem_cert_pass ] else pem File . read ( options [ :pem_cert ] ) end end end | Set HTTParty params that we need to set after initialize is called These params come from |
24,291 | def granulate ( options = { } ) @request_data = Hash . new if options [ :doc_link ] insert_download_data options else file_data = { :doc => options [ :file ] , :filename => options [ :filename ] } @request_data . merge! file_data end insert_callback_data options request = prepare_request :POST , @request_data . to_json... | Send a document be granulated by a nsi . cloudooo node |
24,292 | def add_write ( key , value , binary = false ) if ( @is_commit ) raise RuntimeError . new ( 'No further request supported after a commit!' ) end @requests << { 'write' => { key => JSONConnection . encode_value ( value , binary ) } } self end | Adds a write operation to the request list . |
24,293 | def add_add_del_on_list ( key , to_add , to_remove ) if ( @is_commit ) raise RuntimeError . new ( 'No further request supported after a commit!' ) end @requests << { 'add_del_on_list' => { 'key' => key , 'add' => to_add , 'del' => to_remove } } self end | Adds a add_del_on_list operation to the request list . |
24,294 | def allow_or_reject my_rejection_url = main_app . url_for ( { host : Handcart :: DomainConstraint . default_constraint . domain , controller : @rejection_url . split ( "#" ) . first , action : @rejection_url . split ( "#" ) . last , trailing_slash : false , } ) if current_handcart . respond_to? ( :enable_ip_blocking? )... | Don t allow unauthorized or blacklisted foreign IP addresses to hit what we assume is the session controller for the franchisee . |
24,295 | def copy ( destination : site . path , mirror : false ) fail 'Must specify a destination' if destination . nil? exclude = options [ :copy_exclude ] exclude . concat config [ :persistent ] unless config [ :persistent ] . nil? Utils . copy_directory directory , destination , exclude : exclude , mirror : mirror self end | Copy the contents of the working directory . |
24,296 | def populate ( from : :auto ) return if populated fail "Cannot populate without 'site'" if site . nil? case from when :auto if site . respond_to? ( :repository ) ? site . repository : nil populate from : :repository else populate from : :source end when :repository fail "Cannot populate without 'reference'" if referenc... | Extracts the site s files from repository to the working directory . |
24,297 | def validate_config message = 'bad path in config' def validate_asset_options ( opts ) opts . each do | k , v | fail 'bad option in config' if k == :sprockets_options fail message if k == :output && ! Utils . safe_path? ( v ) end end @config [ :excludes ] . each do | v | fail message unless Utils . safe_path? v end unl... | Checks the config file for invalid settings . |
24,298 | def get ( options = { } ) lower = nil upper = nil if options [ :in ] . nil? lower = options [ :after ] . nil? ? '-inf' : coerce_time_milli ( options [ :after ] ) upper = options [ :before ] . nil? ? '+inf' : [ 0 , coerce_time_milli ( options [ :before ] ) ] . max else lower = coerce_time_milli ( options [ :in ] . begin... | Returns data points from within a given time range . |
24,299 | def record ( action , * args ) msg = '' msg << color ( ACTION_COLORS [ action ] ) msg << action_padding ( action ) + action . to_s msg << color ( :clear ) msg << ' ' + args . join ( ' ' ) info msg end | Record that an action has occurred . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.