rails_env_prompt 1.0.2 → 1.0.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: 5efe2038228e5f7918c456888399305aa18cec4e39e11d7243e680ff5a35db7f
4
- data.tar.gz: 8701250d6b6d6f60e5bfc24bfcefd8a52639543aae98a932fc9bf18846fe6da3
3
+ metadata.gz: 2c52c247346b9f37d8c766f78cbefd1b09f86a81a7178c35d783252314075ea9
4
+ data.tar.gz: 438890789491f250be29ac4d0673c2ed4ccb750a0ab483726b18842706aad9b0
5
5
  SHA512:
6
- metadata.gz: 60da8aa637cfa05d4ffdb6544e841a961237ddddeb2fc1c4a4ebd347b542a30989557076009dca67728675d1f0f510b50f820edf1f11cd09de541f6beb1c352b
7
- data.tar.gz: '039c7b13ebf3b836f2630ad26c7440d7e1f6d8897e3c950232adce0ae74dbdac94548637223d94b7bdbd03083cfb6510dfad8435e2ca72294f6bc6aa66bb1865'
6
+ metadata.gz: 05bbe43b291cbc3ce8b220b204378ef6d938b2803e905960dcfd826ee32a4c4d4e295a0f4788b3684939cc0ea6a0ce3afddfcdfd4719d7bdcc0ad33f1f9797f9
7
+ data.tar.gz: a1f5c1da2d5ce4feb3f88540c9e267821594de20f6f7ad624ec035b33a82e3977a084a344326f75d97646135e1f5bd7d41fcc44b85aa674fce8cc3ed2f67f3b5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_env_prompt (1.0.2)
4
+ rails_env_prompt (1.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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.2'.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)
@@ -7,6 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.version = RailsEnvPrompt::VERSION
8
8
  spec.authors = ['Rene van Lieshout']
9
9
  spec.email = ['rene@lico.nl']
10
+ spec.licenses = ['MIT']
10
11
 
11
12
  spec.summary = 'Adds current Rails env and Apartment tenant to prompt'
12
13
  spec.description = 'Adds current Rails env and Apartment tenant to prompt'
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.2
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: 2020-12-20 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
@@ -56,7 +56,8 @@ files:
56
56
  - lib/rails_env_prompt/version.rb
57
57
  - rails_env_prompt.gemspec
58
58
  homepage: https://github.com/rvanlieshout/rails_env_prompt
59
- licenses: []
59
+ licenses:
60
+ - MIT
60
61
  metadata: {}
61
62
  post_install_message:
62
63
  rdoc_options: []
@@ -73,7 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
74
  - !ruby/object:Gem::Version
74
75
  version: '0'
75
76
  requirements: []
76
- rubygems_version: 3.0.3
77
+ rubyforge_project:
78
+ rubygems_version: 2.7.6.3
77
79
  signing_key:
78
80
  specification_version: 4
79
81
  summary: Adds current Rails env and Apartment tenant to prompt