aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorRyan Bigg <ryan@getup.org.au>2010-04-06 08:46:57 +1000
committerXavier Noria <fxn@hashref.com>2010-04-09 04:49:55 -0700
commitb2a2d9f91b62564e30ab6e77a1347f51f90156f2 (patch)
tree84456685bd1966b310dd84311267fbaa50e42e1a /railties
parent5fa70e8ba96965b44a971908080e5506b495a0bd (diff)
downloadrails-b2a2d9f91b62564e30ab6e77a1347f51f90156f2.tar.gz
rails-b2a2d9f91b62564e30ab6e77a1347f51f90156f2.tar.bz2
rails-b2a2d9f91b62564e30ab6e77a1347f51f90156f2.zip
Further expansion into how Bundler loads the gemfile.
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/source/initialization.textile51
1 files changed, 49 insertions, 2 deletions
diff --git a/railties/guides/source/initialization.textile b/railties/guides/source/initialization.textile
index 2d64510c2f..1b76034f82 100644
--- a/railties/guides/source/initialization.textile
+++ b/railties/guides/source/initialization.textile
@@ -2021,7 +2021,7 @@ This sets up a couple of important things initially. If you specify a gem like t
gem 'rails', "2.3.4"
</ruby>
-This sets +options+ to be an empty hash, but +version+ to be +"2.3.4"+. TODO: How does one pass options and versions?
+This sets +options+ to be an empty hash, but +version+ to be +"2.3.4"+. TODO: How does one pass options and versions at the same time?
In the Gemfile for a default Rails project, the first +gem+ line is:
@@ -2054,7 +2054,54 @@ This line will check that +options+ contains no deprecated options by using the
end
</ruby>
-+_normalize_hash+ will convert all the keys in the +opts+ hash to strings.
++_normalize_hash+ will convert all the keys in the +opts+ hash to strings. There is neither a +git+ or a +path+ key in the +opts+ hash so the next couple of lines are ignored, then the +source+ and +group+ keys are set up.
+
+TODO: Maybe it is best to cover what would happen in the case these lines did exist?
+
+The next line goes about defining a dependency for this gem:
+
+<ruby>
+ @dependencies << Dependency.new(name, version, options)
+</ruby>
+
+This class is defined like this:
+
+<ruby>
+ module Bundler
+ class Dependency < Gem::Dependency
+ attr_reader :autorequire
+ attr_reader :groups
+
+ def initialize(name, version, options = {}, &blk)
+ super(name, version)
+
+ @autorequire = nil
+ @groups = Array(options["group"] || :default).map { |g| g.to_sym }
+ @source = options["source"]
+
+ if options.key?('require')
+ @autorequire = Array(options['require'] || [])
+ end
+ end
+ end
+ end
+</ruby>
+
+The +initialize+ method in +Gem::Dependency+ is defined:
+
+<ruby>
+ def initialize(name, version_requirements, type=:runtime)
+ @name = name
+ unless TYPES.include? type
+ raise ArgumentError, "Valid types are #{TYPES.inspect}, not #{@type.inspect}"
+ end
+ @type = type
+ @version_requirements = Gem::Requirement.create version_requirements
+ @version_requirement = nil # Avoid warnings.
+ end
+</ruby>
+
+