Skip to content

Commit

Permalink
Ignore long lines in Markdown files
Browse files Browse the repository at this point in the history
  • Loading branch information
pkuczynski committed Jul 18, 2019
1 parent 5aad800 commit 4294b18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .mdlstyle.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
all
rule 'MD013', :line_length => 120
rule 'MD013', :line_length => 1000
50 changes: 16 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ register Config

### Installing on Sinatra

Add the gem to your `Gemfile` and run `bundle install` to install it. Afterwards in need to register `Config` in your
app and give it a root so it can find the config files.
Add the gem to your `Gemfile` and run `bundle install` to install it. Afterwards in need to register `Config` in your app and give it a root so it can find the config files.

```ruby
set :root, File.dirname(__FILE__)
Expand All @@ -67,24 +66,21 @@ register Config

### Installing on other ruby projects

Add the gem to your `Gemfile` and run `bundle install` to install it.
Then initialize `Config` manually within your configure block.
Add the gem to your `Gemfile` and run `bundle install` to install it. Then initialize `Config` manually within your configure block.

```ruby
Config.load_and_set_settings(Config.setting_files("/path/to/config_root", "your_project_environment"))
```

It's also possible to initialize `Config` manually within your configure block if you want to just give it some yml
paths to load from.
It's also possible to initialize `Config` manually within your configure block if you want to just give it some yml paths to load from.

```ruby
Config.load_and_set_settings("/path/to/yaml1", "/path/to/yaml2", ...)
```

## Accessing the Settings object

After installing the gem, `Settings` object will become available globally and by default will be compiled from the
files listed below. Settings defined in files that are lower in the list override settings higher.
After installing the gem, `Settings` object will become available globally and by default will be compiled from the files listed below. Settings defined in files that are lower in the list override settings higher.

config/settings.yml
config/settings/#{environment}.yml
Expand Down Expand Up @@ -136,8 +132,7 @@ Settings.reload_from_files(

### Environment specific config files

You can have environment specific config files. Environment specific config entries take precedence over common config
entries.
You can have environment specific config files. Environment specific config entries take precedence over common config entries.

Example development environment config file:

Expand All @@ -153,18 +148,15 @@ Example production environment config file:

### Developer specific config files

If you want to have local settings, specific to your machine or development environment,
you can use the following files, which are automatically `.gitignore` :
If you want to have local settings, specific to your machine or development environment, you can use the following files, which are automatically `.gitignore` :

```ruby
Rails.root.join("config", "settings.local.yml").to_s,
Rails.root.join("config", "settings", "#{Rails.env}.local.yml").to_s,
Rails.root.join("config", "environments", "#{Rails.env}.local.yml").to_s
```

**NOTE:** The file `settings.local.yml` will not be loaded in tests to prevent local
configuration from causing flaky or non-deterministic tests. Environment-specific files
(e.g. `settings/test.local.yml`) will still be loaded to allow test-specific credentials.
**NOTE:** The file `settings.local.yml` will not be loaded in tests to prevent local configuration from causing flaky or non-deterministic tests. Environment-specific files (e.g. `settings/test.local.yml`) will still be loaded to allow test-specific credentials.

### Adding sources at runtime

Expand All @@ -184,11 +176,9 @@ Settings.prepend_source!("/path/to/source.yml")
Settings.reload!
```

This will do the same as `add_source`, but the given YML file will be loaded first (instead of last) and its settings
will be overwritten by any other configuration file. This is especially useful if you want to define defaults.
This will do the same as `add_source`, but the given YML file will be loaded first (instead of last) and its settings will be overwritten by any other configuration file. This is especially useful if you want to define defaults.

One thing I like to do for my Rails projects is provide a local.yml config file that is .gitignored (so its independent
per developer). Then I create a new initializer in `config/initializers/add_local_config.rb` with the contents
One thing I like to do for my Rails projects is provide a local.yml config file that is .gitignored (so its independent per developer). Then I create a new initializer in `config/initializers/add_local_config.rb` with the contents

```ruby
Settings.add_source!("#{Rails.root}/config/settings/local.yml")
Expand Down Expand Up @@ -256,18 +246,16 @@ Settings.section.servers[1].name # => amazon.com

## Configuration

There are multiple configuration options available, however you can customize `Config` only once, preferably during
application initialization phase:
There are multiple configuration options available, however you can customize `Config` only once, preferably during application initialization phase:

```ruby
Config.setup do |config|
config.const_name = 'Settings'
...
# ...
end
```

After installing `Config` in Rails, you will find automatically generated file that contains default configuration
located at `config/initializers/config.rb`.
After installing `Config` in Rails, you will find automatically generated file that contains default configuration located at `config/initializers/config.rb`.

### General

Expand Down Expand Up @@ -375,8 +363,7 @@ See section below for more details.

## Working with environment variables

To load environment variables from the `ENV` object, that will override any settings defined in files, set the `use_env`
to true in your `config/initializers/config.rb` file:
To load environment variables from the `ENV` object, that will override any settings defined in files, set the `use_env` to true in your `config/initializers/config.rb` file:

```ruby
Config.setup do |config|
Expand All @@ -385,8 +372,7 @@ Config.setup do |config|
end
```

Now config would read values from the ENV object to the settings. For the example above it would look for keys starting
with `Settings`:
Now config would read values from the ENV object to the settings. For the example above it would look for keys starting with `Settings`:

```ruby
ENV['Settings.section.size'] = 1
Expand All @@ -397,9 +383,7 @@ It won't work with arrays, though.

### Working with Heroku

Heroku uses ENV object to store sensitive settings. You cannot upload such files to Heroku because it's ephemeral
filesystem gets recreated from the git sources on each instance refresh. To use config with Heroku just set the
`use_env` var to `true` as mentioned above.
Heroku uses ENV object to store sensitive settings. You cannot upload such files to Heroku because it's ephemeral filesystem gets recreated from the git sources on each instance refresh. To use config with Heroku just set the `use_env` var to `true` as mentioned above.

To upload your local values to Heroku you could ran `bundle exec rake config:heroku`.

Expand All @@ -408,9 +392,7 @@ To upload your local values to Heroku you could ran `bundle exec rake config:her
You can customize how environment variables are processed:

* `env_prefix` (default: `SETTINGS`) - which ENV variables to load into config
* `env_separator` (default: `.`) - what string to use as level separator - default value of `.` works well with
Heroku, but you might want to change it for example for `__` to easy override settings from command line, where using
dots in variable names might not be allowed (eg. Bash)
* `env_separator` (default: `.`) - what string to use as level separator - default value of `.` works well with Heroku, but you might want to change it for example for `__` to easy override settings from command line, where using dots in variable names might not be allowed (eg. Bash)
* `env_converter` (default: `:downcase`) - how to process variables names:
* `nil` - no change
* `:downcase` - convert to lower case
Expand Down

0 comments on commit 4294b18

Please sign in to comment.