orchestration 0.7.2 → 0.7.4

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: 3423dc31e2b526868cb869c930d6f73039437939aa7b2ceb859e0e8106536344
4
- data.tar.gz: 4669fd75876e047f52d256dd2f2e3840ecd42f157b04c6f4f81e315ae96ca6ff
3
+ metadata.gz: ec214938f5a9d352579f7fa8f84ae16ef4c957698eab47ab058fa0cdbb1bde7b
4
+ data.tar.gz: e3e10e2c892d33271ecf36d48ffff35b861e13aeee59f0d49bdf08c4e3b30763
5
5
  SHA512:
6
- metadata.gz: 2a4f0579b2698d30103975b175b8a4cdc1df51c5ce883560f2b11f24b8fd3307fd1e6a35868689f6152d182e07ddbc65b6f081fe4b33ae1114e7957b64338c02
7
- data.tar.gz: 380413ccb1b108614ad09247a2435178a042c352775712b287c79e707938aa409290ab42f9b0b5d7cc32184fe73de200a8a551ae5c24ba37b3c08655e4caeaf0
6
+ metadata.gz: dcd8cd6fd5b6b8dbec62e42a1a8dbc6c199d8b822eac2c8fb46350e7057ce8f8d397f0f0baf61239e5e65ede48fdbfe799d3a4ae4db8bba7e9bc6514e1c6ca89
7
+ data.tar.gz: 10253172f0a5f1c984134c71a375c71388b7eeeff2afdb160ff10e4a7179e80c4a440227cf892487d1d9634edc6e6deeaed083ba476a755fc2c3df7794c8f8e1
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orchestration (0.7.2)
4
+ orchestration (0.7.4)
5
5
  database_url (~> 0.1.2)
6
+ dotenv-rails (~> 2.8)
6
7
  erubis (~> 2.7)
7
8
  i18n
8
9
  paint (~> 2.2)
@@ -94,6 +95,10 @@ GEM
94
95
  devpack (0.4.0)
95
96
  diff-lcs (1.5.0)
96
97
  digest (3.1.0)
98
+ dotenv (2.8.1)
99
+ dotenv-rails (2.8.1)
100
+ dotenv (= 2.8.1)
101
+ railties (>= 3.2)
97
102
  erubi (1.10.0)
98
103
  erubis (2.7.0)
99
104
  globalid (1.0.0)
data/README.md CHANGED
@@ -31,7 +31,7 @@ Add _Orchestration_ to your `Gemfile`:
31
31
  _Ruby 3.x_:
32
32
 
33
33
  ```ruby
34
- gem 'orchestration', '~> 0.7.2'
34
+ gem 'orchestration', '~> 0.7.3'
35
35
  ```
36
36
 
37
37
  _Ruby 2.x_:
@@ -166,30 +166,15 @@ make push
166
166
 
167
167
  ### Development
168
168
 
169
- An [`.env` file](https://docs.docker.com/compose/env-file/) is created automatically in your project root. This file is _not_ stored in version control. Set all application environment variables in this file.
169
+ A [`.env` file](https://docs.docker.com/compose/env-file/) is created automatically in your project root. This file is _not_ stored in version control. Set all application environment variables in this file.
170
170
 
171
171
  #### Launching a development server
172
172
 
173
- To load all variables from `.env` and launch a development server, run the following command:
173
+ Use vanilla _Rails_ commands to load a server or console. If present, a `.env` file will be read and loaded (via the [dotenv](https://github.com/bkeepers/dotenv) gem) to populate the environment.
174
174
 
175
175
  ```bash
176
- make serve
177
- ```
178
-
179
- To load a _Rails_ console:
180
- ```bash
181
- make console
182
- ```
183
-
184
- The application environment will be output on launch for convenience.
185
-
186
- To pass extra commands to the _Rails_ server:
187
- ```bash
188
- # Custom server, custom port
189
- make serve server='webrick -p 3001'
190
-
191
- # Default server, custom port, custom bind address
192
- make serve server='-p 3001 -b 192.168.0.1'
176
+ bundle exec rails s # Launch a server
177
+ bundle exec rails c # Launch a console
193
178
  ```
194
179
 
195
180
  ### Testing
@@ -220,11 +220,16 @@ all: build
220
220
 
221
221
  ### Container management commands ###
222
222
 
223
+ .PHONY: pull
224
+ pull:
225
+ @$(call system,${compose_human} pull)
226
+ @${compose} pull
227
+
223
228
  .PHONY: start
224
229
  ifndef network
225
230
  start: network := ${compose_project_name}
226
231
  endif
227
- start: _create-log-directory _clean-logs
232
+ start: _create-log-directory _clean-logs pull
228
233
  ifneq (,${compose_services})
229
234
  @$(call system,${compose_human} up --detach)
230
235
  ifeq (${env},$(filter ${env},test development))
@@ -47,6 +47,10 @@ module Orchestration
47
47
  @settings.set(setting, read(prompt, default))
48
48
  end
49
49
 
50
+ def print_variable(variable, value)
51
+ $stdout.print "#{Paint[variable, :blue]}#{Paint['=', :white]}#{Paint[value, :cyan]}"
52
+ end
53
+
50
54
  private
51
55
 
52
56
  def prompt(message, default)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orchestration
4
- VERSION = '0.7.2'
4
+ VERSION = '0.7.4'
5
5
  end
data/lib/orchestration.rb CHANGED
@@ -33,28 +33,67 @@ require 'orchestration/terminal'
33
33
  require 'orchestration/version'
34
34
 
35
35
  module Orchestration
36
- def self.root
37
- Pathname.new(File.dirname(__dir__))
38
- end
36
+ class << self
37
+ def root
38
+ Pathname.new(File.dirname(__dir__))
39
+ end
39
40
 
40
- def self.makefile
41
- root.join('lib', 'orchestration', 'make', 'orchestration.mk')
42
- end
41
+ def makefile
42
+ root.join('lib', 'orchestration', 'make', 'orchestration.mk')
43
+ end
43
44
 
44
- def self.rakefile
45
- root.join('lib', 'Rakefile')
46
- end
45
+ def rakefile
46
+ root.join('lib', 'Rakefile')
47
+ end
47
48
 
48
- def self.error(key, options = {})
49
- warn('# Orchestration Error')
50
- warn("# #{I18n.t("orchestration.#{key}", options)}")
51
- end
49
+ def error(key, options = {})
50
+ warn('# Orchestration Error')
51
+ warn("# #{I18n.t("orchestration.#{key}", options)}")
52
+ end
53
+
54
+ def random_local_port
55
+ socket = Socket.new(:INET, :STREAM, 0)
56
+ socket.bind(Addrinfo.tcp('127.0.0.1', 0))
57
+ port = socket.local_address.ip_port
58
+ socket.close
59
+ port
60
+ end
61
+
62
+ def print_environment
63
+ return unless File.exist?('.env')
52
64
 
53
- def self.random_local_port
54
- socket = Socket.new(:INET, :STREAM, 0)
55
- socket.bind(Addrinfo.tcp('127.0.0.1', 0))
56
- port = socket.local_address.ip_port
57
- socket.close
58
- port
65
+ $stdout.puts
66
+ $stdout.puts("#{prefix} #{Paint['Loading environment from', :cyan]} #{Paint['.env', :green]}")
67
+ $stdout.puts
68
+ environment_variables.each do |variable, value|
69
+ terminal.print_variable(variable, value)
70
+ end
71
+ $stdout.puts
72
+ end
73
+
74
+ private
75
+
76
+ def terminal
77
+ @terminal ||= Terminal.new(Environment.new.settings)
78
+ end
79
+
80
+ def prefix
81
+ "#{Paint['[', :white]}#{Paint['orchestration', :cyan]}#{Paint[']', :white]}"
82
+ end
83
+
84
+ def environment_variables
85
+ File.readlines('.env').reject { |line| line.match(/^\s*#/) }
86
+ .select { |line| line.include?('=') }
87
+ .map do |line|
88
+ variable, _, value = line.partition('=')
89
+ [variable, value]
90
+ end
91
+ end
59
92
  end
60
93
  end
94
+
95
+ if ENV['RAILS_ENV'] == 'development'
96
+ require 'dotenv-rails'
97
+ Dotenv::Railtie.load
98
+ Orchestration.print_environment
99
+ end
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ['lib']
29
29
 
30
30
  spec.add_runtime_dependency 'database_url', '~> 0.1.2'
31
+ spec.add_runtime_dependency 'dotenv-rails', '~> 2.8'
31
32
  spec.add_runtime_dependency 'erubis', '~> 2.7'
32
33
  spec.add_runtime_dependency 'i18n'
33
34
  spec.add_runtime_dependency 'paint', '~> 2.2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orchestration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-05 00:00:00.000000000 Z
11
+ date: 2023-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: database_url
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.1.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: dotenv-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.8'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: erubis
29
43
  requirement: !ruby/object:Gem::Requirement