bezel 0.1.0 → 0.2.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/.ruby ADDED
@@ -0,0 +1,66 @@
1
+ ---
2
+ source:
3
+ - meta
4
+ authors:
5
+ - name: trans
6
+ email: transfire@gmail.com
7
+ copyrights:
8
+ - holder: Rubyworks
9
+ year: '2010'
10
+ license: BSD-2-Clause
11
+ requirements:
12
+ - name: finder
13
+ version: 0.3~
14
+ - name: detroit
15
+ groups:
16
+ - build
17
+ development: true
18
+ - name: qed
19
+ groups:
20
+ - test
21
+ development: true
22
+ - name: ae
23
+ groups:
24
+ - test
25
+ development: true
26
+ - name: ansi
27
+ version: 1.4.2
28
+ groups:
29
+ - test
30
+ development: true
31
+ dependencies: []
32
+ alternatives: []
33
+ conflicts: []
34
+ repositories:
35
+ - uri: git://github.com/proutils/bezel.git
36
+ scm: git
37
+ name: upstream
38
+ resources:
39
+ - uri: http://rubyworks.github.com/bezel
40
+ label: Website
41
+ type: home
42
+ - uri: http://github.com/rubyworks/bezel
43
+ label: Source Code
44
+ type: code
45
+ - uri: http://github.com/rubyworks/bezel/issues
46
+ label: Issue Tracker
47
+ type: bugs
48
+ - uri: http://groups.google.com/groups/rubyworks-mailinglist
49
+ label: Mailing List
50
+ type: mail
51
+ - uri: irc://us.chat.freenode.net/rubyworks
52
+ label: IRC Channel
53
+ type: chat
54
+ categories: []
55
+ extra: {}
56
+ load_path:
57
+ - lib
58
+ revision: 0
59
+ name: bezel
60
+ title: Bezel
61
+ organization: Rubyworks
62
+ created: '2010-02-19'
63
+ summary: Alternate loading system for Ruby allowing version multiplicity.
64
+ version: 0.2.0
65
+ description: Alternate loading system for Ruby allowing version multiplicity.
66
+ date: '2012-05-23'
data/DEMO.md ADDED
@@ -0,0 +1,101 @@
1
+ = Bezel
2
+
3
+ First Bezel must be loaded. This has been done via the applique.
4
+ It will also load RubyGems as Bezel currently uses the +Gem.path+
5
+ to locate Ruby libraries. We also use a dummy Gem location for
6
+ this example (see +fixtures+).
7
+
8
+ Now we can try it out. The dummy gem location houses two libraries
9
+ of the same name but different versions.
10
+
11
+ module Example1
12
+ TryMe = lib('tryme', '1.0')
13
+ end
14
+
15
+ TryMe has a class method called #report and we should see that
16
+ it works as expected.
17
+
18
+ Example1::TryMe.report.assert == "You are using version 1.0!"
19
+
20
+ It also imports a method called #extra from a seperate file.
21
+
22
+ Example1::TryMe.extra.assert == "Something extra from version 1.0!"
23
+
24
+ Now we should be able to do the same for TryMe v1.1 without any
25
+ issues of interference between the two versions.
26
+
27
+ module Example2
28
+ TryMe = lib('tryme', '1.1')
29
+ end
30
+
31
+ Again we should see that the #report method works as expected, but this
32
+ time reported form the new version.
33
+
34
+ Example2::TryMe.report.assert == "You are using version 1.1!"
35
+
36
+ And that it also imports a method called #extra from a seperate file.
37
+
38
+ Example2::TryMe.extra.assert == "Something extra from version 1.1!"
39
+
40
+ Just to be sure, let try v1.0 again.
41
+
42
+ Example1::TryMe.report.assert == "You are using version 1.0!"
43
+ Example1::TryMe.extra.assert == "Something extra from version 1.0!"
44
+
45
+ That's all folks!
46
+
47
+
48
+ = ANSI Example
49
+
50
+ require 'bezel'
51
+
52
+ ANSI_VERSION = '1.4.2'
53
+
54
+ class ColorfulString
55
+ X = lib('ansi', ANSI_VERSION)
56
+ #include x
57
+
58
+ COLORS = [:red, :yellow, :green, :blue, :magenta]
59
+
60
+ def initialize(string)
61
+ @string = string
62
+ reset_colors
63
+ end
64
+
65
+ def to_s
66
+ s = ""
67
+ @string.split(//).each do |c|
68
+ s << X::ANSI::Code.send(next_color) + c;
69
+ end
70
+ s << X::ANSI::Code::CLEAR
71
+ reset_colors
72
+ return s
73
+ end
74
+
75
+ def next_color
76
+ color = @colors.shift
77
+ @colors << color
78
+ color
79
+ end
80
+
81
+ def reset_colors
82
+ @colors = COLORS.dup
83
+ end
84
+ end
85
+
86
+ Then
87
+
88
+ cs = ColorfulString.new("Hello World!")
89
+
90
+ #puts cs
91
+
92
+ cs.to_s.assert == "\e[31mH\e[33me\e[32ml\e[34ml\e[35mo\e[31m \e[33mW\e[32mo\e[34mr\e[35ml\e[31md\e[33m!\e[0m"
93
+
94
+ ANSI 1.2.6+ has been fine-tuned to work with Bezel. So even core extensions
95
+ work.
96
+
97
+ red = "How about this!".ansi(:red)
98
+
99
+ red.assert == "\e[31mHow about this!\e[0m"
100
+
101
+
@@ -0,0 +1,26 @@
1
+ = RELEASE HISTORY
2
+
3
+ == 0.2.0 / 2012-05-23
4
+
5
+ New release finally address a number of important issues.
6
+ You can think of this release as a "beta" release, in that
7
+ it is *almost* suitable for general use. The next release
8
+ should provide the final polish for production usage.
9
+
10
+ Changes:
11
+
12
+ * Add development mode to always use latest version.
13
+ * Depend on Finder gem for feature lookup.
14
+ * No longer need to use #import for internal #require.
15
+
16
+
17
+ == 0.1.0 / 2010-02-19
18
+
19
+ This is an alpha release of Bezel, an alternate load
20
+ system for Ruby, just to put it out there and get
21
+ some feedback.
22
+
23
+ Changes:
24
+
25
+ * Happy Birthday!
26
+
@@ -0,0 +1,23 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010 Thomas Sawyer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+
@@ -0,0 +1,76 @@
1
+ # Bezel
2
+
3
+
4
+ ## DESCRIPTION
5
+
6
+ The idea of Bezel is to overcome the limitations of using different
7
+ versions of the same package in the same Ruby process.
8
+
9
+
10
+ ## RESOURCES
11
+
12
+ * home: http://proutils.github.com/bezel
13
+ * work: http://github.com/proutils/bezel
14
+ * mail: http://googlegroups.com/group/rubyworks-mailinglist
15
+ * chat: irc://chat.us.freenode.net/rubyworks
16
+
17
+
18
+ ## USAGE
19
+
20
+ It works like this. Let's say I wrote a library called TomsLib. Now I
21
+ want to use TomsLib in my new fancy app, FancyApp. In my FancyApp
22
+ namespace I have to create a reference to TomsLib.
23
+
24
+ module FancyApp
25
+ TomsLib = lib('tomslib', '1.5')
26
+ ...
27
+
28
+ Now I have access to TomsLib, but it is localized to my application.
29
+ If Jane comes along and wants to use a different version of TomsLib
30
+ but also utilizes my FancyApp, she could do so:
31
+
32
+ module JanesProgram
33
+ TomsLib = lib('tomslib', '1.0')
34
+ FancyApp = lib('fancyapp') # use newest available
35
+ ...
36
+
37
+ How does this work? When you call lib(), Bezel looks for the package
38
+ in the current Gem paths (and in the future, Roll ledger) then it
39
+ reads the primary package file (eg. tomslib.rb) from the package and
40
+ evals it into an anonymous module.
41
+
42
+ This has a some important effects on how you write your Ruby programs:
43
+
44
+ 1. Any reference to core/standard libraries must be referenced via '::'
45
+ prefix (eg. ::Enumerable).
46
+
47
+ 2. Core extensions are not version isolated. So when possible, avoid them
48
+ or depend on highly stable standardized bases such as Ruby Facets
49
+ and ActiveSupport.
50
+
51
+ 3. Since Bezel is a completely different alternative to Ruby's normal
52
+ load system, your program will require Bezel be installed by your
53
+ users. No big deal. In other words, list it into your projects dependencies.
54
+
55
+ 4. A project's main require file must be the same as the library's name.
56
+
57
+ Despite these necessary practices for its use, Bezel is highly advantageous
58
+ to the developers and end-users alike in that it puts an *absolute* end to
59
+ the dreaded *Dependency Hell*.
60
+
61
+
62
+ ## STATUS
63
+
64
+ It may not be possible to test Bezel via Travis CI because of the way the tests
65
+ change the GEM_HOME. Currently they fail because of this, even though they pass
66
+ on local development machine. We'll leave this for now in hopes we will get it
67
+ working at some point:
68
+ [![Build Status](https://secure.travis-ci.org/rubyworks/bezel.png)](http://travis-ci.org/rubyworks/bezel)
69
+
70
+
71
+ ## LICENSE
72
+
73
+ Copyright (c) 2009 Thomas Sawyer
74
+
75
+ Bezel is distributed under the same terms as Ruby 1.9+, namely the
76
+ BSD 2-clause license.
@@ -1,16 +1,11 @@
1
1
  = Bezel
2
2
 
3
- First Bezel must be loaded, of course. This will also load
4
- RubyGems as Bezel presently uses the +Gem.path+ to locate
5
- Ruby libraries.
3
+ First Bezel must be loaded. This has been done via the applique.
4
+ It will also load RubyGems as Bezel currently uses the +Gem.path+
5
+ to locate Ruby libraries. We also use a dummy Gem location for
6
+ this example (see +fixtures+).
6
7
 
7
- require 'bezel'
8
-
9
- We are going to use a dummy Gem location for this example.
10
-
11
- Gem.path.unshift(File.expand_path('../fixtures'))
12
-
13
- Now we can try it out. The dummy location houses two libraries
8
+ Now we can try it out. The dummy gem location houses two libraries
14
9
  of the same name but different versions.
15
10
 
16
11
  module Example1
@@ -27,7 +22,7 @@ It also imports a method called #extra from a seperate file.
27
22
  Example1::TryMe.extra.assert == "Something extra from version 1.0!"
28
23
 
29
24
  Now we should be able to do the same for TryMe v1.1 without any
30
- issues of interference betwee the two versions.
25
+ issues of interference between the two versions.
31
26
 
32
27
  module Example2
33
28
  TryMe = lib('tryme', '1.1')
@@ -42,5 +37,10 @@ And that it also imports a method called #extra from a seperate file.
42
37
 
43
38
  Example2::TryMe.extra.assert == "Something extra from version 1.1!"
44
39
 
40
+ Just to be sure, let try v1.0 again.
41
+
42
+ Example1::TryMe.report.assert == "You are using version 1.0!"
43
+ Example1::TryMe.extra.assert == "Something extra from version 1.0!"
44
+
45
45
  That's all folks!
46
46
 
@@ -0,0 +1,53 @@
1
+ = ANSI Example
2
+
3
+ require 'bezel'
4
+
5
+ ANSI_VERSION = '1.4.2'
6
+
7
+ class ColorfulString
8
+ X = lib('ansi', ANSI_VERSION)
9
+ #include x
10
+
11
+ COLORS = [:red, :yellow, :green, :blue, :magenta]
12
+
13
+ def initialize(string)
14
+ @string = string
15
+ reset_colors
16
+ end
17
+
18
+ def to_s
19
+ s = ""
20
+ @string.split(//).each do |c|
21
+ s << X::ANSI::Code.send(next_color) + c;
22
+ end
23
+ s << X::ANSI::Code::CLEAR
24
+ reset_colors
25
+ return s
26
+ end
27
+
28
+ def next_color
29
+ color = @colors.shift
30
+ @colors << color
31
+ color
32
+ end
33
+
34
+ def reset_colors
35
+ @colors = COLORS.dup
36
+ end
37
+ end
38
+
39
+ Then
40
+
41
+ cs = ColorfulString.new("Hello World!")
42
+
43
+ #puts cs
44
+
45
+ cs.to_s.assert == "\e[31mH\e[33me\e[32ml\e[34ml\e[35mo\e[31m \e[33mW\e[32mo\e[34mr\e[35ml\e[31md\e[33m!\e[0m"
46
+
47
+ ANSI 1.2.6+ has been fine-tuned to work with Bezel. So even core extensions
48
+ work.
49
+
50
+ red = "How about this!".ansi(:red)
51
+
52
+ red.assert == "\e[31mHow about this!\e[0m"
53
+
@@ -0,0 +1 @@
1
+ require 'ae'
@@ -0,0 +1,14 @@
1
+ # Use a dummy Gem location for this example.
2
+ dummy_gem_home = File.expand_path('../fixtures', File.dirname(__FILE__))
3
+
4
+ ENV['GEM_HOME'] = dummy_gem_home
5
+ Gem.path.unshift(dummy_gem_home)
6
+
7
+ Gem::Specification.reset
8
+
9
+ #p Gem::Specification.all_names
10
+ #puts "Gem path added: #{dummy_gem_home}"
11
+
12
+ # Require Bezel
13
+ require 'bezel'
14
+
@@ -0,0 +1 @@
1
+ import 'tryme'
@@ -6,6 +6,6 @@ def self.report
6
6
  "You are using version #{VERSION}!"
7
7
  end
8
8
 
9
- import("extra.rb")
9
+ require "tryme/extra"
10
10
 
11
11
 
@@ -0,0 +1 @@
1
+ import 'tryme'
@@ -6,5 +6,5 @@ def self.report
6
6
  "You are using version #{VERSION}!"
7
7
  end
8
8
 
9
- import("extra.rb")
9
+ require "tryme/extra.rb"
10
10
 
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{tryme}
5
+ s.version = "1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = [%q{trans}]
9
+ s.date = %q{2012-05-21}
10
+ s.description = %q{TryMe is a dummy gem for testing purposes.}
11
+ s.email = [%q{trans@transfire@gmail.com}]
12
+ s.homepage = %q{http://github.com/rubyworks/bezel}
13
+ s.require_paths = [%q{lib}]
14
+ s.rubygems_version = %q{1.8.5}
15
+ s.summary = %q{Dummy gem for testing.}
16
+
17
+ if s.respond_to? :specification_version then
18
+ s.specification_version = 3
19
+
20
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
21
+ else
22
+ end
23
+ else
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{tryme}
5
+ s.version = "1.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = [%q{trans}]
9
+ s.date = %q{2012-05-22}
10
+ s.description = %q{TryMe is a dummy gem for testing purposes.}
11
+ s.email = [%q{trans@transfire@gmail.com}]
12
+ s.homepage = %q{http://github.com/rubyworks/bezel}
13
+ s.require_paths = [%q{lib}]
14
+ s.rubygems_version = %q{1.8.5}
15
+ s.summary = %q{Dummy gem for testing.}
16
+
17
+ if s.respond_to? :specification_version then
18
+ s.specification_version = 3
19
+
20
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
21
+ else
22
+ end
23
+ else
24
+ end
25
+ end
@@ -20,15 +20,15 @@
20
20
  # FancyApp = lib('fancyapp') # use newest available
21
21
  # ...
22
22
  #
23
- # How does this work? When you call library(), Bezel looks for
24
- # the package in the current gem paths (and, in the future, Roll ledger)
25
- # then it reads the primary package file (eg. tomslib.rb) fro the package
23
+ # How does this work? When you call lib(), Bezel looks for the
24
+ # package in the current gem paths (and, in the future, Roll ledger)
25
+ # then it reads the bezel file (e.g. lib/tomslib.rbz) from the package
26
26
  # and evals it into an anonymous module.
27
27
  #
28
28
  # This has a some important effects on how you write your Ruby programs:
29
29
  #
30
30
  # 1. Any reference to core/standard libraries must be referenced via
31
- # :: prefix (eg. ::Enumerable).
31
+ # toplevel `::` prefix (eg. ::Enumerable).
32
32
  #
33
33
  # 2. Core extensions are not version controlled. So avoid them when
34
34
  # possible, or depend on highly stable standardized bases such as
@@ -38,46 +38,85 @@
38
38
  # load system, your program will require Bezel be installed by your
39
39
  # users.
40
40
  #
41
- # Despite the limitations and necessary practices required for its use
42
- # Bezel is highly advantageous to the developers and end-users alike
43
- # in that it puts an end to the dreaded Dependency Hell.
41
+ # Despite these necessary practices for its use, Bezel is highly advantageous
42
+ # to developers and end-users alike in that it puts an end to the dreaded
43
+ # Dependency Hell.
44
44
  #
45
+ # TODO: Consider how best to support alternate loadpaths beyond 'lib/'.
46
+
45
47
  class Bezel < Module
46
- require 'rubygems'
48
+ require 'finder'
47
49
 
48
50
  # Cache of loaded modules. This speeds things
49
51
  # up if two libraries load the same third library.
50
- TABLE = Hash.new{|h,k|h[k]={}}
52
+ TABLE = Hash.new #{|h,k|h[k]={}}
53
+
54
+ # Script cache.
55
+ SCRIPT = {}
51
56
 
52
57
  # Load stack keeps track of what modules are in the process
53
58
  # of being loaded.
54
59
  STACK = []
55
60
 
56
- #
57
- def self.gem_paths
58
- @gem_paths ||= (
59
- Gem.path.map do |dir|
60
- Dir[File.join(dir, 'gems', '*')]
61
- end.flatten
62
- )
61
+ # When in development mode, Bezel uses the latest and greatest
62
+ # available version regardless of version settings.
63
+ def self.development=(boolean)
64
+ @development = !!boolean
63
65
  end
64
66
 
65
67
  #
66
- def self.select(name)
67
- gem_paths.select do |path|
68
- File.basename(path) =~ /^#{name}-/
69
- end
68
+ def self.development?
69
+ @development
70
+ end
71
+
72
+ # Load library into a module namespace.
73
+ def self.lib(name, version=nil)
74
+ version = nil if development?
75
+
76
+ ##path = find(name, version)
77
+ ##raise LoadError, "#{name}-#{version} not found" unless path
78
+ ## location of main requirement file
79
+ ## TODO: should we require a dedicated bezel file instead? e.g. `*.rbz`.
80
+ #main = File.join(path, 'lib', name + '.rb') #.rbz #TODO: LOADPATH
81
+
82
+ main = Find.feature(name, :from=>name, :version=>version, :absolute=>true).first
83
+
84
+ ## check cache
85
+ return TABLE[main] if TABLE.key?(main)
86
+
87
+ ## load error if no bezel file
88
+ raise LoadError, "#{name}-#{version} has no bezel!" unless main && File.exist?(main)
89
+
90
+ ## read in bezel file
91
+ #script = File.read(main)
92
+
93
+ ## create new Bezel module for file
94
+ mod = new(name, version) #, main)
95
+
96
+ ## put module on STACK
97
+ STACK.push mod
98
+
99
+ ## evaluate script in the context of module
100
+ #mod.module_eval(script, main, 0) # r =
101
+ mod.__load_feature__(main)
102
+
103
+ ## pop module off STACK
104
+ STACK.pop
105
+
106
+ ## add module to cache, and return module
107
+ TABLE[main] = mod
70
108
  end
71
109
 
72
110
  #
73
- def self.find(name, version=nil)
74
- if version
75
- basename = "#{name}-#{version}"
76
- select(name).find do |path|
77
- File.basename(path) == basename
111
+ def self.require(path)
112
+ if current = STACK.last
113
+ begin
114
+ current.__load_feature__(path) ? true : false
115
+ rescue LoadError
116
+ require_without_bezel(path)
78
117
  end
79
118
  else
80
- select(name).max
119
+ require_without_bezel(path)
81
120
  end
82
121
  end
83
122
 
@@ -87,44 +126,82 @@ class Bezel < Module
87
126
  # File.join(path, 'lib', name + '.rb')
88
127
  #end
89
128
 
90
- #
91
- def initialize(name, path)
92
- @__name__ = name
93
- @__path__ = path
129
+ # Construct new Bezel module.
130
+ def initialize(name, version) #, path)
131
+ @__name__ = name
132
+ @__version__ = version
133
+ #@__path__ = path
134
+ @__features__ = []
135
+ super()
94
136
  end
95
137
 
138
+ # Name of library.
96
139
  def __name__
97
140
  @__name__
98
141
  end
99
142
 
100
- def __path__
101
- @__path__
143
+ # Version of library.
144
+ def __version__
145
+ @__version__
102
146
  end
103
147
 
104
- end
105
-
106
- #
107
- def lib(name, version=nil)
108
- path = Bezel.find(name, version)
109
- main = File.join(path, 'lib', name + '.rb')
148
+ # Path to library.
149
+ #def __path__
150
+ # @__path__
151
+ #end
110
152
 
111
- return Bezel::TABLE[main] if Bezel::TABLE.key?(main)
153
+ #
154
+ def __features__
155
+ @__features__
156
+ end
112
157
 
113
- mod = Bezel.new(name, path)
158
+ #
159
+ def __load_feature__(path)
160
+ if path =~ /^[\.\/]/ # if absolute path
161
+ file = File.expand_path(path)
162
+ else
163
+ file = Find.feature(path, :from=>__name__, :version=>__version__, :absolute=>true).first
164
+ end
114
165
 
115
- Bezel::STACK << mod
166
+ raise LoadError, "no such file to load -- #{file}" unless file
116
167
 
117
- mod.module_eval(File.read(main), main, 0)
168
+ if __features__.include?(file)
169
+ return false
170
+ else
171
+ __features__ << file
172
+ script = File.read(file) #(SCRIPT[file] ||= File.read(file))
173
+ module_eval(script, file, 0)
174
+ end
118
175
 
119
- Bezel::STACK.pop
176
+ return file
177
+ end
120
178
 
121
- Bezel::TABLE[main] = mod
122
179
  end
123
180
 
124
- # When using Bezel, rather than use #require or #load, you use #import.
125
- def import(fname)
126
- mod = Bezel::STACK.last
127
- file = File.join(mod.__path__, 'lib', mod.__name__, fname)
128
- mod.module_eval(File.read(file), file, 0)
181
+ module Kernel
182
+ # TODO require_relative
183
+
184
+ class << self
185
+ # Alias original require.
186
+ alias require_without_bezel require
187
+
188
+ # Override require to try bezel first.
189
+ def require(fname)
190
+ Bezel.require(fname)
191
+ end
192
+ end
193
+
194
+ # Alias original require.
195
+ alias require_without_bezel require
196
+
197
+ # Override require to try bezel first.
198
+ def require(fname)
199
+ Bezel.require(fname)
200
+ end
201
+
202
+ # Retuns a new Bezel Module.
203
+ def lib(name, version=nil)
204
+ Bezel.lib(name, version)
205
+ end
129
206
  end
130
207
 
@@ -0,0 +1,66 @@
1
+ ---
2
+ source:
3
+ - meta
4
+ authors:
5
+ - name: trans
6
+ email: transfire@gmail.com
7
+ copyrights:
8
+ - holder: Rubyworks
9
+ year: '2010'
10
+ license: BSD-2-Clause
11
+ requirements:
12
+ - name: finder
13
+ version: 0.3~
14
+ - name: detroit
15
+ groups:
16
+ - build
17
+ development: true
18
+ - name: qed
19
+ groups:
20
+ - test
21
+ development: true
22
+ - name: ae
23
+ groups:
24
+ - test
25
+ development: true
26
+ - name: ansi
27
+ version: 1.4.2
28
+ groups:
29
+ - test
30
+ development: true
31
+ dependencies: []
32
+ alternatives: []
33
+ conflicts: []
34
+ repositories:
35
+ - uri: git://github.com/proutils/bezel.git
36
+ scm: git
37
+ name: upstream
38
+ resources:
39
+ - uri: http://rubyworks.github.com/bezel
40
+ label: Website
41
+ type: home
42
+ - uri: http://github.com/rubyworks/bezel
43
+ label: Source Code
44
+ type: code
45
+ - uri: http://github.com/rubyworks/bezel/issues
46
+ label: Issue Tracker
47
+ type: bugs
48
+ - uri: http://groups.google.com/groups/rubyworks-mailinglist
49
+ label: Mailing List
50
+ type: mail
51
+ - uri: irc://us.chat.freenode.net/rubyworks
52
+ label: IRC Channel
53
+ type: chat
54
+ categories: []
55
+ extra: {}
56
+ load_path:
57
+ - lib
58
+ revision: 0
59
+ name: bezel
60
+ title: Bezel
61
+ organization: Rubyworks
62
+ created: '2010-02-19'
63
+ summary: Alternate loading system for Ruby allowing version multiplicity.
64
+ version: 0.2.0
65
+ description: Alternate loading system for Ruby allowing version multiplicity.
66
+ date: '2012-05-23'
metadata CHANGED
@@ -1,80 +1,124 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bezel
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 0
9
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors: []
12
-
7
+ authors:
8
+ - trans
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-02-19 00:00:00 -05:00
18
- default_executable:
19
- dependencies: []
20
-
21
- description: ""
22
- email:
12
+ date: 2012-05-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: finder
16
+ requirement: &21356920 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.3'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *21356920
25
+ - !ruby/object:Gem::Dependency
26
+ name: detroit
27
+ requirement: &21356440 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *21356440
36
+ - !ruby/object:Gem::Dependency
37
+ name: qed
38
+ requirement: &21372260 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *21372260
47
+ - !ruby/object:Gem::Dependency
48
+ name: ae
49
+ requirement: &21371740 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *21371740
58
+ - !ruby/object:Gem::Dependency
59
+ name: ansi
60
+ requirement: &21371180 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - =
64
+ - !ruby/object:Gem::Version
65
+ version: 1.4.2
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *21371180
69
+ description: Alternate loading system for Ruby allowing version multiplicity.
70
+ email:
71
+ - transfire@gmail.com
23
72
  executables: []
24
-
25
73
  extensions: []
26
-
27
- extra_rdoc_files:
28
- - README
29
- files:
30
- - HISTORY
31
- - MANIFEST
32
- - README
74
+ extra_rdoc_files:
75
+ - LICENSE.txt
76
+ - HISTORY.rdoc
77
+ - README.md
78
+ - DEMO.md
79
+ files:
80
+ - .ruby
81
+ - demo/01_example.rdoc
82
+ - demo/02_example.rdoc
83
+ - demo/applique/ae.rb
84
+ - demo/applique/bezel.rb
85
+ - demo/fixtures/gems/tryme-1.0/lib/tryme/extra.rb
86
+ - demo/fixtures/gems/tryme-1.0/lib/tryme.bezel
87
+ - demo/fixtures/gems/tryme-1.0/lib/tryme.rb
88
+ - demo/fixtures/gems/tryme-1.1/lib/tryme/extra.rb
89
+ - demo/fixtures/gems/tryme-1.1/lib/tryme.bezel
90
+ - demo/fixtures/gems/tryme-1.1/lib/tryme.rb
91
+ - demo/fixtures/specifications/tryme-1.0.gemspec
92
+ - demo/fixtures/specifications/tryme-1.1.gemspec
33
93
  - lib/bezel.rb
34
- - meta/homepage
35
- - meta/name
36
- - meta/ruby
37
- - meta/suite
38
- - meta/summary
39
- - meta/title
40
- - meta/version
41
- - test/demos/01_example.rdoc
42
- - test/fixtures/gems/tryme-1.0/lib/tryme.rb
43
- - test/fixtures/gems/tryme-1.0/lib/tryme/extra.rb
44
- - test/fixtures/gems/tryme-1.1/lib/tryme.rb
45
- - test/fixtures/gems/tryme-1.1/lib/tryme/extra.rb
46
- has_rdoc: true
47
- homepage: http://proutils.github.com/bezel
48
- licenses: []
49
-
94
+ - lib/bezel.yml
95
+ - HISTORY.rdoc
96
+ - LICENSE.txt
97
+ - README.md
98
+ - DEMO.md
99
+ homepage: http://rubyworks.github.com/bezel
100
+ licenses:
101
+ - BSD-2-Clause
50
102
  post_install_message:
51
- rdoc_options:
52
- - --title
53
- - Bezel API
54
- - --main
55
- - README
56
- require_paths:
103
+ rdoc_options: []
104
+ require_paths:
57
105
  - lib
58
- required_ruby_version: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- segments:
63
- - 0
64
- version: "0"
65
- required_rubygems_version: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- segments:
70
- - 0
71
- version: "0"
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
72
118
  requirements: []
73
-
74
- rubyforge_project: bezel
75
- rubygems_version: 1.3.6.pre.3
119
+ rubyforge_project:
120
+ rubygems_version: 1.8.11
76
121
  signing_key:
77
122
  specification_version: 3
78
123
  summary: Alternate loading system for Ruby allowing version multiplicity.
79
124
  test_files: []
80
-
data/HISTORY DELETED
@@ -1,12 +0,0 @@
1
- = Release History
2
-
3
- == 0.1.0 / 2010-02-19
4
-
5
- This is an alpha release of Bezel, an alternate load
6
- system for Ruby, just to put it out there and get
7
- some feedback.
8
-
9
- Changes:
10
-
11
- * Happy Frakn Birthday!
12
-
data/MANIFEST DELETED
@@ -1,25 +0,0 @@
1
- HISTORY
2
- MANIFEST
3
- README
4
- lib/bezel.rb
5
- meta/homepage
6
- meta/name
7
- meta/ruby
8
- meta/suite
9
- meta/summary
10
- meta/title
11
- meta/version
12
- test/demos
13
- test/demos/01_example.rdoc
14
- test/fixtures
15
- test/fixtures/gems
16
- test/fixtures/gems/tryme-1.0
17
- test/fixtures/gems/tryme-1.0/lib
18
- test/fixtures/gems/tryme-1.0/lib/tryme
19
- test/fixtures/gems/tryme-1.0/lib/tryme.rb
20
- test/fixtures/gems/tryme-1.0/lib/tryme/extra.rb
21
- test/fixtures/gems/tryme-1.1
22
- test/fixtures/gems/tryme-1.1/lib
23
- test/fixtures/gems/tryme-1.1/lib/tryme
24
- test/fixtures/gems/tryme-1.1/lib/tryme.rb
25
- test/fixtures/gems/tryme-1.1/lib/tryme/extra.rb
data/README DELETED
@@ -1,60 +0,0 @@
1
- = Bezel
2
-
3
- * home: http://proutils.github.com/bezel
4
- * work: http://github.com/proutils/bezel
5
-
6
- == DESCRIPTION
7
-
8
- The idea of Bezel is to overcome the limitations of using different
9
- versions of the same package in the same Ruby process.
10
-
11
- == USAGE
12
-
13
- It works like this. Let's say I wrote a library called TomsLib. Now I
14
- want to use TomsLib in my new fancy app, FancyApp. In my FancyApp
15
- namespace I have to create a reference to TomsLib.
16
-
17
- module FancyApp
18
- TomsLib = lib('tomslib', '1.5')
19
- ...
20
-
21
- Now I have access to TomsLib, but it is localized to my application.
22
- If Jane comes along and wants to use a different version of TomsLib
23
- but also utilizes my FancyApp, she could do so:
24
-
25
- module JanesProgram
26
- TomsLib = lib('tomslib', '1.0')
27
- FancyApp = lib('fancyapp') # use newest available
28
- ...
29
-
30
- How does this work? When you call lib(), Bezel looks for the package
31
- in the current Gem paths (and in the future, Roll ledger) then it
32
- reads the primary package file (eg. tomslib.rb) from the package and
33
- evals it into an anonymous module.
34
-
35
- This has a some important effects on how you write your Ruby programs:
36
-
37
- 1. Any reference to core/standard libraries must be referenced via '::'
38
- prefix (eg. ::Enumerable).
39
-
40
- 2. Core extensions are not version isolated. So avoid them when
41
- possible, or depend on highly stable standardized bases such as
42
- Ruby Facets and ActiveSupport.
43
-
44
- 3. Since Bezel is a completely different alternative to Ruby's normal
45
- load system, your program will require Bezel be installed by your
46
- users.
47
-
48
- 4. Within Bezel dependent libraries #import must be used instead of
49
- #require or #load in order to keep the code within the current module.
50
-
51
- Despite the minor limitations and necessary practices required for its
52
- use, Bezel is highly advantageous to the developers and end-users alike
53
- in that it puts an end to the dreaded Dependency Hell.
54
-
55
- == COPYRIGHT
56
-
57
- Copyright (c) 2009 Thomas Sawyer
58
-
59
- Bezel is distributed under the terms of the Ruby License.
60
-
@@ -1 +0,0 @@
1
- http://proutils.github.com/bezel
data/meta/name DELETED
@@ -1 +0,0 @@
1
- bezel
data/meta/ruby DELETED
@@ -1 +0,0 @@
1
- 1.8.7
data/meta/suite DELETED
@@ -1 +0,0 @@
1
- proutils
@@ -1 +0,0 @@
1
- Alternate loading system for Ruby allowing version multiplicity.
data/meta/title DELETED
@@ -1 +0,0 @@
1
- Bezel
@@ -1 +0,0 @@
1
- 0.1.0