bundler_ext 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG ADDED
@@ -0,0 +1,5 @@
1
+ ====== version 0.3.0 =========
2
+
3
+ Jason Guiditta (2):
4
+ Flatten namespace, since this is now used outside of Aeolus project.
5
+ Change to MIT license and minor cleanups.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 Red Hat, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -22,17 +22,17 @@ other.
22
22
 
23
23
  If you want to load ALL Gemfile groups, use the following statement:
24
24
 
25
- Aeolus::Ext::BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :all)
25
+ BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :all)
26
26
 
27
27
  When you want to load only the default one, use:
28
28
 
29
- Aeolus::Ext::BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :default)
29
+ BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :default)
30
30
 
31
31
  You can provide multiple parameters to the system_require function
32
32
  of course. Finally, you will be likely requiring default group and
33
33
  group named as the current Rails environment; use this:
34
34
 
35
- Aeolus::Ext::BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :default, Rails.env)
35
+ BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :default, Rails.env)
36
36
 
37
37
  You may also want to wrap your call in some kind of check, to allow
38
38
  non-platform users (ie, mac, or any developer not installing as a
@@ -77,3 +77,9 @@ not running daemonized. For this purposes there is BUNDLER_EXT_HOME
77
77
  variable which can be used to set HOME environment variable before
78
78
  any rubygem gets loaded. The variable is not exported for
79
79
  subprocesses.
80
+
81
+ ### License ###
82
+
83
+ bundler_ext is licensed under the MIT Licence.
84
+
85
+ * http://www.opensource.org/licenses/MIT
data/Rakefile CHANGED
@@ -1,25 +1,13 @@
1
- #
2
- # Copyright 2011 Red Hat, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
1
+ #!/usr/bin/env rake
17
2
  begin
18
3
  require 'rspec/core/rake_task'
4
+ require 'bundler'
19
5
  rescue LoadError
20
- puts "Please install development dependencies to run specs"
6
+ puts "Please install runtime and development dependencies to run tasks"
21
7
  end
22
8
 
9
+ Bundler::GemHelper.install_tasks
10
+
23
11
  RSpec::Core::RakeTask.new('spec')
24
12
 
25
13
  desc "Run specs"
@@ -0,0 +1 @@
1
+ require 'bundler_ext/bundler_ext'
@@ -0,0 +1,65 @@
1
+ require "bundler"
2
+
3
+ # some rubygems does not play well with daemonized processes ($HOME is empty)
4
+ ENV['HOME'] = ENV['BUNDLER_EXT_HOME'] if ENV['BUNDLER_EXT_HOME']
5
+
6
+ class BundlerExt
7
+ def self.parse_from_gemfile(gemfile,*groups)
8
+ ENV['BUNDLE_GEMFILE'] = gemfile
9
+ extra_groups = ENV['BUNDLER_EXT_GROUPS']
10
+ extra_groups.split(/\s/).each {|g| groups << g.to_sym} if extra_groups
11
+ all_groups = false
12
+ all_groups = true if groups.size == 1 and groups.include?(:all) and not extra_groups
13
+ groups.map! { |g| g.to_sym }
14
+ g = Bundler::Dsl.evaluate(gemfile,'foo',true)
15
+ list = []
16
+ g.dependencies.each do |dep|
17
+ if ((groups & dep.groups).any? || all_groups) && dep.current_platform?
18
+ Array(dep.autorequire || dep.name).each do |file|
19
+ list << file
20
+ end
21
+ end
22
+ end
23
+ list
24
+ end
25
+
26
+ def self.strict_error(msg)
27
+ if ENV['BUNDLER_EXT_NOSTRICT']
28
+ puts msg
29
+ else
30
+ raise msg
31
+ end
32
+ end
33
+
34
+ def self.system_require(gemfile,*groups)
35
+ BundlerExt.parse_from_gemfile(gemfile,*groups).each do |dep|
36
+ #This part ripped wholesale from lib/bundler/runtime.rb (github/master)
37
+ begin
38
+ #puts "Attempting to require #{dep}"
39
+ require dep
40
+ rescue LoadError => e
41
+ #puts "Caught error: #{e.message}"
42
+ if dep.include?('-')
43
+ begin
44
+ if dep.respond_to? :name
45
+ namespaced_file = dep.name.gsub('-', '/')
46
+ else
47
+ # try to load unresolved deps
48
+ namespaced_file = dep.gsub('-', '/')
49
+ end
50
+ #puts "Munged the name, now trying to require as #{namespaced_file}"
51
+ require namespaced_file
52
+ rescue LoadError => e2
53
+ strict_error "Gem loading error: #{e2.message}"
54
+ end
55
+ else
56
+ strict_error "Gem loading error: #{e.message}"
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ def self.output
63
+ ENV['BUNDLER_STDERR'] || $stderr
64
+ end
65
+ end
@@ -0,0 +1,3 @@
1
+ module BundlerExt
2
+ VERSION = '0.3.0'
3
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ describe BundlerExt do
4
+ before(:each) do
5
+ @gemfile = 'spec/fixtures/Gemfile.in'
6
+ end
7
+ after(:each) do
8
+ ENV['BUNDLER_EXT_NOSTRICT'] = nil
9
+ ENV['BUNDLER_EXT_GROUPS'] = nil
10
+ end
11
+
12
+ describe "#parse_from_gemfile" do
13
+ describe "with no group passed in" do
14
+ it "should return nothing to require" do
15
+ libs = BundlerExt.parse_from_gemfile(@gemfile)
16
+ libs.should be_an(Array)
17
+ libs.should_not include('deltacloud')
18
+ libs.should_not include('vcr')
19
+ end
20
+ end
21
+ describe "with :all passed in" do
22
+ it "should return the list of system libraries in all groups to require" do
23
+ libs = BundlerExt.parse_from_gemfile(@gemfile, :all)
24
+ libs.should be_an(Array)
25
+ libs.should include('deltacloud')
26
+ libs.should include('vcr')
27
+ end
28
+ end
29
+ describe "with group passed in" do
30
+ it "should not return any deps that are not in the 'development' group" do
31
+ libs = BundlerExt.parse_from_gemfile(@gemfile,'development')
32
+ libs.should be_an(Array)
33
+ libs.should_not include('deltacloud')
34
+ end
35
+ it "should return only deps that are in the :test group" do
36
+ libs = BundlerExt.parse_from_gemfile(@gemfile, :test)
37
+ libs.should be_an(Array)
38
+ libs.should_not include('deltacloud')
39
+ libs.should include('vcr')
40
+ end
41
+ it "should return deps from both the :default and :test groups" do
42
+ libs = BundlerExt.parse_from_gemfile(@gemfile, :default, :test)
43
+ libs.should be_an(Array)
44
+ libs.should include('deltacloud')
45
+ libs.should include('vcr')
46
+ end
47
+ end
48
+ it "should only return deps for the current platform" do
49
+ libs = BundlerExt.parse_from_gemfile(@gemfile)
50
+ libs.should be_an(Array)
51
+ if RUBY_VERSION < "1.9"
52
+ libs.should_not include('cinch')
53
+ else
54
+ libs.should_not include('fastercsv')
55
+ end
56
+ end
57
+ end
58
+ describe "#system_require" do
59
+ it "strict mode should fail loading non existing gem" do
60
+ expect { BundlerExt.system_require(@gemfile, :fail) }.to raise_error
61
+ end
62
+ it "non-strict mode should load the libraries in the gemfile" do
63
+ ENV['BUNDLER_EXT_NOSTRICT'] = 'true'
64
+ BundlerExt.system_require(@gemfile)
65
+ defined?(Gem).should be_true
66
+ end
67
+ it "non-strict mode should load the libraries in the gemfile" do
68
+ ENV['BUNDLER_EXT_NOSTRICT'] = 'true'
69
+ BundlerExt.system_require(@gemfile, :fail)
70
+ defined?(Gem).should be_true
71
+ end
72
+ it "non-strict mode should load the libraries using env var list" do
73
+ ENV['BUNDLER_EXT_GROUPS'] = 'test development blah'
74
+ ENV['BUNDLER_EXT_NOSTRICT'] = 'true'
75
+ defined?(Gem::Command).should be_true
76
+ end
77
+ end
78
+ end
@@ -0,0 +1 @@
1
+ require 'bundler_ext/bundler_ext'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler_ext
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Guiditta
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-11-28 00:00:00 Z
18
+ date: 2013-01-15 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: bundler
@@ -57,19 +57,20 @@ extensions: []
57
57
  extra_rdoc_files: []
58
58
 
59
59
  files:
60
- - lib/aeolus/ext.rb
61
- - lib/aeolus/ext/version.rb
62
- - lib/aeolus/ext/bundler_ext.rb
60
+ - lib/bundler_ext/version.rb
61
+ - lib/bundler_ext/bundler_ext.rb
62
+ - lib/bundler_ext.rb
63
63
  - README.md
64
- - COPYING
64
+ - MIT-LICENSE
65
65
  - Rakefile
66
- - spec/bundler_ext_helper.rb
67
- - spec/aeolus/ext/bundler_ext_spec.rb
66
+ - CHANGELOG
67
+ - spec/bundler_ext/bundler_ext_spec.rb
68
+ - spec/spec_helper.rb
68
69
  - spec/fixtures/Gemfile.in
69
70
  - .rspec
70
71
  homepage: https://github.com/aeolus-incubator/bundler_ext
71
72
  licenses:
72
- - ASL 2.0
73
+ - MIT
73
74
  post_install_message:
74
75
  rdoc_options: []
75
76
 
@@ -101,7 +102,7 @@ signing_key:
101
102
  specification_version: 3
102
103
  summary: Load system gems via Bundler DSL
103
104
  test_files:
104
- - spec/bundler_ext_helper.rb
105
- - spec/aeolus/ext/bundler_ext_spec.rb
105
+ - spec/bundler_ext/bundler_ext_spec.rb
106
+ - spec/spec_helper.rb
106
107
  - spec/fixtures/Gemfile.in
107
108
  - .rspec
data/COPYING DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
data/lib/aeolus/ext.rb DELETED
@@ -1,18 +0,0 @@
1
- #
2
- # Copyright 2011 Red Hat, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
- #
17
-
18
- require File.join(File.dirname(__FILE__), 'ext', 'bundler_ext')
@@ -1,85 +0,0 @@
1
- #
2
- # Copyright 2011 Red Hat, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- require "bundler"
18
-
19
- # some rubygems does not play well with daemonized processes ($HOME is empty)
20
- ENV['HOME'] = ENV['BUNDLER_EXT_HOME'] if ENV['BUNDLER_EXT_HOME']
21
-
22
- module Aeolus
23
- module Ext
24
- class BundlerExt
25
- def self.parse_from_gemfile(gemfile,*groups)
26
- ENV['BUNDLE_GEMFILE'] = gemfile
27
- extra_groups = ENV['BUNDLER_EXT_GROUPS']
28
- extra_groups.split(/\s/).each {|g| groups << g.to_sym} if extra_groups
29
- all_groups = false
30
- all_groups = true if groups.size == 1 and groups.include?(:all) and not extra_groups
31
- groups.map! { |g| g.to_sym }
32
- g = Bundler::Dsl.evaluate(gemfile,'foo',true)
33
- list = []
34
- g.dependencies.each do |dep|
35
- if ((groups & dep.groups).any? || all_groups) && dep.current_platform?
36
- Array(dep.autorequire || dep.name).each do |file|
37
- list << file
38
- end
39
- end
40
- end
41
- list
42
- end
43
-
44
- def self.strict_error(msg)
45
- if ENV['BUNDLER_EXT_NOSTRICT']
46
- puts msg
47
- else
48
- raise msg
49
- end
50
- end
51
-
52
- def self.system_require(gemfile,*groups)
53
- BundlerExt.parse_from_gemfile(gemfile,*groups).each do |dep|
54
- #This part ripped wholesale from lib/bundler/runtime.rb (github/master)
55
- begin
56
- #puts "Attempting to require #{dep}"
57
- require dep
58
- rescue LoadError => e
59
- #puts "Caught error: #{e.message}"
60
- if dep.include?('-')
61
- begin
62
- if dep.respond_to? :name
63
- namespaced_file = dep.name.gsub('-', '/')
64
- else
65
- # try to load unresolved deps
66
- namespaced_file = dep.gsub('-', '/')
67
- end
68
- #puts "Munged the name, now trying to require as #{namespaced_file}"
69
- require namespaced_file
70
- rescue LoadError => e2
71
- strict_error "Gem loading error: #{e2.message}"
72
- end
73
- else
74
- strict_error "Gem loading error: #{e.message}"
75
- end
76
- end
77
- end
78
- end
79
-
80
- def self.output
81
- ENV['BUNDLER_STDERR'] || $stderr
82
- end
83
- end
84
- end
85
- end
@@ -1,21 +0,0 @@
1
- #
2
- # Copyright 2011 Red Hat, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- module Aeolus
18
- module Ext
19
- VERSION = '0.2.0'
20
- end
21
- end
@@ -1,97 +0,0 @@
1
- #
2
- # Copyright 2011 Red Hat, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
- require 'bundler_ext_helper'
17
-
18
- module Aeolus
19
- module Ext
20
- describe BundlerExt do
21
- before(:each) do
22
- @gemfile = 'spec/fixtures/Gemfile.in'
23
- end
24
- after(:each) do
25
- ENV['BUNDLER_EXT_NOSTRICT'] = nil
26
- ENV['BUNDLER_EXT_GROUPS'] = nil
27
- end
28
-
29
- describe "#parse_from_gemfile" do
30
- describe "with no group passed in" do
31
- it "should return nothing to require" do
32
- libs = BundlerExt.parse_from_gemfile(@gemfile)
33
- libs.should be_an(Array)
34
- libs.should_not include('deltacloud')
35
- libs.should_not include('vcr')
36
- end
37
- end
38
- describe "with :all passed in" do
39
- it "should return the list of system libraries in all groups to require" do
40
- libs = BundlerExt.parse_from_gemfile(@gemfile, :all)
41
- libs.should be_an(Array)
42
- libs.should include('deltacloud')
43
- libs.should include('vcr')
44
- end
45
- end
46
- describe "with group passed in" do
47
- it "should not return any deps that are not in the 'development' group" do
48
- libs = BundlerExt.parse_from_gemfile(@gemfile,'development')
49
- libs.should be_an(Array)
50
- libs.should_not include('deltacloud')
51
- end
52
- it "should return only deps that are in the :test group" do
53
- libs = BundlerExt.parse_from_gemfile(@gemfile, :test)
54
- libs.should be_an(Array)
55
- libs.should_not include('deltacloud')
56
- libs.should include('vcr')
57
- end
58
- it "should return deps from both the :default and :test groups" do
59
- libs = BundlerExt.parse_from_gemfile(@gemfile, :default, :test)
60
- libs.should be_an(Array)
61
- libs.should include('deltacloud')
62
- libs.should include('vcr')
63
- end
64
- end
65
- it "should only return deps for the current platform" do
66
- libs = BundlerExt.parse_from_gemfile(@gemfile)
67
- libs.should be_an(Array)
68
- if RUBY_VERSION < "1.9"
69
- libs.should_not include('cinch')
70
- else
71
- libs.should_not include('fastercsv')
72
- end
73
- end
74
- end
75
- describe "#system_require" do
76
- it "strict mode should fail loading non existing gem" do
77
- expect { BundlerExt.system_require(@gemfile, :fail) }.to raise_error
78
- end
79
- it "non-strict mode should load the libraries in the gemfile" do
80
- ENV['BUNDLER_EXT_NOSTRICT'] = 'true'
81
- BundlerExt.system_require(@gemfile)
82
- defined?(Gem).should be_true
83
- end
84
- it "non-strict mode should load the libraries in the gemfile" do
85
- ENV['BUNDLER_EXT_NOSTRICT'] = 'true'
86
- BundlerExt.system_require(@gemfile, :fail)
87
- defined?(Gem).should be_true
88
- end
89
- it "non-strict mode should load the libraries using env var list" do
90
- ENV['BUNDLER_EXT_GROUPS'] = 'test development blah'
91
- ENV['BUNDLER_EXT_NOSTRICT'] = 'true'
92
- defined?(Gem::Command).should be_true
93
- end
94
- end
95
- end
96
- end
97
- end
@@ -1,17 +0,0 @@
1
- #
2
- # Copyright 2011 Red Hat, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
- #require File.expand_path("../../bundler_ext", __FILE__)
17
- require 'aeolus/ext'