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,
lib/inline_forms_installer/user_model_config.rb
Defined Under Namespace
Modules: CreateLog Classes: Creator, UserModelConfig
Constant Summary collapse
- VERSION =
"8.1.40"- TARGET_RUBY_VERSION =
Canonical bare Ruby version (must match gemspec
required_ruby_version). Written verbatim into generated apps'.ruby-versionfor rbenv/chruby/asdf/ mise (which need the bareX.Y.Zform). For RVM installs the Creator writes theruby-X.Y.Zform instead, because RVM's.ruby-versionreader rejects a bare version. See Creator#create (ENV). "4.0.4"- INLINE_FORMS_VERSION =
Kept in sync with inline_forms gem releases from the same repo tag.
VERSION
Class Method Summary collapse
-
.checkout_has_built_gem?(checkout, name) ⇒ Boolean
Look for built
<name>-*.gemfiles in both the checkout root andpkg/—gem buildwrites to the root, butrake build(i.e.Bundler::GemHelper.install_tasksfrom the Rakefile) writes topkg/. - .dev_checkout_with_gems(repo_name) ⇒ Object
-
.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.
- .gem_root ⇒ Object
- .inline_forms_gem_root ⇒ Object
- .inline_forms_version ⇒ Object
Class Method Details
.checkout_has_built_gem?(checkout, name) ⇒ Boolean
Look for built <name>-*.gem files in both the checkout root and
pkg/ — gem build writes to the root, but rake build (i.e.
Bundler::GemHelper.install_tasks from the Rakefile) writes to
pkg/. Either is a legitimate "I just built this" location; only
globbing the root meant a freshly-rake build-ed gem was invisible
to install_prerelease_gems_from_roots! and the installer would
silently fall back to whatever stale *.gem was sitting in the
checkout root from a previous gem build run.
90 91 92 |
# File 'lib/inline_forms_installer.rb', line 90 def self.checkout_has_built_gem?(checkout, name) Dir[File.join(checkout, "#{name}-*.gem"), File.join(checkout, "pkg", "#{name}-*.gem")].any? end |
.dev_checkout_with_gems(repo_name) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/inline_forms_installer.rb', line 72 def self.dev_checkout_with_gems(repo_name) [ File.("~/code/#{repo_name}"), File.("~/#{repo_name}") ].uniq.find do |checkout| File.file?(File.join(checkout, "#{repo_name}.gemspec")) && checkout_has_built_gem?(checkout, repo_name) 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.
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 70 |
# File 'lib/inline_forms_installer.rb', line 36 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")) && checkout_has_built_gem?(dir, "inline_forms") ENV["INLINE_FORMS_RELEASE_ROOT"] = dir end if ENV["VALIDATION_HINTS_ROOT"].to_s == "" && File.file?(File.join(dir, "validation_hints.gemspec")) && checkout_has_built_gem?(dir, "validation_hints") ENV["VALIDATION_HINTS_ROOT"] = dir end parent = File.("..", dir) break if parent == dir dir = parent end end if ENV["VALIDATION_HINTS_ROOT"].to_s == "" sibling_vh = File.("../validation_hints", File.("..", 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_root ⇒ Object
6 7 8 9 10 11 |
# File 'lib/inline_forms_installer.rb', line 6 def self.gem_root @gem_root ||= begin spec = Gem.loaded_specs["inline_forms_installer"] spec ? spec.full_gem_path : File.("..", __dir__) end end |
.inline_forms_gem_root ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/inline_forms_installer.rb', line 13 def self.inline_forms_gem_root @inline_forms_gem_root ||= begin if ENV["INLINE_FORMS_ROOT"] && File.directory?(ENV["INLINE_FORMS_ROOT"]) File.(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.("..", __dir__) end |
.inline_forms_version ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/inline_forms_installer.rb', line 26 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 |