force_require 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in force_require.gemspec
4
+ gemspec
@@ -0,0 +1,29 @@
1
+ force_require
2
+ ====
3
+
4
+ It provides the Kernel#force_require to require gems over the bundler.
5
+
6
+ Install
7
+ ----
8
+
9
+ ### In Gemfile
10
+
11
+ gem "force_require"
12
+
13
+ ### To local
14
+
15
+ curl https://github.com/jugyo/force_require/raw/master/lib/force_require.rb > ~/force_require.rb
16
+
17
+ Usage
18
+ ----
19
+
20
+ e.g.
21
+
22
+ force_require 'ir_b'
23
+
24
+ See also `./example`.
25
+
26
+ Copyright
27
+ ----
28
+
29
+ Copyright (c) 2011 jugyo, released under the MIT license
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ source 'http://rubygems.org'
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+
5
+ require File.expand_path('../../lib/force_require', __FILE__)
6
+ force_require 'ir_b' # need `gem install ir_b`
7
+ ir b
@@ -0,0 +1,16 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["jugyo"]
5
+ gem.email = ["jugyo.org@gmail.com"]
6
+ gem.description = %q{Force require for Bundler environment! Yeaaaaaaaaaaah!}
7
+ gem.summary = %q{You can require any gems on Bundler!}
8
+ gem.homepage = "https://github.com/jugyo/force_require"
9
+
10
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ gem.name = "force_require"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = '1.0.0'
16
+ end
@@ -0,0 +1,47 @@
1
+ module Gem
2
+ def self._all_partials(gemdir)
3
+ Dir[File.join(gemdir, "gems/*")]
4
+ end
5
+
6
+ def self._all_load_paths
7
+ result = []
8
+
9
+ Gem.path.each do |gemdir|
10
+ each_load_path _all_partials(gemdir) do |load_path|
11
+ result << load_path
12
+ end
13
+ end
14
+
15
+ result
16
+ end
17
+ end
18
+
19
+ module Kernel
20
+ def new_require(name)
21
+ begin
22
+ org_require name
23
+ rescue LoadError
24
+ if Thread.current[:force_require_mode]
25
+ force_require name
26
+ else
27
+ raise
28
+ end
29
+ end
30
+ end
31
+ alias_method :org_require, :require
32
+ alias_method :require, :new_require
33
+
34
+ def force_require(name)
35
+ Thread.current[:force_require_mode] = true
36
+ Gem._all_load_paths.each do |dir|
37
+ Dir[File.join(dir, "#{name}#{Gem.suffix_pattern}")].each do |file|
38
+ require file
39
+ return true
40
+ end
41
+ end
42
+ raise LoadError, "no such file to load -- #{name}"
43
+ ensure
44
+ Thread.current[:force_require_mode] = false
45
+ end
46
+ alias_method :require!, :force_require
47
+ end
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: force_require
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - jugyo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-11 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Force require for Bundler environment! Yeaaaaaaaaaaah!
15
+ email:
16
+ - jugyo.org@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - Gemfile
22
+ - README.md
23
+ - Rakefile
24
+ - example/Gemfile
25
+ - example/foo.rb
26
+ - force_require.gemspec
27
+ - lib/force_require.rb
28
+ homepage: https://github.com/jugyo/force_require
29
+ licenses: []
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 1.8.11
49
+ signing_key:
50
+ specification_version: 3
51
+ summary: You can require any gems on Bundler!
52
+ test_files: []