def mv(src, dst, mkdir: false)
      mkdir_if_necessary(File.dirname(dst)) if mkdir
      FileUtils.mv(src, dst, verbose: verbose?)
    end

def mv ( src , dst , mkdir : false ) mkdir_if_necessary ( File . dirname ( dst ) ) if mkdir FileUtils . mv ( src , dst , verbose : verbose? ) end

Like mv +src+ +dst. If +mkdir+ is true, the dst directoy will be created
 if necessary before the copy. Like all file commands, the operation will
 be printed out if verbose?.

Like mv + src + + dst . If + mkdir + is true the dst directoy will be created if necessary before the copy . Like all file commands the operation will be printed out if verbose? .


def ln(src, dst)
      FileUtils.ln_sf(src, dst, verbose: verbose?)
    rescue Errno::EEXIST => e
      # It's a race - this can occur because ln_sf removes the old
      # dst, then creates the symlink. Raise if they don't match.
      raise e if !(File.symlink?(dst) && src == File.readlink(dst))
    end

Like ln -sf +src+ +dst. The command will be printed out if
 verbose?.

Like ln - sf + src + + dst . The command will be printed out if verbose? .


def chmod(file, mode)
      return if File.stat(file).mode == mode
      FileUtils.chmod(mode, file, verbose: verbose?)
    end

def chmod ( file , mode ) return if File . stat ( file ) . mode == mode FileUtils . chmod ( mode , file , verbose : verbose? ) end

Like chmod mode file. Like all file commands, the operation will be
 printed out if verbose?.

Like chmod mode file . Like all file commands the operation will be printed out if verbose? .


def rm_and_mkdir(dir)
      raise "don't do this" if dir == ""
      FileUtils.rm_rf(dir, verbose: verbose?)
      mkdir(dir)
    end

def
rm_and_mkdir
(
dir
)
raise
"don't do this"
if
dir
==
""
FileUtils
.
rm_rf
(
dir
,
verbose
:
verbose?
)
mkdir
(
dir
)
end

Like rm -rf && mkdir -p. Like all file commands, the operation will be
 printed out if verbose?.

Like rm - rf && mkdir - p . Like all file commands the operation will be printed out if verbose? .


def copy_metadata(src, dst)
      stat = File.stat(src)
      File.chmod(stat.mode, dst)
      File.utime(stat.atime, stat.mtime, dst)
    end

def copy_metadata ( src , dst ) stat = File . stat ( src ) File . chmod ( stat . mode , dst ) File . utime ( stat . atime , stat . mtime , dst ) end

Copy mode, atime and mtime from +src+ to +dst+. This one is rarely used
 and doesn't echo.

Copy mode atime and mtime from + src + to + dst + . This one is rarely used and doesn t echo .


def atomic_write(path)
      tmp = Tempfile.new(File.basename(path))
      yield(tmp)
      tmp.close
      chmod(tmp.path, 0o644)
      mv(tmp.path, path)
    ensure
      rm_if_necessary(tmp.path)
    end

def atomic_write ( path ) tmp = Tempfile . new ( File . basename ( path ) ) yield ( tmp ) tmp . close chmod ( tmp . path , 0o644 ) mv ( tmp . path , path ) ensure rm_if_necessary ( tmp . path ) end

Atomically write to +path+. An open temp file is yielded.

Atomically write to + path + . An open temp file is yielded .


def handle_requests
      until @requestmq.empty?
        request = @requestmq.deq(true)
        begin
          request.response = @app.call(request.env)
        rescue Exception => e
          request.exception = e
        ensure
          body = request.response.try(:last)
          body.close  if body.respond_to? :close
        end
      end
    end

def handle_requests until @requestmq . empty? request = @requestmq . deq ( true ) begin request . response = @app . call ( request . env ) rescue Exception => e request . exception = e ensure body = request . response . try ( :last ) body . close if body . respond_to? :close end end end

Should be run by another thread - respond to all queued requests


def configfile_hash

      config  = {}
      begin
        json    = File.read(configfile)
        config  = JSON.parse(json)
      rescue Errno::ENOENT
        # depending on whether the instance has been saved or not, we may not
        # yet have a configfile - allow to proceed
        @logger.debug "#{configfile} does not exist"
        @force_save = true
      rescue JSON::ParserError
        # swallow parse errors so that we can destroy and recreate automatically
        @logger.debug "JSON parse error in #{configfile}"
        @force_save = true
      end
      config
    end

return a hash of the configfile or empty hash if error encountered


def email_addresses(text)
      text.gsub(@regex[:mail]) do
        text = $&
        if auto_linked?($`, $')
          text
        else
          display_text = (block_given?) ? yield(text) : text
          # mail_to text, display_text
          "#{display_text}"
        end
      end
    end

Turns all email addresses into clickable links.  If a block is given,
 each email is yielded and the result is used as the link text.

Turns all email addresses into clickable links . If a block is given each email is yielded and the result is used as the link text .


def plural(rule, replacement)
      @uncountables.delete(rule) if rule.is_a?(String)
      @uncountables.delete(replacement)
      @plurals.insert(0, [rule, replacement])
    end

def plural ( rule , replacement ) @uncountables . delete ( rule ) if rule . is_a? ( String ) @uncountables . delete ( replacement ) @plurals . insert ( 0 , [ rule , replacement ] ) end

Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression.
 The replacement should always be a string that may include references to the matched data from the rule.

Specifies a new pluralization rule and its replacement . The rule can either be a string or a regular expression . The replacement should always be a string that may include references to the matched data from the rule .


def singular(rule, replacement)
      @uncountables.delete(rule) if rule.is_a?(String)
      @uncountables.delete(replacement)
      @singulars.insert(0, [rule, replacement])
    end

def singular ( rule , replacement ) @uncountables . delete ( rule ) if rule . is_a? ( String ) @uncountables . delete ( replacement ) @singulars . insert ( 0 , [ rule , replacement ] ) end

Specifies a new singularization rule and its replacement. The rule can either be a string or a regular expression.
 The replacement should always be a string that may include references to the matched data from the rule.

Specifies a new singularization rule and its replacement . The rule can either be a string or a regular expression . The replacement should always be a string that may include references to the matched data from the rule .


def irregular(singular, plural)
      @uncountables.delete(singular)
      @uncountables.delete(plural)
      if singular[0,1].upcase == plural[0,1].upcase
        plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1])
        singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1])
      else
        plural(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), plural[0,1].upcase + plural[1..-1])
        plural(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
        singular(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), singular[0,1].upcase + singular[1..-1])
        singular(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), singular[0,1].downcase + singular[1..-1])
      end
    end

Specifies a new irregular that applies to both pluralization and singularization at the same time. This can only be used
 for strings, not regular expressions. You simply pass the irregular in singular and plural form.

 Examples:
   irregular 'octopus', 'octopi'
   irregular 'person', 'people'

Specifies a new irregular that applies to both pluralization and singularization at the same time . This can only be used for strings not regular expressions . You simply pass the irregular in singular and plural form .


def execute
      raise errors.to_sentences unless valid?

      # default failing command
      result = false

      # protect command from recursion
      mutex = Mutagem::Mutex.new('revenc.lck')
      lock_successful = mutex.execute do
        result = system_cmd(cmd)
      end

      raise "action failed, lock file present" unless lock_successful
      result
    end

def
execute
raise
errors
.
to_sentences
unless
valid?
# default failing command
result
=
false
# protect command from recursion
mutex
=
Mutagem
::
Mutex
.
new
(
'revenc.lck'
)
lock_successful
=
mutex
.
execute
do
result
=
system_cmd
(
cmd
)
end
raise
"action failed, lock file present"
unless
lock_successful
result
end

run the action if valid and return true if successful


def output
      opts = options
      if opts.format
        FileUtils.mkdir_p opts.output_dir
        formatted_output
      end
      @results.clear
    end

def output opts = options if opts . format FileUtils . mkdir_p opts . output_dir formatted_output end @results . clear end

Output the results based on the requested output format


def run
      while @jobs.length > 0 do
        # do a warm up run first with the highest connection rate
        @current_job = @jobs.pop
        @current_rate = @current_job.high_rate.to_i
        httperf true

        (@current_job.low_rate.to_i..@current_job.high_rate.to_i).
            step(@current_job.rate_step.to_i) do |rate|
          @current_rate = rate
          httperf
        end
        output
      end
    end

Run httperf from low_rate to high_rate, stepping by rate_step

Run httperf from low_rate to high_rate stepping by rate_step


def authenticate(username, password, tenant = nil)
                  data = {
                          "auth" => {
                                  "passwordCredentials" => {
                                          "username" => username,
                                          "password" => password
                                  }
                          }
                  }
                  unless tenant.nil?
                          data["auth"]["tenantName"] = tenant
                  end
                  @data = post_request(address("/tokens"), data, @token)
          end

def authenticate ( username , password , tenant = nil ) data = { "auth" => { "passwordCredentials" => { "username" => username , "password" => password } } } unless tenant . nil? data [ "auth" ] [ "tenantName" ] = tenant end @data = post_request ( address ( "/tokens" ) , data , @token ) end

Authenticate via keystone, unless a token and tenant are defined then a unscoped
 token is returned with all associated data and stored in the @data variable.
 Does not return anything, but all data is accessible through accessor methods.

Authenticate via keystone unless a token and tenant are defined then a unscoped token is returned with all associated data and stored in the


def add_to_services(name, type, description)
                  data = {
                          'OS-KSADM:service' => {
                                   'name' => name,
                                   'type' => type,
                                   'description' => description
                          }
                  }
                  return post_request(address("/OS-KSADM/services"), data, token())
          end

def add_to_services ( name , type , description ) data = { 'OS-KSADM:service' => { 'name' => name , 'type' => type , 'description' => description } } return post_request ( address ( "/OS-KSADM/services" ) , data , token ( ) ) end

Add a service to the keystone services directory


def add_endpoint(region, service_id, publicurl, adminurl, internalurl)
                  data = {
                          'endpoint' => {
                                  'region' => region,
                                  'service_id' => service_id,
                                  'publicurl' => publicurl,
                                  'adminurl' => adminurl,
                                  'internalurl' => internalurl
                          }
                  }
                  return post_request(address("/endpoints"), data, token())
          end

def add_endpoint ( region , service_id , publicurl , adminurl , internalurl ) data = { 'endpoint' => { 'region' => region , 'service_id' => service_id , 'publicurl' => publicurl , 'adminurl' => adminurl , 'internalurl' => internalurl } } return post_request ( address ( "/endpoints" ) , data , token ( ) ) end


def get_endpoints(token = nil)
                  if token.nil?
                          return get_request(address("/endpoints"), token())
                  else
                          return get_request(address("/tokens/#{token}/endpoints"), token())
                  end
          end

def get_endpoints ( token = nil ) if token . nil? return get_request ( address ( "/endpoints" ) , token ( ) ) else return get_request ( address ( "/tokens/#{token}/endpoints" ) , token ( ) ) end end


def disable_method(method_name, message = nil)
      disabled_methods[method_name] ||= DisabledMethod.new(self, method_name, message)
      disabled_methods[method_name].disable!
    end

def disable_method ( method_name , message = nil ) disabled_methods [ method_name ] ||= DisabledMethod . new ( self , method_name , message ) disabled_methods [ method_name ] . disable! end

Disables an instance method.

 @param [Symbol,String]  method_name   The name of the method to disable.
 @param [String]         message       An error message. Defaults to "Class#method is disabled".


def to_proc
      disabled_method = self

      # This proc will be evaluated with "self" set to the original object.
      Proc.new do |*args, &block|
        disabled_method.execute(self, *args, &block)
      end
    end

Returns a Proc that acts as a replacement for the disabled method.

Returns a Proc that acts as a replacement for the disabled method .


def execute(object, *args, &block)
      if disabled?
        raise NoMethodError, message
      else
        object.send(aliased_name, *args, &block)
      end
    end

def execute ( object , * args , & block ) if disabled? raise NoMethodError , message else object . send ( aliased_name , args , block ) end end

The replacement for the original method. It will raise a NoMethodError if the method is
 disabled. Otherwise, it will execute the original method.

 @param [Object] object  The "self" object of the method being called.
 @param [Array]  args    The arguments that were passed to the method.
 @param [Proc]   block   The block that was passed to the method.

 @return Whatever the original method returns.

The replacement for the original method . It will raise a NoMethodError if the method is disabled . Otherwise it will execute the original method .


def alias_method!
      klass.send(:define_method, replacement_name, &self)
      klass.send(:alias_method, aliased_name, method_name)
      klass.send(:alias_method, method_name, replacement_name)
    end

def alias_method! klass . send ( :define_method , replacement_name , self ) klass . send ( :alias_method , aliased_name , method_name ) klass . send ( :alias_method , method_name , replacement_name ) end

Replaces the original implementation of the method with an implementation that allows
 disabling.

Replaces the original implementation of the method with an implementation that allows disabling .


def secret_to_public(secret, form=:byte)
      publickey = p_secret_to_public( change_argument_format(secret, form) )
      return change_result_format( publickey, form )
    end

def secret_to_public ( secret , form = :byte ) publickey = p_secret_to_public ( change_argument_format ( secret , form ) ) return change_result_format ( publickey , form ) end


def point_equal(pa, pb)
      # x1 / z1 == x2 / z2  <==>  x1 * z2 == x2 * z1
      return false if (pa[0] * pb[2] - pb[0] * pa[2]) % @@p != 0
      return false if (pa[1] * pb[2] - pb[1] * pa[2]) % @@p != 0
      return true
    end


def recover_x(y, sign)
      return nil if y >= @@p
      # x2 means x^2
      x2 = (y*y-1) * modp_inv(@@d*y*y+1)
      # when x2==0 and sign!=0, these combination of arguments is illegal
      if x2.equal? 0 then
        unless sign.equal? 0 then
          return nil
        else
          return 0
        end
      end
      # Compute square root of x2
      x = pow_mod(x2 , ((@@p+3) / 8) , @@p)
      x = x * @@modp_sqrt_m1 % @@p unless ((x*x - x2) % @@p).equal? 0
      return nil unless ((x*x - x2) % @@p).equal? 0
      x = @@p - x  unless (x & 1).equal? sign
      return x
    end

region point manipulation
 Compute corresponding x-coordinate, with low bit corresponding to
 sign, or return nil on failure

region point manipulation Compute corresponding x - coordinate with low bit corresponding to sign or return nil on failure


def point_decompress(s)
      # check argument
      raise ArgumentError , "Invalid input length for decompression" unless s.length.equal? 32

      y = int_form_bytes(s)
      sign = y >> 255
      y &= (1 << 255) - 1
      x = recover_x(y, sign)
      if x.nil? then
        return nil
      else
        return [x, y, 1, x*y % @@p]
      end
    end

decompress point that is compressed into 32bytes


def p_secret_to_public(secret)
      expanded = secret_expand(secret)
      a = expanded.first
      return point_compress(point_mul(a, @@G))
    end

def p_secret_to_public ( secret ) expanded = secret_expand ( secret ) a = expanded . first return point_compress ( point_mul ( a , @@G ) ) end

public_keyKey = aG
 "a" is generated form a secret

public_keyKey = aG a is generated form a secret


def part(name)
      parts.select {|p| p.name.downcase == name.to_s.downcase }.first
    end

def part ( name ) parts . select { | p | p . name . downcase == name . to_s . downcase } . first end

get part by its name
 param
 @return Part