In Files

  • openssl/lib/openssl/config.rb
  • openssl/ossl.c

Parent

Included Modules

Class/Module Index [+]

Quicksearch

OpenSSL::Config

Constants

DEFAULT_CONFIG_FILE
ESCAPE_MAP

escaped char map

QUOTE_REGEXP_DQ

escape with backslash and doubled dq

QUOTE_REGEXP_SQ

escape with backslash

Public Class Methods

new(filename = nil) click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 212
def initialize(filename = nil)
  @data = {}
  if filename
    File.open(filename.to_s) do |file|
      Config.parse_config(file).each do |section, hash|
        self[section] = hash
      end
    end
  end
end
            

Public Instance Methods

[](section) click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 248
def [](section)
  @data[section] || {}
end
            
[]=(section, pairs) click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 257
def []=(section, pairs)
  check_modify
  @data[section] ||= {}
  pairs.each do |key, value|
    self.add_value(section, key, value)
  end
end
            
add_value(section, key, value) click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 243
def add_value(section, key, value)
  check_modify
  (@data[section] ||= {})[key] = value
end
            
each() click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 281
def each
  @data.each do |section, hash|
    hash.each do |key, value|
      yield [section, key, value]
    end
  end
end
            
get_value(section, key) click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 223
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
            
inspect() click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 289
def inspect
  "#<#{self.class.name} sections=#{sections.inspect}>"
end
            
parse(str) click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 20
def parse(str)
  c = new()
  parse_config(StringIO.new(str)).each do |section, hash|
    c[section] = hash
  end
  c
end
            
parse_config(io) click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 30
def parse_config(io)
  begin
    parse_config_lines(io)
  rescue ConfigError => e
    e.message.replace("error in line #{io.lineno}: " + e.message)
    raise
  end
end
            
section(name) click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 252
def section(name)
  warn('Config#section is deprecated; use Config#[]')
  @data[name] || {}
end
            
sections() click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 265
def sections
  @data.keys
end
            
to_s() click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 269
def to_s
  ary = []
  @data.keys.sort.each do |section|
    ary << "[ #{section} ]\n"
    @data[section].keys.each do |key|
      ary << "#{key}=#{@data[section][key]}\n"
    end
    ary << "\n"
  end
  ary.join
end
            
value(arg1, arg2 = nil) click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 231
def value(arg1, arg2 = nil)
  warn('Config#value is deprecated; use Config#get_value')
  if arg2.nil?
    section, key = 'default', arg1
  else
    section, key = arg1, arg2
  end
  section ||= 'default'
  section = 'default' if section.empty?
  get_key_string(section, key)
end
            

Protected Instance Methods

data() click to toggle source
 
               # File openssl/lib/openssl/config.rb, line 295
def data
  @data
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus