Sha256: b011622a1805211a7eb6feceb59a2bfee2a2f5d8d0ac60d4974508013139d0dc

Contents?: true

Size: 567 Bytes

Versions: 1

Compression:

Stored size: 567 Bytes

Contents

# frozen_string_literal: true

module CloudFlare
  module DynamicDNS
    # reads cloudflare-dynamic-dns config and converts into a Hash object.
    class ConfigParser
      # @param [String] data config file read as is from file system.
      def initialize(data:)
        @data = data
      end

      # @return [Hash] k,v of configuration specified in cloudflare-dynamic-dns.conf
      def execute
        items = data.chomp.split("\n").map { |item| item.split('=') }
        Hash[*items.flatten]
      end

      private

      attr_reader :data
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cloudflare-dynamic-dns-0.1.0 lib/cloud_flare/dynamic_dns/config_parser.rb