orchestration 0.7.3 → 0.7.4

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: fd668d1ea77820075d2ad454dde1691304daed2c1e26d7e446e2e729a62625db
4
- data.tar.gz: 0d3e1d8796810142973303a530972b9bb38e165822c7b403c52ddfb439d91947
3
+ metadata.gz: ec214938f5a9d352579f7fa8f84ae16ef4c957698eab47ab058fa0cdbb1bde7b
4
+ data.tar.gz: e3e10e2c892d33271ecf36d48ffff35b861e13aeee59f0d49bdf08c4e3b30763
5
5
  SHA512:
6
- metadata.gz: d308e88beaaf4c792c2aea6c7ac3ea78c5249ac956da2f1a8ae0637432321a1118a02d9ccef59ae6abf51ac0f381e4bf7e7be249721d1bd2138a51e4fda63f4a
7
- data.tar.gz: 322620f4c68eb845f63006531355d93193df31757dae2ca97b6bc5d45186262557da6a4f9381fd8dfa6754e619cb370d0b5d93aa6e155f053fb3265e2639ab06
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
@@ -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
@@ -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.3'
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.3
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-17 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