Sha256: 229dca098e83abc7f02249cf3d0159496cbd55997709ff25b335075496ec304f

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

#!/usr/bin/env ruby
require 'pathname'

source_path = (Pathname.new(__FILE__).dirname + '../lib').expand_path
$LOAD_PATH << source_path

activate_rails_version = ->(rails_version) do
  rails_bin_path = Gem.activate_bin_path("railties", "rails", rails_version)
  rails_path = File.expand_path("../..", rails_bin_path)
  $LOAD_PATH.unshift(rails_path)
end

if str = ARGV.first
  str = str.b[/\A_(.*)_\z/, 1]

  if str && Gem::Version.correct?(str)
    rails_version = str
    ARGV.shift

    begin
      activate_rails_version.call(rails_version)
    rescue Gem::GemNotFoundException
      abort "Suspenders error: Unable to find Rails version #{rails_version}"
    end
  else
    require "suspenders/version"

    spec = Gem::Specification.find_by_name("rails", Suspenders::RAILS_VERSION)

    activate_rails_version.call(spec.version.to_s)
  end
end

require "suspenders"

if ARGV.empty?
  puts "Please provide a path for the new application"
  puts
  puts "See --help for more info"
  exit 0
elsif ["-v", "--version"].include? ARGV[0]
  puts Suspenders::VERSION
  exit 0
end

templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
Suspenders::AppGenerator.source_root templates_root
Suspenders::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root

Suspenders::AppGenerator.start

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
suspenders-20230113.0 bin/suspenders
suspenders-1.56.1 bin/suspenders