dice_bag 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +1 -1
- data/lib/dice_bag.rb +2 -0
- data/lib/dice_bag/available_templates.rb +2 -0
- data/lib/dice_bag/command.rb +2 -0
- data/lib/dice_bag/config_file.rb +3 -1
- data/lib/dice_bag/configuration.rb +3 -0
- data/lib/dice_bag/default_template_file.rb +3 -3
- data/lib/dice_bag/dice_bag_file.rb +8 -5
- data/lib/dice_bag/private_key.rb +4 -2
- data/lib/dice_bag/project.rb +2 -0
- data/lib/dice_bag/railtie.rb +2 -0
- data/lib/dice_bag/tasks.rb +2 -0
- data/lib/dice_bag/tasks/config.rake +16 -9
- data/lib/dice_bag/template_file.rb +3 -1
- data/lib/dice_bag/template_helpers.rb +4 -2
- data/lib/dice_bag/templates/gems_checker.rb +5 -9
- data/lib/dice_bag/version.rb +1 -1
- data/lib/dice_bag/warning.rb +4 -2
- data/spec/command_spec.rb +2 -0
- data/spec/configuration_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- metadata +33 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0aeb57da5b1f84e4929fa3e5d84a5fdfc6df0a90ff14d3007ca92d2a61082448
|
4
|
+
data.tar.gz: e974c236127bdb24655128d2ab7c19a8cbda6824f15d1c0aa25181261a2fba7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ddc53b4204485be8747048633ecb73248719ef72a24548c5873846fea9f7db56531d917121e82a8288a3cdbf967281b7c2c57c85f657e602913ff3e970cd306
|
7
|
+
data.tar.gz: e1ab8a58dc1055cad2c39fec29d768c77840f1c74b2a399763ea813b0dc5e18bae66d83e9f3783885c2242896bd8305263ccef3a93ddc282037a106f8f10a7b5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# DiceBag
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.
|
3
|
+
[![Build Status](https://travis-ci.com/mdsol/dice_bag.svg?branch=develop)](https://travis-ci.com/mdsol/dice_bag)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/mdsol/dice_bag.png)](https://codeclimate.com/github/mdsol/dice_bag)
|
5
5
|
|
6
6
|
DiceBag is a library of rake tasks for configuring web apps in the style of [The
|
data/lib/dice_bag.rb
CHANGED
data/lib/dice_bag/command.rb
CHANGED
data/lib/dice_bag/config_file.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module DiceBag
|
2
4
|
# This class abstracts access to configuration values, to be used within ERB
|
3
5
|
# templates. Currently, the values are read from the environment, as per the
|
@@ -29,6 +31,7 @@ module DiceBag
|
|
29
31
|
if in_production? && value.nil?
|
30
32
|
raise "Environment variable #{variable_name} required in production but it was not provided"
|
31
33
|
end
|
34
|
+
|
32
35
|
value
|
33
36
|
end
|
34
37
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "dice_bag/dice_bag_file"
|
2
4
|
require "dice_bag/project"
|
3
5
|
|
@@ -11,9 +13,7 @@ module DiceBag
|
|
11
13
|
|
12
14
|
def initialize(name, location = nil, save_as = nil)
|
13
15
|
# if called from command line with only a name we search in all our templates for the file
|
14
|
-
if File.dirname(name) == "."
|
15
|
-
name = AvailableTemplates.template_filename_for(name)
|
16
|
-
end
|
16
|
+
name = AvailableTemplates.template_filename_for(name) if File.dirname(name) == "."
|
17
17
|
@filename = File.basename(save_as || name)
|
18
18
|
@file = name
|
19
19
|
@template_location = location
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "dice_bag/version"
|
2
4
|
|
3
5
|
# This module contains common methods for all the type of files Dicebag knows about:
|
@@ -5,12 +7,11 @@ require "dice_bag/version"
|
|
5
7
|
module DiceBag
|
6
8
|
module DiceBagFile
|
7
9
|
attr_reader :file, :filename, :destination
|
10
|
+
|
8
11
|
@@overwrite_all = false
|
9
12
|
|
10
13
|
def assert_existence
|
11
|
-
unless File.
|
12
|
-
raise "File #{@file} not found. Configuration file not created"
|
13
|
-
end
|
14
|
+
raise "File #{@file} not found. Configuration file not created" unless File.exist?(@file)
|
14
15
|
end
|
15
16
|
|
16
17
|
def write(contents)
|
@@ -20,10 +21,11 @@ module DiceBag
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def should_write?(new_contents)
|
23
|
-
return true if @@overwrite_all || !File.
|
24
|
+
return true if @@overwrite_all || !File.exist?(file)
|
24
25
|
return false if diff(file, new_contents).empty?
|
25
26
|
|
26
|
-
|
27
|
+
# rubocop:disable Metrics/BlockLength
|
28
|
+
loop do
|
27
29
|
puts "Overwrite #{file} ? Recommended: Yes. "
|
28
30
|
puts " [Y]es, [n]o, [a]ll files, [q]uit, [d]show diff"
|
29
31
|
answer = $stdin.gets
|
@@ -43,6 +45,7 @@ module DiceBag
|
|
43
45
|
return true
|
44
46
|
end
|
45
47
|
end
|
48
|
+
# rubocop:enable Metrics/BlockLength
|
46
49
|
end
|
47
50
|
|
48
51
|
private
|
data/lib/dice_bag/private_key.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module DiceBag
|
2
4
|
class PrivateKey
|
3
5
|
attr_accessor :private_key
|
@@ -35,8 +37,8 @@ module DiceBag
|
|
35
37
|
|
36
38
|
private
|
37
39
|
|
38
|
-
HEADER = "-----BEGIN RSA PRIVATE KEY-----"
|
39
|
-
FOOTER = "-----END RSA PRIVATE KEY-----"
|
40
|
+
HEADER = "-----BEGIN RSA PRIVATE KEY-----"
|
41
|
+
FOOTER = "-----END RSA PRIVATE KEY-----"
|
40
42
|
|
41
43
|
def strip_down_key
|
42
44
|
@private_key.gsub!(HEADER, "")
|
data/lib/dice_bag/project.rb
CHANGED
data/lib/dice_bag/railtie.rb
CHANGED
data/lib/dice_bag/tasks.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "erb"
|
2
4
|
require "dice_bag/command"
|
3
5
|
|
4
|
-
FORCE_ENV_VAR = "DICEBAG_FORCE"
|
6
|
+
FORCE_ENV_VAR = "DICEBAG_FORCE"
|
5
7
|
|
6
8
|
desc "Populate all templates using values from the environment to create configuration files"
|
7
|
-
task :
|
9
|
+
task config: ["config:all"]
|
8
10
|
|
9
11
|
namespace :config do
|
10
12
|
# Deprecated, present only for backward compatibility.
|
@@ -14,17 +16,19 @@ namespace :config do
|
|
14
16
|
|
15
17
|
desc "As per the config task but automatically overwrites pre-existing configuration files"
|
16
18
|
task :deploy do
|
17
|
-
DiceBag::Command.new.write_all(:
|
19
|
+
DiceBag::Command.new.write_all(deploy: true)
|
18
20
|
end
|
19
21
|
|
20
22
|
desc "Populate just the specified template to create the associated configuration file"
|
21
|
-
task :file, :filename do |
|
23
|
+
task :file, :filename do |_t, args|
|
22
24
|
filename = args[:filename]
|
23
25
|
raise "A filename needs to be provided" if filename.nil?
|
26
|
+
|
24
27
|
DiceBag::Command.new.write(filename)
|
25
28
|
end
|
26
29
|
|
27
|
-
desc "Generate all configuration file templates with interactive commands
|
30
|
+
desc "Generate all configuration file templates with interactive commands " \
|
31
|
+
"(use config:generate_all:force to replace all without asking for input)"
|
28
32
|
task :generate_all do
|
29
33
|
DiceBag::Command.new.generate_all_templates(false)
|
30
34
|
end
|
@@ -36,18 +40,21 @@ namespace :config do
|
|
36
40
|
end
|
37
41
|
|
38
42
|
desc "Generate specified template, optionally in the specified location with options to control file actions"
|
39
|
-
task :generate, :filename, :location do |
|
43
|
+
task :generate, :filename, :location do |_t, args|
|
40
44
|
filename = args[:filename]
|
41
45
|
location = args[:location]
|
42
46
|
raise "A filename needs to be provided" if filename.nil?
|
47
|
+
|
43
48
|
DiceBag::Command.new.generate_template(DiceBag::DefaultTemplateFile.new(filename, location), false)
|
44
49
|
end
|
45
50
|
|
46
|
-
desc "Generate the templates from the specified gems only ('config:generate_from_gems gem1 gem2 gemN',
|
47
|
-
|
48
|
-
|
51
|
+
desc "Generate the templates from the specified gems only ('config:generate_from_gems gem1 gem2 gemN'," \
|
52
|
+
" set the env variable '#{FORCE_ENV_VAR}' to overwrite the templates without asking for confirmation)"
|
53
|
+
task :generate_from_gems, :names do |_t, _args|
|
54
|
+
ARGV.each { |a| task a.to_sym do; end }
|
49
55
|
names = ARGV[1..-1]
|
50
56
|
raise "One or more gem names need to be provided" if names.empty?
|
57
|
+
|
51
58
|
DiceBag::Command.new.generate_gems_templates(names, !ENV[FORCE_ENV_VAR].nil?)
|
52
59
|
end
|
53
60
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "dice_bag/private_key"
|
2
4
|
|
3
5
|
module DiceBag
|
@@ -36,7 +38,7 @@ module DiceBag
|
|
36
38
|
ef.issuer_certificate = root_ca
|
37
39
|
cert.add_extension(ef.create_extension("keyUsage", "digitalSignature", true))
|
38
40
|
cert.add_extension(ef.create_extension("subjectKeyIdentifier", "hash", false))
|
39
|
-
cert.sign(root_key, OpenSSL::Digest
|
41
|
+
cert.sign(root_key, OpenSSL::Digest.new("SHA256"))
|
40
42
|
cert
|
41
43
|
end
|
42
44
|
|
@@ -67,7 +69,7 @@ module DiceBag
|
|
67
69
|
root_ca.add_extension(ef.create_extension("keyUsage", "keyCertSign, cRLSign", true))
|
68
70
|
root_ca.add_extension(ef.create_extension("subjectKeyIdentifier", "hash", false))
|
69
71
|
root_ca.add_extension(ef.create_extension("authorityKeyIdentifier", "keyid:always", false))
|
70
|
-
root_ca.sign(root_key, OpenSSL::Digest
|
72
|
+
root_ca.sign(root_key, OpenSSL::Digest.new("SHA256"))
|
71
73
|
end
|
72
74
|
end
|
73
75
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This module has the logic that decides what templates will be
|
2
4
|
# generated for this project.
|
3
5
|
# this file lives in the same directory than all the templates it
|
@@ -10,9 +12,7 @@ module DiceBag
|
|
10
12
|
@needed_templates = []
|
11
13
|
configured = Configuration.new
|
12
14
|
|
13
|
-
if defined?(Dalli)
|
14
|
-
add_template("dalli.yml.dice")
|
15
|
-
end
|
15
|
+
add_template("dalli.yml.dice") if defined?(Dalli)
|
16
16
|
|
17
17
|
if defined?(Mysql2)
|
18
18
|
add_template("databases/mysql.yml.dice", save_as: "database.yml.dice")
|
@@ -20,13 +20,9 @@ module DiceBag
|
|
20
20
|
add_template("databases/postgres.yml.dice", save_as: "database.yml.dice")
|
21
21
|
end
|
22
22
|
|
23
|
-
if defined?(AWS)
|
24
|
-
add_template("aws.yml.dice")
|
25
|
-
end
|
23
|
+
add_template("aws.yml.dice") if defined?(AWS)
|
26
24
|
|
27
|
-
if configured.google_analytics_id
|
28
|
-
add_template("google_analytics.yml.dice")
|
29
|
-
end
|
25
|
+
add_template("google_analytics.yml.dice") if configured.google_analytics_id
|
30
26
|
|
31
27
|
@needed_templates
|
32
28
|
end
|
data/lib/dice_bag/version.rb
CHANGED
data/lib/dice_bag/warning.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module DiceBag
|
2
4
|
class Warning
|
3
5
|
def initialize(template_filename)
|
@@ -8,7 +10,7 @@ module DiceBag
|
|
8
10
|
lines.map { |line| "# #{line}".rstrip }.join("\n") + "\n"
|
9
11
|
end
|
10
12
|
|
11
|
-
alias
|
13
|
+
alias as_yaml_comment as_ruby_comment
|
12
14
|
|
13
15
|
def as_xml_comment
|
14
16
|
["<!--", lines, "-->"].flatten.join("\n")
|
@@ -19,7 +21,7 @@ module DiceBag
|
|
19
21
|
def lines
|
20
22
|
[
|
21
23
|
"WARNING! Do not modify this file directly. It was generated from the",
|
22
|
-
"'
|
24
|
+
"'#{@template_filename}' template file.",
|
23
25
|
"",
|
24
26
|
"Use the rake config task to reconfigure. See the template file for",
|
25
27
|
"further guidance."
|
data/spec/command_spec.rb
CHANGED
data/spec/configuration_spec.rb
CHANGED
data/spec/spec_helper.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
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Smith
|
@@ -9,8 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: diff-lcs
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.0'
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: rake
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,33 +54,33 @@ dependencies:
|
|
40
54
|
- !ruby/object:Gem::Version
|
41
55
|
version: '2.0'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
57
|
+
name: aruba
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
45
59
|
requirements:
|
46
60
|
- - "~>"
|
47
61
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
49
|
-
type: :
|
62
|
+
version: 0.6.0
|
63
|
+
type: :development
|
50
64
|
prerelease: false
|
51
65
|
version_requirements: !ruby/object:Gem::Requirement
|
52
66
|
requirements:
|
53
67
|
- - "~>"
|
54
68
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
69
|
+
version: 0.6.0
|
56
70
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
71
|
+
name: bundler
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|
59
73
|
requirements:
|
60
|
-
- - "
|
74
|
+
- - ">="
|
61
75
|
- !ruby/object:Gem::Version
|
62
|
-
version: 0
|
76
|
+
version: '0'
|
63
77
|
type: :development
|
64
78
|
prerelease: false
|
65
79
|
version_requirements: !ruby/object:Gem::Requirement
|
66
80
|
requirements:
|
67
|
-
- - "
|
81
|
+
- - ">="
|
68
82
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0
|
83
|
+
version: '0'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: rspec
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,19 +96,19 @@ dependencies:
|
|
82
96
|
- !ruby/object:Gem::Version
|
83
97
|
version: '3.0'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
99
|
+
name: rubocop
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
87
101
|
requirements:
|
88
|
-
- - "
|
102
|
+
- - "~>"
|
89
103
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
104
|
+
version: '1.8'
|
91
105
|
type: :development
|
92
106
|
prerelease: false
|
93
107
|
version_requirements: !ruby/object:Gem::Requirement
|
94
108
|
requirements:
|
95
|
-
- - "
|
109
|
+
- - "~>"
|
96
110
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
111
|
+
version: '1.8'
|
98
112
|
description:
|
99
113
|
email:
|
100
114
|
- asmith@mdsol.com
|
@@ -145,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
159
|
requirements:
|
146
160
|
- - ">="
|
147
161
|
- !ruby/object:Gem::Version
|
148
|
-
version: '2.
|
162
|
+
version: '2.5'
|
149
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
164
|
requirements:
|
151
165
|
- - ">="
|
@@ -159,6 +173,6 @@ summary: Dice Bag is a library of rake tasks for configuring web apps in the sty
|
|
159
173
|
of The Twelve-Factor App. It also provides continuous integration tasks that rely
|
160
174
|
on the configuration tasks.
|
161
175
|
test_files:
|
162
|
-
- spec/configuration_spec.rb
|
163
|
-
- spec/spec_helper.rb
|
164
176
|
- spec/command_spec.rb
|
177
|
+
- spec/spec_helper.rb
|
178
|
+
- spec/configuration_spec.rb
|