diff --git a/README.md b/README.md
index 58f2949..26d7e04 100644
--- a/README.md
+++ b/README.md
@@ -548,6 +548,7 @@ ruby_bundle(
gemfile_lock,
bundler_version = "2.1.4",
excludes = [],
+ vendor_cache = False,
ruby_sdk = "@org_ruby_lang_ruby_toolchain",
ruby_interpreter = "@org_ruby_lang_ruby_toolchain//:ruby",
)
@@ -589,6 +590,13 @@ ruby_bundle(
bundler_version |
@@ -627,6 +635,28 @@ ruby_bundle(
)
```
+##### Vendor directory handling
+
+To use the vendor cache, you have to declare a `managed_directory` in
+your workspace. The name should match the name of the bundle.
+
+``` bazel
+load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_bundle")
+
+workspace(
+ name = "my_wksp",
+ managed_directories = {"@bundle": ["vendor"]},
+)
+
+ruby_bundle(
+ name = "bundle",
+ bundler_version = "2.1.2",
+ vendor_cache = True,
+ gemfile = "//:Gemfile",
+ gemfile_lock = "//:Gemfile.lock",
+)
+```
+
#### `BUILD.bazel`:
```python
diff --git a/examples/simple_script_vendored/.gitignore b/examples/simple_script_vendored/.gitignore
new file mode 100644
index 0000000..a6ef824
--- /dev/null
+++ b/examples/simple_script_vendored/.gitignore
@@ -0,0 +1 @@
+/bazel-*
diff --git a/examples/simple_script_vendored/.relaxed-rubocop-2.4.yml b/examples/simple_script_vendored/.relaxed-rubocop-2.4.yml
new file mode 100644
index 0000000..fce806f
--- /dev/null
+++ b/examples/simple_script_vendored/.relaxed-rubocop-2.4.yml
@@ -0,0 +1,174 @@
+# Relaxed.Ruby.Style
+## Version 2.4
+
+Style/Alias:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylealias
+
+Style/AsciiComments:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#styleasciicomments
+
+Style/BeginBlock:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylebeginblock
+
+Style/BlockDelimiters:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#styleblockdelimiters
+
+Style/CommentAnnotation:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylecommentannotation
+
+Style/Documentation:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#styledocumentation
+
+Layout/DotPosition:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#layoutdotposition
+
+Style/DoubleNegation:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#styledoublenegation
+
+Style/EndBlock:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#styleendblock
+
+Style/FormatString:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#styleformatstring
+
+Style/IfUnlessModifier:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#styleifunlessmodifier
+
+Style/Lambda:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylelambda
+
+Style/ModuleFunction:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylemodulefunction
+
+Style/MultilineBlockChain:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylemultilineblockchain
+
+Style/NegatedIf:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylenegatedif
+
+Style/NegatedWhile:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylenegatedwhile
+
+Style/NumericPredicate:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylenumericpredicate
+
+Style/ParallelAssignment:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#styleparallelassignment
+
+Style/PercentLiteralDelimiters:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylepercentliteraldelimiters
+
+Style/PerlBackrefs:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#styleperlbackrefs
+
+Style/Semicolon:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylesemicolon
+
+Style/SignalException:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylesignalexception
+
+Style/SingleLineBlockParams:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylesinglelineblockparams
+
+Style/SingleLineMethods:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylesinglelinemethods
+
+Layout/SpaceBeforeBlockBraces:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#layoutspacebeforeblockbraces
+
+Layout/SpaceInsideParens:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#layoutspaceinsideparens
+
+Layout/LineLength:
+ Enabled: false
+
+Style/SpecialGlobalVars:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylespecialglobalvars
+
+Style/StringLiterals:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylestringliterals
+
+Style/TrailingCommaInArguments:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarguments
+
+Style/TrailingCommaInArrayLiteral:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarrayliteral
+
+Style/TrailingCommaInHashLiteral:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#styletrailingcommainhashliteral
+
+Style/SymbolArray:
+ Enabled: false
+ StyleGuide: http://relaxed.ruby.style/#stylesymbolarray
+
+Style/WhileUntilModifier:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylewhileuntilmodifier
+
+Style/WordArray:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#stylewordarray
+
+Lint/AmbiguousRegexpLiteral:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#lintambiguousregexpliteral
+
+Lint/AssignmentInCondition:
+ Enabled: false
+ StyleGuide: https://relaxed.ruby.style/#lintassignmentincondition
+
+Metrics/AbcSize:
+ Enabled: false
+
+Metrics/BlockNesting:
+ Enabled: false
+
+Metrics/ClassLength:
+ Enabled: false
+
+Metrics/ModuleLength:
+ Enabled: false
+
+Metrics/CyclomaticComplexity:
+ Enabled: false
+
+Metrics/MethodLength:
+ Enabled: false
+
+Metrics/ParameterLists:
+ Enabled: false
+
+Metrics/PerceivedComplexity:
+ Enabled: false
+
diff --git a/examples/simple_script_vendored/.rubocop.yml b/examples/simple_script_vendored/.rubocop.yml
new file mode 100644
index 0000000..7b653d9
--- /dev/null
+++ b/examples/simple_script_vendored/.rubocop.yml
@@ -0,0 +1,36 @@
+inherit_from: .relaxed-rubocop-2.4.yml
+
+AllCops:
+ TargetRubyVersion: 2.6
+ UseCache: true
+ DefaultFormatter: progress
+ DisplayStyleGuide: true
+ DisplayCopNames: true
+ Exclude:
+ - "external*/**/*"
+ - "bazel-*/**/*"
+ - "**/examples/**/*"
+ - "**/BUILD"
+ - "**/*.bazel"
+ - "**/*.bzl"
+ - "**/rubocop"
+ - "**/vendor/bundle/**/*"
+ Include:
+ - '**/*.rb'
+ - '**/*.gemfile'
+ - '**/*.gemspec'
+ - '**/*.rake'
+ - '**/*.ru'
+ - '**/Gemfile'
+ - '**/Rakefile'
+
+Layout/HashAlignment:
+ Enabled: true
+ EnforcedColonStyle: table
+
+Style/Dir:
+ Enabled: false
+
+# In Bazel we want to use __FILE__ because __dir__points to the actual sources
+Style/ExpandPathArguments:
+ Enabled: false
diff --git a/examples/simple_script_vendored/BUILD.bazel b/examples/simple_script_vendored/BUILD.bazel
new file mode 100644
index 0000000..1fc2d13
--- /dev/null
+++ b/examples/simple_script_vendored/BUILD.bazel
@@ -0,0 +1,94 @@
+load(
+ "@bazelruby_rules_ruby//ruby:defs.bzl",
+ "ruby_binary",
+ "ruby_rspec",
+ "ruby_rubocop",
+ "ruby_test",
+)
+
+package(default_visibility = ["//:__subpackages__"])
+
+ruby_binary(
+ name = "bin",
+ srcs = ["script.rb"],
+ main = "script.rb",
+ deps = [
+ "//lib:foo",
+ ],
+)
+
+# This is an example of the RSpec definition that uses autorun
+# and points to spec_helper as the main spec file. It specifies
+# which specs to run using the args.
+
+ruby_test(
+ name = "all-specs",
+ timeout = "short",
+ srcs = [
+ "script.rb",
+ "//lib:foo",
+ ] + glob([
+ "spec/**/*.rb",
+ ]),
+ # This is a WORKSPACE-relative path to a spec directory.
+ # It could be longer, like "my/path/to/spec".
+ args = [
+ "spec",
+ ],
+ main = "@bundle//:bin/rspec",
+ deps = [
+ "@bundle//:bin",
+ "@bundle//:rspec",
+ "@bundle//:rspec-its",
+ ],
+)
+
+# Finally, this is the short version of the same thing, expressed
+# via the ruby_rspec_test rule that does what the above example
+# shows but encapsulated in the rule itself. It adds rspec and rspec-its
+# gems to the dependency list, executes bin/rspec and passes spec_targets
+# as arguments to rspec.
+ruby_rspec(
+ name = "ruby-rspec-test",
+ srcs = [
+ "script.rb",
+ "//lib:foo",
+ ],
+ rspec_args = {
+ # NOTE: the output is only visible with --test_output=streamed flag
+ "--format": "progress", # this is how we can override rspec output format
+ },
+ specs = glob([
+ "spec/**/*.rb",
+ ]),
+ deps = [],
+)
+
+ruby_binary(
+ name = "rubocop-bin",
+ srcs = [
+ "script.rb",
+ "//lib:foo",
+ ] + glob([
+ "spec/**/*.rb",
+ ]),
+ args = [
+ "-- *.rb spec/*.rb lib/*.rb -a",
+ ],
+ main = "@bundle//:bin/rubocop",
+ deps = [
+ "//lib:foo",
+ "@bundle//:bin",
+ ],
+)
+
+# Rubocop rule
+# To check
+# bazel run rubocop -- -a
+ruby_rubocop(
+ name = "rubocop",
+ bin = "@bundle//:bin/rubocop",
+ deps = [
+ "@bundle//:rubocop",
+ ],
+)
diff --git a/examples/simple_script_vendored/Gemfile b/examples/simple_script_vendored/Gemfile
new file mode 100644
index 0000000..efb2cf7
--- /dev/null
+++ b/examples/simple_script_vendored/Gemfile
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+source 'https://rubygems.org'
+
+gem 'rspec', '~> 3.7.0'
+gem 'rspec-its'
+gem 'rubocop', '~> 0.78.0'
diff --git a/examples/simple_script_vendored/Gemfile.lock b/examples/simple_script_vendored/Gemfile.lock
new file mode 100644
index 0000000..4460ad6
--- /dev/null
+++ b/examples/simple_script_vendored/Gemfile.lock
@@ -0,0 +1,46 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ ast (2.4.2)
+ diff-lcs (1.4.4)
+ jaro_winkler (1.5.4)
+ parallel (1.20.1)
+ parser (3.0.0.0)
+ ast (~> 2.4.1)
+ rainbow (3.0.0)
+ rspec (3.7.0)
+ rspec-core (~> 3.7.0)
+ rspec-expectations (~> 3.7.0)
+ rspec-mocks (~> 3.7.0)
+ rspec-core (3.7.1)
+ rspec-support (~> 3.7.0)
+ rspec-expectations (3.7.0)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.7.0)
+ rspec-its (1.3.0)
+ rspec-core (>= 3.0.0)
+ rspec-expectations (>= 3.0.0)
+ rspec-mocks (3.7.0)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.7.0)
+ rspec-support (3.7.1)
+ rubocop (0.78.0)
+ jaro_winkler (~> 1.5.1)
+ parallel (~> 1.10)
+ parser (>= 2.6)
+ rainbow (>= 2.2.2, < 4.0)
+ ruby-progressbar (~> 1.7)
+ unicode-display_width (>= 1.4.0, < 1.7)
+ ruby-progressbar (1.11.0)
+ unicode-display_width (1.6.1)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ rspec (~> 3.7.0)
+ rspec-its
+ rubocop (~> 0.78.0)
+
+BUNDLED WITH
+ 2.1.4
diff --git a/examples/simple_script_vendored/README.md b/examples/simple_script_vendored/README.md
new file mode 100644
index 0000000..4949968
--- /dev/null
+++ b/examples/simple_script_vendored/README.md
@@ -0,0 +1,17 @@
+# Simple Script Example
+
+This Workspace includes a simple ruby script that includes and external gem and an internal library
+
+### Bundle
+
+Update gemfile using
+```
+bundle update
+```
+
+### Rubocop
+Run rubocop with:
+
+```
+bazel run //:rubocop
+```
diff --git a/examples/simple_script_vendored/WORKSPACE b/examples/simple_script_vendored/WORKSPACE
new file mode 100644
index 0000000..3aff264
--- /dev/null
+++ b/examples/simple_script_vendored/WORKSPACE
@@ -0,0 +1,34 @@
+workspace(
+ name = "bazelruby_rules_ruby_example",
+ managed_directories = {"@bundle": ["vendor"]},
+)
+
+# Importing rules_ruby from the parent directory for developing
+# rules_ruby itself...
+local_repository(
+ name = "bazelruby_rules_ruby",
+ path = "../..",
+)
+
+load(
+ "@bazelruby_rules_ruby//ruby:deps.bzl",
+ "rules_ruby_dependencies",
+ "rules_ruby_select_sdk",
+)
+
+rules_ruby_dependencies()
+
+rules_ruby_select_sdk(version = "2.7.1")
+
+load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_bundle")
+
+ruby_bundle(
+ name = "bundle",
+ bundler_version = "2.1.2",
+ excludes = {
+ "mini_portile": ["test/**/*"],
+ },
+ gemfile = "//:Gemfile",
+ gemfile_lock = "//:Gemfile.lock",
+ vendor_cache = True,
+)
diff --git a/examples/simple_script_vendored/lib/BUILD b/examples/simple_script_vendored/lib/BUILD
new file mode 100644
index 0000000..f125ff8
--- /dev/null
+++ b/examples/simple_script_vendored/lib/BUILD
@@ -0,0 +1,11 @@
+load(
+ "@bazelruby_rules_ruby//ruby:defs.bzl",
+ "ruby_library",
+)
+
+package(default_visibility = ["//:__subpackages__"])
+
+ruby_library(
+ name = "foo",
+ srcs = ["foo.rb"],
+)
diff --git a/examples/simple_script_vendored/lib/foo.rb b/examples/simple_script_vendored/lib/foo.rb
new file mode 100644
index 0000000..eff4466
--- /dev/null
+++ b/examples/simple_script_vendored/lib/foo.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class Foo
+ class << self
+ def yell_aha
+ puts aha
+ end
+
+ def aha
+ 'You said, aha?'
+ end
+
+ def rot13(value)
+ return nil unless value.is_a?(String)
+
+ value.tr('abcdefghijklmnopqrstuvwxyz', 'nopqrstuvwxyzabcdefghijklm')
+ end
+ end
+
+ attr_reader :goo, :foo
+
+ def initialize(goo)
+ @goo = goo
+ @foo = transform(goo)
+ end
+
+ def transform(incoming = goo)
+ Foo.rot13(incoming)
+ end
+end
diff --git a/examples/simple_script_vendored/script.rb b/examples/simple_script_vendored/script.rb
new file mode 100644
index 0000000..64c6ea2
--- /dev/null
+++ b/examples/simple_script_vendored/script.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+require 'openssl'
+
+require_relative 'lib/foo'
+
+def oss_rand
+ OpenSSL::BN.rand(512).to_s
+end
+
+puts Foo.aha + ' ' + oss_rand
diff --git a/examples/simple_script_vendored/spec/lib/foo_spec.rb b/examples/simple_script_vendored/spec/lib/foo_spec.rb
new file mode 100644
index 0000000..31ca665
--- /dev/null
+++ b/examples/simple_script_vendored/spec/lib/foo_spec.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+require_relative '../spec_helper'
+require_relative '../../lib/foo'
+
+RSpec.describe Foo do
+ let(:goo) { 'Green slime was dripping down his throat into his lapdomen...' }
+ subject(:foo) { Foo.new(goo) }
+
+ context 'without the aha' do
+ before { allow(Foo).to receive(:yell_aha).and_return('tiny dongle') }
+
+ it "should have goo" do
+ expect(subject.goo).to eql goo
+ end
+ it "should have transformed goo" do
+ expect(subject.transform).not_to eql goo
+ end
+
+ # Some rot13 old school encryption :)
+ it "should use rot13 for transform" do
+ expect(subject.transform).to eql 'Gerra fyvzr jnf qevccvat qbja uvf guebng vagb uvf yncqbzra...'
+ end
+ end
+
+ context 'aha' do
+ it 'should print aha' do
+ expect(Foo).to receive(:puts).with('You said, aha?').and_return(nil)
+ Foo.yell_aha
+ end
+ end
+end
diff --git a/examples/simple_script_vendored/spec/script_spec.rb b/examples/simple_script_vendored/spec/script_spec.rb
new file mode 100644
index 0000000..458b928
--- /dev/null
+++ b/examples/simple_script_vendored/spec/script_spec.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require 'script'
+
+describe 'oss_rand' do
+ it 'generates a String' do
+ expect(oss_rand).to be_a_kind_of String
+ end
+end
diff --git a/examples/simple_script_vendored/spec/spec_helper.rb b/examples/simple_script_vendored/spec/spec_helper.rb
new file mode 100644
index 0000000..9c7f07a
--- /dev/null
+++ b/examples/simple_script_vendored/spec/spec_helper.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+# Sets HOME here because:
+# If otherwise, it causes a runtime failure with the following steps.
+# 1. RSpec::Core::ConfigurationOptions.global_options_file raises an exception
+# because $HOME is not set in the sandbox environment of Bazel
+# 2. the rescue clause calls RSpec::Support.#warning
+# 3. #warning calls #warn_with
+# 4. #warn_with tries to lookup the first caller which is not a part of RSpec.
+# But all the call stack entires are about RSpec at this time because
+# it is invoked by rpsec/autorun. So #warn_with raises an exception
+# 5. The process fails with an unhandled exception.
+
+ENV['HOME'] ||= '/'
+
+require 'rspec'
+
+RSpec.configure do |config|
+ config.expect_with :rspec do |expectations|
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
+ end
+
+ config.mock_with :rspec do |mocks|
+ mocks.verify_partial_doubles = true
+ end
+
+ config.shared_context_metadata_behavior = :apply_to_host_groups
+
+ config.warnings = true
+ config.filter_run_when_matching :focus
+ # config.disable_monkey_patching!
+ config.order = :random
+ Kernel.srand config.seed
+end
diff --git a/examples/simple_script_vendored/vendor/cache/ast-2.4.2.gem b/examples/simple_script_vendored/vendor/cache/ast-2.4.2.gem
new file mode 100644
index 0000000..abe1643
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/ast-2.4.2.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/diff-lcs-1.4.4.gem b/examples/simple_script_vendored/vendor/cache/diff-lcs-1.4.4.gem
new file mode 100644
index 0000000..3be4edc
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/diff-lcs-1.4.4.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/jaro_winkler-1.5.4.gem b/examples/simple_script_vendored/vendor/cache/jaro_winkler-1.5.4.gem
new file mode 100644
index 0000000..5ed9b9b
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/jaro_winkler-1.5.4.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/parallel-1.20.1.gem b/examples/simple_script_vendored/vendor/cache/parallel-1.20.1.gem
new file mode 100644
index 0000000..7804c61
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/parallel-1.20.1.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/parser-3.0.0.0.gem b/examples/simple_script_vendored/vendor/cache/parser-3.0.0.0.gem
new file mode 100644
index 0000000..f542329
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/parser-3.0.0.0.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/rainbow-3.0.0.gem b/examples/simple_script_vendored/vendor/cache/rainbow-3.0.0.gem
new file mode 100644
index 0000000..c53caf7
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/rainbow-3.0.0.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/rspec-3.7.0.gem b/examples/simple_script_vendored/vendor/cache/rspec-3.7.0.gem
new file mode 100644
index 0000000..6ce573a
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/rspec-3.7.0.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/rspec-core-3.7.1.gem b/examples/simple_script_vendored/vendor/cache/rspec-core-3.7.1.gem
new file mode 100644
index 0000000..d949df8
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/rspec-core-3.7.1.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/rspec-expectations-3.7.0.gem b/examples/simple_script_vendored/vendor/cache/rspec-expectations-3.7.0.gem
new file mode 100644
index 0000000..119eda3
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/rspec-expectations-3.7.0.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/rspec-its-1.3.0.gem b/examples/simple_script_vendored/vendor/cache/rspec-its-1.3.0.gem
new file mode 100644
index 0000000..bcff4af
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/rspec-its-1.3.0.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/rspec-mocks-3.7.0.gem b/examples/simple_script_vendored/vendor/cache/rspec-mocks-3.7.0.gem
new file mode 100644
index 0000000..f34bef2
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/rspec-mocks-3.7.0.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/rspec-support-3.7.1.gem b/examples/simple_script_vendored/vendor/cache/rspec-support-3.7.1.gem
new file mode 100644
index 0000000..4d29cf9
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/rspec-support-3.7.1.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/rubocop-0.78.0.gem b/examples/simple_script_vendored/vendor/cache/rubocop-0.78.0.gem
new file mode 100644
index 0000000..b8f797d
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/rubocop-0.78.0.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/ruby-progressbar-1.11.0.gem b/examples/simple_script_vendored/vendor/cache/ruby-progressbar-1.11.0.gem
new file mode 100644
index 0000000..a9d84e5
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/ruby-progressbar-1.11.0.gem differ
diff --git a/examples/simple_script_vendored/vendor/cache/unicode-display_width-1.6.1.gem b/examples/simple_script_vendored/vendor/cache/unicode-display_width-1.6.1.gem
new file mode 100644
index 0000000..55f1986
Binary files /dev/null and b/examples/simple_script_vendored/vendor/cache/unicode-display_width-1.6.1.gem differ
diff --git a/ruby/private/bundle/def.bzl b/ruby/private/bundle/def.bzl
index fade53e..c3fd334 100644
--- a/ruby/private/bundle/def.bzl
+++ b/ruby/private/bundle/def.bzl
@@ -155,6 +155,11 @@ def generate_bundle_build_file(runtime_ctx, previous_result):
def _ruby_bundle_impl(ctx):
ctx.symlink(ctx.attr.gemfile, "Gemfile")
ctx.symlink(ctx.attr.gemfile_lock, "Gemfile.lock")
+ if ctx.attr.vendor_cache:
+ ctx.symlink(
+ ctx.path(str(ctx.path(ctx.attr.gemfile).dirname) + "/vendor"),
+ ctx.path("vendor"),
+ )
ctx.symlink(ctx.attr._create_bundle_build_file, SCRIPT_BUILD_FILE_GENERATOR)
ctx.symlink(ctx.attr._install_bundler, SCRIPT_INSTALL_GEM)
diff --git a/ruby/private/constants.bzl b/ruby/private/constants.bzl
index c74b6ef..2730717 100644
--- a/ruby/private/constants.bzl
+++ b/ruby/private/constants.bzl
@@ -79,6 +79,9 @@ BUNDLE_ATTRS = {
"gemfile_lock": attr.label(
allow_single_file = True,
),
+ "vendor_cache": attr.bool(
+ doc = "Symlink the vendor directory into the Bazel build space, this allows Bundler to access vendored Gems",
+ ),
"bundler_version": attr.string(
default = DEFAULT_BUNDLER_VERSION,
),
|