dice_bag 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +78 -0
- data/MIT-LICENSE +19 -0
- data/README.md +174 -0
- data/lib/dice_bag/version.rb +3 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67394e5cb64e5f46237587f1003f18728424dae2b61387244312cc188e45b27a
|
4
|
+
data.tar.gz: 8491e662b055c31b0089a7c916a884857d3f3e77683a21479513bfac3840e2dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ccb8dc0a4d26c920ac7df9bebfc4e5ec56b14b43b451858fb89a5e36a16505e4a6e6f5711fd14056e516928e4f2684d2cfa28320a78643d19d65d07a09783c3
|
7
|
+
data.tar.gz: 5c803e0e968f9f16f4012a1d2cc129723885adcfd113189a282b4ff5e7e46fa88419da151c2c4d92d2203720038d7fafaba36352439cb504af480ee9a1f4c246
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# 1.4.1
|
2
|
+
* Bundle extra files in the gem (MIT-LICENSE etc.).
|
3
|
+
|
4
|
+
# 1.4.0
|
5
|
+
* Allow thor 0.x and 1.x.
|
6
|
+
|
7
|
+
# 1.3.4
|
8
|
+
* Remove extra spaces from the database templates.
|
9
|
+
|
10
|
+
# 1.3.3
|
11
|
+
* Address a deprecation warning when using Rails 6.0.
|
12
|
+
|
13
|
+
# 1.3.2
|
14
|
+
* Gem specifies MIT license.
|
15
|
+
|
16
|
+
# 1.3.1
|
17
|
+
* Fix adapter name in the database.yml.dice template for PostgreSQL.
|
18
|
+
|
19
|
+
# 1.3.0
|
20
|
+
* Detect pg gem and generate database.yml.dice for PostgreSQL.
|
21
|
+
|
22
|
+
# 1.2.3
|
23
|
+
* Fix: Add missing newline after ruby warning message.
|
24
|
+
|
25
|
+
# 1.2.2
|
26
|
+
* Remove trailing space from the message generated by `<%= warning.as_yaml_comment %>`.
|
27
|
+
|
28
|
+
# 1.2.1
|
29
|
+
* Replaces `starts_with?` with `start_with?` to remove Rails dependency.
|
30
|
+
|
31
|
+
# 1.2.0
|
32
|
+
* Adds a `config:generate_from_gems` task to generate the templates from the specified gems only
|
33
|
+
|
34
|
+
# 1.1.1
|
35
|
+
* Updates the database.yml.dice file to not provide settings for test and development when
|
36
|
+
building in production.
|
37
|
+
|
38
|
+
# 1.1.0
|
39
|
+
* Removed the template for Newrelic.
|
40
|
+
|
41
|
+
# 1.0.0
|
42
|
+
* `config:generate_all` task allows user to choose an appropriate action when source and local templates are different.
|
43
|
+
* `config:generate_all:force` allows user to generate templates in 'force mode' (replacing local templates with the source).
|
44
|
+
|
45
|
+
# 0.9.0
|
46
|
+
* Feature: Adding a bang (!) at the end of method names, will raise when the variable
|
47
|
+
is not found in production.
|
48
|
+
* New relic template to use SSL by default
|
49
|
+
|
50
|
+
# 0.8.0
|
51
|
+
* Fix Template generation fails if the target directory is missing
|
52
|
+
* Document that configuration files must not be loaded in Rails config/application.rb
|
53
|
+
* Don't overwrite config files if user responds 'No' instead of just 'N'.
|
54
|
+
* Omit .dice files in Bundler path or in dot-prefixed directories
|
55
|
+
|
56
|
+
# 0.7.1
|
57
|
+
* The ensure_is_private_key method now additionally supports RSA keys without spaces.
|
58
|
+
|
59
|
+
# 0.7.0
|
60
|
+
* New ensure_is_private_key helper method to process RSA private keys.
|
61
|
+
* New config:deploy rake task to use for deployments, which overwrites config files without prompting.
|
62
|
+
|
63
|
+
# 0.6.0
|
64
|
+
* **Breaking change:** Only templates with the '.dice' extension are processed.
|
65
|
+
* **Breaking change:** Local override via the '.local' extension has been removed.
|
66
|
+
* Templates are processed in all directories.
|
67
|
+
|
68
|
+
# 0.5.0
|
69
|
+
* Generated templates should be committed to source control.
|
70
|
+
* New '.dice' extension for templates.
|
71
|
+
* Better testing infrastructure.
|
72
|
+
* Plugins and rake task can specify custom location for templates.
|
73
|
+
|
74
|
+
# 0.4.1
|
75
|
+
* Fix: Templates are generated in 'config' directory for Rails projects.
|
76
|
+
|
77
|
+
# 0.4.0
|
78
|
+
* Initial open source release.
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2012-2020 Medidata Solutions Worldwide
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
# DiceBag
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/mdsol/dice_bag.svg?branch=develop)](https://travis-ci.org/mdsol/dice_bag)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/mdsol/dice_bag.png)](https://codeclimate.com/github/mdsol/dice_bag)
|
5
|
+
|
6
|
+
DiceBag is a library of rake tasks for configuring web apps in the style of [The
|
7
|
+
Twelve-Factor App][1]. Configuration values are picked up from the environment
|
8
|
+
and used to populate configuration files from templates. Pre-packaged templates
|
9
|
+
for common configuration files are provided.
|
10
|
+
|
11
|
+
Although Rails already supports ERB syntax for its YML configuration files, DiceBag will generate a final
|
12
|
+
static file that will work without keeping your deployment environment variables in sync with your
|
13
|
+
production environment variables. For security reasons, these environments may sometimes differ.
|
14
|
+
|
15
|
+
Also DiceBag will work with any kind of text files, not only YML files. It can be very useful for
|
16
|
+
ruby initializer files for instance.
|
17
|
+
|
18
|
+
[1]: http://www.12factor.net/
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
Add the following to your `Gemfile`:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem 'dice_bag'
|
26
|
+
```
|
27
|
+
|
28
|
+
If you are using these tasks outside of a Rails project, add the following to
|
29
|
+
your `Rakefile` or wherever your local rake tasks are defined:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'dice_bag/tasks'
|
33
|
+
```
|
34
|
+
|
35
|
+
Run the following command to see the new tasks:
|
36
|
+
|
37
|
+
```
|
38
|
+
[bundle exec] rake -T | grep "rake config"
|
39
|
+
```
|
40
|
+
|
41
|
+
## Create configuration files from templates
|
42
|
+
|
43
|
+
When the rake "config" task is run, configuration files are populated for all
|
44
|
+
ERB template files in the project that have a ".dice" extension. Configuration
|
45
|
+
values from the environment are made available to the templates through the
|
46
|
+
`configured` object.
|
47
|
+
|
48
|
+
For example, take a "database.yml.dice" file containing this template:
|
49
|
+
|
50
|
+
```erb
|
51
|
+
development:
|
52
|
+
database: development
|
53
|
+
username: <%= configured.database_username || 'root' %>
|
54
|
+
password: <%= configured.database_password %>
|
55
|
+
```
|
56
|
+
|
57
|
+
Then running the following command:
|
58
|
+
|
59
|
+
```
|
60
|
+
DATABASE_USERNAME=alice DATABASE_PASSWORD=xyzzy [bundle exec] rake config
|
61
|
+
```
|
62
|
+
|
63
|
+
will generate a "database.yml" file with the following contents:
|
64
|
+
|
65
|
+
```yaml
|
66
|
+
development:
|
67
|
+
database: development
|
68
|
+
username: alice
|
69
|
+
password: xyzzy
|
70
|
+
```
|
71
|
+
|
72
|
+
See the [feature documentation][features] for further examples and
|
73
|
+
functionality.
|
74
|
+
|
75
|
+
[features]: https://www.relishapp.com/mdsol/dice-bag/docs
|
76
|
+
|
77
|
+
As discussed in [The Twelve-Factor App section on configuration][2], do not
|
78
|
+
commit your generated configuration files to source control. Instead, commit the
|
79
|
+
templates to source control and then regenerate the configuration files at
|
80
|
+
deployment time by running the rake `config:deploy` task.
|
81
|
+
|
82
|
+
[2]: http://www.12factor.net/config
|
83
|
+
|
84
|
+
|
85
|
+
### Ensuring variables are set in production
|
86
|
+
|
87
|
+
It is a common pattern to use default information for development but to not
|
88
|
+
allow defaults in production, instead we want to always set up the environment variables
|
89
|
+
in production.
|
90
|
+
|
91
|
+
It is very easy to discover what variables have not been set in production using a bang after
|
92
|
+
the variable name, for instance:
|
93
|
+
```
|
94
|
+
secret_key: <%= configured.secret_key_base! || 'any text is ok' %>
|
95
|
+
```
|
96
|
+
Will raise an explanatory error if we are using Rails, we are in production and the
|
97
|
+
variable SECRET_KEY_BASE is not set. In other environments will not care about it
|
98
|
+
not being set and will use the default.
|
99
|
+
|
100
|
+
|
101
|
+
### Generating the templates of given gems only
|
102
|
+
|
103
|
+
`config:generate_all` will generate all the templates it can find. Since sometimes this behavior
|
104
|
+
is not desirable you can use the `config:generate_from_gems` task to specify gem names:
|
105
|
+
|
106
|
+
```
|
107
|
+
[bundle exec] rake config:generate_from_gems gem1 gem2 gemN
|
108
|
+
```
|
109
|
+
|
110
|
+
will generate only the templates provided by `gem1`, `gem2` and `gemN`.
|
111
|
+
|
112
|
+
To force-generate set the `DICEBAG_FORCE` environment variable to any value when running the task.
|
113
|
+
|
114
|
+
|
115
|
+
## Generating the pre-packaged templates
|
116
|
+
|
117
|
+
If the corresponding gems are installed, the following pre-packaged templates are provided:
|
118
|
+
|
119
|
+
* mysql2 or pg: `database.yml.dice` for [Rails](https://github.com/rails/rails/)
|
120
|
+
* aws-sdk: `aws.yml.dice`
|
121
|
+
* dalli: `dalli.yml.dice`
|
122
|
+
|
123
|
+
Run the following command to generate them:
|
124
|
+
|
125
|
+
```
|
126
|
+
[bundle exec] rake config:generate_all
|
127
|
+
```
|
128
|
+
|
129
|
+
This command provides options to compare changes between source and local templates, so new additions to the source templates can be safely added while preserving any project specific customization to local templates.
|
130
|
+
|
131
|
+
Alternatively, to force generate templates (replacing existing local templates with the source), run the following:
|
132
|
+
|
133
|
+
```
|
134
|
+
[bundle exec] rake config:generate_all:force
|
135
|
+
```
|
136
|
+
|
137
|
+
|
138
|
+
As with your own templates, you should commit these pre-packaged templates to
|
139
|
+
source control.
|
140
|
+
|
141
|
+
You can customize these pre-packaged template to your needs but if the change is
|
142
|
+
a generic fix or extension, please consider contributing it back to this project
|
143
|
+
so that everyone benefits.
|
144
|
+
|
145
|
+
### Defining your own pre-packaged templates
|
146
|
+
|
147
|
+
If you want DiceBag to generate your own pre-packaged templates when you run the
|
148
|
+
rake "config:generate_all" task, you can create a plug-in. Read the
|
149
|
+
[templates.md](./templates.md) file to learn how to do this.
|
150
|
+
|
151
|
+
## Troubleshooting
|
152
|
+
|
153
|
+
### rake config fails in Rails project with file not found
|
154
|
+
|
155
|
+
Due to rake running ``` config/application.rb ``` before kicking off a task,
|
156
|
+
if ``` config/application.rb ``` loads any configuration files that dice_bag
|
157
|
+
must generate a 'file not found' error may occur. Makes sense that a file
|
158
|
+
``` rake config:generate_all ``` needs to create, does not exist before it has ran.
|
159
|
+
|
160
|
+
Solution: Move any config loading that depends on files generated by dice_bag out of `application.rb` and into `config/initializers/*`. Since the commands
|
161
|
+
`rails server` or `rails console` etc. always run the initializers, moving the logic
|
162
|
+
here should be a safe bet.
|
163
|
+
|
164
|
+
## Contributors
|
165
|
+
|
166
|
+
* [Andrew Smith](https://github.com/asmith-mdsol)
|
167
|
+
* [Jordi Carres](https://github.com/jcarres-mdsol)
|
168
|
+
* [Dan Hoizner](https://github.com/dhoizner-mdsol)
|
169
|
+
* [Aaron Weiner](https://github.com/HonoreDB)
|
170
|
+
* [Luke Greene](https://github.com/lgreene-mdsol)
|
171
|
+
* [Johnny Lo](https://github.com/jlo188)
|
172
|
+
* [Connor Ross](https://github.com/cross311)
|
173
|
+
* [Mathieu Jobin](https://github.com/mjobin-mdsol)
|
174
|
+
|
data/lib/dice_bag/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dice_bag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Smith
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -103,6 +103,9 @@ executables: []
|
|
103
103
|
extensions: []
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
|
+
- CHANGELOG.md
|
107
|
+
- MIT-LICENSE
|
108
|
+
- README.md
|
106
109
|
- lib/dice_bag.rb
|
107
110
|
- lib/dice_bag/available_templates.rb
|
108
111
|
- lib/dice_bag/command.rb
|
@@ -142,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
145
|
requirements:
|
143
146
|
- - ">="
|
144
147
|
- !ruby/object:Gem::Version
|
145
|
-
version: 2.3
|
148
|
+
version: '2.3'
|
146
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
150
|
requirements:
|
148
151
|
- - ">="
|
@@ -156,6 +159,6 @@ summary: Dice Bag is a library of rake tasks for configuring web apps in the sty
|
|
156
159
|
of The Twelve-Factor App. It also provides continuous integration tasks that rely
|
157
160
|
on the configuration tasks.
|
158
161
|
test_files:
|
159
|
-
- spec/spec_helper.rb
|
160
162
|
- spec/configuration_spec.rb
|
163
|
+
- spec/spec_helper.rb
|
161
164
|
- spec/command_spec.rb
|