pry-rails 0.3.5 → 0.3.6
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 +4 -4
- data/Readme.md +1 -1
- data/lib/pry-rails/commands/show_routes.rb +15 -2
- data/lib/pry-rails/version.rb +1 -1
- data/pry-rails.gemspec +1 -1
- data/spec/show_model_spec.rb +1 -1
- data/spec/show_models_spec.rb +19 -5
- data/spec/show_routes_spec.rb +14 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 872ce478163eb40d95c6eeb4fe9e937e36b650b8
|
4
|
+
data.tar.gz: 24b1c4fba3bd4bb30c47e9a092d0df98c035b9f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65684708da223b83ae7a56a9cedb0c44249c2e791194831ea7b4d2d7e148e3cd38dd1f26d07938cf81b90be539cffb98ff4cd4641bb81c52e01481ca29218702
|
7
|
+
data.tar.gz: 329c7a447152cb95becaf837e3239b43698b449dcf67c9354d9d658f82e0e040697153f6595d0170cef186f1469694c7d77200dfe889ef0a5e57b81a6291b552
|
data/Readme.md
CHANGED
@@ -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",
|
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
|
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
|
data/lib/pry-rails/version.rb
CHANGED
data/pry-rails.gemspec
CHANGED
@@ -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.
|
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
|
data/spec/show_model_spec.rb
CHANGED
data/spec/show_models_spec.rb
CHANGED
@@ -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!
|
47
|
-
output.gsub!
|
48
|
-
|
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
|
data/spec/show_routes_spec.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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.
|
26
|
+
version: 0.10.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: appraisal
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|