Module: InlineFormsInstaller

Defined in:
lib/inline_forms_installer.rb,
lib/inline_forms_installer/creator.rb,
lib/inline_forms_installer/version.rb,
lib/inline_forms_installer/create_log.rb

Defined Under Namespace

Modules: CreateLog Classes: Creator

Constant Summary collapse

VERSION =
"8.0.3"
TARGET_RUBY_VERSION =

Written into generated apps’ ‘.ruby-version` (must match gemspec `required_ruby_version`).

"ruby-4.0.4"
INLINE_FORMS_VERSION =

Kept in sync with inline_forms gem releases from the same repo tag.

VERSION

Class Method Summary collapse

Class Method Details

.dev_checkout_with_gems(repo_name) ⇒ Object



71
72
73
74
75
76
77
78
79
# File 'lib/inline_forms_installer.rb', line 71

def self.dev_checkout_with_gems(repo_name)
  [
    File.expand_path("~/code/#{repo_name}"),
    File.expand_path("~/#{repo_name}")
  ].uniq.find do |checkout|
    File.file?(File.join(checkout, "#{repo_name}.gemspec")) &&
      Dir[File.join(checkout, "#{repo_name}-*.gem")].any?
  end
end

.discover_prerelease_env!Object

When developing unreleased 8.x gems, point env at checkouts that contain built *.gem files so the installer can gem-install them into the app gemset.



35
36
37
38
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
66
67
68
69
# File 'lib/inline_forms_installer.rb', line 35

def self.discover_prerelease_env!
  if ENV["INLINE_FORMS_RELEASE_ROOT"].to_s == "" || ENV["VALIDATION_HINTS_ROOT"].to_s == ""
    dir = gem_root
    6.times do
      if ENV["INLINE_FORMS_RELEASE_ROOT"].to_s == "" &&
         File.file?(File.join(dir, "inline_forms.gemspec")) &&
         Dir[File.join(dir, "inline_forms-*.gem")].any?
        ENV["INLINE_FORMS_RELEASE_ROOT"] = dir
      end
      if ENV["VALIDATION_HINTS_ROOT"].to_s == "" &&
         File.file?(File.join(dir, "validation_hints.gemspec")) &&
         Dir[File.join(dir, "validation_hints-*.gem")].any?
        ENV["VALIDATION_HINTS_ROOT"] = dir
      end
      parent = File.expand_path("..", dir)
      break if parent == dir
      dir = parent
    end
  end

  if ENV["VALIDATION_HINTS_ROOT"].to_s == ""
    sibling_vh = File.expand_path("../validation_hints", File.expand_path("..", gem_root))
    ENV["VALIDATION_HINTS_ROOT"] = sibling_vh if File.directory?(sibling_vh)
  end

  {
    "INLINE_FORMS_RELEASE_ROOT" => "inline_forms",
    "VALIDATION_HINTS_ROOT" => "validation_hints"
  }.each do |env_key, repo_name|
    next if ENV[env_key].to_s != ""

    checkout = dev_checkout_with_gems(repo_name)
    ENV[env_key] = checkout if checkout
  end
end

.gem_rootObject



5
6
7
8
9
10
# File 'lib/inline_forms_installer.rb', line 5

def self.gem_root
  @gem_root ||= begin
    spec = Gem.loaded_specs["inline_forms_installer"]
    spec ? spec.full_gem_path : File.expand_path("..", __dir__)
  end
end

.inline_forms_gem_rootObject



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

def self.inline_forms_gem_root
  @inline_forms_gem_root ||= begin
    if ENV["INLINE_FORMS_ROOT"] && File.directory?(ENV["INLINE_FORMS_ROOT"])
      File.expand_path(ENV["INLINE_FORMS_ROOT"])
    else
      Gem::Specification.find_by_name("inline_forms").full_gem_path
    end
  end
rescue Gem::MissingSpecError
  # Monorepo dev: engine sources live beside the installer gem.
  File.expand_path("..", __dir__)
end

.inline_forms_versionObject



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

def self.inline_forms_version
  @inline_forms_version ||= begin
    Gem::Specification.find_by_name("inline_forms").version.to_s
  rescue Gem::MissingSpecError
    INLINE_FORMS_VERSION
  end
end