amazing_rails_console 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9efcd64e44f76c93b63c3346247de965c12a1d85a2f959f9e729d89e86815d37
4
+ data.tar.gz: 446c933699dbe7f05ad63960cc1dbc13b60ab1f1953de83d41a30a1ee7a3a94f
5
+ SHA512:
6
+ metadata.gz: c1d124c616caf3149aa0b617ad9ae04452560ff3d9a2a15f1a11633e43912f19d65dce8d990776a8e3a1a48922c7c79065f2c4b7a7f86d5bf37d6b96539ed873
7
+ data.tar.gz: 5253e51adeeff75de1821e490ed17415ffb63cfcae62eb28c66637d7cb8bbe42c3d2d1f5234239c471c7acf5082ea144e03d71f7c84768d098beb88a3c672fb3
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
@@ -0,0 +1,40 @@
1
+ # CHANGELOG
2
+
3
+ ## v0.4.4
4
+
5
+ * Fix deprecation warning `Module#parent_name` in Rails 6.x
6
+
7
+ ## v0.4.3
8
+
9
+ * Fix my stupid mistake on v0.4.2: Require hirb-unicode-steakknife as hirb-unicode
10
+
11
+ ## v0.4.2 [DO NOT USE]
12
+
13
+ * Require hirb-unicode-steakknife as unicode-steakknife
14
+ * BUG: The require name was wrong
15
+
16
+ ## v0.4.1 [DO NOT USE]
17
+
18
+ * Replace `hirb-unicode` with `hirb-unicode-steakknife` in optional enhancement. (Run `rails generate amazing_rails_console:install` to install them)
19
+ * BUG: It doesn't require properly
20
+
21
+ ## v0.4.0
22
+
23
+ * Add `pry-byebug`, `pry-stack_explorer` and `hirb` back as optional enhancement. (Run `rails generate amazing_rails_console:install` to install them)
24
+
25
+ ## v0.3.0
26
+
27
+ * Remove `pry-byebug`, `pry-stack_explorer` and `hirb` dependency. Please add them into your application `Gemfile` if you still want to use.
28
+ * Remove color indicator from prompt.
29
+
30
+ ## v0.2.1
31
+
32
+ * No changes in functionality. Release for updating information on rubygems.org.
33
+
34
+ ## v0.2.0
35
+
36
+ * Remove Ruby 1.9 support.
37
+
38
+ ## v0.1.0
39
+
40
+ * First release.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in amazing_rails_console.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 by Bruce Li
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,70 @@
1
+ # Make Your Rails Console Amazing
2
+
3
+ This gem was inspired by [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 `amazing_rails_console` are:
6
+
7
+ * Less gem dependances (Only pry-rails and amazing_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 'amazing_rails_console'
17
+ ```
18
+
19
+ In terminal:
20
+
21
+ ``` sh
22
+ bundle
23
+ rails g amazing_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
+ ![](http://i.imgur.com/CKrJYqk.png)
40
+
41
+ ### Beautiful formatting with pry and amazing_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
+ ![](http://i.imgur.com/I1iV8n9.png)
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
+ ![](http://i.imgur.com/9z3XDSU.png)
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
+ ![](http://i.imgur.com/mJbC24h.png)
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -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 'amazing_rails_console/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "amazing_rails_console"
8
+ spec.version = AmazingRailsConsole::VERSION
9
+ spec.authors = ["Justin Butkowski"]
10
+ spec.email = ["jbutkowski@gmail.com"]
11
+
12
+ spec.summary = %q{Simple and useful rails console enhancements}
13
+ spec.description = %q{Enhance rails console by using amazing_print, pry and several pry plugins. And useful prompt tweaks. Makes rails console amazing by default. Forked from xunker/amazing_rails_console}
14
+ spec.homepage = "https://github.com/jbutkowski/amazing_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 "amazing_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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "amazing_rails_console"
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
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ require "amazing_rails_console/version"
2
+ if defined?(Rails)
3
+ require "amazing_rails_console/prompts"
4
+ require "amazing_rails_console/railtie"
5
+ end
@@ -0,0 +1,40 @@
1
+ require "pry-rails"
2
+
3
+ module AmazingRailsConsole
4
+ module Prompts
5
+ def self.choose_prompt_for_pry_version
6
+ old_prompt = Pry.config.prompt
7
+
8
+ Pry.config.prompt = if Pry::VERSION && (Gem::Version.new(Pry::VERSION) >= Gem::Version.new('0.13.0'))
9
+ post_pry_13_prompt(old_prompt)
10
+ else
11
+ pre_pry_13_prompt(old_prompt)
12
+ end
13
+ end
14
+
15
+ # Define a custom prompt using pre pry-0.13.0 syntax
16
+ def self.pre_pry_13_prompt(old_prompt)
17
+ [
18
+ proc { |*a| "#{Rails.env.classify} #{old_prompt.first.call(*a)}" },
19
+ proc { |*a| "#{Rails.env.classify} #{old_prompt.second.call(*a)}" }
20
+ ]
21
+ end
22
+
23
+ # Pry 0.13.0 introduces new syntax for registering a prompt.
24
+ # https://github.com/pry/pry/wiki/Customization-and-configuration#Config_prompt
25
+ def self.post_pry_13_prompt(old_prompt)
26
+ Pry::Prompt.new(
27
+ :amazing_rails_console, # name
28
+ "amazing_rails_console default prompt", # description
29
+ [
30
+ proc { |*a| # "main" prompt
31
+ "#{Rails.env.classify} #{old_prompt.wait_proc.call(*a)}"
32
+ },
33
+ proc { |*a| # "wait" prompt (multiline input continuation)
34
+ "#{Rails.env.classify} #{old_prompt.incomplete_proc.call(*a)}"
35
+ }
36
+ ]
37
+ )
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,37 @@
1
+ require "pry-rails"
2
+ require "amazing_print"
3
+
4
+ module AmazingRailsConsole
5
+ class Railtie < Rails::Railtie
6
+ initializer "amazing_rails_console.initialize" do |app|
7
+ disables_pry_plugin_loading
8
+ use_amazing_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_amazing_print_for_formatting
20
+ AmazingPrint.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
+ Prompts.choose_prompt_for_pry_version
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module AmazingRailsConsole
2
+ VERSION = "0.4.4"
3
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+ Install hirb, pry-byebug, pry-stack_explorer to make your rails console even more amazing
3
+
4
+ Example:
5
+ rails generate amazing_rails_console:install
@@ -0,0 +1,34 @@
1
+ require 'rails/generators/base'
2
+
3
+ class AmazingRailsConsole::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,4 @@
1
+ if Rails.env.development? || Rails.env.test?
2
+ # This introduces the `table` statement
3
+ extend Hirb::Console
4
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: amazing_rails_console
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.4
5
+ platform: ruby
6
+ authors:
7
+ - Justin Butkowski
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-12-30 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: amazing_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 amazing_print, pry and several pry plugins.
98
+ And useful prompt tweaks. Makes rails console amazing by default. Forked from xunker/amazing_rails_console
99
+ email:
100
+ - jbutkowski@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - CHANGELOG.md
109
+ - Gemfile
110
+ - LICENSE
111
+ - README.md
112
+ - Rakefile
113
+ - amazing_rails_console.gemspec
114
+ - bin/console
115
+ - bin/setup
116
+ - lib/amazing_rails_console.rb
117
+ - lib/amazing_rails_console/prompts.rb
118
+ - lib/amazing_rails_console/railtie.rb
119
+ - lib/amazing_rails_console/version.rb
120
+ - lib/generators/amazing_rails_console/install/USAGE
121
+ - lib/generators/amazing_rails_console/install/install_generator.rb
122
+ - lib/generators/amazing_rails_console/install/templates/.pryrc
123
+ homepage: https://github.com/jbutkowski/amazing_rails_console
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: 2.0.0
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubygems_version: 3.1.2
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Simple and useful rails console enhancements
146
+ test_files: []