Skip to content
This repository
Browse code

Removed AS core_ext/kernel/requires as it's not used and is bad pract…

…ice.
  • Loading branch information...
commit eff5d9aed468e8d6c4ffb103dad8e99b0a65465d 1 parent a8b2a89
Josh Kalderimis authored May 23, 2011
1  activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
... ...
@@ -1,5 +1,4 @@
1 1
 require 'active_record/connection_adapters/abstract_adapter'
2  
-require 'active_support/core_ext/kernel/requires'
3 2
 require 'active_support/core_ext/object/blank'
4 3
 require 'set'
5 4
 
1  activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
... ...
@@ -1,5 +1,4 @@
1 1
 require 'active_record/connection_adapters/abstract_adapter'
2  
-require 'active_support/core_ext/kernel/requires'
3 2
 require 'active_support/core_ext/object/blank'
4 3
 
5 4
 # Make sure we're using pg high enough for PGResult#values
1  activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
... ...
@@ -1,5 +1,4 @@
1 1
 require 'active_record/connection_adapters/abstract_adapter'
2  
-require 'active_support/core_ext/kernel/requires'
3 2
 
4 3
 module ActiveRecord
5 4
   module ConnectionAdapters #:nodoc:
1  activesupport/lib/active_support/core_ext/kernel.rb
... ...
@@ -1,5 +1,4 @@
1 1
 require 'active_support/core_ext/kernel/reporting'
2 2
 require 'active_support/core_ext/kernel/agnostics'
3  
-require 'active_support/core_ext/kernel/requires'
4 3
 require 'active_support/core_ext/kernel/debugger'
5 4
 require 'active_support/core_ext/kernel/singleton_class'
26  activesupport/lib/active_support/core_ext/kernel/requires.rb
... ...
@@ -1,26 +0,0 @@
1  
-require 'active_support/core_ext/kernel/reporting'
2  
-
3  
-module Kernel
4  
-  # Require a library with fallback to RubyGems.  Warnings during library
5  
-  # loading are silenced to increase signal/noise for application warnings.
6  
-  def require_library_or_gem(library_name)
7  
-    silence_warnings do
8  
-      begin
9  
-        require library_name
10  
-      rescue LoadError => cannot_require
11  
-        # 1. Requiring the module is unsuccessful, maybe it's a gem and nobody required rubygems yet. Try.
12  
-        begin
13  
-          require 'rubygems'
14  
-        rescue LoadError # => rubygems_not_installed
15  
-          raise cannot_require
16  
-        end
17  
-        # 2. Rubygems is installed and loaded. Try to load the library again
18  
-        begin
19  
-          require library_name
20  
-        rescue LoadError # => gem_not_installed
21  
-          raise cannot_require
22  
-        end
23  
-      end
24  
-    end
25  
-  end
26  
-end
7  railties/lib/rails/rack/debugger.rb
... ...
@@ -1,5 +1,3 @@
1  
-require 'active_support/core_ext/kernel/requires'
2  
-
3 1
 module Rails
4 2
   module Rack
5 3
     class Debugger
@@ -8,11 +6,12 @@ def initialize(app)
8 6
 
9 7
         ARGV.clear # clear ARGV so that rails server options aren't passed to IRB
10 8
 
11  
-        require_library_or_gem 'ruby-debug'
  9
+        require 'ruby-debug'
  10
+
12 11
         ::Debugger.start
13 12
         ::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings)
14 13
         puts "=> Debugger enabled"
15  
-      rescue Exception
  14
+      rescue LoadError
16 15
         puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'"
17 16
         exit
18 17
       end
1  railties/lib/rails/test_help.rb
@@ -3,7 +3,6 @@
3 3
 abort("Abort testing: Your Rails environment is running in production mode!") if Rails.env.production?
4 4
 
5 5
 require 'test/unit'
6  
-require 'active_support/core_ext/kernel/requires'
7 6
 require 'active_support/test_case'
8 7
 require 'action_controller/test_case'
9 8
 require 'action_dispatch/testing/integration'

13 notes on commit eff5d9a

Xavier Noria
Owner
fxn commented on eff5d9a May 23, 2011

Hey, there are still references to this method in the project. Could you perform another grep?

Josh Kalderimis
joshk commented on eff5d9a May 23, 2011

Are there? I'm sorry, I will check into it further, my ack didn't pick anything up.

Xavier Noria
Owner
fxn commented on eff5d9a May 23, 2011

You're not the first one to fall there, I promise you :).

Thing is guides are written in Textile, and ack ignores .textile files by default. You need to pass -a to have them ack'ed :).

Josh Kalderimis
joshk commented on eff5d9a May 23, 2011

ahhhhhhhhh, so require_library_or_gem is referenced in the guides? I am using the textmate ack bundle, not sure how to tell it to include textile, I'll look into it and get this updated.

Thanks for letting me know.

Vijay Dev
Collaborator

@fxn I just tried out using ack and it did search through the textile files. @joshk: Check out Active Support Core Extensions Guide! :)

Josh Kalderimis
joshk commented on eff5d9a May 23, 2011

I have committed the correction to docrails

rails/docrails@09314f2

Josh Kalderimis
joshk commented on eff5d9a May 23, 2011

@vijaydec i fixed my ackmate textmate plugin to include textile for now on

Xavier Noria
Owner
fxn commented on eff5d9a May 23, 2011

@vijaydev could it be the case that you've got a custom ~/.ackrc ?

Vijay Dev
Collaborator

@fxn No, I don't have one.

Xavier Noria
Owner
fxn commented on eff5d9a May 24, 2011

That's strange. The default types do not include .textile

https://github.com/petdance/ack/blob/master/Ack.pm#L74-128

What does the command

ack --help=types | ack textile

output in your machine?

Vijay Dev
Collaborator

Hmm... the command outputs nothing. Meaning textile is not a supported type?!

ack-grep version: 1.92

Xavier Noria
Owner
fxn commented on eff5d9a May 24, 2011

That's the expected output. I have 1.94 here, but .textile has never been among the types known by ack by default. Errrr, can't understand why is searching them in your machine.

What about environment variables? For example,

env | ack ACK

Vijay Dev
Collaborator

Nothing in env either!

Please sign in to comment.
Something went wrong with that request. Please try again.