pry-rails 0.3.5 → 0.3.6

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: c8fd6ae367ba116b763e2a8b73f7e344bf88d339
4
- data.tar.gz: 386621db935531fa72a9283fcb7f088e9d279f2b
3
+ metadata.gz: 872ce478163eb40d95c6eeb4fe9e937e36b650b8
4
+ data.tar.gz: 24b1c4fba3bd4bb30c47e9a092d0df98c035b9f8
5
5
  SHA512:
6
- metadata.gz: d71528bac8e319bd6878f7b182c2eb66499fcb9dc627f336a5cd224de963df5251fde703405d4e2aaf5e3ea4c02116225364f9d4c7ccd13ee5fe369f6fbe423e
7
- data.tar.gz: b5af4a6bd4b96b9710c4acec78a8c5a65f193f936feb104198f0094371d2bff8649bf3aa47236dc83a7138104d9792a2305396e84e5f67fb42a334a4aaefda12
6
+ metadata.gz: 65684708da223b83ae7a56a9cedb0c44249c2e791194831ea7b4d2d7e148e3cd38dd1f26d07938cf81b90be539cffb98ff4cd4641bb81c52e01481ca29218702
7
+ data.tar.gz: 329c7a447152cb95becaf837e3239b43698b449dcf67c9354d9d658f82e0e040697153f6595d0170cef186f1469694c7d77200dfe889ef0a5e57b81a6291b552
data/Readme.md CHANGED
@@ -101,4 +101,4 @@ appraisal:rails31`, `rake appraisal:rails32`, etc.
101
101
  # Alternative
102
102
 
103
103
  If you want to enable pry everywhere, make sure to check out
104
- [pry everywhere](http://lucapette.me/pry-everywhere/).
104
+ [pry everywhere](http://lucapette.me/pry-everywhere).
@@ -8,7 +8,9 @@ class PryRails::ShowRoutes < Pry::ClassCommand
8
8
  BANNER
9
9
 
10
10
  def options(opt)
11
- opt.on :G, "grep", "Filter output by regular expression", :argument => true
11
+ opt.on :G, "grep", "Filter output by regular expression",
12
+ :argument => true,
13
+ :as => Array
12
14
  end
13
15
 
14
16
  def process
@@ -24,7 +26,18 @@ class PryRails::ShowRoutes < Pry::ClassCommand
24
26
  process_rails_3_0_and_3_1(all_routes)
25
27
  end
26
28
 
27
- output.puts formatted.grep(Regexp.new(opts[:G] || ".")).join("\n")
29
+ output.puts grep_routes(formatted).join("\n")
30
+ end
31
+
32
+ # Takes an array of lines. Returns a list filtered by the conditions in
33
+ # `opts[:G]`.
34
+ def grep_routes(formatted)
35
+ return formatted unless opts[:G]
36
+ grep_opts = opts[:G]
37
+
38
+ grep_opts.reduce(formatted) do |lines, pattern|
39
+ lines.grep(Regexp.new(pattern))
40
+ end
28
41
  end
29
42
 
30
43
  # Cribbed from https://github.com/rails/rails/blob/3-1-stable/railties/lib/rails/tasks/routes.rake
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module PryRails
4
- VERSION = "0.3.5"
4
+ VERSION = "0.3.6"
5
5
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_dependency "pry", ">= 0.9.10"
23
+ s.add_dependency "pry", ">= 0.10.4"
24
24
  s.add_development_dependency "appraisal"
25
25
  s.add_development_dependency "minitest"
26
26
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe "show-models" do
5
+ describe "show-model" do
6
6
  it "should print one ActiveRecord model" do
7
7
  output = mock_pry('show-model Beer', 'exit-all')
8
8
 
@@ -42,13 +42,27 @@ Instrument
42
42
  embedded_in :artist
43
43
  MODELS
44
44
 
45
+ internal_models = <<MODELS
46
+ ActiveRecord::InternalMetadata
47
+ key: string
48
+ value: string
49
+ created_at: datetime
50
+ updated_at: datetime
51
+ MODELS
52
+
53
+ expected_output = ar_models
54
+
45
55
  if defined?(Mongoid)
46
- output.gsub! /^ *_type: String\n/, '' # mongoid 3.0 and 3.1 differ on this
47
- output.gsub! /Moped::BSON/, 'BSON' # mongoid 3 and 4 differ on this
48
- output.must_equal [ar_models, mongoid_models].join
49
- else
50
- output.must_equal ar_models
56
+ output.gsub!(/^ *_type: String\n/, '') # mongoid 3.0 and 3.1 differ on this
57
+ output.gsub!(/Moped::BSON/, 'BSON') # mongoid 3 and 4 differ on this
58
+ expected_output += mongoid_models
51
59
  end
60
+
61
+ if Rails.version.to_s =~ /^5/
62
+ expected_output = internal_models + expected_output
63
+ end
64
+
65
+ output.must_equal expected_output
52
66
  end
53
67
 
54
68
  it "should highlight the given phrase with --grep" do
@@ -12,4 +12,18 @@ describe "show-routes" do
12
12
 
13
13
  output.must_match %r{^edit_pokemon GET /pokemon/edit}
14
14
  end
15
+
16
+ it "should print a list of routes which include grep option" do
17
+ output = mock_pry('show-routes -G edit', 'exit-all')
18
+
19
+ output.must_match %r{^edit_pokemon GET /pokemon/edit}
20
+ output.must_match %r{^ edit_beer GET /beer/edit}
21
+ end
22
+
23
+ it "should filter list based on multiple grep options" do
24
+ output = mock_pry('show-routes -G edit -G pokemon', 'exit-all')
25
+
26
+ output.must_match %r{^edit_pokemon GET /pokemon/edit}
27
+ output.wont_match %r{edit_beer}
28
+ end
15
29
  end
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.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Wenglewski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-14 00:00:00.000000000 Z
11
+ date: 2017-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.10
19
+ version: 0.10.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.9.10
26
+ version: 0.10.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: appraisal
29
29
  requirement: !ruby/object:Gem::Requirement