Sha256: 701e5f28e1d2732ad0bd5d94f44c5384e40ef4d1eff236258a7cd65a57c50ab9
Contents?: true
Size: 1.85 KB
Versions: 6
Compression:
Stored size: 1.85 KB
Contents
module Jobshop module Generators class TeamGenerator < Rails::Generators::NamedBase source_root File.expand_path("../templates", __FILE__) desc "Create a jobshop team." attr_reader :team, :link_text, :first_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!(name: name) 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. @link_text = ::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 "#{name}" has been initialized. You may use the following link to complete the setup process. #{link_text} 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
6 entries across 6 versions & 1 rubygems