rails_env_prompt 1.0.3 → 1.0.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: 87ebd0c44cea8f3e036144384823b8bf9e615370097b305fb550071c2b4f7560
4
- data.tar.gz: 905eaf47bd13897857597c36b25d47fb6fba8962ad78b3268f0d8812d196c248
3
+ metadata.gz: 2c52c247346b9f37d8c766f78cbefd1b09f86a81a7178c35d783252314075ea9
4
+ data.tar.gz: 438890789491f250be29ac4d0673c2ed4ccb750a0ab483726b18842706aad9b0
5
5
  SHA512:
6
- metadata.gz: 7cea7c22d61b726e78fc205e505ad7ddfab6acd2c7d8bf9c9561ff3043449d5ab1d50cfee1e5cb395450383669a9be70334014c470013b120bdc504fc8e262fe
7
- data.tar.gz: 2d8bbc9f4553eb202b6141bbc40005c26068b62ae1ad3f882b77c2f9faecf4094c0bae5701efa029c1faeafa39a5e411d896635179a13df0b166a38128f3bb66
6
+ metadata.gz: 05bbe43b291cbc3ce8b220b204378ef6d938b2803e905960dcfd826ee32a4c4d4e295a0f4788b3684939cc0ea6a0ce3afddfcdfd4719d7bdcc0ad33f1f9797f9
7
+ data.tar.gz: a1f5c1da2d5ce4feb3f88540c9e267821594de20f6f7ad624ec035b33a82e3977a084a344326f75d97646135e1f5bd7d41fcc44b85aa674fce8cc3ed2f67f3b5
@@ -3,31 +3,16 @@ require 'irb'
3
3
  module IRB
4
4
  class << self
5
5
  def _patch
6
- prompt = RailsEnvPrompt.template
6
+ template = RailsEnvPrompt.template
7
7
 
8
- prompts = {
9
- normal: "#{prompt} %03n:%i> ",
10
- for_continuated_strings: "#{prompt} %03n:%i%l ",
11
- for_continuated_statements: "#{prompt} %03n:%i* "
12
- }
8
+ current_prompt = IRB.conf[:PROMPT_MODE]
13
9
 
14
- # Some older versions store this value and call dup. We'll have to change it each time to have it include current
15
- # tenant and possible other dynamic variables
16
- %i[normal for_continuated_strings for_continuated_statements].each do |key|
17
- prompts[key] = prompts[key].tap do |string|
18
- def string.dup
19
- RailsEnvPrompt.parse(self)
20
- end
21
- end
22
- end
23
-
24
- IRB.conf[:PROMPT][:RAILS_ENV_PROMPT] = {
25
- PROMPT_I: prompts[:normal],
26
- PROMPT_N: prompts[:normal],
27
- PROMPT_S: prompts[:for_continuated_strings],
28
- PROMPT_C: prompts[:for_continuated_statements],
29
- RETURN: "=> %s\n"
30
- }
10
+ IRB.conf[:PROMPT][:RAILS_ENV_PROMPT] = IRB.conf[:PROMPT][:DEFAULT].map do |key, value|
11
+ [
12
+ key,
13
+ (template + value)
14
+ ]
15
+ end.to_h
31
16
 
32
17
  IRB.conf[:PROMPT_MODE] = :RAILS_ENV_PROMPT
33
18
  end
@@ -5,6 +5,6 @@ end
5
5
 
6
6
  if defined?(Pry)
7
7
  Pry.config.prompt = proc do |obj, nest_level, _|
8
- "#{RailsEnvPrompt.to_s} #{obj}:#{nest_level}> "
8
+ "#{RailsEnvPrompt.template} #{obj}:#{nest_level}> "
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module RailsEnvPrompt
2
- VERSION = '1.0.3'.freeze
2
+ VERSION = '1.0.4'.freeze
3
3
  end
@@ -3,6 +3,14 @@ require 'rails_env_prompt/pry'
3
3
  require 'rails_env_prompt/version'
4
4
 
5
5
  module RailsEnvPrompt
6
+ def self.template
7
+ [
8
+ app_name,
9
+ environment_name,
10
+ tenant_prompt
11
+ ].compact.join('/') + ' '
12
+ end
13
+
6
14
  def self.app_name
7
15
  @app_name ||= begin
8
16
  application_class = Rails.application.class
@@ -15,28 +23,14 @@ module RailsEnvPrompt
15
23
  end
16
24
  end
17
25
 
18
- def self.template
19
- [
20
- '[APP]',
21
- '[ENV]',
22
- tenant_prompt
23
- ].compact.join('/')
24
- end
25
-
26
- def self.parse(string)
27
- string.gsub('[APP]', app_name)
28
- .gsub('[ENV]', colored(Rails.env, environment_color))
29
- .gsub('[TENANT]', defined?(Apartment) ? Apartment::Tenant.current : '')
30
- end
31
-
32
- def self.to_s
33
- parse(template)
26
+ def self.environment_name
27
+ colored(Rails.env, environment_color)
34
28
  end
35
29
 
36
30
  def self.tenant_prompt
37
31
  return unless defined?(Apartment)
38
32
 
39
- '[TENANT]'
33
+ Apartment::Tenant.current
40
34
  end
41
35
 
42
36
  def self.colored(text, color)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_env_prompt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rene van Lieshout
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-19 00:00:00.000000000 Z
11
+ date: 2024-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,7 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 3.0.3
77
+ rubyforge_project:
78
+ rubygems_version: 2.7.6.3
78
79
  signing_key:
79
80
  specification_version: 4
80
81
  summary: Adds current Rails env and Apartment tenant to prompt