Module: Marfa::FileTemplates
- Defined in:
- lib/marfa/file_templates.rb
Instance Method Summary collapse
-
#application_rb(project_path) ⇒ Object
generates content for ‘config/application.rb’ file.
-
#bootstrap_rb(project_path) ⇒ Object
content for ‘app/bootstrap.rb’.
-
#config_ru(project_path) ⇒ Object
content for ‘config.ru’ file.
-
#marfa_rb(project_path) ⇒ Object
generates content for ‘config/marfa.rb’ file.
Instance Method Details
#application_rb(project_path) ⇒ Object
generates content for ‘config/application.rb’ file
6 7 8 9 10 |
# File 'lib/marfa/file_templates.rb', line 6 def application_rb(project_path) File.open("#{project_path}/config/application.rb", 'w') do |file| file.puts '' end end |
#bootstrap_rb(project_path) ⇒ Object
content for ‘app/bootstrap.rb’
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/marfa/file_templates.rb', line 105 def bootstrap_rb(project_path) File.open("#{project_path}/app/bootstrap.rb", 'w') do |file| file.puts "require './config/application' # requiring all blocks and controllers Dir[File.dirname(__FILE__) + '/blocks/**/*.rb'].each { |file| require file } Dir[File.dirname(__FILE__) + '/controllers/**/*.rb'].each { |file| require file } " end end |
#config_ru(project_path) ⇒ Object
content for ‘config.ru’ file
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/marfa/file_templates.rb', line 118 def config_ru(project_path) File.open("#{project_path}/config.ru", 'w') do |file| file.puts "Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 require 'marfa' require File.dirname(__FILE__) + '/app/bootstrap' require File.dirname(__FILE__) + '/config/marfa/' + ENV['RACK_ENV'] require 'pp' if ENV['RACK_ENV'] == 'production' p Using config #{File.dirname(__FILE__) + '/config/marfa/' + ENV['RACK_ENV']} Marfa.configure_app # Controllers auto-bootstrap controllers = Object.constants.select { |c| c.to_s.include? 'Controller' } controllers.map! { |controller| Object.const_get(controller) } # controllers += Marfa::Controllers.controllers_list app_map = { # '.css': CssController, '/': IndexController } run Rack::AppMapper.new(controllers, app_map) " end end |
#marfa_rb(project_path) ⇒ Object
generates content for ‘config/marfa.rb’ file
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/marfa/file_templates.rb', line 14 def marfa_rb(project_path) File.open("#{project_path}/config/marfa.rb", 'w') do |file| file.puts "# Marfa configuration file Marfa.configure do |cfg| # Environment cfg.environment = :development # Request logging cfg.logging = true # Logging level see Logger cfg.logging_level = Logger::INFO # Logging format time cfg.logging_datetime_format = '%d/%b/%Y:%H:%M:%S %z' # Show error page with backtrace cfg.show_exceptions = true # log exception backtraces to STDERR cfg.dump_errors = true # Mode (not implemented yet) cfg.mode = 'api' # Specifying API Server is needed cfg.api_server = '' # Paths settings cfg.content_path = '/images/content/' cfg.public_folder = File.expand_path('./static') cfg.views = File.expand_path('./app/views') cfg.block_templates_path = 'blocks' # Redis cache settings cfg.cache = { enabled: false, host: 'localhost', port: 6379, db: 0, expiration_time: 86_400 } # Cache header cfg.static_cache_control = [public, max_age: 0] # CSS build cfg.use_css_build = false # CSS file cache cfg.cache_styles = false # CSRF protection cfg.csrf_enabled = false # HTML compression cfg.html_compression_options = { enabled: true, remove_intertag_spaces: true } # CSS/JS Minifying cfg.minify_css = false cfg.minify_js = true # Email settings cfg.email = { default: { address: '', port: '587', enable_starttls_auto: true, user_name: '', password: '', authentication: :plain, domain: 'localhost.localdomain' } } # Device detector cfg.device_detector = { enabled: true } # Pagination default template cfg.pagination_template = '/pagination' # Rack::Session secret cfg.session_secret = 'secret' end " end end |