Sha256: 8a0f15276e5f10eccc07b64b3bfc6aedf30e232ba4894cbb9260df1a1c7ac629

Contents?: true

Size: 563 Bytes

Versions: 9

Compression:

Stored size: 563 Bytes

Contents

require "yaml"
require "time"

module Feed2Gram
  Config = Struct.new(
    :feed_url,
    :facebook_app_id,
    :facebook_app_secret,
    :instagram_id,
    :access_token,
    :access_token_refreshed_at,
    keyword_init: true
  ) do
    def as_yaml
      to_h.transform_keys(&:to_s).to_yaml.gsub(/^---\n/, "")
    end
  end

  class LoadsConfig
    def load(options)
      puts "Loading config from: #{options.config_path}" if options.verbose
      yaml = YAML.load_file(options.config_path, permitted_classes: [Time])
      Config.new(**yaml)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
feed2gram-1.3.0 lib/feed2gram/loads_config.rb
feed2gram-1.2.4 lib/feed2gram/loads_config.rb
feed2gram-1.2.2 lib/feed2gram/loads_config.rb
feed2gram-1.2.1 lib/feed2gram/loads_config.rb
feed2gram-1.2.0 lib/feed2gram/loads_config.rb
feed2gram-1.1.0 lib/feed2gram/loads_config.rb
feed2gram-1.0.0 lib/feed2gram/loads_config.rb
feed2gram-0.0.4 lib/feed2gram/loads_config.rb
feed2gram-0.0.3 lib/feed2gram/loads_config.rb