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’
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/marfa/file_templates.rb', line 80 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
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/marfa/file_templates.rb', line 93 def config_ru(project_path) File.open("#{project_path}/config.ru", 'w') do |file| file.puts "require 'marfa' require File.dirname(__FILE__) + '/app/bootstrap' require File.dirname(__FILE__) + '/config/marfa' 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 run Rack::Cascade.new(controllers) " 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 |
# 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 # Specifying API Server is needed Marfa.config.api_server = '' # Views path is needed Marfa.config.views = File.expand_path('./app/views') # Cache config Marfa.config.cache = { enabled: false, host: '', port: 0, db: 0, expiration_time: 3600 } # Static files content path Marfa.config.content_path = '/images/content/' Marfa.config.cache_styles = true # Public folder Marfa.config.public_folder = File.expand_path('./static') # Static files cache Marfa.config.static_cache_control = [:public, max_age: 2_592_000] # CSRF Protection Marfa.config.csrf_enabled = false # HTML Compression Marfa.config.html_compression_options = { enabled: true, remove_multi_spaces: true, remove_comments: true, remove_intertag_spaces: false, remove_quotes: true, compress_css: false, compress_javascript: false, simple_doctype: false, remove_script_attributes: true, remove_style_attributes: true, remove_link_attributes: true, remove_form_attributes: false, remove_input_attributes: true, remove_javascript_protocol: true, remove_http_protocol: false, remove_https_protocol: false, preserve_line_breaks: false, simple_boolean_attributes: true } # CSS Minifying Marfa.config.minify_css = true # JS Minifying Marfa.config.minify_js = true " end end |