Sha256: b48deafd89029cd446db5384bfa2076a73a9709bc57ad3d5465882291b891645

Contents?: true

Size: 1.11 KB

Versions: 77

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

class LocalPlugins
  def self.rails_root
    File.expand_path('..', __dir__)
  end

  def self.plugins_roots
    [File.expand_path('vendor/gems', rails_root), File.expand_path('engines', rails_root)]
  end

  def self.plugins
    r = []
    plugins_roots.each do |root|
      Dir.glob("#{root}/*/").each do |plugin_dir|
        next unless File.directory?(plugin_dir)
        next unless Dir.entries(plugin_dir).any? { |f| f.match(/\.gemspec/) }

        r << LocalPlugin.new(plugin_dir)
      end
    end
    r
  end

  def self.app
    LocalPlugin.new(rails_root)
  end

  def self.app_and_plugins
    plugins + [app]
  end
end

class LocalPlugin
  attr_reader :root

  def initialize(root)
    @root = root
  end

  def bundle
    bin_bundle = File.expand_path('bin/bundle', root)
    File.exist?(bin_bundle) ? 'bin/bundle' : 'bundle'
  end

  def subpath(path)
    File.expand_path(path, root)
  end

  def name
    app? ? 'APP' : File.basename(root)
  end

  def app?
    root == LocalPlugins.rails_root
  end

  def bundle_execute(args)
    Dir.chdir(root) { system(*([bundle] + args)) }
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
eac_rails_base0-0.44.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.43.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.42.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.41.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.40.1 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.40.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.39.1 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.39.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.38.1 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.38.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.37.1 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.37.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.36.1 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.36.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.35.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.34.1 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.34.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.33.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.32.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
eac_rails_base0-0.31.0 lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb