Class: Bundler::Plugin::DSL
Overview
Dsl to parse the Gemfile looking for plugins to install
Defined Under Namespace
Classes: PluginGemfileError
Constant Summary
Constants inherited from Dsl
Dsl::GITHUB_PULL_REQUEST_URL, Dsl::GITLAB_MERGE_REQUEST_URL, Dsl::VALID_KEYS, Dsl::VALID_PLATFORMS
Instance Attribute Summary collapse
-
#inferred_plugins ⇒ Object
readonly
This lists the plugins that was added automatically and not specified by the user.
Attributes inherited from Dsl
#dependencies, #gemfile, #gemspecs
Instance Method Summary collapse
-
#initialize ⇒ DSL
constructor
A new instance of DSL.
- #method_missing(name, *args) ⇒ Object
- #plugin(name, *args) ⇒ Object
- #source(source, *args, &blk) ⇒ Object
Methods inherited from Dsl
#check_primary_source_safety, #env, #eval_gemfile, evaluate, #gem, #gemspec, #git, #git_source, #github, #group, #install_if, #path, #platforms, #to_definition
Methods included from RubyDsl
Constructor Details
#initialize ⇒ DSL
Returns a new instance of DSL.
25 26 27 28 29 |
# File 'lib/bundler/plugin/dsl.rb', line 25 def initialize super @sources = Plugin::SourceList.new @inferred_plugins = [] # The source plugins inferred from :type end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
35 36 37 |
# File 'lib/bundler/plugin/dsl.rb', line 35 def method_missing(name, *args) raise PluginGemfileError, "Undefined local variable or method `#{name}' for Gemfile" unless Bundler::Dsl.method_defined? name end |
Instance Attribute Details
#inferred_plugins ⇒ Object (readonly)
This lists the plugins that was added automatically and not specified by the user.
When we encounter :type attribute with a source block, we add a plugin by name bundler-source-<type> to list of plugins to be installed.
These plugins are optional and are not installed when there is conflict with any other plugin.
23 24 25 |
# File 'lib/bundler/plugin/dsl.rb', line 23 def inferred_plugins @inferred_plugins end |
Instance Method Details
#plugin(name, *args) ⇒ Object
31 32 33 |
# File 'lib/bundler/plugin/dsl.rb', line 31 def plugin(name, *args) _gem(name, *args) end |
#source(source, *args, &blk) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bundler/plugin/dsl.rb', line 39 def source(source, *args, &blk) = args.last.is_a?(Hash) ? args.pop.dup : {} = normalize_hash() return super unless .key?("type") plugin_name = "bundler-source-#{["type"]}" return if @dependencies.any? {|d| d.name == plugin_name } plugin(plugin_name) @inferred_plugins << plugin_name end |