Top Level Namespace

Defined Under Namespace

Modules: InlineFormsInstaller Classes: ExampleAppApartmentFieldTurboTest, ExampleAppApartmentNameListTest, ExampleAppApartmentNameRequiredTest, ExampleAppApartmentNameValidationTest, ExampleAppApartmentOpeningDateTest, ExampleAppApartmentPhotoTest, ExampleAppApartmentPhotosPaginationTest, ExampleAppApartmentRowTurboTest, ExampleAppApartmentTopLevelNewTest, ExampleAppApartmentTopLevelPaginationTest, ExampleAppApartmentVersionsTurboTest, ExampleAppFormElementShowcaseTest, ExampleAppGuestAccessTest, ExampleAppIntegrationTestCase, ExampleAppOwnerTabsTest, ExampleAppPaperTrailChangesetTest, ExampleAppPhotoRevertTest, ExampleAppPhotosTest, ExampleAppPlainTextRichTextEdgeCasesTest, ExampleAppRoutingTest, ExampleAppShowcaseChoiceScaleFieldsTest, ExampleAppShowcaseDateTimeFieldsTest, ExampleAppShowcaseLocalesAssociationsTest, ExampleAppShowcaseNumericFieldsTest, ExampleAppShowcasePageRenderTest, ExampleAppShowcaseTextFieldsTest, ExampleAppTurboLayoutTest, ExampleAppValidationHintsTest

Constant Summary collapse

INSTALLER_ROOT =
File.expand_path(ENV.fetch("INLINE_FORMS_INSTALLER_ROOT", File.expand_path("..", __dir__)))
INLINE_FORMS_ROOT =
File.expand_path(ENV.fetch("INLINE_FORMS_ROOT", INSTALLER_ROOT))

Instance Method Summary collapse

Instance Method Details

#bundle_install!Object



25
26
27
28
29
30
31
32
33
# File 'lib/inline_forms_installer/installer_core.rb', line 25

def bundle_install!
  say "- Running bundle install..."
  unless system("bundle", "install")
    abort "ERROR: bundle install failed in #{Dir.pwd}. From the app directory run: rvm use . && bundle install"
  end
  unless system("bundle", "check")
    abort "ERROR: bundle check failed (gems missing). From the app directory run: rvm use . && bundle install"
  end
end

#install_prerelease_gems_from_roots!Object

Pre-install built .gem files into the app RVM gemset so Bundler can resolve inline_forms ~> 8 before those releases exist on RubyGems. Set INLINE_FORMS_RELEASE_ROOT and/or VALIDATION_HINTS_ROOT (creator sets the latter when a sibling validation_hints checkout exists).



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/inline_forms_installer/installer_core.rb', line 39

def install_prerelease_gems_from_roots!
  roots = []
  %w[INLINE_FORMS_RELEASE_ROOT VALIDATION_HINTS_ROOT].each do |key|
    root = ENV[key].to_s
    roots << File.expand_path(root) if root != "" && File.directory?(root)
  end
  roots.uniq!
  return if roots.empty?

  %w[validation_hints inline_forms inline_forms_installer].each do |name|
    # Pick the *highest version*, not the highest filename. String sort
    # placed `inline_forms-8.1.7.gem` above `inline_forms-8.1.10.gem`
    # because "7" > "1" lexicographically — silently picking up a stale
    # gem build on every release once minor versions cross a digit
    # boundary. Parse the version out of the filename with Gem::Version
    # so the comparison is numeric.
    candidates = roots.flat_map { |root| Dir[File.join(root, "#{name}-*.gem")] }
    gem_file = candidates.max_by do |path|
      ver_str = File.basename(path, ".gem").sub(/\A#{Regexp.escape(name)}-/, "")
      Gem::Version.new(ver_str) rescue Gem::Version.new("0")
    end
    next unless gem_file && File.file?(gem_file)

    say "- Installing #{File.basename(gem_file)} into app gemset..."
    run "gem install #{Shellwords.escape(gem_file)} --no-document"
  end
end

#use_app_rvm_gemset!Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/inline_forms_installer/installer_core.rb', line 8

def use_app_rvm_gemset!
  return if ENV["skiprvm"] == "true"
  return unless (gemset = ENV["inline_forms_rvm_gemset"]).to_s != ""

  begin
    require "rvm"
  rescue LoadError
    say "rvm gem not available; skipping gemset switch", :yellow
    return
  end
  return unless RVM.current

  say "Working directory is #{Dir.pwd}", :green
  RVM.use_from_path! "."
  say "Installing using gemset: #{RVM.current.environment_name}", :green
end