fasterer

Set up fasterer
Icons/chart bar
Used 41 times
Created by
T TobiasBales

Usage

Run this command in your Rails app directory in the terminal:

rails app:template LOCATION="https://railsbytes.com/script/zamsNZ"
Template Source

Review the code before running this template on your machine.

def create_bin(name, command = nil)
  create_file "bin/#{name}" do <<~EOF
    #!/usr/bin/env ruby
    APP_ROOT = File.expand_path('..', __dir__)
    Dir.chdir(APP_ROOT) do
      begin
        exec '#{command || name}'
      rescue Errno::ENOENT
        $stderr.puts "#{name} executable was not detected in the system."
        exit 1
      end
    end
  EOF
  end
  `chmod +x bin/#{name}`
end


gem_group :development, :test do
  gem 'fasterer'
end

create_file '.fasterer.yml' do <<~YAML
  speedups:
    rescue_vs_respond_to: true
    module_eval: true
    shuffle_first_vs_sample: true
    for_loop_vs_each: true
    each_with_index_vs_while: false
    map_flatten_vs_flat_map: true
    reverse_each_vs_reverse_each: true
    select_first_vs_detect: true
    sort_vs_sort_by: true
    fetch_with_argument_vs_block: true
    keys_each_vs_each_key: true
    hash_merge_bang_vs_hash_brackets: true
    block_vs_symbol_to_proc: true
    proc_call_vs_yield: true
    gsub_vs_tr: true
    select_last_vs_reverse_detect: true
    getter_vs_attr_reader: true
    setter_vs_attr_writer: true

  exclude_paths:
    - 'config/puma.rb'
    - 'db/schema.rb'
    - 'vendor/**/*.rb'
  YAML
end

create_bin 'fasterer'
Comments

Sign up or Login to leave a comment.

© 2023 GoRails, LLC