rails_env_prompt 1.0.3 → 1.0.5

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: 87ebd0c44cea8f3e036144384823b8bf9e615370097b305fb550071c2b4f7560
4
- data.tar.gz: 905eaf47bd13897857597c36b25d47fb6fba8962ad78b3268f0d8812d196c248
3
+ metadata.gz: 38a8d4d69de6506f630f17bf0d4427246bce8640d280ccf3a765568a0ab2e4e3
4
+ data.tar.gz: 27237e643cf7b905e664ba67d1a88fe5988c5f8387fe9e07e059f932eb9254f2
5
5
  SHA512:
6
- metadata.gz: 7cea7c22d61b726e78fc205e505ad7ddfab6acd2c7d8bf9c9561ff3043449d5ab1d50cfee1e5cb395450383669a9be70334014c470013b120bdc504fc8e262fe
7
- data.tar.gz: 2d8bbc9f4553eb202b6141bbc40005c26068b62ae1ad3f882b77c2f9faecf4094c0bae5701efa029c1faeafa39a5e411d896635179a13df0b166a38128f3bb66
6
+ metadata.gz: 764346be500386598dffbcf9f42df420cd8e8fcbd6efbd3c221d997d49714bdc65c1f801bafc0bfa65b973afe2e074b66b1d02fc6bd84bc1c16ee3068b0f39f2
7
+ data.tar.gz: ab9737443f7ef3f543706e3a09475d289b45248e6aabe91d590cdd9eb6e879ceedeb911b529899b6a363bb4cc1cc12fb9723348e9c86afde46e312c21df1b811
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_env_prompt (1.0.3)
4
+ rails_env_prompt (1.0.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,15 @@
1
+ require 'irb'
2
+
3
+ if IRB::VERSION >= Gem::Version.new('1.9.0')
4
+ module IRB
5
+ class Irb
6
+ original_format_prompt = instance_method(:format_prompt)
7
+
8
+ define_method(:format_prompt) do |format, ltype, indent, line_no|
9
+ original_format_prompt.bind(self).(
10
+ "#{RailsEnvPrompt.to_s} #{format}", ltype, indent, line_no
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,51 @@
1
+ require 'irb'
2
+
3
+ if IRB::VERSION < Gem::Version.new('1.9.0')
4
+ module IRB
5
+ class << self
6
+ def _patch
7
+ prompt = RailsEnvPrompt.template
8
+
9
+ prompts = {
10
+ normal: "#{prompt} %03n:%i> ",
11
+ for_continuated_strings: "#{prompt} %03n:%i%l ",
12
+ for_continuated_statements: "#{prompt} %03n:%i* "
13
+ }
14
+
15
+ # Some older versions store this value and call dup. We'll have to change it each time to have it include current
16
+ # tenant and possible other dynamic variables
17
+ %i[normal for_continuated_strings for_continuated_statements].each do |key|
18
+ prompts[key] = prompts[key].tap do |string|
19
+ def string.dup
20
+ RailsEnvPrompt.parse(self)
21
+ end
22
+ end
23
+ end
24
+
25
+ IRB.conf[:PROMPT][:RAILS_ENV_PROMPT] = {
26
+ PROMPT_I: prompts[:normal],
27
+ PROMPT_N: prompts[:normal],
28
+ PROMPT_S: prompts[:for_continuated_strings],
29
+ PROMPT_C: prompts[:for_continuated_statements],
30
+ RETURN: "=> %s\n"
31
+ }
32
+
33
+ IRB.conf[:PROMPT_MODE] = :RAILS_ENV_PROMPT
34
+ end
35
+
36
+ _setup = instance_method(:setup)
37
+
38
+ if _setup.arity == -2
39
+ define_method(:setup) do |ap_path, argv: ::ARGV|
40
+ _setup.bind(self).call(ap_path, argv: argv)
41
+ _patch
42
+ end
43
+ else
44
+ define_method(:setup) do |ap_path|
45
+ _setup.bind(self).call(ap_path)
46
+ _patch
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsEnvPrompt
2
- VERSION = '1.0.3'.freeze
2
+ VERSION = '1.0.5'.freeze
3
3
  end
@@ -1,5 +1,3 @@
1
- require 'rails_env_prompt/irb'
2
- require 'rails_env_prompt/pry'
3
1
  require 'rails_env_prompt/version'
4
2
 
5
3
  module RailsEnvPrompt
@@ -51,3 +49,8 @@ module RailsEnvPrompt
51
49
  end
52
50
  end
53
51
  end
52
+
53
+ # Load patches
54
+ require 'rails_env_prompt/irb-pre-190'
55
+ require 'rails_env_prompt/irb-190'
56
+ require 'rails_env_prompt/pry'
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.5
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-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -51,7 +51,8 @@ files:
51
51
  - README.md
52
52
  - Rakefile
53
53
  - lib/rails_env_prompt.rb
54
- - lib/rails_env_prompt/irb.rb
54
+ - lib/rails_env_prompt/irb-190.rb
55
+ - lib/rails_env_prompt/irb-pre-190.rb
55
56
  - lib/rails_env_prompt/pry.rb
56
57
  - lib/rails_env_prompt/version.rb
57
58
  - rails_env_prompt.gemspec
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
77
  requirements: []
77
- rubygems_version: 3.0.3
78
+ rubygems_version: 3.1.2
78
79
  signing_key:
79
80
  specification_version: 4
80
81
  summary: Adds current Rails env and Apartment tenant to prompt
@@ -1,49 +0,0 @@
1
- require 'irb'
2
-
3
- module IRB
4
- class << self
5
- def _patch
6
- prompt = RailsEnvPrompt.template
7
-
8
- prompts = {
9
- normal: "#{prompt} %03n:%i> ",
10
- for_continuated_strings: "#{prompt} %03n:%i%l ",
11
- for_continuated_statements: "#{prompt} %03n:%i* "
12
- }
13
-
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
- }
31
-
32
- IRB.conf[:PROMPT_MODE] = :RAILS_ENV_PROMPT
33
- end
34
-
35
- _setup = instance_method(:setup)
36
-
37
- if _setup.arity == -2
38
- define_method(:setup) do |ap_path, argv: ::ARGV|
39
- _setup.bind(self).call(ap_path, argv: argv)
40
- _patch
41
- end
42
- else
43
- define_method(:setup) do |ap_path|
44
- _setup.bind(self).call(ap_path)
45
- _patch
46
- end
47
- end
48
- end
49
- end