aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides
diff options
context:
space:
mode:
authorRyan Bigg <ryan@getup.org.au>2010-04-06 08:46:57 +1000
committerRyan Bigg <radarlistener@gmail.com>2010-04-09 06:48:41 +1000
commit7005e6db471ca9920ab680ce6c4fc5f0974e8cbb (patch)
treee076b5b89c7fab82dde7a7344343cfb7fb8b3cc7 /railties/guides
parent07b09bd404a39a9b2801d62fbce60416bba92ec8 (diff)
downloadrails-7005e6db471ca9920ab680ce6c4fc5f0974e8cbb.tar.gz
rails-7005e6db471ca9920ab680ce6c4fc5f0974e8cbb.tar.bz2
rails-7005e6db471ca9920ab680ce6c4fc5f0974e8cbb.zip
Further expansion into how Bundler loads the gemfile.
Diffstat (limited to 'railties/guides')
-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>
+
+