jefferies_tube 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/CHANGELOG.md +2 -1
- data/README.md +10 -0
- data/lib/jefferies_tube.rb +21 -1
- data/lib/jefferies_tube/custom_prompts.irbrc.rb +31 -0
- data/lib/jefferies_tube/railtie.rb +22 -1
- data/lib/jefferies_tube/version.rb +1 -1
- data/spec/configuration_spec.rb +22 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 62abf29481a5ecce36e8f8dbd660b81dbe2977de464ecc7cfc74f448c5f8ff2c
|
4
|
+
data.tar.gz: 9c42932c67cd2c0c83c5a98e6953218f75b50791446a524fc28f5d12a1f79cd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28f1ff3cf8753d02182acb2c49752aae9040a55ecc89e63826cdf9be4bd1df8eaed69fdd48156442377f34885447024a4077a8bf4183f351578d69fa2035f966
|
7
|
+
data.tar.gz: 55a53583bfdd56eb0447a06bc83a2e101f11ff32837a8fbd826c687f991ece7b2dcae4a7197774b6481f20be7d5810225ab08bfdc50f5982e8066a1f80d8fcb3
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3
|
1
|
+
2.6.3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -155,6 +155,16 @@ end
|
|
155
155
|
|
156
156
|
If you do this, don't forget to add `my.development.rb` to the gitignore file.
|
157
157
|
|
158
|
+
### Terminal colors
|
159
|
+
Changes the prompt color of your terminal. Shows Development environments in blue, Test in yellow, and Production in a scary red.
|
160
|
+
Defaults to using the Rails env and Rails app class name, but configuration can be done in a Rails initializer like:
|
161
|
+
```
|
162
|
+
JefferiesTube.configure do |config|
|
163
|
+
config.environment = 'production' # If you're using a nonstandard env name but want colors.
|
164
|
+
config.prompt_name = 'ShortName' #For a shorter prompt name if you have a long app
|
165
|
+
end
|
166
|
+
```
|
167
|
+
|
158
168
|
## Contributing
|
159
169
|
|
160
170
|
1. Fork it ( http://github.com/<my-github-username>/jefferies_tube/fork )
|
data/lib/jefferies_tube.rb
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
require 'jefferies_tube/version'
|
2
|
-
require 'jefferies_tube/engine'
|
2
|
+
require 'jefferies_tube/engine' if defined?(Rails)
|
3
3
|
|
4
4
|
module JefferiesTube
|
5
5
|
require 'jefferies_tube/railtie' if defined?(Rails)
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def configure
|
9
|
+
yield(configuration)
|
10
|
+
end
|
11
|
+
|
12
|
+
def configuration
|
13
|
+
@configuration ||= Configuration.new
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Configuration
|
18
|
+
attr_accessor :environment
|
19
|
+
attr_accessor :prompt_name
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
@environment = ::Rails.env.downcase || nil
|
23
|
+
@prompt_name = ::Rails.application.class.parent_name || nil
|
24
|
+
end
|
25
|
+
end
|
6
26
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
rails_env = JefferiesTube.configuration.environment
|
2
|
+
|
3
|
+
if rails_env
|
4
|
+
color = "\e[0m" #Default to white text on no background
|
5
|
+
current_app = JefferiesTube.configuration.prompt_name
|
6
|
+
|
7
|
+
# shorten some common long environment names
|
8
|
+
if ["development", "dev"].include? rails_env
|
9
|
+
rails_env = "dev"
|
10
|
+
color = "\e[0;37m\e[1;44m" #White on blue
|
11
|
+
elsif ["test", "qa", "staging"].include? rails_env
|
12
|
+
color = "\e[0;37m\e[1;43m" #White on yellow
|
13
|
+
elsif rails_env == "production"
|
14
|
+
rails_env = "prod"
|
15
|
+
color = "\e[0;37m\e[1;41m" #White on red
|
16
|
+
end
|
17
|
+
|
18
|
+
base = "#{color}#{current_app}(#{rails_env})\e[0m"
|
19
|
+
prompt = base + "> "
|
20
|
+
|
21
|
+
IRB.conf[:PROMPT][:RAILS_ENV] = {
|
22
|
+
:PROMPT_I => prompt,
|
23
|
+
:PROMPT_N => prompt,
|
24
|
+
:PROMPT_S => nil,
|
25
|
+
:PROMPT_C => base + ">* ",
|
26
|
+
:RETURN => "=> %s\n"
|
27
|
+
}
|
28
|
+
|
29
|
+
IRB.conf[:PROMPT_MODE] = :RAILS_ENV
|
30
|
+
|
31
|
+
end
|
@@ -2,11 +2,32 @@ require 'jefferies_tube'
|
|
2
2
|
require 'rails'
|
3
3
|
|
4
4
|
module JefferiesTube
|
5
|
+
|
5
6
|
class Railtie < ::Rails::Railtie
|
6
7
|
railtie_name :jefferies_tube
|
7
|
-
|
8
|
+
|
8
9
|
console do
|
9
10
|
ActiveRecord::Base.connection
|
11
|
+
unless defined? Pry
|
12
|
+
ARGV.push "-r", File.join(File.dirname(__FILE__),"custom_prompts.irbrc.rb")
|
13
|
+
end
|
14
|
+
|
15
|
+
if defined? Pry
|
16
|
+
Pry.config.prompt = proc {
|
17
|
+
current_app = JefferiesTube.configuration.prompt_name
|
18
|
+
rails_env = JefferiesTube.configuration.environment
|
19
|
+
|
20
|
+
# shorten some common long environment names
|
21
|
+
if rails_env == "development"
|
22
|
+
rails_env = "dev"
|
23
|
+
elsif rails_env == "production"
|
24
|
+
rails_env = "prod"
|
25
|
+
end
|
26
|
+
|
27
|
+
base = "#{current_app}(#{rails_env})"
|
28
|
+
prompt = base + "> "
|
29
|
+
}
|
30
|
+
end
|
10
31
|
end
|
11
32
|
|
12
33
|
config.after_initialize do |args|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../lib/jefferies_tube'
|
2
|
+
require 'rails'
|
3
|
+
|
4
|
+
|
5
|
+
RSpec.describe "Configuration" do
|
6
|
+
describe 'configuration' do
|
7
|
+
it 'allows the Environment name to be initialized' do
|
8
|
+
expect(JefferiesTube.configuration.environment).to_not be_nil
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'allows a custom environment name & prompt' do
|
12
|
+
JefferiesTube.configure do |config|
|
13
|
+
config.environment = 'production' # If you're using a nonstandard env name but want colors.
|
14
|
+
config.prompt_name = 'ShortName' #For a shorter prompt name if you have a long app
|
15
|
+
end
|
16
|
+
|
17
|
+
expect(JefferiesTube.configuration.environment).to eq("production")
|
18
|
+
expect(JefferiesTube.configuration.prompt_name).to eq("ShortName")
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jefferies_tube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Samson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/jefferies_tube/capistrano/rails.rb
|
143
143
|
- lib/jefferies_tube/capistrano/s3_assets.rb
|
144
144
|
- lib/jefferies_tube/capistrano/ssh.rb
|
145
|
+
- lib/jefferies_tube/custom_prompts.irbrc.rb
|
145
146
|
- lib/jefferies_tube/database_backup.rb
|
146
147
|
- lib/jefferies_tube/database_backup_adapter.rb
|
147
148
|
- lib/jefferies_tube/engine.rb
|
@@ -151,6 +152,7 @@ files:
|
|
151
152
|
- lib/jefferies_tube/test_backup_adapter.rb
|
152
153
|
- lib/jefferies_tube/version.rb
|
153
154
|
- lib/tasks/db.rake
|
155
|
+
- spec/configuration_spec.rb
|
154
156
|
- spec/database_backup_spec.rb
|
155
157
|
- spec/spec_helper.rb
|
156
158
|
homepage: https://github.com/tenforwardconsulting/jefferies_tube/
|
@@ -172,11 +174,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
174
|
- !ruby/object:Gem::Version
|
173
175
|
version: '0'
|
174
176
|
requirements: []
|
175
|
-
|
176
|
-
rubygems_version: 2.6.13
|
177
|
+
rubygems_version: 3.0.3
|
177
178
|
signing_key:
|
178
179
|
specification_version: 4
|
179
180
|
summary: Ten Forward Consulting useful tools.
|
180
181
|
test_files:
|
182
|
+
- spec/configuration_spec.rb
|
181
183
|
- spec/database_backup_spec.rb
|
182
184
|
- spec/spec_helper.rb
|