console_utils 0.4.1.1 → 0.5.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: f1380c26eef04f62bc9906a37c1474345e76288c
4
- data.tar.gz: daf25af3f2816e5e09085792acf9f45c9cfca548
3
+ metadata.gz: 3607787694af8ed4bc9e4466f95e9d090c312d22
4
+ data.tar.gz: fb4da9e048ac320e0aaa9d57fb919e90b2f505b2
5
5
  SHA512:
6
- metadata.gz: c584be72495886bdb5d1cccbfaf6746e2e5d032c905fde9979b75189f9aced1cab4a1c51bb2ea606482bd4605b5d9608f83d463c7313fe63ce22234d1c46e328
7
- data.tar.gz: 0b33ba83c797b0ccd130d51e60f92787d7ba85d2f50d4fabd5cccb33eeb729bba5829aef97a477c4a04b013b88404a69915de165e54f584f532ac47ac8ab9df2
6
+ metadata.gz: 2027cc176a4275fb61bec377d9dfc369bb51f736c84bb10f436da81c131ed0692896032a14802277b3c9f5af6119cbde468342cbf9864a4dc8bd3a6cc59e390c
7
+ data.tar.gz: 78be8092f07add77fca5eba1b95ff521af70f815c3818d76cc72b37da22ffb2bd95bf09ee4f3c974cbcfdd8312ffca77ce9aff7016b5ee9a9d797194eb67a60e
@@ -0,0 +1,5 @@
1
+ appraise "rails42" do
2
+ gem "rails", "~> 4.2"
3
+ gem "sqlite3"
4
+ gem "pry-rails"
5
+ end
data/Gemfile CHANGED
@@ -1,8 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rails-console-utils.gemspec
4
- gemspec
5
-
6
- gem "rails", "~> 4.2"
7
- gem "pry"
8
- gem "rspec"
4
+ gemspec
data/Rakefile CHANGED
@@ -1,10 +1,33 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
1
3
  require "bundler/gem_tasks"
2
-
4
+ require "rake/testtask"
5
+ require "appraisal"
3
6
  require 'rdoc/task'
4
7
 
8
+ Rake::TestTask.new do |t|
9
+ t.libs.concat %w(console_utils spec)
10
+ t.pattern = "spec/*_spec.rb"
11
+ end
12
+
13
+ desc 'Start the Rails console'
14
+ task :console => :development_env do
15
+ require 'rails/commands/console'
16
+ Rails::Console.start(Rails.application)
17
+ end
18
+
19
+ task :development_env do
20
+ ENV['RAILS_ENV'] = 'development'
21
+ require File.expand_path('../spec/config/environment', __FILE__)
22
+ Dir.chdir(Rails.application.root)
23
+ end
24
+
5
25
  RDoc::Task.new do |rdoc|
6
26
  rdoc.main = "README.md"
7
27
  rdoc.rdoc_dir = "doc"
8
28
  rdoc.rdoc_files.include("README.md", "lib/**/*.rb")
9
29
  rdoc.options = ["--no-dcov", "--visibility=protected"]
10
- end
30
+ end
31
+
32
+ # Must invoke indirectly, using `rake appraisal`.
33
+ task :default => [:test]
@@ -1,6 +1,8 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
4
6
  require 'console_utils/version'
5
7
 
6
8
  Gem::Specification.new do |spec|
@@ -14,16 +16,18 @@ Gem::Specification.new do |spec|
14
16
  spec.homepage = "https://github.com/estum/console_utils"
15
17
  spec.license = "MIT"
16
18
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
18
20
  spec.require_paths = ["lib"]
21
+ spec.required_ruby_version = ">= 2.1"
19
22
 
20
23
  spec.add_dependency "activesupport", ">= 4.1", "< 5"
21
24
  spec.add_dependency "term-ansicolor"
22
25
  spec.add_dependency "awesome_print"
23
26
  spec.add_dependency "benchmark-ips"
27
+ spec.add_dependency "pry-rails"
24
28
  # spec.add_dependency 'sourcify', '~> 0.6.0.rc4'
25
29
 
26
- spec.add_development_dependency "bundler", "~> 1.9"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
30
  spec.add_development_dependency "rdoc"
31
+ spec.add_development_dependency "appraisal"
32
+ spec.add_development_dependency "minitest"
29
33
  end
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.2"
6
+ gem "sqlite3"
7
+ gem "pry-rails"
8
+
9
+ gemspec :path => "../"
@@ -0,0 +1,137 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ console_utils (0.4.1.1)
5
+ activesupport (>= 4.1, < 5)
6
+ awesome_print
7
+ benchmark-ips
8
+ pry-rails
9
+ term-ansicolor
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ actionmailer (4.2.4)
15
+ actionpack (= 4.2.4)
16
+ actionview (= 4.2.4)
17
+ activejob (= 4.2.4)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 1.0, >= 1.0.5)
20
+ actionpack (4.2.4)
21
+ actionview (= 4.2.4)
22
+ activesupport (= 4.2.4)
23
+ rack (~> 1.6)
24
+ rack-test (~> 0.6.2)
25
+ rails-dom-testing (~> 1.0, >= 1.0.5)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (4.2.4)
28
+ activesupport (= 4.2.4)
29
+ builder (~> 3.1)
30
+ erubis (~> 2.7.0)
31
+ rails-dom-testing (~> 1.0, >= 1.0.5)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
33
+ activejob (4.2.4)
34
+ activesupport (= 4.2.4)
35
+ globalid (>= 0.3.0)
36
+ activemodel (4.2.4)
37
+ activesupport (= 4.2.4)
38
+ builder (~> 3.1)
39
+ activerecord (4.2.4)
40
+ activemodel (= 4.2.4)
41
+ activesupport (= 4.2.4)
42
+ arel (~> 6.0)
43
+ activesupport (4.2.4)
44
+ i18n (~> 0.7)
45
+ json (~> 1.7, >= 1.7.7)
46
+ minitest (~> 5.1)
47
+ thread_safe (~> 0.3, >= 0.3.4)
48
+ tzinfo (~> 1.1)
49
+ appraisal (2.1.0)
50
+ bundler
51
+ rake
52
+ thor (>= 0.14.0)
53
+ arel (6.0.3)
54
+ awesome_print (1.6.1)
55
+ benchmark-ips (2.3.0)
56
+ builder (3.2.2)
57
+ coderay (1.1.0)
58
+ erubis (2.7.0)
59
+ globalid (0.3.6)
60
+ activesupport (>= 4.1.0)
61
+ i18n (0.7.0)
62
+ json (1.8.3)
63
+ loofah (2.0.3)
64
+ nokogiri (>= 1.5.9)
65
+ mail (2.6.3)
66
+ mime-types (>= 1.16, < 3)
67
+ method_source (0.8.2)
68
+ mime-types (2.6.2)
69
+ mini_portile (0.6.2)
70
+ minitest (5.8.0)
71
+ nokogiri (1.6.6.2)
72
+ mini_portile (~> 0.6.0)
73
+ pry (0.10.2)
74
+ coderay (~> 1.1.0)
75
+ method_source (~> 0.8.1)
76
+ slop (~> 3.4)
77
+ pry-rails (0.3.4)
78
+ pry (>= 0.9.10)
79
+ rack (1.6.4)
80
+ rack-test (0.6.3)
81
+ rack (>= 1.0)
82
+ rails (4.2.4)
83
+ actionmailer (= 4.2.4)
84
+ actionpack (= 4.2.4)
85
+ actionview (= 4.2.4)
86
+ activejob (= 4.2.4)
87
+ activemodel (= 4.2.4)
88
+ activerecord (= 4.2.4)
89
+ activesupport (= 4.2.4)
90
+ bundler (>= 1.3.0, < 2.0)
91
+ railties (= 4.2.4)
92
+ sprockets-rails
93
+ rails-deprecated_sanitizer (1.0.3)
94
+ activesupport (>= 4.2.0.alpha)
95
+ rails-dom-testing (1.0.7)
96
+ activesupport (>= 4.2.0.beta, < 5.0)
97
+ nokogiri (~> 1.6.0)
98
+ rails-deprecated_sanitizer (>= 1.0.1)
99
+ rails-html-sanitizer (1.0.2)
100
+ loofah (~> 2.0)
101
+ railties (4.2.4)
102
+ actionpack (= 4.2.4)
103
+ activesupport (= 4.2.4)
104
+ rake (>= 0.8.7)
105
+ thor (>= 0.18.1, < 2.0)
106
+ rake (10.4.2)
107
+ rdoc (4.2.0)
108
+ slop (3.6.0)
109
+ sprockets (3.3.4)
110
+ rack (~> 1.0)
111
+ sprockets-rails (2.3.3)
112
+ actionpack (>= 3.0)
113
+ activesupport (>= 3.0)
114
+ sprockets (>= 2.8, < 4.0)
115
+ sqlite3 (1.3.10)
116
+ term-ansicolor (1.3.2)
117
+ tins (~> 1.0)
118
+ thor (0.19.1)
119
+ thread_safe (0.3.5)
120
+ tins (1.6.0)
121
+ tzinfo (1.2.2)
122
+ thread_safe (~> 0.1)
123
+
124
+ PLATFORMS
125
+ ruby
126
+
127
+ DEPENDENCIES
128
+ appraisal
129
+ console_utils!
130
+ minitest
131
+ pry-rails
132
+ rails (~> 4.2)
133
+ rdoc
134
+ sqlite3
135
+
136
+ BUNDLED WITH
137
+ 1.10.6
@@ -1,9 +1,9 @@
1
1
  require 'active_support'
2
2
  require 'active_support/core_ext'
3
+ require 'active_support/tagged_logging'
3
4
  require 'term/ansicolor'
4
5
  require 'console_utils/core_ext/array_to_proc'
5
6
  require 'console_utils/core_ext/local_values'
6
- require 'console_utils/repl_context'
7
7
  require 'console_utils/version'
8
8
 
9
9
  begin
@@ -118,7 +118,7 @@ module ConsoleUtils
118
118
 
119
119
  # :attr:
120
120
  # Output logger (<tt>Logger.new(STDOUT)</tt> by default)
121
- mattr_accessor(:logger) { Logger.new(STDOUT) }
121
+ mattr_accessor(:logger) { ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) }
122
122
 
123
123
  # :attr:
124
124
  # Enable the auth automator with the "exap"
@@ -145,17 +145,18 @@ module ConsoleUtils
145
145
  alias_method :config, :itself
146
146
 
147
147
  # :method: self.configure
148
- def configure
148
+ def configure # :yields:
149
149
  yield(config)
150
150
  end
151
151
 
152
- def enabled_modules
153
- ConsoleUtils::MODULES - disabled_modules
154
- end
152
+ def enabled_modules # :yields:
153
+ unless block_given?
154
+ return to_enum(__method__) { ConsoleUtils::MODULES.size - disabled_modules.dize }
155
+ end
155
156
 
156
- # Yields each enabled module with a given block
157
- def each_enabled_module
158
- enabled_modules.each { |mod| yield const_get(mod) }
157
+ (ConsoleUtils::MODULES - disabled_modules).each do |mod|
158
+ yield(const_get(mod))
159
+ end
159
160
  end
160
161
 
161
162
  # Returns User's class set in the <tt>:user_class_name</tt>
@@ -189,40 +190,38 @@ module ConsoleUtils
189
190
  user.public_send(user_token_column)
190
191
  end
191
192
 
192
- # Setup enabled modules for IRB context
193
- def irb!
194
- setup_modules_to(ReplContext.instance.irb!)
195
- end
196
-
197
193
  # Setup enabled modules for Pry context
198
194
  def pry!
199
- setup_modules_to(ReplContext.instance.pry!)
195
+ setup_modules_to { TOPLEVEL_BINDING.eval('self') }
200
196
  end
201
197
 
202
198
  # Setup enabled modules by extending given context
203
- def setup_modules_to(context = nil)
204
- context, block = block, context if !block_given? && context.respond_to?(:call)
205
- context ||= yield if block_given?
199
+ def setup_modules_to # :yields:
200
+ logger.level = Logger::WARN
206
201
 
207
- if context.nil?
208
- warn "[ConsoleUtils] Trying to setup with empty context"
209
- return
210
- end
202
+ logger.tagged(name) do
203
+ unless block_given?
204
+ logger.warn { "Trying to setup with empty context" }
205
+ return
206
+ end
211
207
 
212
- if ENV["CONSOLE_UTILS_DEBUG"] == "1"
213
- logger.level = Logger::DEBUG
214
- logger.debug { "Console instance: #{context.inspect} (#{ReplContext.instance.initialized_to})" }
215
- else
216
- logger.level = Logger::WARN
217
- end
208
+ if ENV["CONSOLE_UTILS_DEBUG"] == "1"
209
+ logger.level = Logger::DEBUG
210
+ logger.debug { "Console instance: #{yield().inspect}" }
211
+ end
218
212
 
219
- each_enabled_module { |mod| context.send(:extend, mod) }
213
+ enabled_modules do |mod|
214
+ logger.debug { "extending with #{mod.inspect}" }
215
+ yield().extend(mod)
216
+ end
217
+ end
220
218
  end
219
+
221
220
  end
222
221
 
223
222
  ActiveSupport.run_load_hooks(:console_utils, self)
224
223
  end
225
224
 
226
- if defined? Rails
225
+ if defined?(Rails)
227
226
  require "console_utils/railtie"
228
227
  end
@@ -3,14 +3,9 @@ require "rails/railtie"
3
3
  module ConsoleUtils
4
4
  ##
5
5
  # Console Utils Railtie
6
- class Railtie < ::Rails::Railtie
7
- #:nodoc: all
6
+ class Railtie < ::Rails::Railtie #:nodoc: all
8
7
  config.console_utils = ActiveSupport::OrderedOptions.new
9
8
 
10
- # initializer 'console_utils.logger' do
11
- # ActiveSupport.on_load(:console_utils) { self.logger = ::Rails.logger }
12
- # end
13
-
14
9
  initializer "console_utils.set_configs" do |app|
15
10
  options = app.config.console_utils
16
11
 
@@ -18,12 +13,12 @@ module ConsoleUtils
18
13
  options.disabled_modules << :ActiveRecordUtils unless defined?(ActiveRecord)
19
14
 
20
15
  ActiveSupport.on_load(:console_utils) do
21
- options.each { |k,v| send(:"#{k}=", v) }
16
+ options.each { |k, v| public_send(:"#{k}=", v) }
22
17
  end
23
18
  end
24
19
 
25
- console do |app|
26
- ConsoleUtils.setup_modules_to(ReplContext.instance)
20
+ console do
21
+ ConsoleUtils.pry!
27
22
  end
28
23
  end
29
24
  end
@@ -1,3 +1,3 @@
1
1
  module ConsoleUtils
2
- VERSION = "0.4.1.1"
2
+ VERSION = "0.5.0"
3
3
  end
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.4.1.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-14 00:00:00.000000000 Z
11
+ date: 2015-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -73,35 +73,49 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
- name: bundler
76
+ name: pry-rails
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rdoc
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
80
94
  - !ruby/object:Gem::Version
81
- version: '1.9'
95
+ version: '0'
82
96
  type: :development
83
97
  prerelease: false
84
98
  version_requirements: !ruby/object:Gem::Requirement
85
99
  requirements:
86
- - - "~>"
100
+ - - ">="
87
101
  - !ruby/object:Gem::Version
88
- version: '1.9'
102
+ version: '0'
89
103
  - !ruby/object:Gem::Dependency
90
- name: rake
104
+ name: appraisal
91
105
  requirement: !ruby/object:Gem::Requirement
92
106
  requirements:
93
- - - "~>"
107
+ - - ">="
94
108
  - !ruby/object:Gem::Version
95
- version: '10.0'
109
+ version: '0'
96
110
  type: :development
97
111
  prerelease: false
98
112
  version_requirements: !ruby/object:Gem::Requirement
99
113
  requirements:
100
- - - "~>"
114
+ - - ">="
101
115
  - !ruby/object:Gem::Version
102
- version: '10.0'
116
+ version: '0'
103
117
  - !ruby/object:Gem::Dependency
104
- name: rdoc
118
+ name: minitest
105
119
  requirement: !ruby/object:Gem::Requirement
106
120
  requirements:
107
121
  - - ">="
@@ -124,6 +138,7 @@ files:
124
138
  - ".gitignore"
125
139
  - ".rspec"
126
140
  - ".travis.yml"
141
+ - Appraisals
127
142
  - CODE_OF_CONDUCT.md
128
143
  - Gemfile
129
144
  - LICENSE.txt
@@ -132,6 +147,8 @@ files:
132
147
  - bin/console
133
148
  - bin/setup
134
149
  - console_utils.gemspec
150
+ - gemfiles/rails42.gemfile
151
+ - gemfiles/rails42.gemfile.lock
135
152
  - lib/awesome_print/proc.rb
136
153
  - lib/console_utils.rb
137
154
  - lib/console_utils/active_record_utils.rb
@@ -147,7 +164,6 @@ files:
147
164
  - lib/console_utils/other_utils.rb
148
165
  - lib/console_utils/pry.rb
149
166
  - lib/console_utils/railtie.rb
150
- - lib/console_utils/repl_context.rb
151
167
  - lib/console_utils/request_utils.rb
152
168
  - lib/console_utils/request_utils/auth_automators.rb
153
169
  - lib/console_utils/request_utils/exap.rb
@@ -167,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
183
  requirements:
168
184
  - - ">="
169
185
  - !ruby/object:Gem::Version
170
- version: '0'
186
+ version: '2.1'
171
187
  required_rubygems_version: !ruby/object:Gem::Requirement
172
188
  requirements:
173
189
  - - ">="
@@ -180,4 +196,3 @@ signing_key:
180
196
  specification_version: 4
181
197
  summary: Groovy tools for Rails Console.
182
198
  test_files: []
183
- has_rdoc:
@@ -1,50 +0,0 @@
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
- init_to(:irb) { irb_rails! || ::IRB::ExtendCommandBundle }
15
- end
16
-
17
- def irb_rails!
18
- init_to(:rails) { ::Rails.application.config.console::ExtendCommandBundle } if rails?
19
- end
20
-
21
- def pry!
22
- init_to(:pry) { ::TOPLEVEL_BINDING.eval('self') } if pry?
23
- end
24
-
25
- def initialized_to
26
- @initialized_to ||= []
27
- end
28
-
29
- def initialized?
30
- initialized_to.size > 0
31
- end
32
-
33
- def rails?
34
- defined? ::Rails::Application
35
- end
36
-
37
- def pry?
38
- defined? ::Pry
39
- end
40
-
41
- private
42
-
43
- def init_to(context)
44
- unless initialized_to.include?(context)
45
- initialized_to << context
46
- yield if block_given?
47
- end
48
- end
49
- end
50
- end