console_utils 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/console_utils/pry.rb +2 -0
- data/lib/console_utils/railtie.rb +1 -7
- data/lib/console_utils/repl_context.rb +35 -0
- data/lib/console_utils/version.rb +1 -1
- data/lib/console_utils.rb +16 -6
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ec5fe50875a44222ed008d871f20af1252723f7
|
4
|
+
data.tar.gz: 49c093ec238e4ab69757bf5068af54ac4cf78ac1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d5a262aa068990424a189760e7d2a750575ecc6ab6f88f7c730f0f18c0fd6dbfc7c8cffda2f27e6092264c307dd16aa38fa1ef59815d3853122da5120259609
|
7
|
+
data.tar.gz: b2c35b09c9a3caf875c586b3d47bc5d8acd9764b5d090bb710c4d3545e9e128ae5f91e6013c149966d38e120cec5b463550939842f3510824878491f3c79abb4
|
@@ -23,13 +23,7 @@ module ConsoleUtils
|
|
23
23
|
end
|
24
24
|
|
25
25
|
console do |app|
|
26
|
-
ConsoleUtils.setup_modules_to
|
27
|
-
if defined?(Pry)
|
28
|
-
TOPLEVEL_BINDING.eval('self')
|
29
|
-
else
|
30
|
-
Rails.application.config.console::ExtendCommandBundle
|
31
|
-
end
|
32
|
-
end
|
26
|
+
ConsoleUtils.setup_modules_to(ReplContext.instance)
|
33
27
|
end
|
34
28
|
end
|
35
29
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module ConsoleUtils
|
2
|
+
class ReplContext
|
3
|
+
include Singleton
|
4
|
+
|
5
|
+
def self.console
|
6
|
+
instance[]
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
pry! || irb!
|
11
|
+
end
|
12
|
+
|
13
|
+
def irb!
|
14
|
+
irb_rails! || ::IRB::ExtendCommandBundle
|
15
|
+
end
|
16
|
+
|
17
|
+
def irb_rails!
|
18
|
+
::Rails.application.config.console::ExtendCommandBundle if rails?
|
19
|
+
end
|
20
|
+
|
21
|
+
def pry!
|
22
|
+
::TOPLEVEL_BINDING.eval('self') if pry?
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def rails?
|
28
|
+
defined?(::Rails::Application)
|
29
|
+
end
|
30
|
+
|
31
|
+
def pry?
|
32
|
+
defined?(::Pry)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/console_utils.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/rails'
|
3
3
|
require 'term/ansicolor'
|
4
4
|
require 'console_utils/core_ext/array_to_proc'
|
5
|
-
require
|
5
|
+
require 'console_utils/repl_context'
|
6
|
+
require 'console_utils/version'
|
6
7
|
|
7
8
|
begin
|
8
9
|
require "awesome_print"
|
@@ -121,7 +122,6 @@ module ConsoleUtils
|
|
121
122
|
def config
|
122
123
|
self
|
123
124
|
end
|
124
|
-
private :config
|
125
125
|
|
126
126
|
# :method: self.configure
|
127
127
|
def configure
|
@@ -155,11 +155,21 @@ module ConsoleUtils
|
|
155
155
|
end
|
156
156
|
|
157
157
|
# Setup enabled modules by extending given context
|
158
|
-
def setup_modules_to(context = nil)
|
159
|
-
context =
|
158
|
+
def setup_modules_to(context = nil, &block)
|
159
|
+
context, block = block, context if !block_given? && context.respond_to?(:call)
|
160
|
+
context ||= block.call
|
161
|
+
|
160
162
|
puts "Console instance: #{context.inspect}" if ENV["CONSOLE_UTILS_DEBUG"]
|
161
163
|
each_enabled_module { |mod| context.send(:extend, mod) }
|
162
164
|
end
|
165
|
+
|
166
|
+
def irb!
|
167
|
+
setup_modules_to(ReplContext.instance.irb!)
|
168
|
+
end
|
169
|
+
|
170
|
+
def pry!
|
171
|
+
setup_modules_to(ReplContext.instance.pry!)
|
172
|
+
end
|
163
173
|
end
|
164
174
|
|
165
175
|
ActiveSupport.run_load_hooks(:console_utils, self)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: console_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -140,7 +140,9 @@ files:
|
|
140
140
|
- lib/console_utils/bench_utils/chips.rb
|
141
141
|
- lib/console_utils/core_ext/array_to_proc.rb
|
142
142
|
- lib/console_utils/other_utils.rb
|
143
|
+
- lib/console_utils/pry.rb
|
143
144
|
- lib/console_utils/railtie.rb
|
145
|
+
- lib/console_utils/repl_context.rb
|
144
146
|
- lib/console_utils/request_utils.rb
|
145
147
|
- lib/console_utils/request_utils/exap.rb
|
146
148
|
- lib/console_utils/request_utils/json_output.rb
|