Class: Kybus::CLI::Bot::ProjectGenerator
- Inherits:
-
Object
- Object
- Kybus::CLI::Bot::ProjectGenerator
- Extended by:
- DRY::ResourceInjector
- Defined in:
- lib/kybus/cli/bot/project_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(name, configs) ⇒ ProjectGenerator
constructor
A new instance of ProjectGenerator.
Constructor Details
#initialize(name, configs) ⇒ ProjectGenerator
Returns a new instance of ProjectGenerator.
19 20 21 22 23 24 25 26 27 |
# File 'lib/kybus/cli/bot/project_generator.rb', line 19 def initialize(name, configs) @name = name.gsub('::', '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase @configs = configs @file_writer = FileWriter.new(@name) end |
Class Method Details
.register_file_provider(file_provider) ⇒ Object
14 15 16 17 |
# File 'lib/kybus/cli/bot/project_generator.rb', line 14 def self.register_file_provider(file_provider) providers = resource(:providers) providers << file_provider end |
Instance Method Details
#generate ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/kybus/cli/bot/project_generator.rb', line 29 def generate if File.directory?(@name) puts "Directory exists #{@name}" exit(1) end create_directories write_files puts `cd #{@name} && git init . && bundle install --path vendor/bundle && git add . && git commit -m "Initial Commit"` puts "Project #{@name} initialized with #{@configs[:db_adapter]} adapter." end |