wellcar 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41fbc50fae9ac8ae5ee904b21027e31a9c863d5e2fb9c3c3758b7f071cfe2fb1
4
- data.tar.gz: 54b46d33182277c74712784613897efd46500cc198ec21166c72b553784eb43a
3
+ metadata.gz: d9629130bcd16fffcc9864daedb27e5f5795c660a33f92816a33851dac2bb98c
4
+ data.tar.gz: d59cc9b695eeaff5af97a498c589b053ab454f6f99583e1a54e913bf19172d7c
5
5
  SHA512:
6
- metadata.gz: 41ca7e4d530f489b8f7c4db42da7b6fc9d31ab6bbce80a0d44c9a7f09a8b4c8598b32affca23b957975b50d7af98e98cda5334a0d31794a89999fec70c694b44
7
- data.tar.gz: 552e7a7d1db64552c44f272464bd2065ea80d2f148f7f05acfdc5d5002b59bbc650858da498ae1e88628b4091cb5c355b16c24cd911501da3c6beabcff0114cc
6
+ metadata.gz: e6da3f0f58f3c7ee6788ed5fd30bd767a8ac3c778a59e797bf174f5762db7eef75f742bdb9cd149e8327f66999f2291fefbfc8ddee139a94bc8849d218d2ce04
7
+ data.tar.gz: f14698f09a94e51c8072f9812b7eef731fb19be0752d03895679b185e6e54a17715acbb1280651fff8273742deb02299495ba80b387999803e4cbf6e4345dde4
data/.gitignore CHANGED
@@ -1,5 +1,27 @@
1
- *swp
2
- *swo
1
+ # Swap
2
+ [._]*.s[a-v][a-z]
3
+ !*.svg # comment out if you don't need vector files
4
+ [._]*.sw[a-p]
5
+ [._]s[a-rt-v][a-z]
6
+ [._]ss[a-gi-z]
7
+ [._]sw[a-p]
8
+
9
+ # Session
10
+ Session.vim
11
+ Sessionx.vim
12
+
13
+ # Temporary
14
+ .netrwhist
15
+ *~
16
+ # Auto-generated tag files
17
+ tags
18
+ # Persistent undo
19
+ [._]*.un~
20
+ # git mergefiles
21
+ *.orig
22
+
23
+ # macos metadata
3
24
  .DS_Store
25
+
4
26
  pkg
5
27
  tmp
@@ -15,3 +15,21 @@ I have published the gem to Rubygems.org, purely to make sure that the name `wel
15
15
  As such, please mess around or whatever but do not expect any polish, or even anything to work.
16
16
 
17
17
  [The DIP gem by @bidendi](https://github.com/bibendi/dip) is an inspiration for my tinkering here. Check it out if you're serious about developing and deploying Rails apps in Docker containers!
18
+ [Kuby](https://github.com/getkuby/kuby-core) is a tool that automates Docker and Kubernetes for a Rails app. I discovered this via Ruby Weekly literally as I was going through publishing `wellcar`.
19
+
20
+ ## Approach
21
+ I've taken a pragmatic, quick-and-dirty approach to building `wellcar`.
22
+
23
+ ### Templating files for Dockerising
24
+ Docker files generation rather crudely relies on ERB templating.
25
+ There are pairs of `.erb` and `.rb` files within `lib/wellcar/templates/` for each of the files that gets generated by `wellcar new` and `wellcar dock`.
26
+
27
+ I would prefer to have some sort of AST for the different file types to make the system more flexible.
28
+ However, I don't know enough about Docker, the files I might need to manage or ASTs to try to tackle that right now.
29
+ It would be a long-term goal to do this.
30
+
31
+ ### Running commands
32
+ Commands are also crudely executed with `system()` calls.
33
+ This is a clunky approach but has helped me deep-dive into Docker and understand the command hierarchy, particularly between `docker` and `docker-compose`, and the workflow for deploying apps.
34
+
35
+ At some stage, it might be possible to interact with the Docker Daemon directly although it's debatable whether this is advantageous or not.
@@ -132,7 +132,7 @@ class NewCommand < CommandBase
132
132
  # remove dockerfile.init and docker-compose.yml with initialisation services
133
133
  %w(Dockerfile.init docker-compose.yml config/database.yml).each {|f| File.delete(f) if File.file?(f) }
134
134
  # Create docker-compose.yml file
135
- Wellcar::Templates::DockerCompose.new(app_name).write
135
+ Wellcar::Templates::DockerCompose.new(app_name, github_account).write
136
136
  Wellcar::Templates::DatabaseYaml.new(app_name).write
137
137
  end
138
138
 
@@ -1,3 +1,3 @@
1
1
  POSTGRES_USER=postgres
2
- POSTGRES_PASSWORD=a-development-password
2
+ POSTGRES_PASSWORD=<%= password %>
3
3
  POSTGRES_DB=<%= app_name %>_development
@@ -1,3 +1,4 @@
1
+ require "securerandom"
1
2
  require File.join(File.dirname(__FILE__), "base")
2
3
 
3
4
  module Wellcar
@@ -5,7 +6,8 @@ module Wellcar
5
6
  class EnvDevelopmentDatabase < Base
6
7
  def initialize(app_name)
7
8
  super ".env/development/database"
8
- with_attributes app_name: app_name
9
+ with_attributes app_name: app_name,
10
+ password: SecureRandom.base64(20)
9
11
  with_template "env_development_database.erb"
10
12
  end
11
13
  end
@@ -1,3 +1,3 @@
1
1
  POSTGRES_USER=postgres
2
- POSTGRES_PASSWORD=replace-me
2
+ POSTGRES_PASSWORD=<%= password %>
3
3
  POSTGRES_DB=<%= app_name %>_production
@@ -1,11 +1,13 @@
1
1
  require File.join(File.dirname(__FILE__), "base")
2
+ require "securerandom"
2
3
 
3
4
  module Wellcar
4
5
  module Templates
5
6
  class EnvProductionDatabase < Base
6
7
  def initialize(app_name)
7
8
  super ".env/production/database"
8
- with_attributes app_name: app_name
9
+ with_attributes app_name: app_name,
10
+ password: SecureRandom.base64(20)
9
11
  with_template "env_production_database.erb"
10
12
  end
11
13
  end
@@ -4,9 +4,9 @@ module Wellcar
4
4
  module Templates
5
5
  class ReverseProxyConf < Base
6
6
  def initialize(domain_name)
7
- super "reverse_proxy.conf"
7
+ super "reverse-proxy.conf"
8
8
  with_attributes domain_name: domain_name
9
- with_template "reverse_proxy.conf.erb"
9
+ with_template "reverse-proxy.conf.erb"
10
10
  within "config/nginx"
11
11
  end
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module Wellcar
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -1,17 +1,23 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "..", "spec_helper.rb")
2
- require "yaml"
3
2
  require "wellcar/templates/env_development_database"
4
3
 
5
4
  RSpec.describe Wellcar::Templates::EnvDevelopmentDatabase do
6
5
  describe "#render" do
7
6
  subject { template.render }
7
+
8
+ let(:password) { class_double "SecureRandom" }
9
+
10
+ before do
11
+ stub_const "SecureRandom", password
12
+ expect(password).to receive(:base64).with(20).and_return "a-password"
13
+ end
8
14
 
9
15
  context "with a first set of inputs" do
10
16
  let(:template) { described_class.new("test_app") }
11
17
 
12
18
  it { is_expected.to include("POSTGRES_DB=test_app_development") }
13
19
  it { is_expected.to include("POSTGRES_USER=postgres") }
14
- it { is_expected.to include("POSTGRES_PASSWORD=a-development-password") }
20
+ it { is_expected.to include("POSTGRES_PASSWORD=a-password") }
15
21
  end
16
22
 
17
23
  context "with another set of inputs" do
@@ -19,7 +25,7 @@ RSpec.describe Wellcar::Templates::EnvDevelopmentDatabase do
19
25
 
20
26
  it { is_expected.to include("POSTGRES_DB=old_app_development") }
21
27
  it { is_expected.to include("POSTGRES_USER=postgres") }
22
- it { is_expected.to include("POSTGRES_PASSWORD=a-development-password") }
28
+ it { is_expected.to include("POSTGRES_PASSWORD=a-password") }
23
29
  end
24
30
  end
25
31
  end
@@ -1,17 +1,23 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "..", "spec_helper.rb")
2
- require "yaml"
3
2
  require "wellcar/templates/env_production_database"
4
3
 
5
4
  RSpec.describe Wellcar::Templates::EnvProductionDatabase do
6
5
  describe "#render" do
7
6
  subject { template.render }
8
7
 
8
+ let(:password) { class_double "SecureRandom" }
9
+
10
+ before do
11
+ stub_const "SecureRandom", password
12
+ expect(password).to receive(:base64).with(20).and_return "prod-password"
13
+ end
14
+
9
15
  context "with a first set of inputs" do
10
16
  let(:template) { described_class.new("test_app") }
11
17
 
12
18
  it { is_expected.to include("POSTGRES_DB=test_app_production") }
13
19
  it { is_expected.to include("POSTGRES_USER=postgres") }
14
- it { is_expected.to include("POSTGRES_PASSWORD=replace-me") }
20
+ it { is_expected.to include("POSTGRES_PASSWORD=prod-password") }
15
21
  end
16
22
 
17
23
  context "with another set of inputs" do
@@ -19,7 +25,7 @@ RSpec.describe Wellcar::Templates::EnvProductionDatabase do
19
25
 
20
26
  it { is_expected.to include("POSTGRES_DB=old_app_production") }
21
27
  it { is_expected.to include("POSTGRES_USER=postgres") }
22
- it { is_expected.to include("POSTGRES_PASSWORD=replace-me") }
28
+ it { is_expected.to include("POSTGRES_PASSWORD=prod-password") }
23
29
  end
24
30
  end
25
31
  end
@@ -1,5 +1,4 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "..", "spec_helper.rb")
2
- require "yaml"
3
2
  require "wellcar/templates/reverse_proxy_conf"
4
3
 
5
4
  RSpec.describe Wellcar::Templates::ReverseProxyConf do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wellcar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - NJ Pearman
@@ -111,7 +111,7 @@ files:
111
111
  - lib/wellcar/templates/env_production_database.rb
112
112
  - lib/wellcar/templates/env_production_web.erb
113
113
  - lib/wellcar/templates/env_production_web.rb
114
- - lib/wellcar/templates/reverse_proxy.conf.erb
114
+ - lib/wellcar/templates/reverse-proxy.conf.erb
115
115
  - lib/wellcar/templates/reverse_proxy_conf.rb
116
116
  - lib/wellcar/version.rb
117
117
  - spec/.keep