idx
int64
0
24.9k
question
stringlengths
68
4.14k
target
stringlengths
9
749
16,600
def send_notification ( notification , delegate : , context : nil ) raise ArgumentError , "Invalid notification: #{notification.inspect}" unless notification . valid? topic = notification . topic || @default_topic headers = { } headers [ "apns-expiration" ] = ( notification . expiration || 0 ) . to_i headers [ "apns-id...
Verifies the notification is valid and then sends it to the remote service . Response feedback is provided via a delegate mechanism .
16,601
def call ( request , options = { } ) add_request ( request ) @publisher . publish ( request . message , routing_key : request . name , correlation_id : request . call_id , reply_to : @subscriber . reply_queue_name ) timeout = ( options [ :timeout ] || SneakersPacker . conf . rpc_timeout ) . to_i client_lock . synchroni...
call remote service via rabbitmq rpc
16,602
def embedded_image_tag ( model , options = { } ) model . load_image format = options [ :format ] || :jpg mime = Mime :: Type . lookup_by_extension ( format . to_s ) . to_s image = model . output_image ( :format => format ) data = Base64 . encode64 ( image ) options = { :alt => model . class . to_s } . merge ( options )...
Creates an image tag that links directly to image data . Recommended for displays of a temporary upload that is not saved to a record in the databse yet .
16,603
def link_to_edit_in_aviary ( text , model , options = { } ) key = aviary_image_hash ( model ) image_url = options . delete ( :image_url ) || url_for ( :action => 'aviary_image' , :id => model , :only_path => false , :key => key ) post_url = options . delete ( :image_update_url ) || url_for ( :action => 'aviary_image_up...
Creates a link that opens an image for editing in Aviary .
16,604
def alias_list lines = normalize_array ( rvm ( :alias , :list ) . stdout ) lines . inject ( { } ) do | acc , current | alias_name , ruby_string = current . to_s . split ( " => " ) unless alias_name . empty? || ruby_string . empty? acc [ alias_name ] = ruby_string end acc end end
Returns a hash of aliases .
16,605
def post ( path : , headers : , body : , delegate : , context : nil ) request ( "POST" , path , headers , body , delegate , context ) end
Sends the provided data as a POST request to the service .
16,606
def ruby ( runnable , options = { } ) if runnable . respond_to? ( :path ) ruby_run runnable . path , options elsif runnable . respond_to? ( :to_str ) runnable = runnable . to_str File . exist? ( runnable ) ? ruby_run ( runnable , options ) : ruby_eval ( runnable , options ) elsif runnable . respond_to? ( :read ) ruby_r...
Passed either something containing ruby code or a path to a ruby file will attempt to exectute it in the current environment .
16,607
def system ( command , * args ) identifier = extract_identifier! ( args ) args = [ identifier , :exec , command , * args ] . compact rvm ( * args ) . successful? end
Like Kernel . system but evaluates it within the environment . Also note that it doesn t support redirection etc .
16,608
def extract_environment! ( options ) values = [ ] [ :environment , :env , :rubies , :ruby ] . each do | k | values << options . delete ( k ) end values . compact . first end
From an options hash extract the environment identifier .
16,609
def extract_identifier! ( args ) options = extract_options! ( args ) identifier = normalize_set_identifier ( extract_environment! ( options ) ) args << options identifier end
Shorthand to extra an identifier from args . Since we
16,610
def chdir ( dir ) run_silently :pushd , dir . to_s result = Dir . chdir ( dir ) { yield } run_silently :popd result end
Run commands inside the given directory .
16,611
def normalize_array ( value ) value . split ( "\n" ) . map { | line | line . strip } . reject { | line | line . empty? } end
Normalizes an array removing blank lines .
16,612
def hash_to_options ( options ) result = [ ] options . each_pair do | key , value | real_key = "--#{key.to_s.gsub("_", "-")}" if value == true result << real_key elsif value != false result << real_key result << value . to_s end end result end
Converts a hash of options to an array of command line argumets . If the value is false it wont be added but if it is true only the key will be added . Lastly when the value is neither true or false to_s will becalled on it and it shall be added to the array .
16,613
def normalize_option_value ( value ) case value when Array value . map { | option | normalize_option_value ( option ) } . join ( "," ) else value . to_s end end
Recursively normalize options .
16,614
def tools_path_identifier ( path ) path_identifier = rvm ( :tools , "path-identifier" , path . to_s ) if path_identifier . exit_status == 2 error_message = "The rvmrc located in '#{path}' could not be loaded, likely due to trust mechanisms." error_message << " Please run 'rvm rvmrc {trust,untrust} \"#{path}\"' to conti...
Gets the identifier after cd ing to a path no destructive .
16,615
def use ( ruby_string , opts = { } ) ruby_string = ruby_string . to_s result = rvm ( :use , ruby_string ) successful = result . successful? if successful @environment_name = ruby_string @expanded_name = nil use_env_from_result! result if opts [ :replace_env ] end successful end
Changes the ruby string for the current environment .
16,616
def source_rvm_environment rvm_path = config_value_for ( :rvm_path , self . class . default_rvm_path , false ) actual_config = defined_config . merge ( 'rvm_path' => rvm_path ) config = [ ] actual_config . each_pair do | k , v | config << "#{k}=#{escape_argument(v.to_s)}" end run_silently "export #{config.join(" ")}" r...
Automatically load rvm config from the multiple sources .
16,617
def formatted_payload if @payload . key? ( "aps" ) @payload else payload = { } payload [ "aps" ] = aps = { } @payload . each do | key , value | next if value . nil? key = key . to_s if APS_KEYS . include? ( key ) aps [ key ] = value else payload [ key ] = value end end payload end end
Unless the payload contains an aps entry the payload is assumed to be a mix of APN defined attributes and custom attributes and re - organized according to the specifications .
16,618
def start ( & block ) @attempts += 1 with_transaction_state ( & block ) rescue ActiveRecord :: StatementInvalid => error raise unless connection . open_transactions . zero? raise unless error . message =~ DEADLOCK_MESSAGES raise if attempts >= RETRY_COUNT logger . info "Deadlock detected on attempt #{attempts}, restart...
Starts persevering transaction
16,619
def compare ( crypted_string , plain_string ) BCrypt :: Password . new ( crypted_string ) . is_password? ( plain_string ) rescue BCrypt :: Errors :: InvalidHash false end
Returns true if the the bcrypted value of a is equal to b
16,620
def clear_audit_attributes all_audit_attributes . each do | attribute_name | if respond_to? ( attribute_name ) && respond_to? ( "#{ attribute_name }=" ) write_attribute ( attribute_name , nil ) end end @changed_attributes = changed_attributes . reduce ( ActiveSupport :: HashWithIndifferentAccess . new ) do | result , (...
Clear attributes and changed_attributes
16,621
def image ( query , opts = { } ) invoke 'Image' , query , opts , param_name_replacements : { filters : 'ImageFilters' } , params : { filters : image_filters_from_opts ( opts ) } end
Searches for images
16,622
def video ( query , opts = { } ) invoke 'Video' , query , opts , passthrough_opts : %i( filters sort ) , enum_opt_to_module : { filters : VideoFilter , sort : VideoSort } , param_name_replacements : { filters : 'VideoFilters' , sort : 'VideoSortBy' } end
Searches for videos
16,623
def news ( query , opts = { } ) invoke 'News' , query , opts , passthrough_opts : %i( category location_override sort ) , enum_opt_to_module : { category : NewsCategory , sort : NewsSort } , param_name_replacements : { category : 'NewsCategory' , location_override : 'NewsLocationOverride' , sort : 'NewsSortBy' } end
Searches for news
16,624
def validate ( record ) if record . password_provider? or options [ :force ] if record . new_record? and record . password . to_s . blank? and ! record . password_changed? record . errors . add :password , :blank elsif record . password_changed? if record . password . to_s . size < 4 record . errors . add :password , :...
Check to make sure a valid password and confirmation were set
16,625
def valid_values if validators [ 'inclusion' ] return case when validators [ 'inclusion' ] . is_a? ( Array ) then validators [ 'inclusion' ] when validators [ 'inclusion' ] . is_a? ( String ) then validators [ 'inclusion' ] . to_s . split ( ',' ) . map { | v | v . to_s . strip } else nil end end nil end
Returns all valid values for this setting which is based on the presence of an inclusion validator . Will return nil if no valid values could be determined .
16,626
def find_in_paths ( logical_path , & block ) dirname , basename = File . split ( logical_path ) @paths . each do | base_path | match ( File . expand_path ( dirname , base_path ) , basename , & block ) end end
Finds logical path across all paths
16,627
def match ( dirname , basename ) matches = @entries [ dirname ] pattern = @patterns [ basename ] matches = matches . select { | m | m =~ pattern } sort_matches ( matches , basename ) . each do | path | filename = File . join ( dirname , path ) stat = @stats [ filename ] if stat && stat . file? yield filename end end en...
Checks if the path is actually on the file system and performs any syscalls if necessary .
16,628
def sort_matches ( matches , basename ) extname = File . extname ( basename ) aliases = @reverse_aliases [ extname ] || [ ] matches . sort_by do | match | extnames = match . sub ( basename , '' ) . scan ( / \. / ) extnames . inject ( 0 ) do | sum , ext | if i = extensions . index ( ext ) sum + i + 1 elsif i = aliases ....
Sorts candidate matches by their extension priority . Extensions in the front of the extensions carry more weight .
16,629
def update_modified_providers_after_save if @password_updated or @username_updated Challah . providers [ :password ] . save ( self ) @password_updated = false @username_updated = false @password = nil end Challah . custom_providers . each do | name , klass | custom_provider_attributes = provider_attributes [ name ] if ...
If password or username was changed update the authorization record
16,630
def method_missing ( sym , * args , & block ) if @params . has_key? ( sym ) return @params [ sym ] elsif sym . to_s =~ / / return @params [ sym . to_s . sub ( / / , '\1' ) . to_sym ] = args . shift elsif sym . to_s =~ / \? / return ! ! @params [ sym . to_s . sub ( / \? / , '\1' ) . to_sym ] end super ( sym , * args , &...
Allow for dynamic setting of instance variables . also allows for variable? to see if it was provided
16,631
def authenticate! Challah . techniques . values . each do | klass | technique = klass . new ( self ) technique . user_model = user_model if technique . respond_to? ( :" " ) @user = technique . authenticate if @user @persist = technique . respond_to? ( :persist? ) ? technique . persist? : false break end end if @user if...
Try and authenticate against the various auth techniques . If one technique works then just exit and make the session active .
16,632
def buffer_key ( key , opts ) opts = opts . inject ( { } ) do | result , ( k , v ) | result [ k . to_s ] = v result end "#{key.to_s}:#{opts.sort.flatten.join(':')}" end
depth_limit is not needed as it s evident in key . to_s
16,633
def register_plugin ( name , & block ) plugin = Plugin . new plugin . instance_eval ( & block ) @plugins [ name ] = plugin end
Register a new plugin .
16,634
def resource_path_from_qualified_name ( qualified_name ) path_options = path_options_for_qualified_name ( qualified_name ) file_path = '' path_options . uniq . each do | path_option | file_path = search_for_file ( path_option ) break if file_path . present? end return file_path if file_path path_for_first_file_in ( pat...
A look for the possible places that various qualified names could be
16,635
def existing? exists = false if session_cookie and validation_cookie session_tmp = session_cookie . to_s validation_tmp = validation_cookie . to_s if validation_tmp == validation_cookie_value ( session_tmp ) exists = true end end exists end
Do the cookies exist and are they valid?
16,636
def authenticate if username? and password? user = user_model . find_for_session ( username ) if user if user . valid_session? if user . authenticate ( @password ) return user end end user . failed_authentication! user = nil end end nil end
grab the params we want from this request if we can successfully authenticate return a User instance otherwise nil
16,637
def entries ( path ) if File . directory? ( path ) Dir . entries ( path ) . reject { | entry | entry =~ / \. \# \# / } . sort else [ ] end end
A version of Dir . entries that filters out . files and ~ swap files . Returns an empty Array if the directory does not exist .
16,638
def validate_each ( record , attribute , value ) unless value =~ EmailValidator . pattern record . errors . add ( attribute , options [ :message ] || :invalid_email ) end end
Called automatically by ActiveModel validation ..
16,639
def authenticate ( * args ) return false unless active? if args . length > 1 method = args . shift if Challah . authenticators [ method ] return Challah . authenticators [ method ] . match? ( self , providers [ method ] , * args ) end false else self . authenticate ( :password , args [ 0 ] ) end end
Generic authentication method . By default this just checks to see if the password given matches this user . You can also pass in the first parameter as the method to use for a different type of authentication .
16,640
def successful_authentication! ( ip_address = nil ) self . last_session_at = Time . now self . last_session_ip = ip_address if respond_to? ( :last_session_ip= ) self . save self . increment! ( :session_count , 1 ) end
Called when a + Session + validation is successful and this user has been authenticated .
16,641
def dcm_mlc_positions ( scale = nil ) coeff = ( scale == :elekta ? - 1 : 1 ) pos_a = @mlc_lp_a . collect { | p | ( p . to_f * 10 * coeff ) . round ( 1 ) unless p . empty? } . compact pos_b = @mlc_lp_b . collect { | p | ( p . to_f * 10 ) . round ( 1 ) unless p . empty? } . compact ( pos_a + pos_b ) . join ( "\\" ) end
Converts the mlc_lp_a & mlc_lp_b attributes to a proper DICOM formatted string .
16,642
def dcm_collimator_1 ( scale = nil , axis ) coeff = 1 if scale == :elekta axis = ( axis == :x ? :y : :x ) coeff = - 1 elsif scale == :varian coeff = - 1 end dcm_collimator ( axis , coeff , side = 1 ) end
Converts the collimator1 attribute to proper DICOM format .
16,643
def versioned_changes modified_changes = { } raw_changes = self . changes . select { | k , _ | versioned_attribute? ( k ) } . to_hash raw_changes . each do | key , ( previous , current ) | if reflection = self . class . reflect_on_association ( key . to_sym ) if reflection . collection? previous = previous . map ( & :v...
The hash that gets serialized into the object_changes column .
16,644
def versioned_attributes json = self . as_json ( :root => false ) . select do | k , _ | versioned_attribute? ( k ) end json . to_hash end
The object s versioned attributes as a hash .
16,645
def get_thread_by_url ( url ) response = Disqus :: Api :: get_thread_by_url ( :url => url , :forum_api_key => key ) if response [ "succeeded" ] t = response [ "message" ] Thread . new ( t [ "id" ] , self , t [ "slug" ] , t [ "title" ] , t [ "created_at" ] , t [ "allow_comments" ] , t [ "url" ] , t [ "identifier" ] ) el...
Returns a thread associated with the given URL .
16,646
def attribute_diffs @attribute_diffs ||= begin changes = self . object_changes . dup attribute_diffs = { } changes . each do | attribute , values | diff = Diffy :: Diff . new ( values [ 0 ] . to_s , values [ 1 ] . to_s ) attribute_diffs [ attribute ] = diff end attribute_diffs end end
The attribute diffs for this version
16,647
def __compat_set_attribute_was ( name , previous ) if respond_to? ( :set_attribute_was , true ) set_attribute_was ( name , previous ) else changed_attributes [ name ] = previous end end
Rails 4 . 2 adds set_attribute_was which must be used so we ll check for it .
16,648
def encode ( options = { } ) encoded_values = values . collect { | v | v && v . encode ( 'ISO8859-1' ) } encoded_values = discard_unsupported_attributes ( encoded_values , options ) if options [ :version ] content = CSV . generate_line ( encoded_values , force_quotes : true , row_sep : '' ) + "," checksum = content . c...
Encodes a string from the contents of this instance .
16,649
def get_parent ( last_parent , klass ) if last_parent . is_a? ( klass ) return last_parent else return last_parent . get_parent ( last_parent . parent , klass ) end end
Follows the tree of parents until the appropriate parent of the requesting record is found .
16,650
def load ( string , options = { } ) values = string . to_s . values ( options [ :repair ] ) raise ArgumentError , "Invalid argument 'string': Expected at least #{@min_elements} elements for #{@keyword}, got #{values.length}." if values . length < @min_elements RTP . logger . warn "The number of given elements (#{values...
Sets up a record by parsing a RTPConnect string line .
16,651
def to_s ( options = { } ) str = encode ( options ) children . each do | child | str += child . to_s ( options ) unless child . class == ExtendedPlan && options [ :version ] . to_f < 2.5 end str end
Encodes the record + any hiearchy of child objects to a properly formatted RTPConnect ascii string .
16,652
def delete_child ( attribute , instance = nil ) if self . send ( attribute ) . is_a? ( Array ) deleted = self . send ( attribute ) . delete ( instance ) deleted . parent = nil if deleted else self . send ( attribute ) . parent = nil if self . send ( attribute ) self . instance_variable_set ( "@#{attribute}" , nil ) end...
Removes the reference of the given instance from the attribute of this record .
16,653
def delete_children ( attribute ) self . send ( attribute ) . each { | c | c . parent = nil } self . send ( attribute ) . clear end
Removes all child references of the given type from this instance .
16,654
def set_attributes ( values ) import_indices ( [ values . length - 1 , @max_elements - 1 ] . min ) . each_with_index do | indices , i | param = nil if indices param = values . values_at ( * indices ) param = param [ 0 ] if param . length == 1 end self . send ( "#{@attributes[i]}=" , param ) end @crc = values [ - 1 ] en...
Sets the attributes of the record instance .
16,655
def discard_unsupported_attributes ( values , options = { } ) case self when SiteSetup options [ :version ] . to_f >= 2.6 ? values : values [ 0 .. - 4 ] when Field options [ :version ] . to_f >= 2.64 ? values : values [ 0 .. - 4 ] when ExtendedField options [ :version ] . to_f >= 2.4 ? values : values [ 0 .. - 5 ] when...
Removes any attributes that are newer than the given compatibility target version . E . g . if a compatibility version of Mosaiq 2 . 4 is specified attributes that were introduced in Mosaiq 2 . 5 or later is removed before the RTP string is created .
16,656
def include_config ( * files ) include_base = File . dirname ( @config_file ) if @config_file files . each do | file | path = File . join ( include_base , file ) if include_base include_file ( path || file ) end end
Includes config code from one or more files and evals it in the context of this stack . Filenames are relative to the file containing the invocation of this method .
16,657
def write ( file , options = { } ) f = open_file ( file ) f . write ( to_s ( options ) ) f . close end
Writes the Plan object along with its hiearchy of child objects to a properly formatted RTPConnect ascii file .
16,658
def tail ( options = { } ) q = [ ] event_id_highwater = nil counter = 0 number = options [ :number ] || 0 for_each_event name do | fetched_event | q . unshift fetched_event if counter < number counter = counter + 1 end while q . size > 0 event = q . shift yield event event_id_highwater = event . event_id end sleep_time...
Yields to the given block for each CloudFormation event that qualifies given the specified options .
16,659
def build_from_block ( * args , & block ) pre_block Docile . dsl_eval ( self , * args , & block ) if block post_block self end
Evaluates a DSL directly from a Ruby block calling pre - and post - hooks .
16,660
def add_angle ( item , angle_tag , direction_tag , angle , direction , current_angle ) if ! self . send ( current_angle ) || angle != self . send ( current_angle ) self . send ( "#{current_angle}=" , angle ) DICOM :: Element . new ( angle_tag , angle , :parent => item ) DICOM :: Element . new ( direction_tag , ( direct...
Adds an angular type value to a Control Point Item by creating the necessary DICOM elements . Note that the element is only added if there is no current attribute defined or the given value is different form the current attribute .
16,661
def add_couch_position ( item , tag , value , current ) if ! self . send ( current ) || value != self . send ( current ) self . send ( "#{current}=" , value ) DICOM :: Element . new ( tag , ( value . empty? ? '' : value . to_f * 10 ) , :parent => item ) end end
Adds a Table Top Position element to a Control Point Item . Note that the element is only added if there is no current attribute defined or the given value is different form the current attribute .
16,662
def add_doserate ( value , item ) if ! @current_doserate || value != @current_doserate @current_doserate = value DICOM :: Element . new ( '300A,0115' , value , :parent => item ) end end
Adds a Dose Rate Set element to a Control Point Item . Note that the element is only added if there is no current attribute defined or the given value is different form the current attribute .
16,663
def create_control_point ( cp , sequence , options = { } ) cp_item = DICOM :: Item . new ( :parent => sequence ) DICOM :: Element . new ( '300A,0112' , "#{cp.index}" , :parent => cp_item ) create_beam_limiting_device_positions ( cp_item , cp , options ) add_ssd ( cp . ssd , cp_item ) DICOM :: Element . new ( '300A,0134...
Creates a control point item in the given control point sequence based on an RTP control point record .
16,664
def create_beam_limiting_devices ( beam_item , field ) bl_seq = DICOM :: Sequence . new ( '300A,00B6' , :parent => beam_item ) if [ 'SYM' , 'ASY' ] . include? ( field . field_x_mode . upcase ) bl_item_x = DICOM :: Item . new ( :parent => bl_seq ) DICOM :: Element . new ( '300A,00B8' , "ASYMX" , :parent => bl_item_x ) D...
Creates a beam limiting device sequence in the given DICOM object .
16,665
def create_asym_item ( cp , dcm_parent , axis , options = { } ) val1 = cp . send ( "dcm_collimator_#{axis.to_s}1" , options [ :scale ] ) val2 = cp . send ( "dcm_collimator_#{axis.to_s}2" , options [ :scale ] ) item = DICOM :: Item . new ( :parent => dcm_parent ) DICOM :: Element . new ( '300A,00B8' , "ASYM#{axis.to_s.u...
Creates an ASYMX or ASYMY item .
16,666
def create_dose_reference ( dcm , description ) dr_seq = DICOM :: Sequence . new ( '300A,0010' , :parent => dcm ) dr_item = DICOM :: Item . new ( :parent => dr_seq ) DICOM :: Element . new ( '300A,0012' , '1' , :parent => dr_item ) DICOM :: Element . new ( '300A,0014' , 'SITE' , :parent => dr_item ) DICOM :: Element . ...
Creates a dose reference sequence in the given DICOM object .
16,667
def create_referenced_dose_reference ( cp_item ) rd_seq = DICOM :: Sequence . new ( '300C,0050' , :parent => cp_item ) rd_item = DICOM :: Item . new ( :parent => rd_seq ) DICOM :: Element . new ( '300A,010C' , '' , :parent => rd_item ) DICOM :: Element . new ( '300C,0051' , '1' , :parent => rd_item ) rd_seq end
Creates a referenced dose reference sequence in the given DICOM object .
16,668
def save run_callbacks ( :before_save ) run_callbacks ( :before_create ) unless self . is_created existing_items = self . class . all if self . new_record? existing_items << self else updated_item = existing_items . find { | item | item . id == self . id } return false unless updated_item updated_item . attributes = se...
Saved YamlRecord instance to file Executes save and create callbacks Returns true if record saved ; false otherwise
16,669
def destroy run_callbacks ( :before_destroy ) new_data = self . class . all . reject { | item | item . persisted_attributes == self . persisted_attributes } . map { | item | item . persisted_attributes } self . class . write_contents ( new_data ) self . is_destroyed = true run_callbacks ( :after_destroy ) true rescue I...
Remove a persisted YamlRecord object Returns true if destroyed ; false otherwise
16,670
def tag ( k , v , ** options ) self [ :Properties ] [ :Tags ] ||= [ ] self [ :Properties ] [ :Tags ] . delete_if { | kv | kv [ "Key" ] == k } self [ :Properties ] [ :Tags ] . unshift ( { "Key" => k , "Value" => v } . merge ( options ) ) end
Sets a tag on this resource . The resource must support the CloudFormation Tags property .
16,671
def parameter ( name , options = { } ) param = { } options . each do | key , v | next if v === nil k = key . to_s . camelize . to_sym param [ k ] = case k when :AllowedPattern if v . class == Regexp v . source end when :Default @parameters [ name ] ||= v end param [ k ] ||= v end param [ :Type ] ||= 'String' self [ :Pa...
Declares a CloudFormation parameter
16,672
def resource ( name , type , options = { } , & block ) Preconditions . check_argument ( / / =~ name , "Resource name must be alphanumeric" ) clazz = Cfer :: Core :: Resource . resource_class ( type ) rc = clazz . new ( name , type , self , options , & block ) self [ :Resources ] [ name ] = rc rc . handle end
Creates a CloudFormation resource
16,673
def include_template ( * files ) include_base = options [ :include_base ] || File . dirname ( caller . first . split ( / \d / , 2 ) . first ) files . each do | file | path = File . join ( include_base , file ) include_file ( path ) end end
Includes template code from one or more files and evals it in the context of this stack . Filenames are relative to the file containing the invocation of this method .
16,674
def lookup_outputs ( stack ) client = @options [ :client ] || raise ( Cfer :: Util :: CferError , "Can not fetch stack outputs without a client" ) client . fetch_outputs ( stack ) end
Looks up a hash of all outputs from another CloudFormation stack in the same region .
16,675
def list ( options ) marker = options [ :marker ] prefix = options [ :prefix ] max_keys = options [ :max_keys ] || 1000 delimiter = options [ :delimiter ] ms = S3MatchSet . new marker_found = true pseudo = nil if marker marker_found = false if ! @object_map [ marker ] pseudo = S3Object . new pseudo . name = marker @sor...
Return back a set of matches based on the passed in options
16,676
def build_node ( node_name , env_hash , node_hash ) node_config = { 'server' => node_hash . slice ( 'host' , 'port' , 'user' , 'password' , 'platform' , 'vagrant' ) , 'attributes' => ( node_hash [ 'attributes' ] || { } ) . deep_merge ( env_hash [ 'attributes' ] || { } ) , 'run_list' => node_hash [ 'run_list' ] || env_h...
Node attributes get deep - merged with the environment ones Node run_list overrides the environment one Environment before hooks override global ones
16,677
def normalize_request ( rack_req ) host = rack_req . host s_req = Request . new s_req . path = path_for_rack_request ( rack_req ) s_req . is_path_style = true s_req . rack_request = rack_req if ! @root_hostnames . include? ( host ) s_req . bucket = host . split ( "." ) [ 0 ] s_req . is_path_style = false end s_req . ht...
This method takes a rack request and generates a normalized RackFakeS3 request
16,678
def generate ( target_dir , with_assets = true ) target_dir = File . expand_path target_dir copy_assets target_dir if with_assets render . each do | view_name , output | file_name = File . join target_dir , view_name . to_s . downcase + '.html' begin output_file = File . open file_name , 'wb' output_file . write output...
Creates a new report for the given repository and commit range
16,679
def copy_assets ( target_dir ) FileUtils . mkdir_p target_dir self . class . assets . map do | asset | asset_path = self . class . find asset asset_dir = File . join target_dir , File . dirname ( asset ) FileUtils . mkdir_p asset_dir unless File . exists? asset_dir FileUtils . cp_r asset_path , asset_dir end end
Copies the assets coming with this report to the given target directory
16,680
def actor ( actor ) id = self . class :: Actor . id_for ( actor ) @actors [ id ] ||= self . class :: Actor . new ( self , actor ) end
Creates a new repository instance with the given file system path
16,681
def commits ( range = current_branch ) range = parse_range range commits = cached_commits range if commits . empty? base_commit , raw_commits = load_commits ( range ) commits = build_commits raw_commits unless base_commit . nil? base_commit = self . class :: Commit . new ( self , base_commit ) base_commit . add_child c...
Loads all commits including their committers and authors from the given commit range
16,682
def file_stats ( range = current_branch ) support! :file_stats stats = { } commits ( range ) . each_value do | commit | commit . added_files . each do | file | stats [ file ] = { :modifications => 0 } unless stats . key? file stats [ file ] [ :added_date ] = commit . authored_date stats [ file ] [ :modifications ] += 1...
This evaluates basic statistics about the files in a given commit range .
16,683
def build_commits ( raw_commits ) child_commit_id = nil raw_commits . map do | commit | commit = self . class :: Commit . new ( self , commit ) commit . add_child child_commit_id unless child_commit_id . nil? child_commit_id = commit . id @commits [ commit . id ] = commit commit end end
Builds VCS specific commit objects for each given commit s raw data that is provided by the VCS implementation
16,684
def cached_commits ( range ) commits = [ ] direction = nil if @commits . key? range . last current_commits = [ @commits [ range . last ] ] direction = :parents elsif @commits . key? range . first current_commits = [ @commits [ range . first ] ] direction = :children end unless direction . nil? while ! current_commits ....
Tries to retrieve as many commits as possible in the given commit range from the commit cache
16,685
def parse_range ( range ) unless range . is_a? Range range = range . to_s . split '..' range = ( ( range . size == 1 ) ? '' : range . first ) .. range . last end range = id_for_ref ( range . first ) .. range . last if range . first != '' range . first .. id_for_ref ( range . last ) end
Parses a string or range of commit IDs or ref names into the coresponding range of unique commit IDs
16,686
def register_for ( vcs ) vcs = Metior . find_vcs vcs vcs . register_adapter id , self class_variable_set :@@vcs , vcs end
Registers this adapter with a VCS
16,687
def ensure_no_tags ( str ) return str unless str . html_safe? str = str . to_str str = strip_tags ( str ) str = HTMLEntities . new . decode ( str ) return str end
If the input is not marked html_safe? just return it . Otherwise strip html tags from it AND replace HTML char entities
16,688
def update ( name , type , ttl , values , comment = nil , zone_apex = nil ) prev = self . clone @name = name unless name . nil? @type = type unless type . nil? @ttl = ttl unless ttl . nil? @values = values unless values . nil? @zone_apex = zone_apex unless zone_apex . nil? @zone . perform_actions ( [ { :action => "DELE...
Need to modify to a param hash
16,689
def update_dirty ( name , type , ttl , values , zone_apex = nil ) prev = self . clone @name = name unless name . nil? @type = type unless type . nil? @ttl = ttl unless ttl . nil? @values = values unless values . nil? @zone_apex = zone_apex unless zone_apex . nil? return [ { :action => "DELETE" , :record => prev } , { :...
Returns the raw array so the developer can update large batches manually Need to modify to a param hash
16,690
def most_significant ( count = 3 ) support! :line_stats authors = ActorCollection . new sort_by { | author | - author . modifications } . each do | author | authors << author break if authors . size == count end authors end
Returns up to the given number of actors in this collection with the biggest impact on the repository i . e . changing the most code
16,691
def top ( count = 3 ) authors = ActorCollection . new sort_by { | author | - author . authored_commits . size } . each do | author | authors << author break if authors . size == count end authors end
Returns up to the given number of actors in this collection with the most commits
16,692
def load_commits ( commit_type , actor_id = nil ) commits = CommitCollection . new if actor_id . nil? each { | actor | commits . merge! actor . send ( commit_type ) } elsif key? actor_id commits = self [ actor_id ] . send commit_type end commits end
Loads the commits authored or committed by all actors in this collection or a specific actor
16,693
def load_commits ( range ) base_commit = nil commits = [ ] last_commit = nil loop do new_commits = :: Octokit . commits ( @path , nil , :last_sha => last_commit , :per_page => 100 , :top => range . last ) break if new_commits . empty? base_commit_index = new_commits . find_index do | commit | commit . sha == range . fi...
This method uses Octokit to load all commits from the given commit range
16,694
def validate ( challenge_password , certname , raw_csr ) @log . debug "running validate" fail unless challenge_password . is_a? ( String ) fail unless certname . is_a? ( String ) case perform_validation ( challenge_password , certname , raw_csr ) when true @log . debug "validated successfully" @log . info "Validated '#...
wrapper method that wraps input validation and logging around the perform_validation method . Do not override or use this class in child classes . This is the class that gets called on validator objects .
16,695
def settings @log . debug "merging settings" setting_sources = [ get_override_settings , load_config , default_settings ] merged_settings = setting_sources . inject ( { } ) { | merged , hash | merged . deep_merge ( hash ) } @log . debug "using merged settings: " + merged_settings . to_s @log . debug "validating merged ...
provide a merged settings hash of default settings for a validator config file settings for the validator and override settings defined in the validator .
16,696
def load_config @log . debug "loading validator-specific configuration" config = Autosign :: Config . new if config . settings . to_hash [ self . name ] . nil? @log . warn "Unable to load validator-specific configuration" @log . warn "Cannot load configuration section named '#{self.name}'" return { } else @log . debug ...
load any required configuration from the config file . Do not override this in child classes .
16,697
def fill_in_search_metadata_for ( results , normalized_arguments = { } ) results . search_args = normalized_arguments results . start = normalized_arguments [ :start ] || 0 results . per_page = normalized_arguments [ :per_page ] results . engine_id = configuration . id results . display_configuration = configuration . ...
SOME of the elements of Results to be returned that SearchEngine implementation fills in automatically post - search . Extracted into a method for DRY in error handling to try to fill these in even in errors . Also can be used as public method for de - serialized or mock results .
16,698
def to_hash action = @parameters [ :action ] userid = @parameters [ :userid ] appname = @parameters [ :appname ] || @appname patientid = @parameters [ :patientid ] token = @parameters [ :token ] || @security_token parameter1 = process_date ( @parameters [ :parameter1 ] ) || '' parameter2 = process_date ( @parameters [ ...
Convert the parameters to a Hash for Faraday with all possible dates converted to the Organization s localtime .
16,699
def get_encounter_list ( userid , patientid , encounter_type = nil , when_param = nil , nostradamus = 0 , show_past_flag = true , billing_provider_user_name = nil , show_all = false ) magic_parameters = { action : 'GetEncounterList' , userid : userid , patientid : patientid , parameter1 : encounter_type , parameter2 : ...
GetEncounterList helper method .