Sha256: 74d0cad73f159664aef1357641cbc8d18d75e18fc1e18030a9411841450c33b9

Contents?: true

Size: 725 Bytes

Versions: 39

Compression:

Stored size: 725 Bytes

Contents

# frozen_string_literal: true

require "rails/generators/named_base"

module Rails
  module Generators
    class BenchmarkGenerator < NamedBase
      IPS_GEM_NAME = "benchmark-ips"
      IPS_GEM_USED_REGEXP = /gem.*\b#{IPS_GEM_NAME}\b.*/

      argument :reports, type: :array, default: ["before", "after"]

      def generate_layout
        add_ips_to_gemfile unless ips_installed?
        template("benchmark.rb.tt", "script/benchmarks/#{file_name}.rb")
      end

    private
      def add_ips_to_gemfile
        gem(IPS_GEM_NAME, group: [:development, :test])
      end

      def ips_installed?
        in_root do
          return File.read("Gemfile").match?(IPS_GEM_USED_REGEXP)
        end
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 5 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/railties-7.1.3.4/lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-8.0.1 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-8.0.0.1 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.2.2.1 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.1.5.1 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-8.0.0 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.2.2 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.1.5 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-8.0.0.rc2 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.2.1.2 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.1.4.2 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-8.0.0.rc1 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.2.1.1 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.1.4.1 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-8.0.0.beta1 lib/rails/generators/rails/benchmark/benchmark_generator.rb
omg-railties-8.0.0.alpha9 lib/rails/generators/rails/benchmark/benchmark_generator.rb
omg-railties-8.0.0.alpha8 lib/rails/generators/rails/benchmark/benchmark_generator.rb
omg-railties-8.0.0.alpha7 lib/rails/generators/rails/benchmark/benchmark_generator.rb
omg-railties-8.0.0.alpha4 lib/rails/generators/rails/benchmark/benchmark_generator.rb
omg-railties-8.0.0.alpha3 lib/rails/generators/rails/benchmark/benchmark_generator.rb