Sha256: 6996f53a24c829be0e13a8e65cce6a3452650e7987d5826117dd92c27985b255

Contents?: true

Size: 1.34 KB

Versions: 156

Compression:

Stored size: 1.34 KB

Contents

class Jets::Commands::Import
  class Base < Sequence
    # Ugly, but when the class_option is only defined in the Thor::Group class
    # it doesnt show up with jets new help :(
    # If anyone knows how to fix this let me know.
    def self.cli_options
      [
        [:submodule, type: :boolean, default: false, desc: "Imports the project as a submodule"],
      ]
    end
    cli_options.each { |args| class_option(*args) }

    # Since setup is public it will automatically run in the subclasses
    def setup
      start_message
      create_rack_folder
      configure_ruby
      create_rackup_wrappers
    end

  private
    def start_message
      puts "Importing app into the rack folder..."
    end

    def create_rack_folder
      repo? ? clone_project : copy_project
    end

    def configure_ruby
      gsub_file 'rack/Gemfile', /^ruby(.*)/, '# ruby\1' # comment out ruby declaration
      create_file "rack/.ruby-version", RUBY_VERSION, force: true
    end

    def create_rackup_wrappers
      path = File.expand_path("../../builders/rackup_wrappers", File.dirname(__FILE__))
      Dir.glob("#{path}/*").each do |p|
        FileUtils.cp(p, "#{rack_folder}/bin/")
      end
      chmod "#{rack_folder}/bin/rackup", 0755
    end

    def bundle_install
      Bundler.with_clean_env do
        run "cd rack && bundle install"
      end
    end
  end
end

Version data entries

156 entries across 156 versions & 3 rubygems

Version Path
jets-1.0.18 lib/jets/commands/import/base.rb
jets-1.0.17 lib/jets/commands/import/base.rb
jets-1.0.16 lib/jets/commands/import/base.rb
jets-1.0.15 lib/jets/commands/import/base.rb
jets-1.0.13 lib/jets/commands/import/base.rb
jets-1.0.12 lib/jets/commands/import/base.rb
jets-1.0.11 lib/jets/commands/import/base.rb
jets-1.0.10 lib/jets/commands/import/base.rb
jets-1.0.9 lib/jets/commands/import/base.rb
jets-1.0.8 lib/jets/commands/import/base.rb
jets-1.0.7 lib/jets/commands/import/base.rb
jets-1.0.6 lib/jets/commands/import/base.rb
jets-1.0.5 lib/jets/commands/import/base.rb
jets-1.0.4 lib/jets/commands/import/base.rb
jets-1.0.3 lib/jets/commands/import/base.rb
jets-1.0.2 lib/jets/commands/import/base.rb