Sha256: 3d0cb3ef06506a4d09da0734f664e1cdb1b7760bc23159abd9137b886a39aa5e

Contents?: true

Size: 1.78 KB

Versions: 13

Compression:

Stored size: 1.78 KB

Contents

module Jobshop
  module Generators
    class TeamGenerator < Rails::Generators::Base
      source_root File.expand_path("../templates", __FILE__)

      desc "Create a jobshop team."

      def require_environment
        ENV["RAILS_ENV"] ||= "development"
        abort "Please run this command within a Rails app." unless Rails.root

        environment_filename = File.expand_path(
          Rails.root + "config/environment.rb")

        require environment_filename
      end

      def create_team
        @team = ::Jobshop::Team.create!
      end

      def generate_token
        @token = @team.generate_registration_token
      end

      def generate_secure_registration_link
        link_protocol = Rails.env.development? ? "http" : "https"
        link_host = Rails.env.development? ? "localhost:3000" : "YOUR-HOST-NAME"
        # TODO: Give environments besides development a decent host and
        # protocol. HTTPS isn't mandatory in production but it is very, VERY
        # highly recommended.
        @secure_url = ::Jobshop::Engine.routes.url_helpers.
          new_team_registration_url(@team,
          protocol: link_protocol,
          host: link_host,
          registration_token: @token
        )
      end

      def print_secure_registration_link
        say <<-MESSAGE
### JOBSHOP - IMPORTANT INFORMATION ############################################

      Your Jobshop team has been initialized.
      You may use the following link to complete the setup process.

      #{@secure_url}

      This link is valid for 30 minutes from now and will expire at:
      #{30.minutes.from_now.in_time_zone("Eastern Time (US & Canada)")}

      Thank you for using Jobshop!

################################################################################
        MESSAGE
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
jobshop-0.0.113 lib/generators/jobshop/team/team_generator.rb
jobshop-0.0.109 lib/generators/jobshop/team/team_generator.rb
jobshop-0.0.107 lib/generators/jobshop/team/team_generator.rb
jobshop-0.0.101 lib/generators/jobshop/team/team_generator.rb
jobshop-0.0.67 lib/generators/jobshop/team/team_generator.rb
jobshop-0.0.61 lib/generators/jobshop/team/team_generator.rb
jobshop-0.0.59 lib/generators/jobshop/team/team_generator.rb
jobshop-0.0.53 lib/generators/jobshop/team/team_generator.rb
jobshop-0.0.41 lib/generators/jobshop/team/team_generator.rb
jobshop-0.0.37 lib/generators/jobshop/team/team_generator.rb
jobshop-0.0.29 lib/generators/jobshop/team/team_generator.rb
jobshop-0.0.23 lib/generators/jobshop/team/team_generator.rb
jobshop-0.0.16 lib/generators/jobshop/team/team_generator.rb