promptify 1.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 53701ed87b0fd869f1d4bd2b12f715f0312ed99546de442bdb423ab61458eeb5
4
+ data.tar.gz: 33496d3df683090dc57488eea8b03cef8be4d0ad5760d56915a7f00614f2d4b1
5
+ SHA512:
6
+ metadata.gz: 96f4475bd162f215711c72485759cc621dd29be5240b3d459da86eac2f32e099a4c23591ec375579dedc440ae2880588094bb6a3d46b4159cadb1947843a1ffa
7
+ data.tar.gz: 93c0858569e0372e2623f14ce707f6e9c5b9bef040be6bdceab6a0f2c4bee31275714b35001c7b40424c536ebcc7a05dab2833229876afd399cb28adaa1dc205
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in promptify.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,44 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ promptify (1.0.2)
5
+ pry
6
+ pry-rails
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ coderay (1.1.3)
12
+ diff-lcs (1.3)
13
+ method_source (1.0.0)
14
+ pry (0.13.1)
15
+ coderay (~> 1.1)
16
+ method_source (~> 1.0)
17
+ pry-rails (0.3.9)
18
+ pry (>= 0.10.4)
19
+ rake (12.3.3)
20
+ rspec (3.8.0)
21
+ rspec-core (~> 3.8.0)
22
+ rspec-expectations (~> 3.8.0)
23
+ rspec-mocks (~> 3.8.0)
24
+ rspec-core (3.8.2)
25
+ rspec-support (~> 3.8.0)
26
+ rspec-expectations (3.8.4)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.8.0)
29
+ rspec-mocks (3.8.1)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.8.0)
32
+ rspec-support (3.8.2)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ bundler
39
+ promptify!
40
+ rake (~> 12.3)
41
+ rspec (~> 3.0)
42
+
43
+ BUNDLED WITH
44
+ 2.2.4
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Promptify
2
+
3
+ Sets pry as the default Rails console on and prepend environment (i.e. `[app_name][STAGING]` or `[app_name][PRODUCTION]`) to the prompt.
4
+
5
+ As an example on a `PartnerMs` rails app:
6
+
7
+ ![Promptify example console](/assets/promptify-example.png)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'promptify'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install promptify
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/onboardiq/promptify.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
Binary file
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "promptify"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/promptify.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "promptify/version"
2
+ require "promptify/railtie" if defined?(Rails)
@@ -0,0 +1,71 @@
1
+ require "pry-rails"
2
+
3
+ module Promptify
4
+ class Railtie < Rails::Railtie
5
+ initializer "promptify.initialize" do |app|
6
+ Pry.config.should_load_plugins = false
7
+
8
+ Pry.config.prompt_name = app_name
9
+
10
+ show_pretty_prompt
11
+ end
12
+
13
+ private
14
+
15
+ def show_pretty_prompt
16
+ old_prompt = Pry.config.prompt
17
+
18
+ if Pry::VERSION >= "0.13.0"
19
+ return Pry::Prompt[:promptify] if Pry::Prompt[:promptify]
20
+
21
+ Pry.prompt = Pry::Prompt.new(
22
+ :promptify,
23
+ "Simple Rails console enhancements",
24
+ new_prompt,
25
+ )
26
+ else
27
+ Pry.config.prompt = new_prompt
28
+ end
29
+ end
30
+
31
+ def app_name
32
+ # ActiveSupport's `Module#parent_name` is deprecated in 6.1+.
33
+ if Rails.application.class.respond_to?(:module_parent_name)
34
+ Rails.application.class.module_parent_name.underscore.dasherize
35
+ else
36
+ Rails.application.class.parent_name.underscore.dasherize
37
+ end
38
+ end
39
+
40
+ def heroku_app
41
+ return unless ENV["HEROKU_APP_NAME"]
42
+
43
+ "[#{Pry::Helpers::Text.cyan(ENV['HEROKU_APP_NAME'])}]"
44
+ end
45
+
46
+ def new_prompt
47
+ [
48
+ proc { |*a| "[#{app_name}]#{heroku_app}[#{environment}]> " },
49
+ proc { |*a| "[#{app_name}]#{heroku_app}[#{environment}]> " },
50
+ ]
51
+ end
52
+
53
+ def environment
54
+ # Distinguish "preview" apps from production/staging apps.
55
+ if Rails.application.config.try(:preview_app)
56
+ Pry::Helpers::Text.yellow("PREVIEW")
57
+ elsif Rails.env.staging?
58
+ Pry::Helpers::Text.yellow(Rails.env.upcase)
59
+ elsif Rails.env.production?
60
+ Pry::Helpers::Text.red(Rails.env.upcase)
61
+ elsif Rails.env.development?
62
+ # "DEVELOPMENT" was too long to always display locally.
63
+ Pry::Helpers::Text.white("DEV")
64
+ else
65
+ # Test, etc.
66
+ Pry::Helpers::Text.white(Rails.env.upcase)
67
+ end
68
+ end
69
+ end
70
+ end
71
+
@@ -0,0 +1,3 @@
1
+ module Promptify
2
+ VERSION = "1.0.2"
3
+ end
data/promptify.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "promptify/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "promptify"
7
+ spec.version = Promptify::VERSION
8
+ spec.authors = ["Joey Cody"]
9
+ spec.email = ["joey@fountain.com"]
10
+
11
+ spec.summary = "Colorize staging/production rails console prompts with environment details"
12
+ spec.homepage = "https://github.com/onboardiq/promptify"
13
+ spec.license = "MIT"
14
+
15
+ spec.metadata = {
16
+ "bug_tracker_uri" => "https://github.com/onboardiq/promptify/issues",
17
+ "changelog_uri" => "https://github.com/onboardiq/promptify",
18
+ "documentation_uri" => "https://github.com/onboardiq/promptify",
19
+ "homepage_uri" => "https://github.com/onboardiq/promptify",
20
+ "source_code_uri" => "https://github.com/onboardiq/promptify",
21
+ }
22
+
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+ spec.required_ruby_version = ">= 2.0.0"
30
+
31
+ spec.add_dependency "pry"
32
+ spec.add_dependency "pry-rails"
33
+
34
+ spec.add_development_dependency "bundler"
35
+ spec.add_development_dependency "rake", "~> 12.3"
36
+ spec.add_development_dependency "rspec", "~> 3.0"
37
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: promptify
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Joey Cody
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-05-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '12.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '12.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description:
84
+ email:
85
+ - joey@fountain.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - README.md
95
+ - Rakefile
96
+ - assets/promptify-example.png
97
+ - bin/console
98
+ - bin/setup
99
+ - lib/promptify.rb
100
+ - lib/promptify/railtie.rb
101
+ - lib/promptify/version.rb
102
+ - promptify.gemspec
103
+ homepage: https://github.com/onboardiq/promptify
104
+ licenses:
105
+ - MIT
106
+ metadata:
107
+ bug_tracker_uri: https://github.com/onboardiq/promptify/issues
108
+ changelog_uri: https://github.com/onboardiq/promptify
109
+ documentation_uri: https://github.com/onboardiq/promptify
110
+ homepage_uri: https://github.com/onboardiq/promptify
111
+ source_code_uri: https://github.com/onboardiq/promptify
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 2.0.0
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubygems_version: 3.1.4
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Colorize staging/production rails console prompts with environment details
131
+ test_files: []