Class: Jobshop::Generators::TeamGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Jobshop::Generators::TeamGenerator
- Defined in:
- lib/generators/jobshop/team/team_generator.rb
Instance Attribute Summary collapse
-
#first_team ⇒ Object
readonly
Returns the value of attribute first_team.
-
#link_text ⇒ Object
readonly
Returns the value of attribute link_text.
-
#team ⇒ Object
readonly
Returns the value of attribute team.
Instance Method Summary collapse
- #create_team ⇒ Object
- #generate_secure_registration_link ⇒ Object
- #generate_token ⇒ Object
- #print_secure_registration_link ⇒ Object
- #require_environment ⇒ Object
Instance Attribute Details
#first_team ⇒ Object (readonly)
Returns the value of attribute first_team.
8 9 10 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 8 def first_team @first_team end |
#link_text ⇒ Object (readonly)
Returns the value of attribute link_text.
8 9 10 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 8 def link_text @link_text end |
#team ⇒ Object (readonly)
Returns the value of attribute team.
8 9 10 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 8 def team @team end |
Instance Method Details
#create_team ⇒ Object
20 21 22 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 20 def create_team @team = Jobshop::Team.create!(name: name) end |
#generate_secure_registration_link ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 28 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 |
#generate_token ⇒ Object
24 25 26 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 24 def generate_token @token = team.generate_registration_token end |
#print_secure_registration_link ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 42 def print_secure_registration_link say "### JOBSHOP - IMPORTANT INFORMATION ############################################\n\nYour Jobshop team \"\#{name}\" has been initialized.\nYou may use the following link to complete the setup process.\n\n\#{link_text}\n\nThis link is valid for 30 minutes from now and will expire at:\n\#{30.minutes.from_now.in_time_zone(\"Eastern Time (US & Canada)\")}\n\nThank you for using Jobshop!\n\n################################################################################\n MESSAGE\nend\n" |
#require_environment ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 10 def require_environment ENV['RAILS_ENV'] ||= "development" abort "Please run this command within a Rails app." unless Rails.root environment_filename = File.( Rails.root + "config/environment.rb") require environment_filename end |