idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
5,100 | def nested @page = Page . find_by ( id : params [ :page_id ] ) || Language . current_root_page render json : PageTreeSerializer . new ( @page , ability : current_ability , user : current_alchemy_user , elements : params [ :elements ] , full : true ) end | Returns all pages as nested json object for tree views |
5,101 | def index @elements = Element . not_nested if cannot? :manage , Alchemy :: Element @elements = @elements . accessible_by ( current_ability , :index ) end if params [ :page_id ] . present? @elements = @elements . where ( page_id : params [ :page_id ] ) end if params [ :named ] . present? @elements = @elements . named ( ... | Returns all elements as json object |
5,102 | def prefix_locale? ( locale = Language . current . code ) multi_language? && locale != :: I18n . default_locale . to_s end | Decides if the locale should be prefixed to urls |
5,103 | def module_definition_for ( name_or_params ) case name_or_params when String alchemy_modules . detect { | m | m [ 'name' ] == name_or_params } when Hash name_or_params . stringify_keys! alchemy_modules . detect do | alchemy_module | module_navi = alchemy_module . fetch ( 'navigation' , { } ) definition_from_mainnavi ( ... | Get the module definition for given module name |
5,104 | def index if can? :manage , Alchemy :: Content @contents = Content . all else @contents = Content . accessible_by ( current_ability , :index ) end if params [ :element_id ] . present? @contents = @contents . where ( element_id : params [ :element_id ] ) end render json : @contents , adapter : :json , root : :contents e... | Returns all contents as json object |
5,105 | def show if params [ :id ] @content = Content . find ( params [ :id ] ) elsif params [ :element_id ] && params [ :name ] @content = Content . find_by! ( element_id : params [ :element_id ] , name : params [ :name ] ) end authorize! :show , @content respond_with @content end | Returns a json object for content |
5,106 | def create_default_language! default_language = Alchemy :: Config . get ( :default_language ) if default_language languages . build ( name : default_language [ 'name' ] , language_code : default_language [ 'code' ] , locale : default_language [ 'code' ] , frontpage_name : default_language [ 'frontpage_name' ] , page_la... | If no languages are present create a default language based on the host app s Alchemy configuration . |
5,107 | def show_page_path_params ( page , optional_params = { } ) raise ArgumentError , 'Page is nil' if page . nil? url_params = { urlname : page . urlname } . update ( optional_params ) prefix_locale? ? url_params . update ( locale : page . language_code ) : url_params end | Returns the correct params - hash for passing to show_page_path |
5,108 | def page_redirect_url ( options = { } ) options = { locale : prefix_locale? ? @page . language_code : nil , urlname : @page . urlname } . merge ( options ) alchemy . show_page_path additional_params . merge ( options ) end | Page url with or without locale while keeping all additional params |
5,109 | def bookable ( options ) if bookable? self . booking_opts = options else class_attribute :booking_opts self . booking_opts = options class_eval do serialize :schedule , IceCube :: Schedule has_many :bookings , as : :bookable , dependent : :destroy , class_name : '::ActsAsBookable::Booking' validates_presence_of :schedu... | Make a model bookable |
5,110 | def bookable_must_be_bookable if bookable . present? && ! bookable . class . bookable? errors . add ( :bookable , T . er ( 'booking.bookable_must_be_bookable' , model : bookable . class . to_s ) ) end end | Validation method . Check if the bookable resource is actually bookable |
5,111 | def booker_must_be_booker if booker . present? && ! booker . class . booker? errors . add ( :booker , T . er ( 'booking.booker_must_be_booker' , model : booker . class . to_s ) ) end end | Validation method . Check if the booker model is actually a booker |
5,112 | def cloud_driver ( app , caps , url ) http_client = :: Selenium :: WebDriver :: Remote :: Http :: Default . new http_client . read_timeout = Howitzer . cloud_http_idle_timeout http_client . open_timeout = Howitzer . cloud_http_idle_timeout options = { url : url , desired_capabilities : :: Selenium :: WebDriver :: Remot... | Buids selenium driver for a cloud service |
5,113 | def logger! ( progname : self . class . name , target : LOG_TARGET , level : nil , debug : false ) @logger = Logger . new ( target ) . tap do | logger | level = Logger :: DEBUG if debug logger . progname = "#{self.class.name}<#{progname}>" logger . level = level || self . class . log_level || K8s :: Logging . log_level... | Use per - instance logger instead of the default per - class logger |
5,114 | def prune ( client , keep_resources : , skip_forbidden : true ) client . list_resources ( labelSelector : { @label => name } , skip_forbidden : skip_forbidden ) . sort do | a , b | if a . metadata . namespace == b . metadata . namespace 0 elsif a . metadata . namespace . nil? && ! b . metadata . namespace . nil? 1 else... | Delete all stack resources that were not applied |
5,115 | def get_resources ( resources ) resource_apis = apis ( resources . map ( & :apiVersion ) , prefetch_resources : true , skip_missing : true ) requests = resources . zip ( resource_apis ) . map { | resource , api_client | next nil unless api_client . api_resources? resource_client = api_client . client_for_resource ( res... | Returns nils for any resources that do not exist . This includes custom resources that were not yet defined . |
5,116 | def create_shipment ( origin , destination , packages , options = { } ) options = @options . merge ( options ) packages = Array ( packages ) raise Error , "Multiple packages are not supported yet." if packages . length > 1 request = build_shipment_request ( origin , destination , packages , options ) logger . debug ( r... | Get Shipping labels |
5,117 | def timestamp_from_business_day ( days ) return unless days date = DateTime . now . utc days . times do date += 1 . day date += 2 . days if date . saturday? date += 1 . day if date . sunday? end date . to_datetime end | Calculates a timestamp that corresponds a given number of business days in the future |
5,118 | def add ( package , rate = nil ) cents = Package . cents_from ( rate ) raise ArgumentError . new ( "New packages must have valid rate information since this RateEstimate has no total_price set." ) if cents . nil? and total_price . nil? @package_rates << { :package => package , :rate => cents } self end | Adds a package to this rate estimate |
5,119 | def create_shipment ( origin , destination , package , line_items = [ ] , options = { } ) request_body = build_shipment_request ( origin , destination , package , line_items , options ) response = ssl_post ( create_shipment_url ( options ) , request_body , headers ( options , SHIPMENT_MIMETYPE , SHIPMENT_MIMETYPE ) ) p... | line_items should be a list of PackageItem s |
5,120 | def batch_slice_columns ( slice_columns ) use_indexes = [ ] headers . values . each_with_index do | val , index | use_indexes << index if val . in? ( slice_columns ) end return csv_lines if use_indexes . empty? @headers = headers . to_a . values_at ( * use_indexes ) . to_h csv_lines . map! do | line | line . values_at ... | Use it when CSV file contain redundant columns |
5,121 | def has_page? ( url ) schemes = %w( http https ) if schemes . include? url . scheme u = url . dup return schemes . any? { | s | u . scheme = s ; has_key? ( u ) } end has_key? url end | Does this PageStore contain the specified URL? HTTP and HTTPS versions of a URL are considered to be the same page . |
5,122 | def run process_options @urls . delete_if { | url | ! visit_link? ( url ) } return if @urls . empty? link_queue = Queue . new page_queue = Queue . new @opts [ :threads ] . times do @tentacles << Thread . new { Tentacle . new ( link_queue , page_queue , @opts ) . run } end @urls . each { | url | link_queue . enq ( url )... | Perform the crawl |
5,123 | def freeze_options @opts . freeze @opts . each_key { | key | @opts [ key ] . freeze } @opts [ :cookies ] . each_key { | key | @opts [ :cookies ] [ key ] . freeze } rescue nil end | Freeze the opts Hash so that no options can be modified once the crawl begins |
5,124 | def allowed? ( to_url , from_url ) to_url . host . nil? || ( to_url . host == from_url . host ) end | Allowed to connect to the requested url? |
5,125 | def run loop do link , referer , depth = @link_queue . deq break if link == :END @http . fetch_pages ( link , referer , depth ) . each { | page | @page_queue << page } delay end end | Create a new Tentacle |
5,126 | def apply_filter? ( records , options = { } ) params [ :filter ] . present? && records . respond_to? ( :where ) && ( options [ :filter ] . nil? || options [ :filter ] ) end | Check whether default filters should be applied . |
5,127 | def filter_params @_filter_params ||= case params [ :filter ] when Hash , ActionController :: Parameters default_filters . each_with_object ( { } ) do | field , hash | unformatted_field = @request . unformat_key ( field ) hash [ unformatted_field ] = params [ :filter ] [ field ] end end end | Build a Hash with the default filters . |
5,128 | def sort_params @_sort_params ||= if params [ :sort ] . present? params [ :sort ] . split ( ',' ) . each_with_object ( { } ) do | field , hash | unformatted_field = @request . unformat_key ( field ) desc , field = unformatted_field . to_s . match ( / \w /i ) [ 1 .. 2 ] hash [ field . to_sym ] = desc . present? ? :desc ... | Build a Hash with the sort criteria . |
5,129 | def setup_request @request ||= JSONAPI :: RequestParser . new ( params , context : context , key_formatter : key_formatter , server_error_callbacks : ( self . class . server_error_callbacks || [ ] ) ) end | Instantiate the request object . |
5,130 | def build_params_for ( param_type ) return { } if @request . operations . empty? keys = %i( attributes to_one to_many ) operation = @request . operations . find { | e | e . options [ :data ] . keys & keys == keys } if operation . nil? { } elsif param_type == :relationship operation . options [ :data ] . values_at ( :to... | Extract params from request and build a Hash with params for either the main resource or relationships . |
5,131 | def initialize_copy ( other ) @trigger_group = other @triggers = nil @chained_calls = [ ] @errors = [ ] @warnings = [ ] @options = @options . dup @options . delete ( :name ) @options . each do | key , value | @options [ key ] = value . dup rescue value end end | after delayed interpolation |
5,132 | def typecast_attribute ( typecaster , value ) raise ArgumentError , "a typecaster must be given" unless typecaster . respond_to? ( :call ) return value if value . nil? typecaster . call ( value ) end | Typecasts a value using a Class |
5,133 | def inspect attribute_descriptions = attributes . sort . map { | key , value | "#{key}: #{value.inspect}" } . join ( ", " ) separator = " " unless attribute_descriptions . empty? "#<#{self.class.name}#{separator}#{attribute_descriptions}>" end | Returns the class name plus its attributes |
5,134 | def inspect options_description = options . map { | key , value | "#{key.inspect} => #{value.inspect}" } . sort . join ( ", " ) inspected_options = ", #{options_description}" unless options_description . empty? "attribute :#{name}#{inspected_options}" end | Creates a new AttributeDefinition |
5,135 | def apply_defaults ( defaults = attribute_defaults ) @attributes ||= { } defaults . each do | name , value | @attributes [ name ] = value unless @attributes . has_key? name end end | Applies the attribute defaults |
5,136 | def _attribute_default ( attribute_name ) default = self . class . attributes [ attribute_name ] [ :default ] case when default . respond_to? ( :call ) then instance_exec ( & default ) when default . duplicable? then default . dup else default end end | Calculates an attribute default |
5,137 | def sanitize_for_mass_assignment_with_or_without_role ( new_attributes , options ) if method ( :sanitize_for_mass_assignment ) . arity . abs > 1 sanitize_for_mass_assignment new_attributes , options [ :as ] || :default else sanitize_for_mass_assignment new_attributes end end | Rails 3 . 0 and 4 . 0 do not take a role argument for the sanitizer |
5,138 | def user_for_draftsman return unless defined? ( current_user ) ActiveSupport :: VERSION :: MAJOR >= 4 ? current_user . try! ( :id ) : current_user . try ( :id ) rescue NoMethodError current_user end | Returns the user who is responsible for any changes that occur . By default this calls current_user and returns the result . |
5,139 | def set_exception ( worker_name , exc_or_message ) if exc_or_message . is_a? ( Exception ) self . exception = JobException . from_exception ( exc_or_message ) exception . worker_name = worker_name else build_exception ( class_name : 'RocketJob::DirmonEntryException' , message : exc_or_message , backtrace : [ ] , worker... | Set exception information for this DirmonEntry and fail it |
5,140 | def later ( pathname ) job_id = BSON :: ObjectId . new archived_file_name = archive_file ( job_id , pathname ) job = RocketJob :: Jobs :: UploadFileJob . create! ( job_class_name : job_class_name , properties : properties , description : "#{name}: #{pathname.basename}" , upload_file_name : archived_file_name . to_s , o... | Archives the file and kicks off a proxy job to upload the file . |
5,141 | def strip_whitespace self . pattern = pattern . strip unless pattern . nil? self . archive_directory = archive_directory . strip unless archive_directory . nil? end | strip whitespaces from all variables that reference paths or patterns |
5,142 | def archive_file ( job_id , pathname ) target_path = archive_pathname ( pathname ) target_path . mkpath target_file_name = target_path . join ( "#{job_id}_#{pathname.basename}" ) FileUtils . move ( pathname . to_s , target_file_name . to_s ) target_file_name . to_s end | Move the file to the archive directory |
5,143 | def job_is_a_rocket_job klass = job_class return if job_class_name . nil? || klass &. ancestors &. include? ( RocketJob :: Job ) errors . add ( :job_class_name , "Job #{job_class_name} must be defined and inherit from RocketJob::Job" ) end | Validates job_class is a Rocket Job |
5,144 | def job_has_properties klass = job_class return unless klass properties . each_pair do | k , _v | next if klass . public_method_defined? ( "#{k}=" . to_sym ) errors . add ( :properties , "Unknown Property: Attempted to set a value for #{k.inspect} which is not allowed on the job #{job_class_name}" ) end end | Does the job have all the supplied properties |
5,145 | def boot_standalone begin require 'bundler/setup' Bundler . require ( environment ) rescue LoadError nil end require 'rocketjob' begin require 'rocketjob_enterprise' rescue LoadError nil end path = log_file ? Pathname . new ( log_file ) : Pathname . pwd . join ( "log/#{environment}.log" ) path . dirname . mkpath Semant... | In a standalone environment explicitly load config files |
5,146 | def write_pidfile return unless pidfile pid = $PID File . open ( pidfile , 'w' ) { | f | f . puts ( pid ) } at_exit do File . delete ( pidfile ) if pid == $PID end end | Create a PID file if requested |
5,147 | def parse ( argv ) parser = OptionParser . new do | o | o . on ( '-n' , '--name NAME' , 'Unique Name of this server (Default: host_name:PID)' ) do | arg | @name = arg end o . on ( '-w' , '--workers COUNT' , 'Number of workers (threads) to start' ) do | arg | @workers = arg . to_i end o . on ( '-t' , '--threads COUNT' ,... | Parse command line options placing results in the corresponding instance variables |
5,148 | def run Thread . current . name = format ( 'rocketjob %03i' , id ) logger . info 'Started' until shutdown? wait = RocketJob :: Config . instance . max_poll_seconds if process_available_jobs wait = rand ( wait * 1000 ) / 1000 end break if wait_for_shutdown? ( wait ) end logger . info 'Stopping' rescue Exception => exc l... | Process jobs until it shuts down |
5,149 | def reset_filter_if_expired time = Time . now return unless ( time - @re_check_start ) > re_check_seconds @re_check_start = time self . current_filter = filter . dup if current_filter != filter end | Resets the current job filter if the relevant time interval has passed |
5,150 | def previous_time ( from = ZoTime . now ) pt = nil zt = ZoTime . new ( from . to_i - 1 , @timezone ) miny = from . year - NEXT_TIME_MAX_YEARS loop do pt = zt . dup fail RangeError . new ( "failed to reach occurrence within " + "#{NEXT_TIME_MAX_YEARS} years for '#{original}'" ) if pt . year < miny unless date_match? ( p... | Returns the previous time the cronline matched . It s like next_time but for the past . |
5,151 | def rebalance ( max_workers , stagger_start = false ) count = max_workers . to_i - living_count return 0 unless count > 0 logger . info ( "#{'Stagger ' if stagger_start}Starting #{count} workers" ) add_one count -= 1 delay = Config . instance . max_poll_seconds . to_f / max_workers count . times . each do sleep ( delay... | Add new workers to get back to the max_workers if not already at max_workers Parameters stagger_start Whether to stagger when the workers poll for work the first time . It spreads out the queue polling over the max_poll_seconds so that not all workers poll at the same time . The worker also responds faster than max_pol... |
5,152 | def export_results ( results ) CSV . open ( "job_results_#{ruby}_#{servers}s_#{workers}w_v#{version}.csv" , 'wb' ) do | csv | csv << results . first . keys results . each { | result | csv << result . values } end end | Export the Results hash to a CSV file |
5,153 | def with ( event_class : self . class , ** attributes ) if self . class != Event && ! attributes [ :type ] . nil? && attributes [ :type ] != type raise Error , 'When using typed events change the type by changing the event class.' end event_class . new ( ** to_h . merge! ( attributes ) ) end | create a new event identical to the old event except for the provided changes |
5,154 | def to_h { id : id , uuid : uuid , aggregate_id : aggregate_id , type : type , body : body , version : version , created_at : created_at , correlation_id : correlation_id , causation_id : causation_id , } end | returns a hash of the event attributes |
5,155 | def parse ( contents , filename = "" , options = { } ) @doc_processor . filename = @filename = filename parse_js_or_scss ( contents , filename , options ) . map do | docset | expand ( docset ) end . flatten . map do | docset | merge ( docset ) end end | Parses file into final docset that can be fed into Aggregator |
5,156 | def parse_js_or_scss ( contents , filename , options ) if filename =~ / \. / docs = Css :: Parser . new ( contents , options ) . parse else docs = Js :: Parser . new ( contents , options ) . parse docs = Js :: Ast . new ( docs ) . detect_all! end end | Parses the file depending on filename as JS or SCSS |
5,157 | def expand ( docset ) docset [ :comment ] = @doc_parser . parse ( docset [ :comment ] , @filename , docset [ :linenr ] ) docset [ :doc_map ] = Doc :: Map . build ( docset [ :comment ] ) docset [ :tagname ] = BaseType . detect ( docset [ :doc_map ] , docset [ :code ] ) if docset [ :tagname ] == :class @class_doc_expande... | Parses the docs detects tagname and expands class docset |
5,158 | def merge ( docset ) @doc_processor . linenr = docset [ :linenr ] docset [ :comment ] = @doc_processor . process ( docset [ :tagname ] , docset [ :doc_map ] ) docset . delete ( :doc_map ) @merger . merge ( docset , @filename , docset [ :linenr ] ) end | Merges comment and code parts of docset |
5,159 | def read ( file_name , file_contents ) fname = cache_file_name ( file_name , file_contents ) if File . exists? ( fname ) @previous_entry = fname File . open ( fname , "rb" ) { | file | Marshal :: load ( file ) } else @previous_entry = nil nil end end | Given the name and contents of a source file reads the already parsed data structure from cache . Returns nil when not found . |
5,160 | def write ( file_name , file_contents , data ) fname = cache_file_name ( file_name , file_contents ) @previous_entry = fname File . open ( fname , "wb" ) { | file | Marshal :: dump ( data , file ) } end | Writes parse data into cache under a name generated from the name and contents of a source file . |
5,161 | def write ( dir ) FileUtils . mkdir ( dir ) unless File . exists? ( dir ) each_item { | guide | write_guide ( guide , dir ) } end | Parses guides config file Writes all guides to given dir in JsonP format |
5,162 | def fix_icon ( dir ) if File . exists? ( dir + "/icon.png" ) elsif File . exists? ( dir + "/icon-lg.png" ) FileUtils . mv ( dir + "/icon-lg.png" , dir + "/icon.png" ) else FileUtils . cp ( @opts . template + "/resources/images/default-guide.png" , dir + "/icon.png" ) end end | Ensures the guide dir contains icon . png . When there isn t looks for icon - lg . png and renames it to icon . png . When neither exists copies over default icon . |
5,163 | def add_class ( cls ) old_cls = @classes [ cls [ :name ] ] if ! old_cls && @alt_names [ cls [ :name ] ] old_cls = @alt_names [ cls [ :name ] ] warn_alt_name ( cls ) end if old_cls merge_classes ( old_cls , cls ) @current_class = old_cls else @current_class = cls @classes [ cls [ :name ] ] = cls cls [ :alternateClassNam... | When class exists merge it with class node . Otherwise add as new class . |
5,164 | def merge_classes ( old , new ) [ :extends , :singleton , :private ] . each do | tag | old [ tag ] = old [ tag ] || new [ tag ] end [ :mixins , :alternateClassNames , :requires , :uses , :files ] . each do | tag | old [ tag ] = ( old [ tag ] || [ ] ) + ( new [ tag ] || [ ] ) end [ :aliases ] . each do | tag | new [ tag... | Merges new class - doc into old one . |
5,165 | def add_member ( node ) return if node [ :ignore ] if node [ :owner ] if @classes [ node [ :owner ] ] add_to_class ( @classes [ node [ :owner ] ] , node ) else add_orphan ( node ) end elsif @current_class node [ :owner ] = @current_class [ :name ] add_to_class ( @current_class , node ) else add_orphan ( node ) end end | Tries to place members into classes where they belong . |
5,166 | def insert_orphans ( cls ) members = @orphans . find_all { | node | node [ :owner ] == cls [ :name ] } members . each do | node | add_to_class ( cls , node ) @orphans . delete ( node ) end end | Inserts available orphans to class |
5,167 | def general_merge ( h , docs , code ) docs . each_pair do | key , value | h [ key ] = value unless h [ key ] end if Merger . can_be_autodetected? ( docs , code ) code . each_pair do | key , value | unless h [ key ] h [ key ] = value mark_autodetected ( h , key ) end end end end | Applies default merge algorithm to the rest of the data . |
5,168 | def merge! ( hash1 , hash2 ) hash2 . each_pair do | name , m | if m [ :hide ] if hash1 [ name ] hash1 . delete ( name ) else msg = "@hide used but #{m[:tagname]} #{m[:name]} not found in parent class" Logger . warn ( :hide , msg , m [ :files ] [ 0 ] ) end else if hash1 [ name ] store_overrides ( hash1 [ name ] , m ) en... | merges second members hash into first one |
5,169 | def store_overrides ( old , new ) if new [ :owner ] != old [ :owner ] new [ :overrides ] = [ ] unless new [ :overrides ] unless new [ :overrides ] . any? { | m | m [ :owner ] == old [ :owner ] } new [ :overrides ] << { :name => old [ :name ] , :owner => old [ :owner ] , } end end end | Invoked when merge! finds two members with the same name . New member always overrides the old but inside new we keep a list of members it overrides . Normally one member will override one other member but a member from mixin can override multiple members - although there s not a single such case in ExtJS we have to ha... |
5,170 | def filter_new_members ( cls ) members = cls . all_local_members . find_all do | m | visible? ( m ) && ( m [ :new ] || new_params? ( m ) ) end members = discard_accessors ( members ) members . sort! { | a , b | a [ :name ] <=> b [ :name ] } end | Returns all members of a class that have been marked as new or have parameters marked as new . |
5,171 | def inject! @html . each_line do | line | if line =~ / \s \/ / level = $1 . to_i original_text = $2 text = Util :: HTML . strip_tags ( original_text ) id = title_to_id ( text ) if include_to_toc? ( level ) @toc . add ( level , id , text ) end @new_html << "<h#{level} id='#{id}'>#{original_text}</h#{level}>\n" else @new... | Inserts table of contents at the top of guide HTML by looking for headings at or below the specified maximum level . |
5,172 | def internal_doc = ( doc ) @doc . merge! ( doc ) do | key , oldval , newval | if key == :members oldval . zip ( newval ) do | ms | ms [ 0 ] . merge! ( ms [ 1 ] ) end oldval else newval end end end | Sets the internal doc object . |
5,173 | def lookup ( classname ) if @relations [ classname ] @relations [ classname ] elsif @relations . ignore? ( classname ) || classname =~ / \* / Class . new ( { :name => classname } , false ) else Logger . warn ( :extend , "Class #{classname} not found" , @doc [ :files ] [ 0 ] ) Class . new ( { :name => classname } , fals... | Looks up class object by name When not found prints warning message . |
5,174 | def find_members ( query = { } ) if query [ :name ] ms = @members_index . global_by_name [ query [ :name ] ] || [ ] ms = ms . find_all { | m | m [ :owner ] == @doc [ :name ] } if query [ :local ] elsif query [ :local ] ms = @members_index . all_local else ms = @members_index . all_global end if query [ :tagname ] ms = ... | Returns list of members filtered by a query . Searches both local and inherited members . |
5,175 | def process_code ( code ) return { :tagname => code [ :tagname ] , :name => code [ :name ] ? code [ :name ] . split ( / \. / ) . last : nil , :autodetected => code [ :autodetected ] , :inheritdoc => code [ :inheritdoc ] , :static => code [ :static ] , :private => code [ :private ] , :inheritable => code [ :inheritable ... | Extracts the fields auto - detected from code that are relevant to the member type and returns a hash with them . |
5,176 | def each_item ( group = nil , & block ) group = group || @groups group . each do | item | if item [ "items" ] each_item ( item [ "items" ] , & block ) else block . call ( item ) end end end | Iterates over all items in all groups |
5,177 | def aggregate ( parsed_files ) agr = Aggregator . new parsed_files . each do | file | Logger . log ( "Aggregating" , file . filename ) agr . aggregate ( file ) end agr . result end | Aggregates parsing results sequencially |
5,178 | def pre_process ( classes_hash , opts ) Process :: IgnoredClasses . new ( classes_hash ) . process_all! Process :: GlobalMembers . new ( classes_hash , opts ) . process_all! Process :: Accessors . new ( classes_hash ) . process_all! Process :: Ext4Events . new ( classes_hash , opts ) . process_all! Process :: Enums . n... | Do all kinds of processing on the classes hash before turning it into Relations object . |
5,179 | def to_class_objects ( docs , opts ) classes = docs . map { | d | Class . new ( d ) } Relations . new ( classes , opts . external ) end | Turns all aggregated data into Class objects and places the classes inside Relations container . |
5,180 | def post_process ( relations , opts ) Process :: CircularDeps . new ( relations ) . process_all! Process :: InheritDoc . new ( relations ) . process_all! Process :: Versions . new ( relations , opts ) . process_all! Process :: ReturnValues . new ( relations ) . process_all! Process :: Fires . new ( relations ) . proces... | Do all kinds of post - processing on Relations object . |
5,181 | def split ( items , n ) if n == 1 [ items ] elsif items . length <= n Array . new ( n ) { | i | items [ i ] ? [ items [ i ] ] : [ ] } else min_max = nil min_arr = nil i = 0 while i <= items . length - n i += 1 cols = [ items [ 0 , i ] ] + split ( items [ i , items . length ] , n - 1 ) max = max_sum ( cols ) if ! min_ma... | Initialized with the name of subitems field . Splits the array of items into n chunks so that the sum of largest chunk is as small as possible . |
5,182 | def add ( level , id , text ) if level == @min_level @items << GuideTocEntry . new ( self ) @items . last . label = "#{prefix} <a href='#!/guide/#{id}'>#{text}</a>\n" else if @items . empty? @items << GuideTocEntry . new ( self ) end @items . last . add ( level - 1 , id , text ) end end | Adds entry at the corresponding heading level . |
5,183 | def add ( name ) if name =~ / \* / @patterns << make_pattern ( name ) elsif name =~ / /i WEB_APIS . each do | cls | @class_names [ cls ] = true end else @class_names [ name ] = true end end | Adds a classname or pattern to list of external classes . |
5,184 | def configure_defaults set_warning ( :all , true ) set_warning ( :link_auto , false ) set_warning ( :param_count , false ) set_warning ( :fires , false ) set_warning ( :nodoc , false ) end | Configures warnings to default settings . |
5,185 | def configure ( opts ) self . verbose = true if opts . verbose self . colors = opts . color unless opts . color . nil? begin opts . warnings . each do | w | set_warning ( w [ :type ] , w [ :enabled ] , w [ :path ] , w [ :params ] ) end rescue Warning :: WarnException => e warn ( nil , e . message ) end end | Configures the logger with command line options . |
5,186 | def warn ( type , msg , file = { } , args = [ ] ) if warning_enabled? ( type , file [ :filename ] , args ) print_warning ( msg , file [ :filename ] , file [ :linenr ] ) end return false end | Prints warning message . |
5,187 | def format ( filename = nil , line = nil ) out = "" if filename out = Util :: OS . windows? ? filename . gsub ( '/' , '\\' ) : filename if line out += ":#{line}:" end end paint ( :magenta , out ) end | Formats filename and line number for output |
5,188 | def paint ( color_name , msg ) if @colors == false || @colors == nil && ( Util :: OS . windows? || ! $stderr . tty? ) msg else COLORS [ color_name ] + msg + CLEAR end end | Helper for doing colored output in UNIX terminal |
5,189 | def add_classes ( relations ) relations . each do | cls | extract ( cls [ :doc ] ) . each_with_index do | ex , i | @examples << { :id => cls [ :name ] + "-" + i . to_s , :name => cls [ :name ] + " example #" + ( i + 1 ) . to_s , :href => '#!/api/' + cls [ :name ] , :code => ex [ :code ] , :options => ex [ :options ] , ... | Extracts inline examples from classes |
5,190 | def add_guides ( guides ) guides . each_item do | guide | extract ( guide [ :html ] ) . each_with_index do | ex , i | @examples << { :id => guide [ "name" ] + "-" + i . to_s , :name => guide [ "title" ] + " example #" + ( i + 1 ) . to_s , :href => '#!/guide/' + guide [ "name" ] , :code => ex [ :code ] , :options => ex ... | Extracts inline examples from guides |
5,191 | def extract ( html ) examples = [ ] s = StringScanner . new ( html ) while ! s . eos? do if s . check ( / / ) if s . check ( @begin_example_re ) s . scan ( @begin_example_re ) =~ @begin_example_re options = build_options_hash ( $1 ) ex = s . scan_until ( @end_example_re ) . sub ( @end_example_re , '' ) examples << { :c... | Extracts inline examples from HTML |
5,192 | def expand_comment ( docset ) groups = { :class => [ ] , :cfg => [ ] , :constructor => [ ] , } group_name = :class docset [ :comment ] . each do | tag | tagname = tag [ :tagname ] if tagname == :cfg || tagname == :constructor group_name = tagname if tagname == :cfg && ( tag [ :name ] !~ / \. / || groups [ :cfg ] . leng... | Handles old syntax where configs and constructor are part of class doc - comment . |
5,193 | def groups_to_docsets ( groups , docset ) results = [ ] results << { :tagname => :class , :type => docset [ :type ] , :comment => groups [ :class ] , :code => docset [ :code ] , :linenr => docset [ :linenr ] , } groups [ :cfg ] . each do | cfg | results << { :tagname => :cfg , :type => docset [ :type ] , :comment => cf... | Turns groups hash into list of docsets |
5,194 | def expand_code ( docset ) results = [ ] if docset [ :code ] ( docset [ :code ] [ :members ] || [ ] ) . each do | m | results << code_to_docset ( m ) unless @constructor_found && JsDuck :: Class . constructor? ( m ) end end results end | Turns auto - detected class members into docsets in their own right . |
5,195 | def load ( path ) if File . directory? ( path ) Dir [ path + "/**/*.rb" ] . each do | file | require ( file ) unless file =~ / \/ \/ \. / end else require ( path ) end end | Loads tag classes from given dir or single file . |
5,196 | def rbvmomi_connection_opts opt :host , "host" , :type => :string , :short => 'o' , :default => ENV [ 'RBVMOMI_HOST' ] opt :port , "port" , :type => :int , :short => :none , :default => ( ENV . member? ( 'RBVMOMI_PORT' ) ? ENV [ 'RBVMOMI_PORT' ] . to_i : 443 ) opt :" " , "don't use ssl" , :short => :none , :default => ... | Options used by VIM . connect |
5,197 | def reload_extensions_dir path loaded = Set . new ( typenames . select { | x | @namespace . const_defined? x } ) Dir . open ( path ) do | dir | dir . each do | file | next unless file =~ / \. / next unless loaded . member? $` file_path = File . join ( dir , file ) load file_path end end end | Reload all extensions for loaded VMODL types from the given directory |
5,198 | def leaf_keyvalue node h = { } node . children . each do | child | next unless child . element? h [ child . name ] = child . content end [ h [ 'key' ] , h [ 'value' ] ] end | XXX does the value need to be deserialized? |
5,199 | def draw_graph_paper ( width , height ) background color : 'white' grid width : 50 , height : 50 , stroke_color : '#659ae9' , stroke_width : 1.5 grid width : 200 , height : 200 , stroke_color : '#659ae9' , stroke_width : 3 , x : 50 , y : 50 ( 50 .. height ) . step ( 200 ) do | y | text str : "y=#{y}" , x : 3 , y : y - ... | Draw graph paper for samples |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.