dice_bag 1.6.0 → 1.6.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 +4 -0
- data/lib/dice_bag/available_templates.rb +1 -2
- data/lib/dice_bag/project.rb +3 -1
- data/lib/dice_bag/tasks/config.rake +0 -1
- data/lib/dice_bag/template_file.rb +13 -5
- data/lib/dice_bag/template_helpers.rb +2 -2
- data/lib/dice_bag/version.rb +1 -1
- data/spec/support/config/database.yml.dice +4 -0
- data/spec/template_file_spec.rb +25 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5bb488ea8f0b38b938b9fd4ac13a69a1f60a8df544d546c123478bb31bb25ae
|
4
|
+
data.tar.gz: 7a351f59b04eaa6703e00608c2e9f90a3c53199529536ffe0ce3eb01f49d698e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4b40020b59067e98abe32f5bdceb5fc93a1dd4d543674423e6c8740f749e1d42563b7d7fcedd06afb99c4869c654c75dcb4e8d1963d41aee1c350a337a70653
|
7
|
+
data.tar.gz: a2470807821c5a6247f1cc8c7581a82b6a0d8195d5a2f3c391b3f74c4af9b31ac39145a766e63cc27b66503b3c461d88482e018ded8500c9de461852ae6f7e47
|
data/CHANGELOG.md
CHANGED
@@ -16,11 +16,10 @@ module DiceBag
|
|
16
16
|
|
17
17
|
class << self
|
18
18
|
def gem_specs
|
19
|
-
@gem_specs ||=
|
19
|
+
@gem_specs ||=
|
20
20
|
Gem::Specification.sort.each_with_object({}) do |spec, hsh|
|
21
21
|
hsh[spec.name] = spec.full_gem_path
|
22
22
|
end
|
23
|
-
end
|
24
23
|
end
|
25
24
|
|
26
25
|
def checker_within_given_gems?(checker, gem_names)
|
data/lib/dice_bag/project.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
module DiceBag
|
5
5
|
class Project
|
6
6
|
DEFAULT_NAME = "project"
|
7
|
+
DEFAULT_BUNDLE_PATH = "vendor/bundle"
|
7
8
|
|
8
9
|
# TODO: how to find the name of the project in non Rails apps?
|
9
10
|
def self.name
|
@@ -22,8 +23,9 @@ module DiceBag
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def self.templates_to_generate
|
26
|
+
bundle_path = (defined?(Bundler) && Bundler.settings[:path]) || DEFAULT_BUNDLE_PATH
|
25
27
|
FileList.new("**/*.dice") do |fl|
|
26
|
-
fl.exclude(File.join(
|
28
|
+
fl.exclude(File.join(bundle_path, "/**/*"))
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
@@ -19,11 +19,6 @@ module DiceBag
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def create_file(config_file, params)
|
22
|
-
# By passing "<>" we're trimming trailing newlines on lines that are
|
23
|
-
# nothing but ERB blocks (see documentation). This is useful for files
|
24
|
-
# like mauth_key where we want to control newlines carefully.
|
25
|
-
template = ERB.new(File.read(@file), nil, "<>")
|
26
|
-
|
27
22
|
# templates expect a configured object
|
28
23
|
configured = Configuration.new
|
29
24
|
warning = Warning.new(@filename)
|
@@ -34,5 +29,18 @@ module DiceBag
|
|
34
29
|
config_file.write(contents)
|
35
30
|
puts "File '#{config_file.file}' created"
|
36
31
|
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def template
|
36
|
+
# By passing "<>" we're trimming trailing newlines on lines that are
|
37
|
+
# nothing but ERB blocks (see documentation). This is useful for files
|
38
|
+
# like mauth_key where we want to control newlines carefully.
|
39
|
+
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
40
|
+
ERB.new(File.read(@file), trim_mode: "<>")
|
41
|
+
else
|
42
|
+
ERB.new(File.read(@file), nil, "<>")
|
43
|
+
end
|
44
|
+
end
|
37
45
|
end
|
38
46
|
end
|
@@ -32,7 +32,7 @@ module DiceBag
|
|
32
32
|
cert.issuer = root_ca.subject # root CA is the issuer
|
33
33
|
cert.public_key = PrivateKey.new(private_key.dup).public_key
|
34
34
|
cert.not_before = Time.now
|
35
|
-
cert.not_after = cert.not_before + 1 * 365 * 24 * 60 * 60 # 1 years validity
|
35
|
+
cert.not_after = cert.not_before + (1 * 365 * 24 * 60 * 60) # 1 years validity
|
36
36
|
ef = OpenSSL::X509::ExtensionFactory.new
|
37
37
|
ef.subject_certificate = cert
|
38
38
|
ef.issuer_certificate = root_ca
|
@@ -61,7 +61,7 @@ module DiceBag
|
|
61
61
|
root_ca.issuer = root_ca.subject # root CA's are "self-signed"
|
62
62
|
root_ca.public_key = root_key.public_key
|
63
63
|
root_ca.not_before = Time.now
|
64
|
-
root_ca.not_after = root_ca.not_before + 2 * 365 * 24 * 60 * 60 # 2 years validity
|
64
|
+
root_ca.not_after = root_ca.not_before + (2 * 365 * 24 * 60 * 60) # 2 years validity
|
65
65
|
ef = OpenSSL::X509::ExtensionFactory.new
|
66
66
|
ef.subject_certificate = root_ca
|
67
67
|
ef.issuer_certificate = root_ca
|
data/lib/dice_bag/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
require "dice_bag/project"
|
5
|
+
require "dice_bag/template_file"
|
6
|
+
|
7
|
+
RSpec.describe DiceBag::TemplateFile do
|
8
|
+
let(:file_name) { "config/database.yml" }
|
9
|
+
let(:template_name) { "#{file_name}.dice" }
|
10
|
+
let(:template_file) { DiceBag::TemplateFile.new(template_name) }
|
11
|
+
let(:config_file) { double(file: file_name) }
|
12
|
+
let(:params) { { deploy: true } }
|
13
|
+
|
14
|
+
before do
|
15
|
+
allow(ENV).to receive(:[]).with("DATABASE_USERNAME").and_return("alice")
|
16
|
+
allow(ENV).to receive(:[]).with("DATABASE_PASSWORD").and_return("xyzzy")
|
17
|
+
allow(DiceBag::Project).to receive(:root).and_return(File.join(__dir__, "support"))
|
18
|
+
end
|
19
|
+
|
20
|
+
it "writes to configuration file" do
|
21
|
+
expect(config_file)
|
22
|
+
.to receive(:write).with("development:\n database: development\n username: alice\n password: xyzzy\n")
|
23
|
+
template_file.create_file(config_file, params)
|
24
|
+
end
|
25
|
+
end
|
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.6.
|
4
|
+
version: 1.6.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:
|
12
|
+
date: 2022-02-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: diff-lcs
|
@@ -145,6 +145,8 @@ files:
|
|
145
145
|
- spec/command_spec.rb
|
146
146
|
- spec/configuration_spec.rb
|
147
147
|
- spec/spec_helper.rb
|
148
|
+
- spec/support/config/database.yml.dice
|
149
|
+
- spec/template_file_spec.rb
|
148
150
|
homepage:
|
149
151
|
licenses:
|
150
152
|
- MIT
|
@@ -173,6 +175,8 @@ summary: Dice Bag is a library of rake tasks for configuring web apps in the sty
|
|
173
175
|
of The Twelve-Factor App. It also provides continuous integration tasks that rely
|
174
176
|
on the configuration tasks.
|
175
177
|
test_files:
|
176
|
-
- spec/command_spec.rb
|
177
|
-
- spec/spec_helper.rb
|
178
178
|
- spec/configuration_spec.rb
|
179
|
+
- spec/spec_helper.rb
|
180
|
+
- spec/support/config/database.yml.dice
|
181
|
+
- spec/command_spec.rb
|
182
|
+
- spec/template_file_spec.rb
|