passages 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/Gemfile.lock +19 -2
- data/app/controllers/passages/routes_controller.rb +10 -4
- data/config/config.rb +3 -1
- data/config/initializers/basic_auth.rb +2 -0
- data/lib/passages/engine.rb +14 -3
- data/lib/passages/engine_route.rb +1 -0
- data/lib/passages/engine_route_collection.rb +4 -2
- data/lib/passages/mount_route.rb +2 -0
- data/lib/passages/route.rb +14 -9
- data/lib/passages/route_collection.rb +4 -2
- data/lib/passages.rb +1 -0
- data/passages.gemspec +7 -3
- data/spec/config/config_spec.rb +4 -4
- data/spec/config/initializers/basic_auth_spec.rb +6 -2
- data/spec/controllers/passages/routes_controller_spec.rb +4 -2
- data/spec/lib/passages/engine_route_collection_spec.rb +16 -6
- data/spec/lib/passages/mount_route_spec.rb +2 -2
- data/spec/lib/passages/route_collection_spec.rb +4 -2
- data/spec/lib/passages/route_spec.rb +3 -1
- data/version.rb +1 -1
- metadata +21 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67624b8b5e3463b0f208b14a7b83b07e2bec4ce8
|
4
|
+
data.tar.gz: 9b5f496d76095f08336886d7eee03ac48604e5f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ac021c052780b84ba0139bdd6043a875b98396d855f411c224d31309b0469cdd2895930ac6705582322e614cf8c94404d5921139e3ed2c0db509c92b017172a
|
7
|
+
data.tar.gz: cc6056f8aadc10df93ec9b52f55194707e9063b57532566fe5b815be41b60dfe9abda08792ca7edc23ae7ad69fe22c87e30c7e8dd97627ae93771668fbb00c39
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
passages (1.
|
4
|
+
passages (1.4.0)
|
5
5
|
rails (~> 4.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -43,6 +43,7 @@ GEM
|
|
43
43
|
thread_safe (~> 0.3, >= 0.3.4)
|
44
44
|
tzinfo (~> 1.1)
|
45
45
|
arel (6.0.3)
|
46
|
+
ast (2.2.0)
|
46
47
|
builder (3.2.2)
|
47
48
|
diff-lcs (1.2.5)
|
48
49
|
erubis (2.7.0)
|
@@ -56,9 +57,12 @@ GEM
|
|
56
57
|
mime-types (>= 1.16, < 3)
|
57
58
|
mime-types (2.6.2)
|
58
59
|
mini_portile (0.6.2)
|
59
|
-
minitest (5.8.
|
60
|
+
minitest (5.8.3)
|
60
61
|
nokogiri (1.6.6.2)
|
61
62
|
mini_portile (~> 0.6.0)
|
63
|
+
parser (2.3.0.7)
|
64
|
+
ast (~> 2.2)
|
65
|
+
powerpack (0.1.1)
|
62
66
|
rack (1.6.4)
|
63
67
|
rack-test (0.6.3)
|
64
68
|
rack (>= 1.0)
|
@@ -86,6 +90,7 @@ GEM
|
|
86
90
|
activesupport (= 4.2.4)
|
87
91
|
rake (>= 0.8.7)
|
88
92
|
thor (>= 0.18.1, < 2.0)
|
93
|
+
rainbow (2.1.0)
|
89
94
|
rake (10.4.2)
|
90
95
|
rspec (3.3.0)
|
91
96
|
rspec-core (~> 3.3.0)
|
@@ -100,6 +105,13 @@ GEM
|
|
100
105
|
diff-lcs (>= 1.2.0, < 2.0)
|
101
106
|
rspec-support (~> 3.3.0)
|
102
107
|
rspec-support (3.3.0)
|
108
|
+
rubocop (0.39.0)
|
109
|
+
parser (>= 2.3.0.7, < 3.0)
|
110
|
+
powerpack (~> 0.1)
|
111
|
+
rainbow (>= 1.99.1, < 3.0)
|
112
|
+
ruby-progressbar (~> 1.7)
|
113
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
114
|
+
ruby-progressbar (1.7.5)
|
103
115
|
sprockets (3.3.5)
|
104
116
|
rack (> 1, < 3)
|
105
117
|
sprockets-rails (2.3.3)
|
@@ -110,6 +122,7 @@ GEM
|
|
110
122
|
thread_safe (0.3.5)
|
111
123
|
tzinfo (1.2.2)
|
112
124
|
thread_safe (~> 0.1)
|
125
|
+
unicode-display_width (1.0.2)
|
113
126
|
|
114
127
|
PLATFORMS
|
115
128
|
ruby
|
@@ -117,3 +130,7 @@ PLATFORMS
|
|
117
130
|
DEPENDENCIES
|
118
131
|
passages!
|
119
132
|
rspec (~> 3.2)
|
133
|
+
rubocop (= 0.39.0)
|
134
|
+
|
135
|
+
BUNDLED WITH
|
136
|
+
1.11.2
|
@@ -5,6 +5,8 @@ require 'passages/route_collection'
|
|
5
5
|
require 'passages/engine_route_collection'
|
6
6
|
|
7
7
|
module Passages
|
8
|
+
# Single Rails controller responsible for
|
9
|
+
# collecting instance variables and rendering the Engine's main page
|
8
10
|
class RoutesController < ActionController::Base
|
9
11
|
layout false
|
10
12
|
|
@@ -28,20 +30,24 @@ module Passages
|
|
28
30
|
|
29
31
|
def mounted_engine_routes
|
30
32
|
@mounted_engine_routes ||= ::Rails::Engine.subclasses.map do |engine|
|
31
|
-
routes = engine.routes.routes.routes.map
|
33
|
+
routes = engine.routes.routes.routes.map do |route|
|
34
|
+
EngineRoute.new(route, engine.name)
|
35
|
+
end
|
32
36
|
|
33
37
|
{ engine: engine.name, routes: routes }
|
34
38
|
end.compact
|
35
39
|
end
|
36
40
|
|
37
41
|
def passages_rails_routes
|
38
|
-
@passages_rails_routes ||= Rails.application.routes.routes.map
|
42
|
+
@passages_rails_routes ||= Rails.application.routes.routes.map do |route|
|
43
|
+
Route.from_raw_route(route)
|
44
|
+
end
|
39
45
|
end
|
40
46
|
|
41
47
|
def mount_routes
|
42
|
-
{}.tap do |
|
48
|
+
{}.tap do |mount_route_hash|
|
43
49
|
passages_rails_routes.each do |route|
|
44
|
-
|
50
|
+
mount_route_hash[route.engine_name] = route if route.is_a?(MountRoute)
|
45
51
|
end
|
46
52
|
end
|
47
53
|
end
|
data/config/config.rb
CHANGED
data/lib/passages/engine.rb
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
module Passages
|
2
|
+
# Engine class, subclass of Rails::Engine and the heart of
|
3
|
+
# namespace isolation, asset precompiliation hooks and
|
4
|
+
# authentication concerns.
|
2
5
|
class Engine < ::Rails::Engine
|
3
6
|
isolate_namespace Passages
|
4
7
|
|
5
|
-
|
8
|
+
# Necessary for rake assets:precompile in a main application
|
9
|
+
# to compile this Engine's assets as well
|
10
|
+
initializer 'passages.assets.precompile' do |app|
|
6
11
|
app.config.assets.precompile += %w(application.css application.js)
|
7
12
|
end
|
8
13
|
|
9
|
-
|
14
|
+
# Optionally mount the /passages route at an applications top
|
15
|
+
# level.
|
16
|
+
#
|
17
|
+
# Optionally allow basic authentication
|
18
|
+
initializer 'passages', after: :load_config_initializers do
|
10
19
|
if Passages.config.automount
|
11
20
|
Rails.application.routes.prepend do
|
12
21
|
mount Passages::Engine, at: '/passages'
|
@@ -14,7 +23,9 @@ module Passages
|
|
14
23
|
end
|
15
24
|
|
16
25
|
unless Passages.config.no_auth?
|
17
|
-
Passages::RoutesController.http_basic_authenticate_with
|
26
|
+
Passages::RoutesController.http_basic_authenticate_with(
|
27
|
+
name: Passages.username,
|
28
|
+
password: Passages.password)
|
18
29
|
end
|
19
30
|
end
|
20
31
|
end
|
@@ -2,9 +2,11 @@ require_relative 'route'
|
|
2
2
|
require_relative 'route_collection'
|
3
3
|
|
4
4
|
module Passages
|
5
|
+
# Specialized collection class inherited from RouteCollection specifically
|
6
|
+
# for routes of Engines (this Engine included)
|
5
7
|
class EngineRouteCollection < RouteCollection
|
6
|
-
def initialize(
|
7
|
-
@routes =
|
8
|
+
def initialize(routes)
|
9
|
+
@routes = routes.reject { |h| h[:routes].all?(&:internal?) }
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
data/lib/passages/mount_route.rb
CHANGED
data/lib/passages/route.rb
CHANGED
@@ -3,15 +3,16 @@ require 'action_dispatch/routing/inspector'
|
|
3
3
|
require_relative 'mount_route'
|
4
4
|
|
5
5
|
module Passages
|
6
|
+
# Main DelegateClass used for decoration and discerning if a route is
|
7
|
+
# a "regular" route or a mount route
|
6
8
|
class Route < DelegateClass(ActionDispatch::Routing::RouteWrapper)
|
7
|
-
|
8
9
|
def initialize(route)
|
9
10
|
super(ActionDispatch::Routing::RouteWrapper.new(route))
|
10
11
|
end
|
11
12
|
|
12
13
|
class << self
|
13
14
|
def attributes_for_display
|
14
|
-
%w
|
15
|
+
%w(name verb controller action path)
|
15
16
|
end
|
16
17
|
|
17
18
|
def from_raw_route(raw_route)
|
@@ -29,16 +30,20 @@ module Passages
|
|
29
30
|
def mount_route_class(route)
|
30
31
|
route_app = route.app
|
31
32
|
|
32
|
-
app
|
33
|
-
route_app
|
34
|
-
else
|
35
|
-
route_app.try(:app)
|
36
|
-
end
|
37
|
-
|
38
|
-
app if app.ancestors.include?(Rails::Engine)
|
33
|
+
app(route_app) if app(route_app).ancestors.include?(Rails::Engine)
|
39
34
|
rescue
|
40
35
|
nil
|
41
36
|
end
|
37
|
+
|
38
|
+
def app(route_app)
|
39
|
+
@app ||= begin
|
40
|
+
if route_app.class == Class
|
41
|
+
route_app
|
42
|
+
else
|
43
|
+
route_app.try(:app)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
42
47
|
end
|
43
48
|
end
|
44
49
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
require_relative 'route'
|
2
2
|
|
3
3
|
module Passages
|
4
|
+
# Enumerable to iterate through and select only external routes
|
5
|
+
# for the main application to display
|
4
6
|
class RouteCollection
|
5
7
|
include Enumerable
|
6
8
|
|
7
9
|
attr_reader :routes
|
8
10
|
|
9
|
-
def initialize(
|
10
|
-
@routes =
|
11
|
+
def initialize(routes)
|
12
|
+
@routes = routes.reject(&:internal?)
|
11
13
|
end
|
12
14
|
|
13
15
|
def each(&block)
|
data/lib/passages.rb
CHANGED
data/passages.gemspec
CHANGED
@@ -6,8 +6,11 @@ require './version'
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = 'passages'
|
8
8
|
s.version = Passages::VERSION
|
9
|
-
s.summary =
|
10
|
-
s.description =
|
9
|
+
s.summary = 'Display and search capabilities for Ruby on Rails routes'
|
10
|
+
s.description = 'Rails Engine to make internal routes searchable and
|
11
|
+
discoverable for more than just the name of the route.
|
12
|
+
All aspects of a route are searchable from the HTTP
|
13
|
+
verb to the paramters a route supports.'
|
11
14
|
s.authors = ['Jake Yesbeck']
|
12
15
|
s.email = 'yesbeckjs@gmail.com'
|
13
16
|
s.homepage = 'https://github.com/yez/passages'
|
@@ -15,10 +18,11 @@ Gem::Specification.new do |s|
|
|
15
18
|
|
16
19
|
s.require_paths = %w(lib app)
|
17
20
|
s.files = `git ls-files`.split("\n")
|
18
|
-
s.test_files = s.files.grep(
|
21
|
+
s.test_files = s.files.grep(%r{^spec/})
|
19
22
|
|
20
23
|
s.required_ruby_version = '>= 2.0.0'
|
21
24
|
s.add_dependency 'rails', '~> 4.0'
|
22
25
|
|
23
26
|
s.add_development_dependency 'rspec', '~> 3.2'
|
27
|
+
s.add_development_dependency 'rubocop', '0.39.0'
|
24
28
|
end
|
data/spec/config/config_spec.rb
CHANGED
@@ -3,18 +3,18 @@ require 'spec_helper'
|
|
3
3
|
module Passages
|
4
4
|
describe Config do
|
5
5
|
describe '#no_auth?' do
|
6
|
-
context '@
|
6
|
+
context '@no_auth is a truthy value' do
|
7
7
|
[true, 'yes', ['1'], { a: :b }].each do |value|
|
8
|
-
it "#{
|
8
|
+
it "#{value} returns true" do
|
9
9
|
Passages.config.no_auth = value
|
10
10
|
expect(Passages.config.no_auth?).to eq(true)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
context '@
|
15
|
+
context '@no_auth is a falsey value' do
|
16
16
|
[false, nil].each do |value|
|
17
|
-
it "#{
|
17
|
+
it "#{value} returns false" do
|
18
18
|
Passages.config.no_auth = value
|
19
19
|
expect(Passages.config.no_auth?).to eq(false)
|
20
20
|
end
|
@@ -16,7 +16,9 @@ describe Passages do
|
|
16
16
|
let(:upper_username) { 'THISISANUPPERUSERNAME' }
|
17
17
|
before do
|
18
18
|
allow(ENV).to receive(:[]).with('passages_username') { nil }
|
19
|
-
allow(ENV).to receive(:[]).with('PASSAGES_USERNAME')
|
19
|
+
allow(ENV).to receive(:[]).with('PASSAGES_USERNAME') do
|
20
|
+
upper_username
|
21
|
+
end
|
20
22
|
end
|
21
23
|
|
22
24
|
it 'uses the ENV var' do
|
@@ -47,7 +49,9 @@ describe Passages do
|
|
47
49
|
let(:upper_password) { 'THISISANUPPERPASSWORD' }
|
48
50
|
before do
|
49
51
|
allow(ENV).to receive(:[]).with('passages_password') { nil }
|
50
|
-
allow(ENV).to receive(:[]).with('PASSAGES_PASSWORD')
|
52
|
+
allow(ENV).to receive(:[]).with('PASSAGES_PASSWORD') do
|
53
|
+
upper_password
|
54
|
+
end
|
51
55
|
end
|
52
56
|
|
53
57
|
it 'uses the ENV var' do
|
@@ -7,7 +7,6 @@ require_relative '../../../app/controllers/passages/routes_controller'
|
|
7
7
|
|
8
8
|
module Passages
|
9
9
|
describe RoutesController do
|
10
|
-
|
11
10
|
describe '#routes' do
|
12
11
|
before do
|
13
12
|
allow(subject).to receive(:application_routes) { anything }
|
@@ -38,7 +37,10 @@ module Passages
|
|
38
37
|
|
39
38
|
describe '!#passages_rails_routes' do
|
40
39
|
it 'calls deep into the Rails routes' do
|
41
|
-
expect(Rails)
|
40
|
+
expect(Rails)
|
41
|
+
.to receive_message_chain(:application, :routes, :routes) do
|
42
|
+
[]
|
43
|
+
end
|
42
44
|
subject.send(:passages_rails_routes)
|
43
45
|
end
|
44
46
|
end
|
@@ -13,10 +13,14 @@ module Passages
|
|
13
13
|
allow(fake_route).to receive(:internal?) { false }
|
14
14
|
end
|
15
15
|
|
16
|
-
subject
|
16
|
+
subject do
|
17
|
+
described_class.new([{ engine: engine_name, routes: [fake_route] }])
|
18
|
+
end
|
17
19
|
|
18
20
|
it 'adds the engine name to each route' do
|
19
|
-
expect(subject.routes.
|
21
|
+
expect(subject.routes).to be_all do |route|
|
22
|
+
route[:engine] == engine_name
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
context 'all an engine\'s routes are internal' do
|
@@ -27,13 +31,19 @@ module Passages
|
|
27
31
|
end
|
28
32
|
|
29
33
|
context 'only some of an engine\'s routes are internal' do
|
30
|
-
|
31
|
-
|
32
|
-
|
34
|
+
subject do
|
35
|
+
described_class.new([{ engine: engine_name, routes: routes }])
|
36
|
+
end
|
37
|
+
let(:another_fake_route) do
|
38
|
+
instance_double(EngineRoute, internal?: false)
|
39
|
+
end
|
40
|
+
let(:routes) { [fake_route, another_fake_route] }
|
33
41
|
|
34
42
|
it 'adds the engine to the ivar' do
|
35
43
|
expect(subject.routes).to_not be_empty
|
36
|
-
expect(subject.routes.
|
44
|
+
expect(subject.routes).to be_all do |r|
|
45
|
+
r[:engine] == engine_name
|
46
|
+
end
|
37
47
|
expect(subject.routes.first[:routes]).to eq(routes)
|
38
48
|
end
|
39
49
|
end
|
@@ -6,7 +6,9 @@ module Passages
|
|
6
6
|
let(:fake_route) { instance_double(Passages::Route) }
|
7
7
|
|
8
8
|
before do
|
9
|
-
allow_any_instance_of(described_class).to receive(:main_app_name)
|
9
|
+
allow_any_instance_of(described_class).to receive(:main_app_name) do
|
10
|
+
'SomeGreatApp'
|
11
|
+
end
|
10
12
|
allow(fake_route).to receive(:internal?) { false }
|
11
13
|
end
|
12
14
|
|
@@ -34,7 +36,7 @@ module Passages
|
|
34
36
|
|
35
37
|
context 'internal and external routes exist' do
|
36
38
|
let(:another_fake_route) { instance_double(Passages::Route) }
|
37
|
-
subject { described_class.new([fake_route, another_fake_route])}
|
39
|
+
subject { described_class.new([fake_route, another_fake_route]) }
|
38
40
|
|
39
41
|
before do
|
40
42
|
allow(another_fake_route).to receive(:internal?) { false }
|
@@ -42,7 +42,9 @@ module Passages
|
|
42
42
|
|
43
43
|
describe '.from_raw_route' do
|
44
44
|
let(:raw_route) { anything }
|
45
|
-
before
|
45
|
+
before do
|
46
|
+
allow(described_class).to receive(:mount_route_class) { mount_class }
|
47
|
+
end
|
46
48
|
|
47
49
|
context 'mount class is present' do
|
48
50
|
let(:mount_class) { anything }
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: passages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Yesbeck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,9 +38,25 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.2'
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.39.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.39.0
|
55
|
+
description: |-
|
56
|
+
Rails Engine to make internal routes searchable and
|
57
|
+
discoverable for more than just the name of the route.
|
58
|
+
All aspects of a route are searchable from the HTTP
|
59
|
+
verb to the paramters a route supports.
|
44
60
|
email: yesbeckjs@gmail.com
|
45
61
|
executables: []
|
46
62
|
extensions: []
|