A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.aws.amazon.com/sdkforruby/api/Aws/IniParser.html below:

IniParser — AWS SDK for Ruby V2

You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::IniParser
Inherits:
Object show all
Defined in:
aws-sdk-core/lib/aws-sdk-core/ini_parser.rb
Attribute Summary collapse Class Method Summary collapse Class Method Details .ini_parse(raw) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'aws-sdk-core/lib/aws-sdk-core/ini_parser.rb', line 5

def ini_parse(raw)
  current_profile = nil
  current_prefix = nil
  raw.lines.inject({}) do |acc, line|
    line = line.split(/^|\s;/).first     profile = line.match(/^\[([^\[\]]+)\]\s*(#.+)?$/) unless line.nil?
    if profile
      current_profile = profile[1]
      named_profile = current_profile.match(/^profile\s+(.+?)$/)
      current_profile = named_profile[1] if named_profile
    elsif current_profile
      unless line.nil?
        item = line.match(/^(.+?)\s*=\s*(.+?)\s*$/)
        prefix = line.match(/^(.+?)\s*=\s*$/)
      end
      if item && item[1].match(/^\s+/)
                inner_item = line.match(/^\s*(.+?)\s*=\s*(.+?)\s*$/)
        acc[current_profile] ||= {}
        acc[current_profile][current_prefix] ||= {}
        acc[current_profile][current_prefix][inner_item[1]] = inner_item[2]
      elsif item
        current_prefix = nil
        acc[current_profile] ||= {}
        acc[current_profile][item[1]] = item[2]
      elsif prefix
        current_prefix = prefix[1]
      end
    end
    acc
  end
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4