idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
6,900 | def to_h @size_dep . depend if @attributes . nil? nil else hash = { } @attributes . each_pair do | key , value | hash [ key ] = deep_unwrap ( value ) end hash end end | Convert the model to a hash all of the way down . |
6,901 | def to_a @size_dep . depend array = [ ] Volt . run_in_mode ( :no_model_promises ) do attributes . size . times do | index | array << deep_unwrap ( self [ index ] ) end end array end | Convert the model to an array all of the way down |
6,902 | def create_new_model ( model , from_method ) if model . is_a? ( Model ) if model . buffer? fail "The #{from_method} does not take a buffer. Call .save! on buffer's to persist them." end model . options = @options . merge ( parent : self , path : @options [ :path ] + [ :[] ] ) else model = wrap_values ( [ model ] ) . f... | called form << append and create . If a hash is passed in it converts it to a model . Then it takes the model and inserts it into the ArrayModel then persists it . |
6,903 | def url_for ( params ) host_with_port = host || location . host host_with_port += ":#{port}" if port && port != 80 scheme = scheme || location . scheme unless RUBY_PLATFORM == 'opal' if ! @router && @routes_loader @routes_loader . call end end path , params = @router . params_to_url ( params ) if path == nil raise "No ... | Full url rebuilds the url from it s constituent parts . The params passed in are used to generate the urls . |
6,904 | def assign_query_hash_to_params query_hash = parse_query new_params = @router . url_to_params ( path ) fail "no routes match path: #{path}" if new_params == false return false if new_params == nil query_hash . merge! ( new_params ) lparams = params assign_from_old ( lparams , query_hash ) assign_new ( lparams , query_h... | Assigning the params is tricky since we don t want to trigger changed on any values that have not changed . So we first loop through all current url params removing any not present in the params while also removing them from the list of new params as added . Then we loop through the remaining new parameters and assign ... |
6,905 | def assign_new ( params , new_params ) new_params . each_pair do | name , value | if value . is_a? ( Hash ) assign_new ( params . get ( name ) , value ) else params . set ( name , value ) end end end | Assign any new params which weren t in the old params . |
6,906 | def query_key ( path ) i = 0 path . map do | v | i += 1 if i != 1 "[#{v}]" else v end end . join ( '' ) end | Generate the key for a nested param attribute |
6,907 | def create_controller_handler ( full_path , controller_path ) args = [ SubContext . new ( @arguments , nil , true ) ] controller_class , action = ControllerHandler . get_controller_and_action ( controller_path ) generated_new = false new_controller = proc do generated_new = true controller_class . new ( @volt_app , * a... | Create controller handler loads up a controller inside of the controller handler for the paths |
6,908 | def app_folders @app_folders ||= begin volt_app = File . expand_path ( File . join ( File . dirname ( __FILE__ ) , '../../../../app' ) ) app_folders = [ volt_app , "#{@root}/app" , "#{@root}/vendor/app" ] . map { | f | File . expand_path ( f ) } app_folders += Gem . loaded_specs . values . select { | gem | gem . name =... | Yield for every folder where we might find components |
6,909 | def components return @components if @components @components = { } app_folders do | app_folder | Dir [ "#{app_folder}/*" ] . sort . each do | folder | if File . directory? ( folder ) folder_name = folder [ / \/ / ] folders = ( @components [ folder_name ] ||= [ ] ) folders << folder unless folders . include? ( folder ) ... | returns an array of every folder that is a component |
6,910 | def asset_folders folders = [ ] app_folders do | app_folder | Dir [ "#{app_folder}/*/assets" ] . sort . each do | asset_folder | folders << yield ( asset_folder ) end end folders . flatten end | Return every asset folder we need to serve from |
6,911 | def track_binding_anchors @binding_anchors = { } @bindings . each_pair do | name , binding | if name . is_a? ( String ) node = nil ` ` @binding_anchors [ name ] = node else start_comment = find_by_comment ( "$#{name}" , @nodes ) end_comment = find_by_comment ( "$/#{name}" , @nodes ) @binding_anchors [ name ] = [ start_... | Finds each of the binding anchors in the temp dom then stores a reference to them so they can be quickly updated without using xpath to find them again . |
6,912 | def path_for_template ( lookup_path , force_section = nil ) parts = lookup_path . split ( '/' ) parts_size = parts . size return nil , nil if parts_size == 0 default_parts = %w( main main index body ) default_parts [ - 1 ] = force_section if force_section ( 5 - parts_size ) . times do | path_position | next if force_se... | Takes in a lookup path and returns the full path for the matching template . Also returns the controller and action name if applicable . |
6,913 | def first_element check_section! ( 'first_element' ) range = dom_nodes nodes = ` ` start_index = ` ` end_index = ` ` start_index . upto ( end_index ) do | index | node = ` ` if ` ` return node end end return nil end | Walks the dom_nodes range until it finds an element . Typically this will be the container element without the whitespace text nodes . |
6,914 | def yield_html if ( template_path = attrs . content_template_path ) @yield_renderer ||= StringTemplateRenderer . new ( @volt_app , attrs . content_controller , template_path ) @yield_renderer . html else '' end end | yield_html renders the content passed into a tag as a string . You can . watch! yield_html and it will be run again when anything in the template changes . |
6,915 | def model = ( val ) if val . is_a? ( Promise ) self . last_promise = val val . then do | result | self . model = result if last_promise == val end . fail do | err | Volt . logger . error ( "Unable to resolve promise assigned to model on #{inspect}" ) end return end self . last_promise = nil self . current_model ||= Mod... | Sets the current model on this controller |
6,916 | def loaded? if model . respond_to? ( :loaded? ) return model . loaded? elsif last_promise || model . is_a? ( Promise ) return false else return true end end | loaded? is a quick way to see if the model for the controller is loaded yet . If the model is there it asks the model if its loaded . If the model was set to a promise it waits for the promise to resolve . |
6,917 | def raw ( str ) if str . is_a? ( Promise ) str = str . then ( & :to_s ) else str = str . to_s unless str . is_a? ( String ) end str . html_safe end | Raw marks a string as html safe so bindings can be rendered as html . With great power comes great responsibility . |
6,918 | def check_errors if @value && @value . is_a? ( Numeric ) if @args . is_a? ( Hash ) @args . each do | arg , val | case arg when :min add_error ( "number must be greater than #{val}" ) if @value < val when :max add_error ( "number must be less than #{val}" ) if @value > val end end end else message = ( @args . is_a? ( Ha... | Looks at the value |
6,919 | def params @params ||= begin params = request . params . symbolize_keys . merge ( @initial_params ) Volt :: Model . new ( params , persistor : Volt :: Persistors :: Params ) end end | Initialzed with the params parsed from the route and the HttpRequest |
6,920 | def rezero_bindings ( html , bindings ) @@base_binding_id ||= 20_000 parts = html . split ( / \< \! \- \- \$ \/ \- \- \> / ) . reject { | v | v == '' } new_html = [ ] new_bindings = { } id_map = { } parts . each do | part | case part when / \< \! \- \- \$ \- \- \> / binding_id = part . match ( / \< \! \- \- \$ \- \- \>... | When using bindings we have to change the binding id so we don t reuse the same id when rendering a binding multiple times . |
6,921 | def set_content_and_rezero_bindings ( html , bindings ) html , bindings = rezero_bindings ( html , bindings ) if @binding_name == 'main' @target . html = html else @target . find_by_binding_id ( @binding_name ) . html = html end bindings end | Takes in our html and bindings and rezero s the comment names and the bindings . Returns an updated bindings hash |
6,922 | def code ( app_reference ) code = '' templates . each_pair do | name , template | binding_code = [ ] if template [ 'bindings' ] template [ 'bindings' ] . each_pair do | key , value | binding_code << "#{key.inspect} => [#{value.join(', ')}]" end end binding_code = "{#{binding_code.join(', ')}}" code << "#{app_reference}... | Generate code for the view that can be evaled . |
6,923 | def duration_in_words ( places = 2 , min_unit = :minutes , recent_message = 'just now' ) parts = [ ] secs = to_i UNIT_MAP . each_pair do | unit , count | val = ( secs / count ) . floor secs = secs % count parts << [ val , unit ] if val > 0 break if unit == min_unit end parts = parts . take ( places ) if places parts = ... | Returns a string representation of the duration . |
6,924 | def response ( promise_id , result , error , cookies ) if cookies cookies . each do | key , value | @volt_app . cookies . set ( key , value ) end end promise = @promises . delete ( promise_id ) if promise if error Volt . logger . error ( 'Task Response:' ) Volt . logger . error ( error ) promise . reject ( error ) else... | When a request is sent to the backend it can attach a callback this is called from the backend to pass to the callback . |
6,925 | def notify_query ( method_name , collection , query , * args ) query_obj = Persistors :: ArrayStore . query_pool . lookup ( collection , query ) query_obj . send ( method_name , * args ) end | Called when the backend sends a notification to change the results of a query . |
6,926 | def depend return unless @dependencies current = Computation . current if current added = @dependencies . add? ( current ) if added @on_dep . call if @on_dep && @dependencies . size == 1 current . on_invalidate do if @dependencies deleted = @dependencies . delete? ( current ) @on_stop_dep . call if @on_stop_dep && dele... | Setup a new dependency . |
6,927 | def assign_attributes ( attrs , initial_setup = false , skip_changes = false ) attrs = wrap_values ( attrs ) if attrs if initial_setup || skip_changes Model . no_change_tracking do assign_all_attributes ( attrs , skip_changes ) end else assign_all_attributes ( attrs ) end else @attributes = { } end @deps . changed_all!... | Assign multiple attributes as a hash directly . |
6,928 | def set ( attribute_name , value , & block ) attribute_name = attribute_name . to_sym check_valid_field_name ( attribute_name ) old_value = @attributes [ attribute_name ] new_value = wrap_value ( value , [ attribute_name ] ) if old_value != new_value attribute_will_change! ( attribute_name , old_value ) unless Volt . i... | Do the assignment to a model and trigger a changed event |
6,929 | def read_new_model ( method_name ) if @persistor && @persistor . respond_to? ( :read_new_model ) return @persistor . read_new_model ( method_name ) else opts = @options . merge ( parent : self , path : path + [ method_name ] ) if method_name . plural? return new_array_model ( [ ] , opts ) else return new_model ( { } , ... | Get a new model make it easy to override |
6,930 | def update ( attrs ) old_attrs = @attributes . dup Model . no_change_tracking do assign_all_attributes ( attrs , false ) validate! . then do | errs | if errs && errs . present? @attributes = old_attrs Promise . new . resolve ( errs ) else persist_changes ( nil ) end end end end | Update tries to update the model and returns |
6,931 | def close_scope ( pop = true ) if pop scope = @handler . scope . pop else scope = @handler . last end fail "template path already exists: #{scope.path}" if @handler . templates [ scope . path ] template = { 'html' => scope . html } if scope . bindings . size > 0 template [ 'bindings' ] = scope . bindings end @handler .... | Called when this scope should be closed out |
6,932 | def + ( other ) if other . is_a? ( Volt :: Duration ) Volt :: Duration . new ( value + other . value , parts + other . parts ) else Volt :: Duration . new ( value + other , parts + [ [ :seconds , other ] ] ) end end | Compares with the value on another Duration if Duration is passed or just compares value with the other object Adds durations or duration to a VoltTime or seconds to the duration |
6,933 | def start_binding binding = '' open_count = 1 loop do binding << @html . scan_until ( / \{ \{ \} \} \n \Z / ) match = @html [ 1 ] if match == '}}' open_count -= 1 break if open_count == 0 elsif match == '{{' open_count += 1 elsif match == "\n" || @html . eos? raise_parse_error ( "unclosed binding: {#{binding.strip}" ) ... | Findings the end of a binding |
6,934 | def dispatch_to_controller ( params , request ) namespace = params [ :component ] || 'main' controller_name = params [ :controller ] + '_controller' action = params [ :action ] namespace_module = Object . const_get ( namespace . camelize . to_sym ) klass = namespace_module . const_get ( controller_name . camelize . to_... | Find the correct controller and call the correct action on it . The controller name and actions need to be set as params for the matching route |
6,935 | def update ( value ) Computation . run_without_tracking do values = current_values ( value ) @value = values remove_listeners if @value . respond_to? ( :on ) @added_listener = @value . on ( 'added' ) { | position | item_added ( position ) } @removed_listener = @value . on ( 'removed' ) { | position | item_removed ( pos... | When a changed event happens we update to the new size . |
6,936 | def update_indexes_after ( start_index ) size = @templates . size if size > 0 start_index . upto ( size - 1 ) do | index | @templates [ index ] . context . locals [ :_index= ] . call ( index ) end end end | When items are added or removed in the middle of the list we need to update each templates index value . |
6,937 | def remove @computation . stop @computation = nil @value = [ ] @getter = nil remove_listeners if @templates template_count = @templates . size template_count . times do | index | item_removed ( template_count - index - 1 ) end @templates = nil end super end | When this each_binding is removed cleanup . |
6,938 | def rest ( path , params ) endpoints = ( params . delete ( :only ) || [ :index , :show , :create , :update , :destroy ] ) . to_a endpoints = endpoints - params . delete ( :except ) . to_a endpoints . each do | endpoint | self . send ( ( 'restful_' + endpoint . to_s ) . to_sym , path , params ) end end | Create rest endpoints |
6,939 | def params_to_url ( test_params ) method = test_params . delete ( :method ) || :client method = method . to_sym test_params = test_params . each_with_object ( { } ) do | ( k , v ) , obj | obj [ k . to_sym ] = v end @param_matches [ method ] . each do | param_matcher | result , new_params = check_params_match ( test_par... | Takes in params and generates a path and the remaining params that should be shown in the url . The extra unused params will be tacked onto the end of the url ?param1 = value1 etc ... |
6,940 | def url_to_params ( * args ) if args . size < 2 path = args [ 0 ] method = :client else path = args [ 1 ] method = args [ 0 ] . to_sym end result = @direct_routes [ method ] [ path ] return result if result parts = url_parts ( path ) match_path ( parts , parts , @indirect_routes [ method ] ) end | Takes in a path and returns the matching params . returns params as a hash |
6,941 | def match_path ( original_parts , remaining_parts , node ) part , * parts = remaining_parts if part . nil? if node [ part ] setup_bindings_in_params ( original_parts , node [ part ] ) else false end else if ( new_node = node [ part ] ) result = match_path ( original_parts , parts , new_node ) return result if result en... | Recursively walk the |
6,942 | def setup_bindings_in_params ( original_parts , params ) params = params . dup params . each_pair do | key , value | if value . is_a? ( Fixnum ) params [ key ] = original_parts [ value ] elsif value . is_a? ( Range ) params [ key ] = original_parts [ value ] . join ( '/' ) end end params end | The params out of match_path will have integers in the params that came from bindings in the url . This replaces those with the values from the url . |
6,943 | def check_params_match ( test_params , param_matcher ) param_matcher . each_pair do | key , value | if value . is_a? ( Hash ) if test_params [ key ] result = check_params_match ( test_params [ key ] , value ) if result == false return false else test_params . delete ( key ) end else return false end elsif value . nil? ... | Takes in a hash of params and checks to make sure keys in param_matcher are in test_params . Checks for equal value unless value in param_matcher is nil . |
6,944 | def association_with_root_model ( method_name ) persistor = self . persistor || ( respond_to? ( :save_to ) && save_to && save_to . persistor ) if persistor . is_a? ( Volt :: Persistors :: ModelStore ) || persistor . is_a? ( Volt :: Persistors :: Page ) root = persistor . try ( :root_model ) yield ( root ) else fail "#{... | Currently the has_many and belongs_to associations only work on the store collection this method checks to make sure we are on store and returns the root reference to it . |
6,945 | def boot_error ( error ) msg = error . inspect if error . respond_to? ( :backtrace ) msg << "\n" + error . backtrace . join ( "\n" ) end Volt . logger . error ( msg ) require 'cgi' @rack_app = Proc . new do path = File . join ( File . dirname ( __FILE__ ) , "forking_server/boot_error.html.erb" ) html = File . read ( pa... | called from the child when the boot failes . Sets up an error page rack app to show the user the error and handle reloading requests . |
6,946 | def process_attributes ( tag_name , attributes ) new_attributes = attributes . dup attributes . each_pair do | name , value | if name [ 0 .. 1 ] == 'e-' process_event_binding ( tag_name , new_attributes , name , value ) else process_attribute ( tag_name , new_attributes , name , value ) end end new_attributes end | Take the attributes and create any bindings |
6,947 | def binding_parts_and_count ( value ) if value . is_a? ( String ) parts = value . split ( / \{ \{ \} \} \} / ) . reject ( & :blank? ) else parts = [ '' ] end binding_count = parts . count { | p | p [ 0 ] == '{' && p [ 1 ] == '{' && p [ - 2 ] == '}' && p [ - 1 ] == '}' } [ parts , binding_count ] end | Takes a string and splits on bindings returns the string split on bindings and the number of bindings . |
6,948 | def close_scope binding_number = @handler . scope [ - 2 ] . binding_number @handler . scope [ - 2 ] . binding_number += 1 @path += "/__template/#{binding_number}" super @handler . html << "<!-- $#{binding_number} @handler . scope . last . save_binding ( binding_number , "lambda { |__p, __t, __c, __id| Volt::ComponentB... | The path passed in is the path used to lookup view s . The path from the tag is passed in as tag_name |
6,949 | def javascript_tags ( volt_app ) @opal_tag_generator ||= Opal :: Server :: Index . new ( nil , volt_app . opal_files . server ) javascript_files = [ ] @assets . each do | type , path | case type when :folder base_path = base ( path ) javascript_files += Dir [ "#{path}/**/*.js" ] . sort . map do | folder | local_path = ... | Returns script tags that should be included |
6,950 | def css css_files = [ ] @assets . each do | type , path | case type when :folder base_path = base ( path ) css_files += Dir [ "#{path}/**/[^_]*.{css,scss,sass}" ] . sort . map do | folder | local_path = folder [ path . size .. - 1 ] . gsub ( / / , '' ) css_path = @app_url + '/' + base_path + local_path css_path += '.cs... | Returns an array of all css files that should be included . |
6,951 | def lookup_without_generate ( * args ) section = @pool args . each_with_index do | arg , index | section = section [ arg ] return nil unless section end section end | Looks up the path without generating a new one |
6,952 | def merge! ( errors ) if errors errors . each_pair do | field , messages | messages . each do | message | add ( field , message ) end end end end | Merge another set of errors in |
6,953 | def link_asset ( url , link = true ) if @sprockets_context linked_url = @sprockets_context . asset_path ( url ) else linked_url = url end last << url if link linked_url end | Called from the view scope when an asset_url binding is hit . |
6,954 | def code initializer_code = @client ? generate_config_code : '' component_code = '' asset_files = AssetFiles . from_cache ( @volt_app . app_url , @component_name , @component_paths ) asset_files . component_paths . each do | component_path , component_name | comp_template = ComponentTemplates . new ( component_path , c... | The client argument is for if this code is being generated for the client |
6,955 | def wrap_value ( value , lookup ) if value . is_a? ( Array ) new_array_model ( value , @options . merge ( parent : self , path : path + lookup ) ) elsif value . is_a? ( Hash ) new_model ( value , @options . merge ( parent : self , path : path + lookup ) ) else value end end | For cretain values we wrap them to make the behave as a model . |
6,956 | def analogous ( options = { } ) size = options [ :size ] || 6 slices = options [ :slice_by ] || 30 hsl = @color . hsl part = 360 / slices hsl . h = ( ( hsl . h - ( part * size >> 1 ) ) + 720 ) % 360 palette = ( size - 1 ) . times . reduce ( [ @color ] ) do | arr , n | hsl . h = ( hsl . h + part ) % 360 arr << Color . n... | Generate an analogous palette . |
6,957 | def monochromatic ( options = { } ) size = options [ :size ] || 6 h , s , v = @color . hsv modification = 1.0 / size palette = size . times . map do Color . new ( ColorModes :: Hsv . new ( h , s , v ) , @color . format ) . tap do v = ( v + modification ) % 1 end end with_reformat ( palette , options [ :as ] ) end | Generate a monochromatic palette . |
6,958 | def dequeue loop do return nil if @stop message = receive_message if message if message . valid? return message else delete_message ( message ) end end end end | Receive a message from SQS queue . |
6,959 | def init_sources ( ) return unless defined? Rho :: RhoConfig :: sources @all_models_loaded = true uniq_sources = Rho :: RhoConfig :: sources . values puts 'init_sources: ' uniq_sources . each do | source | source [ 'str_associations' ] = "" end uniq_sources . each do | source | partition = source [ 'partition' ] @db_pa... | setup the sources table and model attributes for all applications |
6,960 | def replace! ( oth ) if self . class != oth . class raise ArgumentError , "expected #{self.class} object" end component . each do | c | self . __send__ ( "#{c}=" , oth . __send__ ( c ) ) end end | replace self by other URI object |
6,961 | def charset type , * parameters = content_type_parse if pair = parameters . assoc ( 'charset' ) pair . last . downcase elsif block_given? yield elsif type && %r{ \A } =~ type && @base_uri && / \A \z /i =~ @base_uri . scheme "iso-8859-1" else nil end end | returns a charset parameter in Content - Type field . It is downcased for canonicalization . |
6,962 | def delete_all mails ( ) . each do | m | yield m if block_given? m . delete unless m . deleted? end end | Deletes all messages on the server . |
6,963 | def pop ( dest = '' , & block ) if block_given? @command . retr ( @number , & block ) nil else @command . retr ( @number ) do | chunk | dest << chunk end dest end end | This method fetches the message . If called with a block the message is yielded to the block one chunk at a time . If called without a block the message is returned as a String . The optional + dest + argument will be prepended to the returned String ; this argument is essentially obsolete . |
6,964 | def directory ( * args , & block ) result = file_create ( * args , & block ) dir , _ = * Rake . application . resolve_args ( args ) Rake . each_dir_parent ( dir ) do | d | file_create d do | t | mkdir_p t . name unless File . exist? ( t . name ) end end result end | Declare a set of files tasks to create the given directories on demand . |
6,965 | def namespace ( name = nil , & block ) name = name . to_s if name . kind_of? ( Symbol ) name = name . to_str if name . respond_to? ( :to_str ) unless name . kind_of? ( String ) || name . nil? raise ArgumentError , "Expected a String or Symbol for a namespace name" end Rake . application . in_namespace ( name , & block ... | Create a new rake namespace and use it for evaluating the given block . Returns a NameSpace object that can be used to lookup tasks defined in the namespace . |
6,966 | def delete_namespace namespace = "xmlns" namespace = "xmlns:#{namespace}" unless namespace == 'xmlns' attribute = attributes . get_attribute ( namespace ) attribute . remove unless attribute . nil? self end | Removes a namespace from this node . This only works if the namespace is actually declared in this node . If no argument is passed deletes the default namespace . |
6,967 | def each_attribute each_value do | val | if val . kind_of? Attribute yield val else val . each_value { | atr | yield atr } end end end | Iterates over the attributes of an Element . Yields actual Attribute nodes not String values . |
6,968 | def sort_obj [ @name , installation_path == File . join ( defined? ( Merb ) && Merb . respond_to? ( :root ) ? Merb . root : Dir . pwd , "gems" ) ? 1 : - 1 , @version . to_ints , @new_platform == Gem :: Platform :: RUBY ? - 1 : 1 ] end | Overwrite this so that gems in the gems directory get preferred over gems from any other location . If there are two gems of different versions in the gems directory the later one will load as usual . |
6,969 | def shutdown stop @listeners . each { | s | if @logger . debug? addr = s . addr @logger . debug ( "close TCPSocket(#{addr[2]}, #{addr[1]})" ) end begin s . shutdown rescue Errno :: ENOTCONN s . close else unless @config [ :ShutdownSocketWithoutClose ] s . close end end } @listeners . clear end | Shuts down the server and all listening sockets . New listeners must be provided to restart the server . |
6,970 | def format ( arg ) if arg . is_a? ( Exception ) "#{arg.class}: #{arg.message}\n\t" << arg . backtrace . join ( "\n\t" ) << "\n" elsif arg . respond_to? ( :to_str ) arg . to_str else arg . inspect end end | Formats + arg + for the logger |
6,971 | def process_url_params url , headers url_params = { } headers . delete_if do | key , value | if 'params' == key . to_s . downcase && value . is_a? ( Hash ) url_params . merge! value true else false end end unless url_params . empty? query_string = url_params . collect { | k , v | "#{k.to_s}=#{CGI::escape(v.to_s)}" } . ... | Extract the query parameters and append them to the url |
6,972 | def stringify_headers headers headers . inject ( { } ) do | result , ( key , value ) | if key . is_a? Symbol key = key . to_s . split ( / / ) . map { | w | w . capitalize } . join ( '-' ) end if 'CONTENT-TYPE' == key . upcase target_value = value . to_s result [ key ] = MIME :: Types . type_for_extension target_value e... | Return a hash of headers whose keys are capitalized strings |
6,973 | def merge ( arr ) super ( arr . inject ( { } ) { | s , x | s [ x ] = true ; s } ) end | Merge _arr_ with receiver producing the union of receiver & _arr_ |
6,974 | def execute puts "Executing #{self.class.taskName} at #{Time::now}" . primary begin self . action rescue => e puts "Executing #{self.class.taskName} failed" . warning puts e . inspect . to_s . info puts e . backtrace . to_s . info end end | Execute specific task action |
6,975 | def dispatchToUrl ( anUri ) uri = URI . join ( anUri , 'tasks/new' ) Net :: HTTP . post_form ( uri , { 'taskName' => self . class . taskName , 'platform' => @platform , 'filename' => @filename } ) end | Method serializes itself to a hash and sends post request with the hash to specified URI |
6,976 | def action updated_list_filename = File . join ( Configuration :: application_root , 'upgrade_package_add_files.txt' ) removed_list_filename = File . join ( Configuration :: application_root , 'upgrade_package_remove_files.txt' ) mkdir_p Configuration :: development_directory Configuration :: enabled_subscriber_platfor... | Checks has source code changes for each platform |
6,977 | def descendant_or_self ( path_stack , nodeset ) rs = [ ] d_o_s ( path_stack , nodeset , rs ) document_order ( rs . flatten . compact ) end | FIXME The next two methods are BAD MOJO! This is my achilles heel . If anybody thinks of a better way of doing this be my guest . This really sucks but it is a wonder it works at all . |
6,978 | def document_order ( array_of_nodes ) new_arry = [ ] array_of_nodes . each { | node | node_idx = [ ] np = node . node_type == :attribute ? node . element : node while np . parent and np . parent . node_type == :element node_idx << np . parent . index ( np ) np = np . parent end new_arry << [ node_idx . reverse , node ]... | Reorders an array of nodes so that they are in document order It tries to do this efficiently . |
6,979 | def break_in_defining_scope ( value = true ) note :a note lambda { note :b if value break :break else break end note :c } . call note :d end | Cases for the invocation of the scope defining the lambda still active on the call stack when the lambda is invoked . |
6,980 | def start ( helo = 'localhost' , user = nil , secret = nil , authtype = nil ) if block_given? begin do_start helo , user , secret , authtype return yield ( self ) ensure do_finish end else do_start helo , user , secret , authtype return self end end | Opens a TCP connection and starts the SMTP session . |
6,981 | def data ( msgstr = nil , & block ) if msgstr and block raise ArgumentError , "message and block are exclusive" end unless msgstr or block raise ArgumentError , "message or block is required" end res = critical { check_continue get_response ( 'DATA' ) if msgstr @socket . write_message msgstr else @socket . write_messag... | This method sends a message . If + msgstr + is given sends it as a message . If block is given yield a message writer stream . You must write message before the block is closed . |
6,982 | def discover! ( scope ) @scopes = { } generator_files . each do | file | load file end @scopes [ scope ] . each { | block | block . call } if @scopes [ scope ] end | Searches installed gems for Generators files and loads all code blocks in them that match the given scope . |
6,983 | def each_recursive ( & block ) self . elements . each { | node | block . call ( node ) node . each_recursive ( & block ) } end | Visit all subnodes of + self + recursively |
6,984 | def to_s ret = "" ret << @name << "=" << @value ret << "; " << "Version=" << @version . to_s if @version > 0 ret << "; " << "Domain=" << @domain if @domain ret << "; " << "Expires=" << @expires if @expires ret << "; " << "Max-Age=" << @max_age . to_s if @max_age ret << "; " << "Comment=" << @comment if @comment ret << ... | The cookie string suitable for use in an HTTP header |
6,985 | def disconnect begin begin @sock . io . shutdown rescue NoMethodError @sock . shutdown end rescue Errno :: ENOTCONN rescue Exception => e @receiver_thread . raise ( e ) end @receiver_thread . join synchronize do unless @sock . closed? @sock . close end end raise e if e end | Disconnects from the server . |
6,986 | def starttls ( options = { } , verify = true ) send_command ( "STARTTLS" ) do | resp | if resp . kind_of? ( TaggedResponse ) && resp . name == "OK" begin certs = options . to_str options = create_ssl_params ( certs , verify ) rescue NoMethodError end start_tls_session ( options ) end end end | Sends a STARTTLS command to start TLS session . |
6,987 | def idle ( & response_handler ) raise LocalJumpError , "no block given" unless response_handler response = nil synchronize do tag = Thread . current [ :net_imap_tag ] = generate_tag put_string ( "#{tag} IDLE#{CRLF}" ) begin add_response_handler ( response_handler ) @idle_done_cond = new_cond @idle_done_cond . wait @idl... | Sends an IDLE command that waits for notifications of new or expunged messages . Yields responses from the server during the IDLE . |
6,988 | def get ( path , initheader = { } , dest = nil , & block ) res = nil request ( Get . new ( path , initheader ) ) { | r | r . read_body dest , & block res = r } res end | Retrieves data from + path + on the connected - to host which may be an absolute path String or a URI to extract the path from . |
6,989 | def patch ( path , data , initheader = nil , dest = nil , & block ) send_entity ( path , data , initheader , dest , Patch , & block ) end | Sends a PATCH request to the + path + and gets a response as an HTTPResponse object . |
6,990 | def proppatch ( path , body , initheader = nil ) request ( Proppatch . new ( path , initheader ) , body ) end | Sends a PROPPATCH request to the + path + and gets a response as an HTTPResponse object . |
6,991 | def lock ( path , body , initheader = nil ) request ( Lock . new ( path , initheader ) , body ) end | Sends a LOCK request to the + path + and gets a response as an HTTPResponse object . |
6,992 | def unlock ( path , body , initheader = nil ) request ( Unlock . new ( path , initheader ) , body ) end | Sends a UNLOCK request to the + path + and gets a response as an HTTPResponse object . |
6,993 | def propfind ( path , body = nil , initheader = { 'Depth' => '0' } ) request ( Propfind . new ( path , initheader ) , body ) end | Sends a PROPFIND request to the + path + and gets a response as an HTTPResponse object . |
6,994 | def mkcol ( path , body = nil , initheader = nil ) request ( Mkcol . new ( path , initheader ) , body ) end | Sends a MKCOL request to the + path + and gets a response as an HTTPResponse object . |
6,995 | def request_post ( path , data , initheader = nil , & block ) request Post . new ( path , initheader ) , data , & block end | Sends a POST request to the + path + . |
6,996 | def request ( req , body = nil , & block ) unless started? start { req [ 'connection' ] ||= 'close' return request ( req , body , & block ) } end if proxy_user ( ) req . proxy_basic_auth proxy_user ( ) , proxy_pass ( ) unless use_ssl? end req . set_body_internal body res = transport_request ( req , & block ) if sspi_au... | Sends an HTTPRequest object + req + to the HTTP server . |
6,997 | def send_entity ( path , data , initheader , dest , type , & block ) res = nil request ( type . new ( path , initheader ) , data ) { | r | r . read_body dest , & block res = r } res end | Executes a request which uses a representation and returns its body . |
6,998 | def get_value ( section , key ) if section . nil? raise TypeError . new ( 'nil not allowed' ) end section = 'default' if section . empty? get_key_string ( section , key ) end | Creates an instance of OpenSSL s configuration class . |
6,999 | def []= ( section , pairs ) check_modify @data [ section ] ||= { } pairs . each do | key , value | self . add_value ( section , key , value ) end end | Sets a specific + section + name with a Hash + pairs + |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.