env_bro 0.1.0 → 0.1.1

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: 1f301689d1d2681e1d23b16f86096cc97c14824c932cf4612fede79b9c6b6803
4
- data.tar.gz: 48cc9e85161a1b69d3d3e55a5fe4fc977a77679b22d4d0ff8445490ac5d0006a
3
+ metadata.gz: 9df4fc28acfe1ed6dd8893dbcdbfc44c179f29d38182250b400b01972d1e156b
4
+ data.tar.gz: 2e2237a10f5337e0aabb232431096ea6352af08dedc367656212093cc98f1870
5
5
  SHA512:
6
- metadata.gz: 50852fb63ffc0305c19e15d9f9dc530f4d3e8df1ddcb00c76d821a90b5b6f872bac641bfc62a110e3c48f353302c59928cef834f6ed03d91f01fd60b35f92fd4
7
- data.tar.gz: 6cfb17faf7c08792749b74cb67a5a4d8e214d9200d0f0bbfa73e81660e6407aa446fde5a498b4f438e4be7a59c622c91c820e01115fbe3773a4fb2166e3c8385
6
+ metadata.gz: 9deb98e680ecad5343371d9a075ce5b312837185508543d3d62120547f877434ce490c52dad7e6f1f1750cced9cd50fd9c0d3ee62dc6ffbdb713054bdac10430
7
+ data.tar.gz: e1d0586feacd8e660c0d31cc6c167fef6dd6284fd8125c69aa07c5343d2e66d00523f20a9b2835ca60536da1ef06f3323ffe40a54144cb6fb9abda0a93705e9c
data/README.md CHANGED
@@ -39,7 +39,7 @@ gem "env_bro", git: "https://github.com/rubydevro/env_bro.git"
39
39
  ```
40
40
 
41
41
  ```sh
42
- bin/rails generate env_bro:install # initializer, route, migration (--mount-path=/admin/env)
42
+ bin/rails generate env_bro:install # initializer, route (asks for the path; or --mount-path=/admin/env), migration
43
43
  bin/rails db:migrate
44
44
  ```
45
45
 
@@ -1,3 +1,3 @@
1
1
  module EnvBro
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -8,7 +8,10 @@ module EnvBro
8
8
 
9
9
  desc "Adds the EnvBro initializer, mounts the engine and copies its migrations."
10
10
 
11
- class_option :mount_path, type: :string, default: "/admin/env", desc: "Where to mount EnvBro"
11
+ DEFAULT_MOUNT_PATH = "/admin/env"
12
+
13
+ class_option :mount_path, type: :string,
14
+ desc: "Where to mount EnvBro (asked interactively when omitted, default #{DEFAULT_MOUNT_PATH})"
12
15
 
13
16
  def copy_initializer
14
17
  copy_file "env_bro.rb", "config/initializers/env_bro.rb"
@@ -19,7 +22,7 @@ module EnvBro
19
22
  if File.exist?(routes) && File.read(routes).include?("EnvBro::Engine")
20
23
  say_status :skip, "EnvBro::Engine is already mounted", :yellow
21
24
  else
22
- route %(mount EnvBro::Engine => "#{options[:mount_path]}")
25
+ route %(mount EnvBro::Engine => "#{mount_path}")
23
26
  end
24
27
  end
25
28
 
@@ -33,9 +36,20 @@ module EnvBro
33
36
  EnvBro is installed. Next:
34
37
  1. bin/rails db:migrate
35
38
  2. Set who may propose, review and reveal in config/initializers/env_bro.rb
36
- 3. Visit #{options[:mount_path]}
39
+ 3. Visit #{mount_path}
37
40
  TEXT
38
41
  end
42
+
43
+ private
44
+ # --mount-path wins; otherwise ask when someone is at the terminal.
45
+ def mount_path
46
+ @mount_path ||= begin
47
+ path = options[:mount_path].presence
48
+ path ||= ask("Where should EnvBro be mounted?", default: DEFAULT_MOUNT_PATH) if $stdin.tty?
49
+ path = path.to_s.strip.presence || DEFAULT_MOUNT_PATH
50
+ "/" + path.delete_prefix("/").delete_suffix("/")
51
+ end
52
+ end
39
53
  end
40
54
  end
41
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: env_bro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruby Dev SRL