<commit_before>---
title: Settings
layout: gem-single
name: dry-system
---

## Basic usage

dry-system provides a built-in `:settings` component which you can use in your application. In order to set it up, simply define a bootable `:settings` component and import it from the `:system` provider:

```ruby
# in system/boot/settings.rb
require "dry/system/components"
require "path/to/dry/types/file"

Application.boot(:settings, from: :system) do
  settings do
    key :database_url, Types::String.constrained(filled: true)
    key :logger_level, Types::Symbol.constructor(proc { |value| value.to_s.downcase.to_sym })
                                    .default(:info)
                                    .enum(:trace, :unknown, :error, :fatal, :warn, :info, :debug)
  end
end
```

Now, dry-system will map values from `ENV` variable to `settings` struct and allows you to use it in the application:<commit_msg>Fix settings component example code (#183)<commit_after>---
title: Settings
layout: gem-single
name: dry-system
---

## Basic usage

dry-system provides a built-in `:settings` component which you can use in your application. In order to set it up, simply define a bootable `:settings` component and import it from the `:system` provider:

```ruby
# in system/boot/settings.rb
require "dry/system/components"
require "path/to/dry/types/file"

Application.boot(:settings, from: :system) do
  settings do
    key :database_url, Types::String.constrained(filled: true)
    key :logger_level, Types::Symbol.constructor { |value| value.to_s.downcase.to_sym }
                                    .default(:info)
                                    .enum(:trace, :unknown, :error, :fatal, :warn, :info, :debug)
  end
end
```

Now, dry-system will map values from `ENV` variable to `settings` struct and allows you to use it in the application:
{'fraction_non_alphanumeric': 0.11532214401732539, 'fraction_numerical': 0.0016242555495397943, 'mean_word_length': 3.219178082191781, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7197370', 'n_tokens_mistral': 547, 'n_tokens_neox': 520, 'n_words': 190}