pretty_rails_console 0.1.1
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 +9 -0
- data/.rpec +2 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +70 -0
- data/Rakefile +1 -0
- data/lib/generators/pretty_rails_console/install/USAGE +5 -0
- data/lib/generators/pretty_rails_console/install/install_generator.rb +34 -0
- data/lib/generators/pretty_rails_console/install/templates/.pryrc +4 -0
- data/lib/pretty_rails_console/railtie.rb +46 -0
- data/lib/pretty_rails_console/version.rb +3 -0
- data/lib/pretty_rails_console.rb +2 -0
- data/pretty_rails_console.gemspec +33 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 55492e44098377ca078fc95505c15fca9a1e665c702f65b3ab9cc854fb46cd1d
|
4
|
+
data.tar.gz: d974584b17ce38991500b99a9784292340fa81e7a7c32bb9de75cf2c58ecf754
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8291456ba27f2a9ca3cbaff7940c28840811614b67a35fb85a2b281b9a39fc4dbd6bcef8affdba6704b9ff443105c63f56f4746b52768529996b5841ec96fd5d
|
7
|
+
data.tar.gz: 19032e4364fb44d940c1fbb74bb231c4186c310c8949c8b5d3a2f7e1518cbfdcb9b57b329b26c094e3820c096bf258de6022a36a614430b025a965287f71699a
|
data/.gitignore
ADDED
data/.rpec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 haidar
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Make Your Rails Console Pretty
|
2
|
+
|
3
|
+
This gem was inspired by [awesome_rails_console](https://github.com/ascendbruce/awesome_rails_console), [Using pry in production](https://bugsnag.com/blog/production-pry), [jazz_hands](https://github.com/nixme/jazz_hands) and [jazz_fingers](https://github.com/plribeiro3000/jazz_fingers).
|
4
|
+
|
5
|
+
The pros of `pretty_rails_console` are:
|
6
|
+
|
7
|
+
- Less gem dependances (Only pry-rails and awesome_print other than rails. The rest are optional)
|
8
|
+
- Simpler prompt modification (Similar to the default prompt you're already familiar with)
|
9
|
+
- No need to worry about configuration (because there are not much options anyway)
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'pretty_rails_console'
|
17
|
+
```
|
18
|
+
|
19
|
+
In terminal:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
bundle
|
23
|
+
rails g pretty_rails_console:install # This will include dependency gems to the gemfile
|
24
|
+
# you should review your Gemfile at this point (and adjust if needed)
|
25
|
+
```
|
26
|
+
|
27
|
+
```sh
|
28
|
+
bundle
|
29
|
+
spring stop # to restart spring, if you are using it
|
30
|
+
rails c
|
31
|
+
```
|
32
|
+
|
33
|
+
## Features
|
34
|
+
|
35
|
+
### Show Rails env and project name in the prompt
|
36
|
+
|
37
|
+
Prevents you from accidentally changing production data to the wrong project.
|
38
|
+
|
39
|
+

|
40
|
+
|
41
|
+
### Beautiful formatting with pry and awesome_print
|
42
|
+
|
43
|
+
Make it easy to read. Reduce the pain while debugging.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
# Try following statements in rails console:
|
47
|
+
[:apple, :orange, :banana]
|
48
|
+
{ a: 1, b: 2, c: 3 }
|
49
|
+
1.methods
|
50
|
+
(1..100).to_a
|
51
|
+
ap (1..100).to_a, limit: 5
|
52
|
+
```
|
53
|
+
|
54
|
+

|
55
|
+
|
56
|
+
### Print table in console
|
57
|
+
|
58
|
+
With Hirb (optional enhancement)
|
59
|
+
|
60
|
+
Very handy when you need to paste some data into issue tracking system.
|
61
|
+
|
62
|
+

|
63
|
+
|
64
|
+
### Debugger
|
65
|
+
|
66
|
+
With pry-byebug (optional enhancement)
|
67
|
+
|
68
|
+
Insert `binding.pry` (break point) to start debugging. See [pry-byebug](https://github.com/deivid-rodriguez/pry-byebug) For detail.
|
69
|
+
|
70
|
+

|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
class PrettyRailsConsole::InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
def update_gemfile
|
7
|
+
gem_group :development, :test do
|
8
|
+
gem 'hirb'
|
9
|
+
gem 'hirb-unicode-steakknife', require: 'hirb-unicode'
|
10
|
+
gem 'pry-byebug'
|
11
|
+
gem 'pry-stack_explorer'
|
12
|
+
end
|
13
|
+
|
14
|
+
inject_into_file 'Gemfile', indication, before: gem_group_declaration
|
15
|
+
end
|
16
|
+
|
17
|
+
def write_to_pryrc_file
|
18
|
+
copy_file '.pryrc', '.pryrc'
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def indication
|
24
|
+
"# Please clean up duplicated gems if any.\n"\
|
25
|
+
"# Feel free to remove gems that you don't want to use or "\
|
26
|
+
"if they conflict with other gem dependencies. "\
|
27
|
+
"(you might need to update .pryrc also)\n"
|
28
|
+
end
|
29
|
+
|
30
|
+
def gem_group_declaration
|
31
|
+
"group :development, :test do\n"\
|
32
|
+
" gem 'hirb'\n"
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "pry-rails"
|
2
|
+
require "awesome_print"
|
3
|
+
|
4
|
+
module PrettyRailsConsole
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
initializer "pretty_rails_console.initialize" do |app|
|
7
|
+
disables_pry_plugin_loading
|
8
|
+
use_awesome_print_for_formatting
|
9
|
+
set_prompt_name_to_project_name
|
10
|
+
show_rails_env_name_before_prompt
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def disables_pry_plugin_loading
|
16
|
+
Pry.config.should_load_plugins = false
|
17
|
+
end
|
18
|
+
|
19
|
+
def use_awesome_print_for_formatting
|
20
|
+
AwesomePrint.pry!
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_prompt_name_to_project_name
|
24
|
+
# ref from https://github.com/rweng/pry-rails/blob/035d5c8203521f5eaac0001300152281c765df88/lib/pry-rails/prompt.rb
|
25
|
+
Pry.config.prompt_name =
|
26
|
+
if Rails::VERSION::MAJOR >= 6
|
27
|
+
Rails.application.class.module_parent_name.underscore
|
28
|
+
else
|
29
|
+
Rails.application.class.parent_name.underscore
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def show_rails_env_name_before_prompt
|
34
|
+
old_prompt = Pry::Prompt[:default]
|
35
|
+
|
36
|
+
Pry.config.prompt = Pry::Prompt.new(
|
37
|
+
"pretty",
|
38
|
+
"pretty rails console",
|
39
|
+
[
|
40
|
+
proc { |*a| "#{Rails.env.classify} #{old_prompt.wait_proc.call(*a)}" },
|
41
|
+
proc { |*a| "#{Rails.env.classify} #{old_prompt.incomplete_proc.call(*a)}" },
|
42
|
+
],
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pretty_rails_console/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pretty_rails_console"
|
8
|
+
spec.version = PrettyRailsConsole::VERSION
|
9
|
+
spec.authors = ["Haidar Pinulung"]
|
10
|
+
spec.email = ["haidarpinulung@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Simple and useful rails console enhancements}
|
13
|
+
spec.description = %q{Enhance rails console by using awesome_print, pry and several pry plugins. And useful prompt tweaks. Makes rails console pretty by default.}
|
14
|
+
spec.homepage = "https://github.com/9edang/pretty_rails_console"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.required_ruby_version = ">= 2.0.0"
|
22
|
+
spec.license = "MIT"
|
23
|
+
|
24
|
+
# Runtime dependencies
|
25
|
+
spec.add_dependency "railties"
|
26
|
+
spec.add_dependency "pry-rails"
|
27
|
+
spec.add_dependency "awesome_print"
|
28
|
+
|
29
|
+
# gem development dependency
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pretty_rails_console
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Haidar Pinulung
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
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: awesome_print
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.9'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.2'
|
97
|
+
description: Enhance rails console by using awesome_print, pry and several pry plugins.
|
98
|
+
And useful prompt tweaks. Makes rails console pretty by default.
|
99
|
+
email:
|
100
|
+
- haidarpinulung@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rpec"
|
107
|
+
- CHANGELOG.md
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- lib/generators/pretty_rails_console/install/USAGE
|
113
|
+
- lib/generators/pretty_rails_console/install/install_generator.rb
|
114
|
+
- lib/generators/pretty_rails_console/install/templates/.pryrc
|
115
|
+
- lib/pretty_rails_console.rb
|
116
|
+
- lib/pretty_rails_console/railtie.rb
|
117
|
+
- lib/pretty_rails_console/version.rb
|
118
|
+
- pretty_rails_console.gemspec
|
119
|
+
homepage: https://github.com/9edang/pretty_rails_console
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 2.0.0
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubygems_version: 3.2.3
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Simple and useful rails console enhancements
|
142
|
+
test_files: []
|