dice_bag 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 874c8d8cd121a6aa6c77dabeca7bc3f14f1942c02c74fa17698eab6dcf487e25
4
- data.tar.gz: 2ec917b4582c85a62855c1c9c259014d75e3c9ed2275b250ef2dd3964a32d32c
3
+ metadata.gz: e0b21d4256744e2c288eae48cd2949029e7e3a4eee8307a03f4aad5998232ef6
4
+ data.tar.gz: 56aa419d74d9b581b380b9f70ab5a45c518e69adc82e740a571b13a6d9ba944a
5
5
  SHA512:
6
- metadata.gz: a07f5df7c3b2d577539b89557c968be3449dc61df0c1399e73d881b4de17017d3ef197c86877537e647eed8aa910bfa7ce1c9d66c521960d0d46642759c17907
7
- data.tar.gz: 8d25d866a4db9e3dd049a00c7cdb2c86a4f5e127995c9eda6c68e741b285788c17d6044e558e4d721976b079470201d826be84c4d0604e95f4337514eaea1a46
6
+ metadata.gz: cd63073daf8e395e12ef4af05818bcf32bfd009815ee2037fc2c9a208a93927d43a9d1c54b7966ee884dfe8cd9c7baf40f2da31bdec8a21f38cbf4825682de35
7
+ data.tar.gz: 006a8f5ae690be23ab34d1e62ac302285b3b135450c3a67089311134bf8a4445f05e1e2d529fa63774038304245cc5e04425a948c1e064ab62e381869d38a3e8
@@ -48,8 +48,8 @@ module DiceBag
48
48
  checker = template_checker.new
49
49
  next if !gem_names.empty? && !checker_within_given_gems?(checker, gem_names)
50
50
  location = checker.templates_location
51
- checker.templates.each do |template|
52
- available_templates.push( DefaultTemplateFile.new(template, location) )
51
+ checker.templates.each do |template, save_as|
52
+ available_templates.push( DefaultTemplateFile.new(template, location, save_as) )
53
53
  end
54
54
  end
55
55
  available_templates
@@ -10,12 +10,12 @@ module DiceBag
10
10
  class DefaultTemplateFile
11
11
  include DiceBagFile
12
12
 
13
- def initialize(name, location=nil)
13
+ def initialize(name, location=nil, save_as=nil)
14
14
  #if called from command line with only a name we search in all our templates for the file
15
15
  if (File.dirname(name) == '.')
16
16
  name = AvailableTemplates.template_filename_for(name)
17
17
  end
18
- @filename = File.basename(name)
18
+ @filename = File.basename(save_as || name)
19
19
  @file = name
20
20
  @template_location = location
21
21
  @destination = File.join(Project.root, @template_location, @filename)
@@ -0,0 +1,19 @@
1
+ <%= warning.as_yaml_comment %>
2
+
3
+ <% environments = Rails.env.production? ? [:production] : [:development, :test] %>
4
+
5
+ <% environments.each do |env| %>
6
+ <%= env %>:
7
+ adapter: <%= configured[env].database_driver || 'postgres' %>
8
+ database: <%= configured[env].database_name! || "PROJECT_NAME_#{env}" %><%= ('<'+'%=ENV["TEST_ENV_NUMBER"] %'+'>') if (env == :test) %>
9
+ username: <%= configured[env].database_username! || 'postgres' %>
10
+ password: <%= configured[env].database_password! %>
11
+ host: <%= configured[env].database_host! || 'localhost' %>
12
+ port: <%= configured[env].database_port || 5432 %>
13
+ pool: <%= configured[env].database_pool || 5 %>
14
+ timeout: <%= configured[env].database_timeout || 5000 %>
15
+ encoding: <%= configured[env].database_encoding || 'unicode' %>
16
+ reconnect: <%= configured[env].database_reconnect || false %>
17
+ <% db_cert = configured[env].database_ssl_cert %>
18
+ <%= db_cert ? "sslca: #{db_cert}" : '' %>
19
+ <% end %>
@@ -16,7 +16,9 @@ module DiceBag
16
16
  end
17
17
 
18
18
  if defined?(Mysql2)
19
- add_template('database.yml.dice')
19
+ add_template('databases/mysql.yml.dice', save_as: 'database.yml.dice')
20
+ elsif defined?(PG)
21
+ add_template('databases/postgres.yml.dice', save_as: 'database.yml.dice')
20
22
  end
21
23
 
22
24
  if defined?(AWS)
@@ -30,9 +32,9 @@ module DiceBag
30
32
  @needed_templates
31
33
  end
32
34
 
33
- def add_template(file)
35
+ def add_template(file, save_as: nil)
34
36
  pwd = File.dirname(__FILE__)
35
- @needed_templates.push(File.join(pwd, file))
37
+ @needed_templates.push([File.join(pwd, file), save_as])
36
38
  end
37
39
 
38
40
  end
@@ -1,3 +1,3 @@
1
1
  module DiceBag
2
- VERSION = '1.2.3'
2
+ VERSION = '1.3.0'
3
3
  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.2.3
4
+ version: 1.3.0
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: 2018-08-08 00:00:00.000000000 Z
12
+ date: 2018-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -119,7 +119,8 @@ files:
119
119
  - lib/dice_bag/template_helpers.rb
120
120
  - lib/dice_bag/templates/aws.yml.dice
121
121
  - lib/dice_bag/templates/dalli.yml.dice
122
- - lib/dice_bag/templates/database.yml.dice
122
+ - lib/dice_bag/templates/databases/mysql.yml.dice
123
+ - lib/dice_bag/templates/databases/postgres.yml.dice
123
124
  - lib/dice_bag/templates/gems_checker.rb
124
125
  - lib/dice_bag/templates/google_analytics.yml.dice
125
126
  - lib/dice_bag/version.rb