Sha256: 95c04e674bee2572e0856df73c87440e09a6206b0725bae28815d00c52d08b4b

Contents?: true

Size: 718 Bytes

Versions: 1

Compression:

Stored size: 718 Bytes

Contents

module SyncFiles
  CONFIG_FILENAMES = %w(
    config/sync_files.yml
    .sync_files.yml
  )

  module Config
    class Loader
      attr_reader :config

      def initialize
        if config_filename
          @config = YAML.load(File.read(config_filename))
        else
          puts "ERROR: No config file found. Please create one of the following files: #{CONFIG_FILENAMES.join(", ")}"
        end
      end

      def has_config?
        !@config.nil?
      end

      private

      def config_filename
        CONFIG_FILENAMES.each do |filename|
          filename = File.join(::Rails.root.to_s, filename)
          return filename if File.exist?(filename)
        end

        nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sync_files-0.1.0 lib/sync_files/config/loader.rb