Sha256: c5b19fc10958f4bf4a03b38023719f362caf807f56a70a18556700eaf800b0db

Contents?: true

Size: 984 Bytes

Versions: 12

Compression:

Stored size: 984 Bytes

Contents

require "erb"

# NOTE pbmenvで参照しているクラス
# 後方互換を維持するために、パラメータの削除・必須をしてはいけない
class AppGenerator
  attr_reader :prefix_path

  # @param [String] prefix_path
  # @param [Boolean] enable_integration_with_pbm_cloud
  def initialize(prefix_path: , enable_integration_with_pbm_cloud: )
    @prefix_path = prefix_path
    @enable_integration_with_pbm_cloud = enable_integration_with_pbm_cloud
  end

  def generate
    erb = File.read(template_path)
    enable_integration_with_pbm_cloud = @enable_integration_with_pbm_cloud
    if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
      app_rb = ERB.new(erb, trim_mode: '-').result(binding)
    else
      app_rb = ERB.new(erb, nil, '-').result(binding)
    end
    File.write(output_path, app_rb)
  end

  private

  def template_path
    File.join(prefix_path, "app.rb.erb")
  end

  def output_path
    File.join(prefix_path, "app.rb")
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
procon_bypass_man-0.3.12 project_template/lib/app_generator.rb
procon_bypass_man-0.3.11 project_template/lib/app_generator.rb
procon_bypass_man-0.3.10 project_template/lib/app_generator.rb
procon_bypass_man-0.3.9 project_template/lib/app_generator.rb
procon_bypass_man-0.3.8.1 project_template/lib/app_generator.rb
procon_bypass_man-0.3.8 project_template/lib/app_generator.rb
procon_bypass_man-0.3.7 project_template/lib/app_generator.rb
procon_bypass_man-0.3.6 project_template/lib/app_generator.rb
procon_bypass_man-0.3.5 project_template/lib/app_generator.rb
procon_bypass_man-0.3.4 project_template/lib/app_generator.rb
procon_bypass_man-0.3.3.1 project_template/lib/app_generator.rb
procon_bypass_man-0.3.3 project_template/lib/app_generator.rb