Sha256: be733853d2d8e62f4284eedc37e915ba6d19f95eed30679101643d969e58cf66

Contents?: true

Size: 839 Bytes

Versions: 1

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true

require 'cloud_flare/dynamic_dns/updater'

module CloudFlare
  module DynamicDNS
    # Main coordinator of the dynamic dns gem which fetches configuration from disk and current ip
    # and invokes the cloudflare updater to change config via API.
    class Runner
      # @param [String] path
      def initialize(path: nil)
        @path = path
      end

      # Update IP in cloudflare.
      def execute
        data = ConfigReader.new(path: path).read
        config = ConfigParser.new(data: data).execute

        ip = IfConfig.new.execute

        Updater.new(
          key: config['key'],
          email: config['email'],
          zone: config['zone'],
          hostname: config['hostname'],
          ipv4: ip
        ).update
      end

      private

      attr_reader :path
    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/runner.rb