site_variables 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -7
- data/lib/site_variables/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7140f304b85e733be6e67b8ab8b40feaeabd244d6760d1ab94236467627dbfad
|
4
|
+
data.tar.gz: f72d1ebc70f40441d7941af9a35d38254cd997bf99a86153e7dc2b675b7866fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d41e4c9a4cb8f9a99f35574eecc94ea8407e5064823e1a1969932ebf6ced820b69ea7ca27d0a793bad5a21accee865bf4e9e348c2ec46ae681dfc1e0ffe1072a
|
7
|
+
data.tar.gz: 32f50c1e8e5b52b6333a4722ce7811128b9a33b2004bc08c1b1c9a6f12c32db10b1f5f43d5b6a7912f0346c3a499630c0a9b3789f4ee338ee1e37f61db9b7d96
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# SiteVariables
|
2
|
+
Over the years I have become accustomed to using the Rails `secrets.yml` file as a nice config file for any non-sensitve constant variables I'd like to use throughout my application. With Rails 5.2 `secrets.yml` is now removed in favor of encrypted credentials. Overall this is a good thing as it was bad practice to store and commit any sensitive variables into `secrets.yml`.
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
4
|
+
The [site_variables](https://rubygems.org/gems/site_variables) gem allows me to continue my practice of using a YAML file for environment specific non-sensitive variables.
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
@@ -22,13 +21,42 @@ Or install it yourself as:
|
|
22
21
|
|
23
22
|
## Usage
|
24
23
|
|
25
|
-
|
24
|
+
After installation run:
|
25
|
+
|
26
|
+
$rails generate site_variables
|
27
|
+
|
28
|
+
This gives us two files:
|
29
|
+
|
30
|
+
1. `config/initializers/site_variables.rb`
|
31
|
+
2. `config/site_variables.yml`
|
32
|
+
|
33
|
+
The important file is `site_variables.yml`
|
34
|
+
Edit the YAML file with the variables you would like to use. Any environment specific variables (in the `development` or `production` sections for example) will override any variables in the `shared` section.
|
26
35
|
|
27
|
-
|
36
|
+
You now can access your hash of site variables inside your Rails app with the `SITE_VARIABLES` constant.
|
28
37
|
|
29
|
-
|
38
|
+
### Example
|
39
|
+
|
40
|
+
`config/site_variables.yml`:
|
41
|
+
|
42
|
+
```
|
43
|
+
shared:
|
44
|
+
base_url: this will be overriden by the environments
|
45
|
+
site_name: My Awesome Site
|
46
|
+
support_email: support@myawesomesite.com
|
30
47
|
|
31
|
-
|
48
|
+
development:
|
49
|
+
base_url: https://somengroksubdomain.ngrok.io
|
50
|
+
|
51
|
+
production:
|
52
|
+
base_url: https://myawesomesite.com
|
53
|
+
```
|
54
|
+
|
55
|
+
In a view:
|
56
|
+
|
57
|
+
```
|
58
|
+
Welcome to <%= SITE_VARIABLES['site_name'] %>
|
59
|
+
```
|
32
60
|
|
33
61
|
## Contributing
|
34
62
|
|