idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
13,800 | def guess_section_number_after_title ( text ) before = text . scan ( / \w \n \n \d \. / ) . length after = text . scan ( / \s \n \d \. \w / ) . length before > after * 1.25 end | Try to determine if section numbers come after titles rather than before . |
13,801 | def text_from_act ( doc ) filename = "/slaw/grammars/#{@grammar}/act_text.xsl" if dir = $LOAD_PATH . find { | p | File . exist? ( p + filename ) } xslt = Nokogiri :: XSLT ( File . read ( dir + filename ) ) xslt . transform ( doc ) . child . to_xml else raise "Unable to find text XSL for grammar #{@grammar}: #{fragment}... | Transform an Akoma Ntoso XML document back into a plain - text version suitable for re - parsing back into XML with no loss of structure . |
13,802 | def authorize ( options ) extensions = options . delete :extensions creds = creds_params ( options ) path = "/transactions/authorize.xml" + options_to_params ( options , ALL_PARAMS ) + '&' + creds headers = extensions_to_header extensions if extensions http_response = @http . get ( path , headers : headers ) case http_... | Authorize an application . |
13,803 | def usage_report ( node ) period_start = node . at ( 'period_start' ) period_end = node . at ( 'period_end' ) { :metric => node [ 'metric' ] . to_s . strip , :period => node [ 'period' ] . to_s . strip . to_sym , :period_start => period_start ? period_start . content : '' , :period_end => period_end ? period_end . cont... | It can be a user usage report or an app usage report |
13,804 | def generate_creds_params define_singleton_method :creds_params , if @service_tokens lambda do | options | token = options . delete ( :service_token ) service_id = options [ :service_id ] raise ArgumentError , "need to specify a service_token and a service_id" unless token && service_id 'service_token=' . freeze + CGI ... | helper to generate the creds_params method |
13,805 | def reply ( tweet_text , options = { } ) return if $bot . nil? or $bot [ :client ] . nil? opts = { reply_all : false } . merge ( options ) mentions = self . mentioned_users ( opts [ :reply_all ] ) result = "@#{mentions.join(" @")} #{tweet_text}" [ ( 0 ... 140 ) ] $bot [ :client ] . update result , in_reply_to_status_id... | Creates a reply to this tweet . |
13,806 | def mentioned_users ( reply_all = true , screen_name = $bot [ :config ] [ :screen_name ] ) userlist = [ self . user . screen_name ] if reply_all self . text . scan / / do | user_name | user_name = user_name [ 0 ] userlist << user_name unless userlist . include? ( user_name ) or screen_name == user_name end end userlist... | Scans the tweet text for screen names . |
13,807 | def reply ( direct_message_text ) return if $bot . nil? or $bot [ :client ] . nil? $bot [ :client ] . create_direct_message self . sender . id , direct_message_text rescue Twitter :: Error => e puts "caught Twitter error while replying via DM: #{e.message}" end | Replies to this direct message . |
13,808 | def perform validate! party_options = options . dup if proxy = self . proxy addr , port = proxy . split ( ':' ) party_options [ :http_proxyaddr ] = addr party_options [ :http_proxyport ] = port || 80 end party_options = party_options . merge ( sinew . runtime_options . httparty_options ) headers = sinew . runtime_optio... | run the request return the result |
13,809 | def parse_url ( url ) s = url s = HTML_ENTITIES . decode ( s ) s = s . gsub ( ' ' , '%20' ) s = s . gsub ( "'" , '%27' ) query = options . delete ( :query ) if query . present? q = HTTParty :: HashConversions . to_params ( query ) separator = s . include? ( '?' ) ? '&' : '?' s = "#{s}#{separator}#{q}" end URI . parse (... | We accept sloppy urls and attempt to clean them up |
13,810 | def cmd ( name , options = { } , & block ) raise "Command already exists: #{name}" if $bot [ :commands ] . include? name raise "Command name does not contain only alphanumerical characters" unless name . to_s . match / \A \z / opts = { admin : true } . merge ( options ) $bot [ :commands ] [ name ] ||= { admin : opts [ ... | Defines a new direct message command . |
13,811 | def task ( name , options = { } , & block ) name = name . to_s . downcase . to_sym task_re = / \A \z / raise "Task already exists: #{name}" if $bot [ :tasks ] . include? ( name ) raise "Task name does not match regexp #{task_re.to_s}" unless name . to_s . match ( task_re ) opts = { desc : '' } . merge ( options ) $bot ... | Defines a new task to be run outside of a running Twittbot process . |
13,812 | def save_config botpart_config = Hash [ @config . to_a - $bot [ :config ] . to_a ] unless botpart_config . empty? File . open @botpart_config_path , 'w' do | f | f . write botpart_config . to_yaml end end end | Saves the botpart s configuration . This is automatically called when Twittbot exits . |
13,813 | def health if state == "STARTED" healthy_count = running_instances expected = total_instances if expected > 0 ratio = healthy_count / expected . to_f if ratio == 1.0 "RUNNING" else "#{(ratio * 100).to_i}%" end else "N/A" end else state end rescue CFoundry :: StagingError , CFoundry :: NotStaged "STAGING FAILED" end | Determine application health . |
13,814 | def bind ( * instances ) instances . each do | i | binding = @client . service_binding binding . app = self binding . service_instance = i binding . create! end self end | Bind services to application . |
13,815 | def unbind ( * instances ) service_bindings . each do | b | if instances . include? b . service_instance b . delete! end end self end | Unbind services from application . |
13,816 | def parser raw = Metar :: Raw :: Noaa . new ( @cccc ) Metar :: Parser . new ( raw ) end | No check is made on the existence of the station |
13,817 | def weburl ( locale : nil , domain : DEFAULT_DOMAIN ) locale ||= self . lc || DEFAULT_LOCALE if self . code && prefix = LOCALE_WEBURL_PREFIXES [ locale ] path = "#{prefix}/#{self.code}" "https://#{locale}.#{domain}/#{path}" end end | Return Product web URL according to locale |
13,818 | def seek_visibility if observer . value == :auto if @chunks [ 0 ] == '////' @chunks . shift return end end if @chunks [ 0 ] == '1' or @chunks [ 0 ] == '2' @visibility = Metar :: Data :: Visibility . parse ( @chunks [ 0 ] + ' ' + @chunks [ 1 ] ) if @visibility @chunks . shift @chunks . shift end else @visibility = Metar... | 15 . 10 15 . 6 . 1 |
13,819 | def inspect use_dimension a = [ Utils . num_inspect ( @factor ) , @dim . inspect ] a << "@name=" + @name . inspect if @name a << "@expr=" + @expr . inspect if @expr a << "@offset=" + @offset . inspect if @offset a << "@dimensionless=true" if @dimensionless if @dimension_value && @dimension_value != 1 a << "@dimension_v... | Inspect string . |
13,820 | def unit_string use_dimension a = [ ] a << Utils . num_inspect ( @factor ) if @factor != 1 a += @dim . map do | k , d | if d == 1 k else "#{k}^#{d}" end end a . join ( " " ) end | Make a string of this unit expressed in base units . |
13,821 | def conversion_factor use_dimension f = @factor @dim . each do | k , d | if d != 0 u = LIST [ k ] if u . dimensionless? f *= u . dimension_value ** d end end end f end | Conversion Factor to base unit including dimension - value . |
13,822 | def convert ( quantity ) if Quantity === quantity assert_same_dimension ( quantity . unit ) v = quantity . unit . convert_value_to_base_unit ( quantity . value ) convert_value_from_base_unit ( v ) else quantity / to_numeric end end | Convert a quantity to this unit . |
13,823 | def convert_scale ( quantity ) if Quantity === quantity assert_same_dimension ( quantity . unit ) v = quantity . value * quantity . unit . conversion_factor v = v / self . conversion_factor else quantity / to_numeric end end | Convert a quantity to this unit only in scale . |
13,824 | def + ( x ) x = Unit . cast ( x ) check_operable2 ( x ) assert_same_dimension ( x ) Unit . new ( @factor + x . factor , @dim . dup ) end | Addition of units . Both units must be operable and conversion - allowed . |
13,825 | def * ( x ) x = Unit . cast ( x ) if scalar? return x elsif x . scalar? return self . dup end check_operable2 ( x ) dims = dimension_binop ( x ) { | a , b | a + b } factor = self . factor * x . factor Unit . new ( factor , dims ) end | Multiplication of units . Both units must be operable . |
13,826 | def inverse check_operable dims = dimension_uop { | a | - a } Unit . new ( Rational ( 1 , self . factor ) , dims ) end | Inverse of units . This unit must be operable . |
13,827 | def ** ( x ) check_operable m = Utils . as_numeric ( x ) dims = dimension_uop { | a | a * m } Unit . new ( @factor ** m , dims ) end | Exponentiation of units . This units must be operable . |
13,828 | def products ( page : - 1 ) Product . from_website_page ( url , page : page , products_count : products_count ) if url end | Get products with country |
13,829 | def send_receipt ( payment ) @payment = payment @payment_url = public_receipt_payment_url ( :payment_id => @payment . id , :public_token => @payment . public_token ) mail ( :to => "#{@payment.customer.email}" , :from => Jackpot . configuration . mailer [ :from ] , :subject => "Payment receipt" ) end | Sends the receipt to the customer who made this payment |
13,830 | def text if handler = find_handler and text = handler . text ( @file , max_size : max_plaintext_bytes ) text . gsub! ( / \s /m , ' ' ) text . strip! text . mb_chars . compose . limit ( max_plaintext_bytes ) . to_s end end | Returns the extracted fulltext or nil if no matching handler was found for the file type . |
13,831 | def explore paths = if Config . explore_role_files? possible_paths else [ get_path ] end paths . find { | path | File . readable? ( path ) } || paths . last end | Returns readable role file exploring possible role files . For example if role is myapp - web - staging this method explores files as |
13,832 | def djatoka_init_openlayers ( rft_id , div_identifier , params = { } ) resolver = determine_resolver ( params ) metadata_url = resolver . metadata_url ( rft_id ) %Q|<script type="text/javascript"> jQuery(document).ready(function() {openlayersInit('#{resolver.scheme}://#{resolver.host}', '#{metadata_ur... | View helper to include a bit of jQuery on the page which waits for document load and then initializes the Ajax OpenLayers viewer . Since this works via Ajax Djatoka will need to be running or proxied at the same domain as the application to avoid cross - domain restrictions . |
13,833 | def localized_resources ( type = :resources , * resources , & block ) localizable_route = nil if @locales res = resources . clone options = res . extract_options! r = res . first resource = resource_from_params ( type , r , options . dup ) stored_locale = I18n . locale @locales . each do | locale | I18n . locale = loca... | Localize a resources or a resource |
13,834 | def initialize_with_i18n_routing ( app , conditions , defaults , name ) @locale = if conditions . key? ( :i18n_locale ) c = conditions . delete ( :i18n_locale ) ( c . respond_to? ( :source ) ? c . source : c ) . to_sym else nil end initialize_without_i18n_routing ( app , conditions , defaults , name ) end | During route initialization if a condition i18n_locale is present Delete it and store it in |
13,835 | def generate_with_i18n_routing ( method , params = { } , recall = { } , options = { } ) return nil if @locale and @locale != I18n . locale . to_sym generate_without_i18n_routing ( method , params , recall , options ) end | Called for dynamic route generation If a |
13,836 | def pending ( hours = 24 ) cutoff = Time . now . to_i + hours * 3600 windows_in_state ( :pending ) . tap do | r | r . response . items . delete_if { | w | w . startTimeInSeconds > cutoff } end end | Get the windows which will be open in the next so - many hours |
13,837 | def constraint_equal? ( region , constraint ) [ region , constraint ] . collect { | v | v . nil? || v == '' ? 'us-east-1' : v } . reduce ( :== ) end | US default constraint is often represented as or nil |
13,838 | def check_sub_type_without ( val , delim ) return false unless val =~ delim new_val = val . gsub ( delim , "" ) . strip NodeCache . find ( attributes [ "type" ] ) == new_valu end | For types like pointers or references we recursively track down the base type when doing comparisons . |
13,839 | def to_s text = '' text << tag_output_string + "\n" unless tags . empty? text << "Feature:#{name_output_string}" text << "\n" + description_output_string unless description_text . empty? text << "\n\n" + background_output_string if background text << "\n\n" + tests_output_string unless tests . empty? text end | Returns gherkin representation of the feature . |
13,840 | def get_images ( params = { } ) @log . trace "Listing images with params = #{params.to_json}..." data = JSON . parse ( RestClient . get ( "#{url}/v1/images" , :params => params ) ) [ 'images' ] @log . trace "Listing done." data end | Retrieves a list of public images with specified filter . If no filter is specified - all images are returned . |
13,841 | def versions ( id ) wf_alert_id? ( id ) resp = api . get ( [ id , 'history' ] . uri_concat ) versions = resp . response . items . map ( & :version ) resp . response [ :items ] = versions resp end | Gets all the versions of the given alert |
13,842 | def define_enum_t_methods defined_enums . each do | enum_attr , values | self . class . send ( :define_method , "#{enum_attr}_t" ) { t_enum ( enum_attr ) } self . class . send ( :define_method , "#{enum_attr.pluralize}_t" ) do t_enum_values ( enum_attr , values ) end end end | enum attrubute_t and attributes_t return translated enum values |
13,843 | def parse_time ( time , in_ms = false ) return relative_time ( time , in_ms ) if time =~ / \- / ParseTime . new ( time , in_ms ) . parse! end | Return a time as an integer however it might come in . |
13,844 | def relative_time ( time , in_ms = false , ref = Time . now ) ref = in_ms ? ref . to_datetime . strftime ( '%Q' ) : ref . to_time ref . to_i + parse_relative_time ( time , in_ms ) end | Return a timestamp described by the given string . That is + 5m is five minutes in the future and - . 1h is half an hour ago . |
13,845 | def time_multiplier ( suffix ) u = { s : 1 , m : 60 , h : 3600 , d : 86_400 , w : 604_800 , y : 31_536_000 } return u [ suffix . to_sym ] if u . key? ( suffix . to_sym ) raise Wavefront :: Exception :: InvalidTimeUnit end | naively return the number of seconds from the given multiplier . This makes absolutely no attempt to compensate for any kind of daylight savings or calendar adjustment . A day is always going to 60 seconds x 60 minutes x 24 hours and a year will always have 365 days . |
13,846 | def create_agreement ( agreement ) agreement_response = Echochamber :: Request . create_agreement ( agreement , token , agreement . user_id , agreement . user_email ) agreement_response . fetch ( "agreementId" ) end | Creates an agreement |
13,847 | def agreement_documents ( agreement_id , recipient_email , format , version_id = nil ) result = Echochamber :: Request . agreement_documents ( token , agreement_id , recipient_email , format , version_id ) end | All documents relating to an agreement |
13,848 | def agreement_document_file ( agreement_id , document_id , file_path = nil ) response = Echochamber :: Request . agreement_document_file ( token , agreement_id , document_id ) unless file_path . nil? file = File . new ( file_path , 'wb' ) file . write ( response ) file . close end response end | Retrieve a document file from an agreement |
13,849 | def agreement_combined_pdf ( agreement_id , file_path = nil , versionId = nil , participantEmail = nil , attachSupportingDocuments = true , auditReport = false ) response = Echochamber :: Request . agreement_combined_pdf ( token , agreement_id , versionId , participantEmail , attachSupportingDocuments , auditReport ) u... | Gets a single combined PDF document for the documents associated with an agreement . |
13,850 | def wf_link_template? ( template ) if template . is_a? ( String ) && template . start_with? ( 'http://' , 'https://' ) return true end raise Wavefront :: Exception :: InvalidLinkTemplate end | Ensure the given argument is a valid external link template |
13,851 | def wf_name? ( name ) return true if name . is_a? ( String ) && name . size < 1024 && name =~ / \w / raise Wavefront :: Exception :: InvalidName end | Ensure the given argument is a valid name for instance for an event . Names can contain AFAIK word characters . |
13,852 | def wf_string? ( str ) if str . is_a? ( String ) && str . size < 1024 && str =~ / \- \w \. / return true end raise Wavefront :: Exception :: InvalidString end | Ensure the given argument is a valid string for a tag name . |
13,853 | def wf_ts? ( timestamp ) return true if timestamp . is_a? ( Time ) || timestamp . is_a? ( Date ) raise Wavefront :: Exception :: InvalidTimestamp end | Ensure the given argument is a valid timestamp |
13,854 | def wf_epoch? ( timestamp ) return true if timestamp . is_a? ( Numeric ) raise Wavefront :: Exception :: InvalidTimestamp end | Ensure the given argument is a valid epoch timestamp . Again no range checking . |
13,855 | def wf_value? ( value ) return true if value . is_a? ( Numeric ) raise Wavefront :: Exception :: InvalidMetricValue end | Ensure the given argument is a valid Wavefront value . Can be any form of Numeric including standard notation . |
13,856 | def wf_version? ( version ) version = version . to_i if version . is_a? ( String ) && version =~ / \d / return true if version . is_a? ( Integer ) && version . positive? raise Wavefront :: Exception :: InvalidVersion end | Ensure the given argument is a valid version number |
13,857 | def wf_alert_id? ( id ) id = id . to_s if id . is_a? ( Numeric ) return true if id . is_a? ( String ) && id . match ( / \d / ) raise Wavefront :: Exception :: InvalidAlertId end | Ensure the given argument is a valid Wavefront alert ID . Alerts are identified by the epoch - nanosecond at which they were created . |
13,858 | def wf_dashboard_id? ( id ) return true if id . is_a? ( String ) && id . size < 256 && id . match ( / \w \- / ) raise Wavefront :: Exception :: InvalidDashboardId end | There doesn t seem to be a public statement on what s allowed in a dashboard name . For now I m going to assume up to 255 word characters . |
13,859 | def wf_derivedmetric_id? ( id ) id = id . to_s if id . is_a? ( Numeric ) return true if id . is_a? ( String ) && id =~ / \d / raise Wavefront :: Exception :: InvalidDerivedMetricId end | Ensure the given argument is a valid derived metric ID . IDs are the millisecond epoch timestamp at which the derived metric was created . |
13,860 | def wf_link_id? ( id ) return true if id . is_a? ( String ) && id =~ / \w / raise Wavefront :: Exception :: InvalidExternalLinkId end | Ensure the given argument is a valid external Link ID |
13,861 | def wf_maintenance_window_id? ( id ) id = id . to_s if id . is_a? ( Numeric ) return true if id . is_a? ( String ) && id =~ / \d / raise Wavefront :: Exception :: InvalidMaintenanceWindowId end | Ensure the given argument is a valid maintenance window ID . IDs are the millisecond epoch timestamp at which the window was created . |
13,862 | def wf_alert_severity? ( severity ) return true if %w[ INFO SMOKE WARN SEVERE ] . include? ( severity ) raise Wavefront :: Exception :: InvalidAlertSeverity end | Ensure the given argument is a valid alert severity |
13,863 | def wf_message_id? ( id ) return true if id . is_a? ( String ) && id =~ / \w \w / raise Wavefront :: Exception :: InvalidMessageId end | Ensure the given argument is a valid message ID |
13,864 | def wf_granularity? ( granularity ) return true if %w[ d h m s ] . include? ( granularity . to_s ) raise Wavefront :: Exception :: InvalidGranularity end | Ensure the given argument is a valid query granularity |
13,865 | def wf_savedsearch_id? ( id ) return true if id . is_a? ( String ) && id =~ / \w / raise Wavefront :: Exception :: InvalidSavedSearchId end | Ensure the given argument is a valid saved search ID . |
13,866 | def wf_savedsearch_entity? ( id ) return true if %w[ DASHBOARD ALERT MAINTENANCE_WINDOW NOTIFICANT EVENT SOURCE EXTERNAL_LINK AGENT CLOUD_INTEGRATION ] . include? ( id ) raise Wavefront :: Exception :: InvalidSavedSearchEntity end | Ensure the given argument is a valid saved search entity type . |
13,867 | def wf_source_id? ( source ) if source . is_a? ( String ) && source . match ( / \w \. \- / ) && source . size < 1024 return true end raise Wavefront :: Exception :: InvalidSourceId end | Ensure the given argument is a valid Wavefront source name |
13,868 | def wf_user_id? ( user ) return true if user . is_a? ( String ) && user . length < 256 && ! user . empty? raise Wavefront :: Exception :: InvalidUserId end | Ensure the given argument is a valid user . |
13,869 | def wf_webhook_id? ( id ) return true if id . is_a? ( String ) && id =~ / / raise Wavefront :: Exception :: InvalidWebhookId end | Ensure the given argument is a valid webhook ID . |
13,870 | def wf_distribution? ( dist ) wf_metric_name? ( dist [ :path ] ) wf_distribution_values? ( dist [ :value ] ) wf_epoch? ( dist [ :ts ] ) if dist [ :ts ] wf_source_id? ( dist [ :source ] ) if dist [ :source ] wf_point_tags? ( dist [ :tags ] ) if dist [ :tags ] true end | Validate a distribution description |
13,871 | def wf_distribution_values? ( vals ) vals . each do | times , val | wf_distribution_count? ( times ) wf_value? ( val ) end true end | Validate an array of distribution values |
13,872 | def wf_notificant_id? ( id ) return true if id . is_a? ( String ) && id =~ / \w / raise Wavefront :: Exception :: InvalidNotificantId end | Ensure the given argument is a valid Wavefront notificant ID . |
13,873 | def wf_integration_id? ( id ) return true if id . is_a? ( String ) && id =~ / / raise Wavefront :: Exception :: InvalidIntegrationId end | Ensure the given argument is a valid Wavefront integration ID . These appear to be lower - case strings . |
13,874 | def wf_distribution_interval? ( interval ) return true if %i[ m h d ] . include? ( interval ) raise Wavefront :: Exception :: InvalidDistributionInterval end | Ensure the given argument is a valid distribution interval . |
13,875 | def wf_distribution_count? ( count ) return true if count . is_a? ( Integer ) && count . positive? raise Wavefront :: Exception :: InvalidDistributionCount end | Ensure the given argument is a valid distribution count . |
13,876 | def response_shim ( body , status ) resp , err_msg = parsed_response ( body ) { response : resp , status : { result : status == 200 ? 'OK' : 'ERROR' , message : err_msg , code : status } } . to_json end | Fake a response which looks like we get from all the other paths . The default response is a single array . |
13,877 | def parsed_response ( body ) [ JSON . parse ( body ) , '' ] rescue JSON :: ParserError [ '' , body . match ( / / ) . captures . first ] end | A bad query doesn t send back a JSON object . It sends back a string with an embedded message . |
13,878 | def populate ( raw ) @config = Map ( raw ) @creds = Map ( raw . select { | k , _v | %i[ endpoint token ] . include? ( k ) } ) @proxy = Map ( raw . select { | k , _v | %i[ proxy port ] . include? ( k ) } ) @all = Map ( raw . select do | k , _v | %i[ proxy port endpoint token ] . include? ( k ) end ) end | Make the helper values . We use a Map so they re super - easy to access |
13,879 | def log_hack read_stderr , write_stderr = IO . pipe fork do write_stderr . close read_stderr . each do | l | @log . trace "GFS: #{l.chomp.strip}" end read_stderr . close end old_stderr = STDERR . clone STDERR . reopen ( write_stderr ) STDERR . sync = true begin yield if block_given? ensure STDERR . reopen ( old_stderr ... | If log callback aren t available we will fail to this which sucks ... |
13,880 | def mount_partitions ( device , mount_prefix = '' ) @log . trace "Mounting partitions..." partitions = mountable_partitions ( device ) mount_points = LinuxHelper . new ( :log => @log ) . partition_mount_points ( @appliance_config . hardware . partitions ) mount_points . delete ( "swap" ) partitions . each_index { | i |... | This mount partitions . We assume that the first partition is a root partition . |
13,881 | def umount_partitions ( device ) partitions = mountable_partitions ( device ) @log . trace "Unmounting partitions..." partitions . reverse . each { | part | umount_partition ( part ) } @log . trace "All partitions unmounted." end | Unmounts partitions in reverse order . |
13,882 | def body ( query , options ) ret = { limit : options [ :limit ] || 10 , offset : options [ :offset ] || 0 } if query && ! query . empty? ret [ :query ] = [ query ] . flatten . map do | q | q . tap { | iq | iq [ :matchingMethod ] ||= 'CONTAINS' } end ret [ :sort ] = sort_field ( options , query ) end ret end | Build a query body |
13,883 | def create_server @log . info "Creating new server..." memory = ( ( is_cloudsigma? and @appliance_config . hardware . memory < 512 ) ? 512 : @appliance_config . hardware . memory ) body = hash_to_request ( 'name' => "#{@appliance_config.name}-#{@appliance_config.version}.#{@appliance_config.release}" , 'cpu' => @applia... | Creates the server for previously uploaded disk |
13,884 | def initialize_plugins @plugin_chain = [ ] os_plugin , os_plugin_info = PluginManager . instance . initialize_plugin ( :os , @appliance_config . os . name . to_sym ) initialize_plugin ( os_plugin , os_plugin_info ) if platform_selected? platform_plugin , platform_plugin_info = PluginManager . instance . initialize_plug... | Here we initialize all required plugins and create a plugin chain . Initialization involves also plugin configuration validation for specified plugin type . |
13,885 | def initialize_plugin ( plugin , plugin_info , options = { } ) options = { :log => @log } . merge ( options ) unless @plugin_chain . empty? options . merge! ( :previous_plugin => @plugin_chain . last [ :plugin ] ) end plugin . init ( @config , @appliance_config , plugin_info , options ) [ :after_init , :validate , :aft... | Initializes the plugin by executing init after_init validate and after_validate methods . |
13,886 | def create @log . debug "Launching new build..." @log . trace "Used configuration: #{@config.to_yaml.gsub(/(\S*(key|account|cert|username|host|password)\S*).*:(.*)/, '\1' + ": <REDACTED>")}" PluginHelper . new ( @config , :log => @log ) . load_plugins read_definition validate_definition initialize_plugins remove_old_bu... | This creates the appliance by executing the plugin chain . |
13,887 | def determine_capabilities ( conn , previous_plugin_info ) plugin = get_plugin ( previous_plugin_info ) root = Nokogiri :: XML . parse ( conn . capabilities ) guests = root . xpath ( "//guest/arch[@name='x86_64']/.." ) guests = guests . sort do | a , b | dom_maps = [ a , b ] . map { | x | plugin . domain_map [ xpath_fi... | Connect to the remote machine and determine the best available settings |
13,888 | def get_plugin ( previous_plugin_info ) if previous_plugin_info [ :type ] == :platform if PLUGINS . has_key? ( previous_plugin_info [ :name ] ) @log . debug ( "Using #{previous_plugin_info[:name]} mapping" ) return PLUGINS [ previous_plugin_info [ :name ] ] else @log . debug ( "This plugin does not know what mappings t... | At present we don t have enough meta - data to work with to easily generalise so we have to assume defaults often . This is something to improve later . |
13,889 | def pay_now order = current_order || raise ( ActiveRecord :: RecordNotFound ) session [ :order_number ] = current_order . number invoice = order . place_bitpay_order notificationURL : bitpay_notification_url @invoice_iframe_url = "#{invoice['url']}&view=iframe" render json : @invoice_iframe_url end | Generates Bitpay Invoice and returns iframe view |
13,890 | def payment_sent order_number = session [ :order_number ] session [ :order_number ] = nil order = Spree :: Order . find_by_number ( order_number ) || raise ( ActiveRecord :: RecordNotFound ) redirect_to spree . order_path ( order ) , :notice => Spree . t ( :order_processed_successfully ) end | Fires on receipt of payment received window message |
13,891 | def notification begin posData = JSON . parse ( params [ "posData" ] ) order_id = posData [ "orderID" ] payment_id = posData [ "paymentID" ] order = Spree :: Order . find_by_number ( order_id ) || raise ( ActiveRecord :: RecordNotFound ) begin order . process_bitpay_ipn payment_id head :ok rescue => exception logger . ... | Handle IPN from Bitpay server Receives incoming IPN message and retrieves official BitPay invoice for processing |
13,892 | def refresh payment = Spree :: Payment . find ( params [ :payment ] ) old_state = payment . state payment . process_bitpay_ipn new_state = payment . reload . state notice = ( new_state == old_state ) ? Spree . t ( :bitpay_payment_not_updated ) : ( Spree . t ( :bitpay_payment_updated ) + new_state . titlecase ) redirect... | Reprocess Invoice and update order status |
13,893 | def add_ec2_user ( guestfs ) @log . debug "Adding ec2-user user..." unless guestfs . fgrep ( "ec2-user" , "/etc/passwd" ) . empty? @log . debug ( "ec2-user already exists, skipping." ) return end guestfs . sh ( "useradd ec2-user" ) guestfs . sh ( "echo -e 'ec2-user\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers" ) @log . d... | Adds ec2 - user will full sudo access without password per Fedora security guidelines . We should not use root access on AMIs as it is not secure and prohibited by AWS . |
13,894 | def step_text ( options = { } ) options = { :with_keywords => true , :with_arguments => true , :left_delimiter => self . left_delimiter , :right_delimiter => self . right_delimiter } . merge ( options ) final_step = [ ] step_text = '' step_text += "#{@keyword} " if options [ :with_keywords ] if options [ :with_argument... | Returns true if the two steps have the same text minus any keywords and arguments and false otherwise . Deprecated |
13,895 | def scan_arguments ( * how ) if how . count == 1 pattern = how . first else left_delimiter = how [ 0 ] || self . left_delimiter right_delimiter = how [ 1 ] || self . right_delimiter return [ ] unless left_delimiter && right_delimiter pattern = Regexp . new ( Regexp . escape ( left_delimiter ) + '(.*?)' + Regexp . escap... | Populates the step s arguments based on the step s text and some method of determining which parts of the text are arguments . Methods include using a regular expression and using the step s delimiters . |
13,896 | def stripped_step ( step , left_delimiter , right_delimiter ) unless left_delimiter . nil? || right_delimiter . nil? pattern = Regexp . new ( Regexp . escape ( left_delimiter ) + '.*?' + Regexp . escape ( right_delimiter ) ) step = step . gsub ( pattern , left_delimiter + right_delimiter ) end step end | Returns the step string minus any arguments based on the given delimiters . |
13,897 | def substitute_vars ( str ) return if str . nil? @appliance_config . variables . keys . each do | var | str = str . gsub ( "##{var}#" , @appliance_config . variables [ var ] ) end str end | Substitute variables in selected string . |
13,898 | def install_files ( guestfs ) @log . debug "Installing files specified in appliance definition file..." @appliance_config . files . each do | dir , files | @log . debug "Proceding files for '#{dir}' destination directory..." local_files = [ ] guestfs . mkdir_p ( dir ) unless guestfs . exists ( dir ) != 0 files . each d... | Copies specified files into appliance . |
13,899 | def get_library_document_file ( library_document_id , file_id , file_path = nil ) response = Echochamber :: Request . get_library_document_file ( token , library_document_id , file_id ) unless file_path . nil? file = File . new ( file_path , 'wb' ) file . write ( response ) file . close end response end | Retrieves library document file data |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.