Class: RubyPitaya::RubyPitaya
- Inherits:
-
Object
- Object
- RubyPitaya::RubyPitaya
- Defined in:
- lib/rubypitaya.rb
Class Method Summary collapse
- .add_plugin(plugin_git_link) ⇒ Object
- .create_migration(migration_name) ⇒ Object
- .create_project(project_name, folder_path) ⇒ Object
- .run_server ⇒ Object
Class Method Details
.add_plugin(plugin_git_link) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rubypitaya.rb', line 41 def self.add_plugin(plugin_git_link) Dir.mkdir(Path::PLUGINS_FOLDER_PATH) unless File.exists?(Path::PLUGINS_FOLDER_PATH) plugin_name = plugin_git_link.scan(/.+\/(.+)\.git/).flatten.first plugin_folder_path = File.join(Path::PLUGINS_FOLDER_PATH, plugin_name) plugin_git_path = File.join(plugin_folder_path, '.git/') FileUtils.rm_rf(plugin_folder_path) if File.exists?(plugin_folder_path) `git -C #{Path::PLUGINS_FOLDER_PATH} clone #{plugin_git_link}` FileUtils.rm_rf(plugin_git_path) plugin_migrations_path = File.join(plugin_folder_path, 'db/migration/') plugin_migrations_files = Dir[File.join(plugin_migrations_path, '*')] = Time.now.utc.to_i plugin_migrations_files.each_with_index do |migration_file, i| = + i new_file = migration_file.gsub(/^(.+\/migration\/)\d+(_.+)$/, "\\1#{migration_timestamp}\\2") File.rename(migration_file, new_file) end plugin_name end |
.create_migration(migration_name) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubypitaya.rb', line 22 def self.create_migration(migration_name) migration_name = "#{migration_name}_migration" unless migration_name.underscore.end_with?('migration') = Time.now.utc.to_i migration_file_name = "#{migration_timestamp}_#{migration_name.underscore}.rb" migration_class_name = migration_name.camelcase template_struct = OpenStruct.new( class_name: migration_class_name, ) template = File.open(Path::MIGRATION_TEMPLATE_PATH, &:read) template_result = ERB.new(template).result(template_struct.instance_eval { binding }) migration_file_path = File.join(Path::MIGRATIONS_FOLDER_PATH, migration_file_name) File.open(migration_file_path, 'w') { |f| f.write(template_result) } migration_file_name end |
.create_project(project_name, folder_path) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/rubypitaya.rb', line 15 def self.create_project(project_name, folder_path) project_path = File.join(folder_path, project_name) app_template_path = Path::APP_TEMPLATE_FOLDER_PATH FileUtils.cp_r app_template_path, project_path end |
.run_server ⇒ Object
11 12 13 |
# File 'lib/rubypitaya.rb', line 11 def self.run_server Main.new end |