pry-rails 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c671c16b7d08553c1f6fee102cf727ab242b85db
4
- data.tar.gz: 145bdfbb1201b49b634730007777505fd0b59d98
3
+ metadata.gz: c8fd6ae367ba116b763e2a8b73f7e344bf88d339
4
+ data.tar.gz: 386621db935531fa72a9283fcb7f088e9d279f2b
5
5
  SHA512:
6
- metadata.gz: 5bacc83f74d5977b4309f0d847ea54217faa19175d9151488d3e21194a83845bd5785513ef623e3b5264000fdd337507e639d0b00bc1446d99e08f727e5dd3f6
7
- data.tar.gz: 2cb4328f489e6ba818f9e5143770fde36b3f0c5996dc43f316fd6721c2546efb5c0d567fa4c62535a0b6b8d91faf8962e384f93157ec07c96fbb7bc693e9584b
6
+ metadata.gz: d71528bac8e319bd6878f7b182c2eb66499fcb9dc627f336a5cd224de963df5251fde703405d4e2aaf5e3ea4c02116225364f9d4c7ccd13ee5fe369f6fbe423e
7
+ data.tar.gz: b5af4a6bd4b96b9710c4acec78a8c5a65f193f936feb104198f0094371d2bff8649bf3aa47236dc83a7138104d9792a2305396e84e5f67fb42a334a4aaefda12
data/Readme.md CHANGED
@@ -6,6 +6,7 @@ This is a small gem which causes `rails console` to open [pry](http://pry.github
6
6
  # Prerequisites
7
7
 
8
8
  - A Rails >= 3.0 Application
9
+ - Ruby >= 1.9
9
10
 
10
11
  # Installation
11
12
 
@@ -75,6 +76,16 @@ $ DISABLE_PRY_RAILS=1 rails console
75
76
  irb(main):001:0>
76
77
  ```
77
78
 
79
+ ## Custom Rails prompt
80
+
81
+ If you want to include the current Rails environment and project name in the pry prompt, put the following lines in your project's `.pryrc`:
82
+
83
+ ```ruby
84
+ if defined?(PryRails::RAILS_PROMPT)
85
+ Pry.config.prompt = PryRails::RAILS_PROMPT
86
+ end
87
+ ```
88
+
78
89
  # Developing and Testing
79
90
 
80
91
  To generate Gemfiles for Rails 3.0, 3.1, 3.2, 4.0, 4.1, and 4.2, run `rake
@@ -90,4 +101,4 @@ appraisal:rails31`, `rake appraisal:rails32`, etc.
90
101
  # Alternative
91
102
 
92
103
  If you want to enable pry everywhere, make sure to check out
93
- [pry everywhere](http://lucapette.com/pry/pry-everywhere/).
104
+ [pry everywhere](http://lucapette.me/pry-everywhere/).
@@ -7,4 +7,5 @@ if defined?(Rails) && !ENV['DISABLE_PRY_RAILS']
7
7
  require 'pry-rails/railtie'
8
8
  require 'pry-rails/commands'
9
9
  require 'pry-rails/model_formatter'
10
+ require 'pry-rails/prompt'
10
11
  end
@@ -51,14 +51,14 @@ class PryRails::FindRoute < Pry::ClassCommand
51
51
  all_routes = routes.select(&block)
52
52
  if all_routes.any?
53
53
  grouped_routes = all_routes.group_by { |route| route.defaults[:controller] }
54
- result = grouped_routes.each_with_object("") do |(controller, routes), result|
55
- result << "Routes for " + text.bold(controller.to_s.camelize + "Controller") + "\n"
56
- result << "--\n"
54
+ result = grouped_routes.each_with_object("") do |(controller, routes), res|
55
+ res << "Routes for " + text.bold(controller.to_s.camelize + "Controller") + "\n"
56
+ res << "--\n"
57
57
  routes.each do |route|
58
58
  spec = route.path.is_a?(String) ? route.path : route.path.spec
59
- result << "#{route.defaults[:action]} #{text.bold(verb_for(route))} #{spec} #{route_helper(route.name)}" + "\n"
59
+ res << "#{route.defaults[:action]} #{text.bold(verb_for(route))} #{spec} #{route_helper(route.name)}" + "\n"
60
60
  end
61
- result << "\n"
61
+ res << "\n"
62
62
  end
63
63
  stagger_output result
64
64
  else
@@ -0,0 +1,41 @@
1
+ module PryRails
2
+ class Prompt
3
+ class << self
4
+ def formatted_env
5
+ if Rails.env.production?
6
+ bold_env = Pry::Helpers::Text.bold(Rails.env)
7
+ Pry::Helpers::Text.red(bold_env)
8
+ elsif Rails.env.development?
9
+ Pry::Helpers::Text.green(Rails.env)
10
+ else
11
+ Rails.env
12
+ end
13
+ end
14
+
15
+ def project_name
16
+ File.basename(Rails.root)
17
+ end
18
+ end
19
+ end
20
+
21
+ RAILS_PROMPT = [
22
+ proc do |target_self, nest_level, pry|
23
+ "[#{pry.input_array.size}] " \
24
+ "[#{Prompt.project_name}][#{Prompt.formatted_env}] " \
25
+ "#{Pry.config.prompt_name}(#{Pry.view_clip(target_self)})" \
26
+ "#{":#{nest_level}" unless nest_level.zero?}> "
27
+ end,
28
+ proc do |target_self, nest_level, pry|
29
+ "[#{pry.input_array.size}] " \
30
+ "[#{Prompt.project_name}][#{Prompt.formatted_env}] " \
31
+ "#{Pry.config.prompt_name}(#{Pry.view_clip(target_self)})" \
32
+ "#{":#{nest_level}" unless nest_level.zero?}* "
33
+ end
34
+ ]
35
+
36
+ Pry::Prompt::MAP["rails"] = {
37
+ value: RAILS_PROMPT,
38
+ description: "Includes the current Rails environment and project folder name.\n" \
39
+ "[1] [project_name][Rails.env] pry(main)>"
40
+ }
41
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module PryRails
4
- VERSION = "0.3.4"
4
+ VERSION = "0.3.5"
5
5
  end
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "https://github.com/rweng/pry-rails"
11
11
  s.summary = %q{Use Pry as your rails console}
12
12
  s.license = "MIT"
13
+ s.required_ruby_version = ">= 1.9.1"
13
14
  # s.description = %q{TODO: Write a gem description}
14
15
 
15
16
  # s.rubyforge_project = "pry-rails"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Wenglewski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-28 00:00:00.000000000 Z
11
+ date: 2017-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -82,6 +82,7 @@ files:
82
82
  - lib/pry-rails/commands/show_routes.rb
83
83
  - lib/pry-rails/console.rb
84
84
  - lib/pry-rails/model_formatter.rb
85
+ - lib/pry-rails/prompt.rb
85
86
  - lib/pry-rails/railtie.rb
86
87
  - lib/pry-rails/version.rb
87
88
  - pry-rails.gemspec
@@ -109,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
110
  requirements:
110
111
  - - ">="
111
112
  - !ruby/object:Gem::Version
112
- version: '0'
113
+ version: 1.9.1
113
114
  required_rubygems_version: !ruby/object:Gem::Requirement
114
115
  requirements:
115
116
  - - ">="
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  version: '0'
118
119
  requirements: []
119
120
  rubyforge_project:
120
- rubygems_version: 2.4.5
121
+ rubygems_version: 2.6.8
121
122
  signing_key:
122
123
  specification_version: 4
123
124
  summary: Use Pry as your rails console