passages 1.0.0 → 1.1.0

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: 91ad2eb2bfd8de3cb90f430b52679748b6458249
4
- data.tar.gz: 2dc1db09ec74c6815f2d5b5b3c236d714b952ee5
3
+ metadata.gz: e97a75c881bbc4231d06586a70743f9aabe9e23b
4
+ data.tar.gz: 48147ce8dab999ba0b281aff172c5b1c12878118
5
5
  SHA512:
6
- metadata.gz: 4aab33a5ca1ade95fa46865311fd94d9f4bae52fb2079a3dbb78df90ad7a99879e0ba2edba6542fd92c2693b344f234acba823273734cc261253806319673989
7
- data.tar.gz: bd078de0461d8dd8367848ebd25a6fdcafd8c19f270282edcf693dd2c348a8563f9518aff855e6cfd6b1f64d3dfdd5a5c25423b8addedc2a0536fe673d84dc49
6
+ metadata.gz: d81bac070a968f9fed29694502dbbacb63c49118793981351c55b2d9e31675a6fdc49450818171fd9020d449a610b3bc645cc14389aa07a30de2bd5765322901
7
+ data.tar.gz: 9a29c7f74cc21601f974b51373766ed57f34cce3ce4387e5964d0570f154f908d77d058596d021ad287a485534b37997796079dcde5f569a2cd67820bb2f08a6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- passages (0.2.0)
4
+ passages (1.0.0)
5
5
  rails (~> 4.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -23,17 +23,45 @@ gem 'passages'
23
23
 
24
24
  `bundle install`
25
25
 
26
- The `Passages` engine will **prepend** a `/passages` route to the application's routes. This means that if a project's `routes.rb` specifically defines a `/passages` route, the `Passages` Engine will not overwrite that.
26
+ By default, the `Passages` Engine must be mounted in your `routes.rb` file.
27
27
 
28
- Visiting `/passages` will display a search box and list of all known routes in an application.
28
+ Example:
29
+
30
+ *routes.rb*
31
+
32
+ ```ruby
33
+ Rails.application.routes.draw do
34
+ mount Passages::Engine, at: '/passages'
35
+ end
36
+ ```
37
+
38
+ *Alternatively*, an initializer can be created that will allow the `Passages` Engine to mount itself.
39
+
40
+ Create a new file: `initializers/passages.rb` and add the following:
41
+
42
+ ```ruby
43
+ Passages.configure do |config|
44
+ config.automount = true
45
+ end
46
+ ```
47
+
48
+ With the Engine mounted at `/passages`, the rendered page will display a search box and list of all known routes within the application.
29
49
 
30
50
  ## Authorization
31
51
 
32
52
  Since there are no environment dependent checks, the `/passages` page uses configurable http basic authentication.
33
53
 
34
- Default username: **username**
54
+ To set a `username` and `password` in the `Passages` Engine, add an `ENV` variable for each value.
55
+
56
+ `ENV['passages_username']` should be the desired `username` and `ENV['passages_password']` should be the desired `password`
57
+
58
+ By default these values are:
59
+
60
+ username: **username**
61
+
62
+ password: **password**
35
63
 
36
- Default password: **password**
64
+ `ENV` variables can prefix a Ruby server command from the command line interface, set with a helper `.ENV` file for systems like `foreman` or set through a web interface on platforms like `heroku`.
37
65
 
38
66
  ## Contributing
39
67
 
data/config/config.rb ADDED
@@ -0,0 +1,15 @@
1
+ module Passages
2
+ class Config
3
+ attr_accessor :automount
4
+ end
5
+
6
+ def config
7
+ @config ||= Config.new
8
+ end
9
+
10
+ def configure
11
+ yield config
12
+ end
13
+
14
+ module_function :config, :configure
15
+ end
@@ -1,10 +1,10 @@
1
1
  module Passages
2
2
  def username
3
- ENV['passages_username'] || 'username'
3
+ ENV['passages_username'] || ENV['PASSAGES_USERNAME'] || 'username'
4
4
  end
5
5
 
6
6
  def password
7
- ENV['passages_password'] || 'password'
7
+ ENV['passages_password'] || ENV['PASSAGES_PASSWORD'] || 'password'
8
8
  end
9
9
 
10
10
  def no_auth=(no_auth)
@@ -1,10 +1,12 @@
1
1
  module Passages
2
2
  class Engine < ::Rails::Engine
3
- isolate_namespace Passages
3
+ isolate_namespace Passages
4
4
 
5
- initializer 'passages', before: :load_config_initializers do |app|
6
- Rails.application.routes.prepend do
7
- mount Passages::Engine, at: '/passages'
5
+ initializer 'passages', after: :load_config_initializers do |app|
6
+ if Passages.config.automount
7
+ Rails.application.routes.prepend do
8
+ mount Passages::Engine, at: '/passages'
9
+ end
8
10
  end
9
11
  end
10
12
  end
data/lib/passages.rb CHANGED
@@ -5,6 +5,7 @@ module Passages
5
5
  end
6
6
 
7
7
  require 'initializers/basic_auth'
8
+ require 'config'
8
9
 
9
10
  if defined? Rails
10
11
  require 'passages/engine'
@@ -11,6 +11,18 @@ describe Passages do
11
11
  it 'uses the ENV var' do
12
12
  expect(described_class.username).to eq(username)
13
13
  end
14
+
15
+ context 'uppercase' do
16
+ let(:upper_username) { 'THISISANUPPERUSERNAME' }
17
+ before do
18
+ allow(ENV).to receive(:[]).with('passages_username') { nil }
19
+ allow(ENV).to receive(:[]).with('PASSAGES_USERNAME') { upper_username }
20
+ end
21
+
22
+ it 'uses the ENV var' do
23
+ expect(described_class.username).to eq(upper_username)
24
+ end
25
+ end
14
26
  end
15
27
 
16
28
  context 'when the ENV variable is not set' do
@@ -30,6 +42,18 @@ describe Passages do
30
42
  it 'uses the ENV var' do
31
43
  expect(described_class.password).to eq(password)
32
44
  end
45
+
46
+ context 'uppercase' do
47
+ let(:upper_password) { 'THISISANUPPERPASSWORD' }
48
+ before do
49
+ allow(ENV).to receive(:[]).with('passages_password') { nil }
50
+ allow(ENV).to receive(:[]).with('PASSAGES_PASSWORD') { upper_password }
51
+ end
52
+
53
+ it 'uses the ENV var' do
54
+ expect(described_class.password).to eq(upper_password)
55
+ end
56
+ end
33
57
  end
34
58
 
35
59
  context 'when the ENV variable is not set' do
data/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Passages
2
2
  MAJOR = 1
3
- MINOR = 0
3
+ MINOR = 1
4
4
  TINY = 0
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join('.').freeze
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.0.0
4
+ version: 1.1.0
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-01-10 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -58,6 +58,7 @@ files:
58
58
  - app/views/passages/routes/_route.html.erb
59
59
  - app/views/passages/routes/_routes_header.html.erb
60
60
  - app/views/passages/routes/routes.html.erb
61
+ - config/config.rb
61
62
  - config/initializers/assets.rb
62
63
  - config/initializers/basic_auth.rb
63
64
  - config/routes.rb