rack-console 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rack/console.rb +22 -12
- data/lib/rack/console/methods.rb +2 -2
- data/lib/rack/console/version.rb +1 -1
- data/spec/rack/console/methods_spec.rb +22 -0
- data/spec/rack/console_spec.rb +20 -0
- data/spec/spec_helper.rb +3 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecc34ea943b04d2e308b3dbf8f3d29982a5fd99d
|
4
|
+
data.tar.gz: 133380b564caefea4356f257f263fe571663147f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a40df50a204f705d51b6772b48817761d34d120267628a60316e79c5e2b393331881ec3a05777492e449c23f5604f999f50af9a3f82df78c1446bd7114c2be92
|
7
|
+
data.tar.gz: 0cde9f6e9de162190b312827d2f0ddb967531a3bb816c10a4fe4aa4097c67fedd43e02a6bc718a37499d013a5913ce15d06ebeba7bd15504967cc8841f2189a5
|
data/lib/rack/console.rb
CHANGED
@@ -10,24 +10,18 @@ module Rack
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def initialize(options = {})
|
13
|
-
@options =
|
13
|
+
@options = default_options.merge(options)
|
14
14
|
|
15
|
-
ENV['RACK_ENV'] = @options[:environment]
|
16
|
-
|
15
|
+
ENV['RACK_ENV'] = @options[:environment]
|
16
|
+
set_preamble
|
17
17
|
|
18
|
-
if
|
19
|
-
$LOAD_PATH.unshift(*includes)
|
20
|
-
end
|
18
|
+
$LOAD_PATH.unshift(*@options[:include]) if @options[:include]
|
21
19
|
|
22
|
-
|
23
|
-
require library
|
24
|
-
end
|
20
|
+
require @options[:require] if @options[:require]
|
25
21
|
end
|
26
22
|
|
27
23
|
def start
|
28
|
-
|
29
|
-
puts ENV['RACK_CONSOLE_PREAMBLE']
|
30
|
-
end
|
24
|
+
puts ENV['RACK_CONSOLE_INTRO'] unless ENV['IGNORE_RACK_CONSOLE_INTRO']
|
31
25
|
|
32
26
|
app = Rack::Builder.parse_file(@options[:config]).first
|
33
27
|
|
@@ -49,5 +43,21 @@ module Rack
|
|
49
43
|
def main
|
50
44
|
TOPLEVEL_BINDING.eval('self')
|
51
45
|
end
|
46
|
+
|
47
|
+
def set_preamble
|
48
|
+
return if ENV['RACK_CONSOLE_INTRO']
|
49
|
+
|
50
|
+
loading = "Loading #{ENV['RACK_ENV']} environment"
|
51
|
+
version = "(Rack::Console #{Rack::Console::VERSION})"
|
52
|
+
|
53
|
+
ENV['RACK_CONSOLE_INTRO'] = "#{loading} #{version}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def default_options
|
57
|
+
{
|
58
|
+
config: 'config.ru',
|
59
|
+
environment: ENV['RACK_ENV'] || 'development'
|
60
|
+
}
|
61
|
+
end
|
52
62
|
end
|
53
63
|
end
|
data/lib/rack/console/methods.rb
CHANGED
data/lib/rack/console/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rack/console/methods'
|
2
|
+
|
3
|
+
describe Rack::Console::Methods do
|
4
|
+
let(:session) { Object.new }
|
5
|
+
|
6
|
+
before { session.send :extend, Rack::Console::Methods }
|
7
|
+
|
8
|
+
describe 'reload!' do
|
9
|
+
it 're-executes the running process' do
|
10
|
+
expect(Kernel).to receive(:exec).with(/bin\/rspec$/)
|
11
|
+
|
12
|
+
session.reload!
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'app' do
|
17
|
+
before { session.instance_variable_set(:@app, 'app') }
|
18
|
+
subject { session.app }
|
19
|
+
|
20
|
+
it { is_expected.to eq('app') }
|
21
|
+
end
|
22
|
+
end
|
data/spec/rack/console_spec.rb
CHANGED
@@ -42,7 +42,27 @@ describe Rack::Console do
|
|
42
42
|
expect(ENV['RACK_ENV']).to eq('production')
|
43
43
|
end
|
44
44
|
|
45
|
+
describe 'preamble message' do
|
46
|
+
it 'defaults to a loading message' do
|
47
|
+
preamble = "Loading #{ENV['RACK_ENV']} environment (Rack::Console #{Rack::Console::VERSION})"
|
48
|
+
|
49
|
+
Rack::Console.new.start
|
50
|
+
expect(ENV['RACK_CONSOLE_INTRO']).to eq(preamble)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'does not override a preamble if one has already been set' do
|
54
|
+
ENV['RACK_CONSOLE_INTRO'] = 'Hello, Rack::Console!'
|
55
|
+
|
56
|
+
expect { Rack::Console.new.start }.not_to change { ENV['RACK_CONSOLE_INTRO'] }
|
57
|
+
|
58
|
+
ENV['RACK_CONSOLE_INTRO'] = nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
45
62
|
after do
|
46
63
|
Dir.chdir @old_pwd
|
64
|
+
|
65
|
+
ENV['RACK_ENV'] = 'test'
|
66
|
+
ENV['RACK_CONSOLE_INTRO'] = nil
|
47
67
|
end
|
48
68
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/rack/console/methods.rb
|
72
72
|
- lib/rack/console/session.rb
|
73
73
|
- lib/rack/console/version.rb
|
74
|
+
- spec/rack/console/methods_spec.rb
|
74
75
|
- spec/rack/console_spec.rb
|
75
76
|
- spec/spec_helper.rb
|
76
77
|
homepage: https://github.com/davidcelis/rack-console
|
@@ -93,11 +94,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
94
|
version: '0'
|
94
95
|
requirements: []
|
95
96
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.2.2
|
97
98
|
signing_key:
|
98
99
|
specification_version: 4
|
99
100
|
summary: "`rails console` for your Rack applications"
|
100
101
|
test_files:
|
102
|
+
- spec/rack/console/methods_spec.rb
|
101
103
|
- spec/rack/console_spec.rb
|
102
104
|
- spec/spec_helper.rb
|
103
105
|
has_rdoc:
|