Managing loaner chromebooks for students and teachers in the HUUSD school district.
1#!/usr/bin/env ruby
2#
3# This file was generated by Bundler.
4#
5# The application 'bundle' is installed as part of a gem, and
6# this file is here to facilitate running it.
7#
8
9require "rubygems"
10
11m = Module.new do
12 module_function
13
14 def invoked_as_script?
15 File.expand_path($0) == File.expand_path(__FILE__)
16 end
17
18 def env_var_version
19 ENV["BUNDLER_VERSION"]
20 end
21
22 def cli_arg_version
23 return unless invoked_as_script? # don't want to hijack other binstubs
24 return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
25 bundler_version = nil
26 update_index = nil
27 ARGV.each_with_index do |a, i|
28 if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
29 bundler_version = a
30 end
31 next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
32 bundler_version = $1
33 update_index = i
34 end
35 bundler_version
36 end
37
38 def gemfile
39 gemfile = ENV["BUNDLE_GEMFILE"]
40 return gemfile if gemfile && !gemfile.empty?
41
42 File.expand_path("../Gemfile", __dir__)
43 end
44
45 def lockfile
46 lockfile =
47 case File.basename(gemfile)
48 when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
49 else "#{gemfile}.lock"
50 end
51 File.expand_path(lockfile)
52 end
53
54 def lockfile_version
55 return unless File.file?(lockfile)
56 lockfile_contents = File.read(lockfile)
57 return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
58 Regexp.last_match(1)
59 end
60
61 def bundler_requirement
62 @bundler_requirement ||=
63 env_var_version ||
64 cli_arg_version ||
65 bundler_requirement_for(lockfile_version)
66 end
67
68 def bundler_requirement_for(version)
69 return "#{Gem::Requirement.default}.a" unless version
70
71 bundler_gem_version = Gem::Version.new(version)
72
73 bundler_gem_version.approximate_recommendation
74 end
75
76 def load_bundler!
77 ENV["BUNDLE_GEMFILE"] ||= gemfile
78
79 activate_bundler
80 end
81
82 def activate_bundler
83 gem_error = activation_error_handling do
84 gem "bundler", bundler_requirement
85 end
86 return if gem_error.nil?
87 require_error = activation_error_handling do
88 require "bundler/version"
89 end
90 return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
91 warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
92 exit 42
93 end
94
95 def activation_error_handling
96 yield
97 nil
98 rescue StandardError, LoadError => e
99 e
100 end
101end
102
103m.load_bundler!
104
105if m.invoked_as_script?
106 load Gem.bin_path("bundler", "bundle")
107end