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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8c1497e6b3181baa95fe33d6112b806e0724404
4
- data.tar.gz: a815bff00b9fbfeb15e6d2ac6c6d78af13776098
3
+ metadata.gz: 0ec5fe50875a44222ed008d871f20af1252723f7
4
+ data.tar.gz: 49c093ec238e4ab69757bf5068af54ac4cf78ac1
5
5
  SHA512:
6
- metadata.gz: 082d3d022dccbd045c3a0312cc2c34a684076eff3d5119c7b70579361298d317efe29f3e2f4c71e1187ebd7209584a367dbd759177c55b97554594c6302358d3
7
- data.tar.gz: 68470ed097f30a499a6ecdc71af8f4d162d00f617e29f18caeaeb158f47e5e1ca72f3c17a7e27c96d4a5ac090d64b1a969be8bd19279a419cca3aa4ad2df22bd
6
+ metadata.gz: 2d5a262aa068990424a189760e7d2a750575ecc6ab6f88f7c730f0f18c0fd6dbfc7c8cffda2f27e6092264c307dd16aa38fa1ef59815d3853122da5120259609
7
+ data.tar.gz: b2c35b09c9a3caf875c586b3d47bc5d8acd9764b5d090bb710c4d3545e9e128ae5f91e6013c149966d38e120cec5b463550939842f3510824878491f3c79abb4
@@ -0,0 +1,2 @@
1
+ require "console_utils"
2
+ ConsoleUtils.pry!
@@ -23,13 +23,7 @@ module ConsoleUtils
23
23
  end
24
24
 
25
25
  console do |app|
26
- ConsoleUtils.setup_modules_to do
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
@@ -1,3 +1,3 @@
1
1
  module ConsoleUtils
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/console_utils.rb CHANGED
@@ -1,8 +1,9 @@
1
- require "active_support"
2
- require "active_support/rails"
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 "console_utils/version"
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 = yield() if block_given?
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.3
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-04-28 00:00:00.000000000 Z
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