Sha256: 21832c08e45e1f89d1b529569e2a9074de2f6f47af7864468aeb780a39639b93

Contents?: true

Size: 677 Bytes

Versions: 75

Compression:

Stored size: 677 Bytes

Contents

# frozen_string_literal: true

require "rails/generators/named_base"

module Rails
  module Generators
    class BenchmarkGenerator < NamedBase
      IPS_GEM_NAME = "benchmark-ips"

      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?(/gem.*\b#{IPS_GEM_NAME}\b.*/)
        end
      end
    end
  end
end

Version data entries

75 entries across 71 versions & 6 rubygems

Version Path
railties-7.0.8.7 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.0.8.6 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-6.1.7.10 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-6.1.7.9 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.0.8.5 lib/rails/generators/rails/benchmark/benchmark_generator.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/railties-7.0.8.4/lib/rails/generators/rails/benchmark/benchmark_generator.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/railties-7.0.5.1/lib/rails/generators/rails/benchmark/benchmark_generator.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/railties-7.0.5.1/lib/rails/generators/rails/benchmark/benchmark_generator.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/railties-7.0.5.1/lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.0.8.4 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-6.1.7.8 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.0.8.1 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-6.1.7.7 lib/rails/generators/rails/benchmark/benchmark_generator.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/railties-7.0.3.1/lib/rails/generators/rails/benchmark/benchmark_generator.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/railties-7.0.2.3/lib/rails/generators/rails/benchmark/benchmark_generator.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/railties-6.1.6.1/lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.0.8 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.0.7.2 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-6.1.7.6 lib/rails/generators/rails/benchmark/benchmark_generator.rb
railties-7.0.7.1 lib/rails/generators/rails/benchmark/benchmark_generator.rb