Class: AttendanceBot::Generator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- AttendanceBot::Generator
- Includes:
- Thor::Actions
- Defined in:
- lib/attendance_bot/generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.source_root ⇒ Object
12 13 14 |
# File 'lib/attendance_bot/generator.rb', line 12 def self.source_root File.dirname(__FILE__) end |
Instance Method Details
#copy_config ⇒ Object
20 21 22 |
# File 'lib/attendance_bot/generator.rb', line 20 def copy_config template('template_config.yml', destination_path) end |
#create_group ⇒ Object
16 17 18 |
# File 'lib/attendance_bot/generator.rb', line 16 def create_group empty_directory('config') end |
#destination_path ⇒ Object
8 9 10 |
# File 'lib/attendance_bot/generator.rb', line 8 def destination_path self.class.source_root + '/config/config.yml' end |
#write_config ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/attendance_bot/generator.rb', line 24 def write_config cli = HighLine.new email = cli.ask 'Enter your attendance email: ' password = cli.ask('Enter your password: ') { |q| q.echo = 'x' } config_file = YAML::load_file(destination_path) config_file['email'] = email config_file['password'] = password File.open(destination_path, 'w') { |f| f.write config_file.to_yaml } end |