rails_env_prompt 0.1.0
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 +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +20 -0
- data/README.md +41 -0
- data/Rakefile +3 -0
- data/lib/rails_env_prompt.rb +43 -0
- data/lib/rails_env_prompt/irb.rb +40 -0
- data/lib/rails_env_prompt/pry.rb +10 -0
- data/lib/rails_env_prompt/version.rb +3 -0
- data/rails_env_prompt.gemspec +27 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 20138a8401772f0262a4d3e792e7b20b1d7c7ee70937341b0a64f04f9f392913
|
4
|
+
data.tar.gz: a3e38add819b79ebc8703f01b81f4c5b663f3a14fb442cc4dc1fc7bea8670b82
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c11b47789f2a079e857a225c739be63a61f6e0a99f0c59c41359454ebbe33c518c36657db114c4b69fdc8156355b5497e7b64fdcce832176f781ba32a7224ced
|
7
|
+
data.tar.gz: eff5129d6c7b01be006c775b4a7198b1c49f6df8aa0be47ed68849fea2432183b55ed4c41b3e0d58ee970c3e66236c2f91a2d7938b978371c4791d1c0fb7f4cb
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rails_env_prompt (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
rake (10.5.0)
|
10
|
+
|
11
|
+
PLATFORMS
|
12
|
+
ruby
|
13
|
+
|
14
|
+
DEPENDENCIES
|
15
|
+
bundler (~> 1.16)
|
16
|
+
rails_env_prompt!
|
17
|
+
rake (~> 10.0)
|
18
|
+
|
19
|
+
BUNDLED WITH
|
20
|
+
1.16.2
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# RailsEnvPrompt
|
2
|
+
|
3
|
+
Adds current Rails env and Apartment tenant to prompt.
|
4
|
+
|
5
|
+
Before:
|
6
|
+
|
7
|
+
```
|
8
|
+
2.5.1 :001 >
|
9
|
+
```
|
10
|
+
|
11
|
+
After:
|
12
|
+
|
13
|
+
```
|
14
|
+
development/tenant-123 001:0>
|
15
|
+
```
|
16
|
+
|
17
|
+
The current tenant is only included if Apartment is available
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add this line to your application's Gemfile:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'rails_env_prompt'
|
25
|
+
```
|
26
|
+
|
27
|
+
And then execute:
|
28
|
+
|
29
|
+
$ bundle
|
30
|
+
|
31
|
+
Or install it yourself as:
|
32
|
+
|
33
|
+
$ gem install rails_env_prompt
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
None. Just include and go.
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rvanlieshout/rails_env_prompt.
|
data/Rakefile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rails_env_prompt/irb'
|
2
|
+
require 'rails_env_prompt/pry'
|
3
|
+
require 'rails_env_prompt/version'
|
4
|
+
|
5
|
+
module RailsEnvPrompt
|
6
|
+
def self.template
|
7
|
+
[
|
8
|
+
env_prompt,
|
9
|
+
tenant_prompt
|
10
|
+
].compact.join('/')
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.parse(string)
|
14
|
+
string.gsub('[ENV]', colored(Rails.env, environment_color))
|
15
|
+
.gsub('[TENANT]', defined?(Apartment) ? Apartment::Tenant.current : '')
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.to_s
|
19
|
+
parse(template)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.env_prompt
|
23
|
+
'[ENV]'
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.tenant_prompt
|
27
|
+
return unless defined?(Apartment)
|
28
|
+
|
29
|
+
'[TENANT]'
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.colored(text, color)
|
33
|
+
"\033[00;#{color}m#{text}\033[00m"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.environment_color
|
37
|
+
case Rails.env
|
38
|
+
when 'development' then 32 # green
|
39
|
+
when 'staging' then 33 # yellow
|
40
|
+
else 31 # red
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'irb'
|
2
|
+
|
3
|
+
module IRB
|
4
|
+
class << self
|
5
|
+
def setup_with_prompt_override(ap_path)
|
6
|
+
setup_without_prompt_override(ap_path)
|
7
|
+
|
8
|
+
prompt = RailsEnvPrompt.template
|
9
|
+
|
10
|
+
prompts = {
|
11
|
+
normal: "#{prompt} %03n:%i> ",
|
12
|
+
for_continuated_strings: "#{prompt} %03n:%i%l ",
|
13
|
+
for_continuated_statements: "#{prompt} %03n:%i* "
|
14
|
+
}
|
15
|
+
|
16
|
+
# Some older versions store this value and call dup. We'll have to change it each time to have it include current
|
17
|
+
# tenant and possible other dynamic variables
|
18
|
+
%i[normal for_continuated_strings for_continuated_statements].each do |key|
|
19
|
+
prompts[key] = prompts[key].tap do |string|
|
20
|
+
def string.dup
|
21
|
+
RailsEnvPrompt.parse(self)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
IRB.conf[:PROMPT][:RAILS_ENV_PROMPT] = {
|
27
|
+
PROMPT_I: prompts[:normal],
|
28
|
+
PROMPT_N: prompts[:normal],
|
29
|
+
PROMPT_S: prompts[:for_continuated_strings],
|
30
|
+
PROMPT_C: prompts[:for_continuated_statements],
|
31
|
+
RETURN: "=> %s\n"
|
32
|
+
}
|
33
|
+
|
34
|
+
IRB.conf[:PROMPT_MODE] = :RAILS_ENV_PROMPT
|
35
|
+
end
|
36
|
+
|
37
|
+
alias setup_without_prompt_override setup
|
38
|
+
alias setup setup_with_prompt_override
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'rails_env_prompt/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'rails_env_prompt'
|
7
|
+
spec.version = RailsEnvPrompt::VERSION
|
8
|
+
spec.authors = ['Rene van Lieshout']
|
9
|
+
spec.email = ['rene@lico.nl']
|
10
|
+
|
11
|
+
spec.summary = 'Adds current Rails env and Apartment tenant to prompt'
|
12
|
+
spec.description = 'Adds current Rails env and Apartment tenant to prompt'
|
13
|
+
spec.homepage = 'https://github.com/rvanlieshout/rails_env_prompt'
|
14
|
+
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
17
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
|
21
|
+
# spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_env_prompt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rene van Lieshout
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Adds current Rails env and Apartment tenant to prompt
|
42
|
+
email:
|
43
|
+
- rene@lico.nl
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/rails_env_prompt.rb
|
54
|
+
- lib/rails_env_prompt/irb.rb
|
55
|
+
- lib/rails_env_prompt/pry.rb
|
56
|
+
- lib/rails_env_prompt/version.rb
|
57
|
+
- rails_env_prompt.gemspec
|
58
|
+
homepage: https://github.com/rvanlieshout/rails_env_prompt
|
59
|
+
licenses: []
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.7.7
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Adds current Rails env and Apartment tenant to prompt
|
81
|
+
test_files: []
|