Class: Rugular::Build
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Rugular::Build
- Includes:
- Thor::Actions
- Defined in:
- lib/rugular/tasks/build.rb
Instance Method Summary collapse
- #add_template_application_sass_file ⇒ Object
- #check_for_rugular_directory ⇒ Object
- #compile_bower_javascript ⇒ Object
- #compile_bower_stylesheets ⇒ Object
- #copy_fonts ⇒ Object
- #copy_images ⇒ Object
- #create_application_css_file ⇒ Object
- #create_application_js_file ⇒ Object
- #inject_backend_urls ⇒ Object
- #inline_template_url_files ⇒ Object
- #write_dist_index_html_file ⇒ Object
Instance Method Details
#add_template_application_sass_file ⇒ Object
76 77 78 79 80 81 |
# File 'lib/rugular/tasks/build.rb', line 76 def add_template_application_sass_file FileUtils.cp( "#{lib_directory}/templates/server/application.sass", "#{destination_root}/.application.sass" ) end |
#check_for_rugular_directory ⇒ Object
13 14 15 16 17 18 |
# File 'lib/rugular/tasks/build.rb', line 13 def check_for_rugular_directory Rugular::AppChecker.check_for_rugular_directory( task_name: name, root_directory: new.destination_root ) end |
#compile_bower_javascript ⇒ Object
26 27 28 29 30 |
# File 'lib/rugular/tasks/build.rb', line 26 def compile_bower_javascript File.open('dist/vendor.js', 'w') do |file| file.write(Uglifier.compile(bower_and_vendor_javascript)) end end |
#compile_bower_stylesheets ⇒ Object
32 33 34 35 36 |
# File 'lib/rugular/tasks/build.rb', line 32 def compile_bower_stylesheets File.open('dist/vendor.css', 'w') do |file| file.write bower_css end end |
#copy_fonts ⇒ Object
91 92 93 |
# File 'lib/rugular/tasks/build.rb', line 91 def copy_fonts FileUtils.cp_r('src/fonts', 'dist') end |
#copy_images ⇒ Object
87 88 89 |
# File 'lib/rugular/tasks/build.rb', line 87 def copy_images FileUtils.cp_r('src/images', 'dist') end |
#create_application_css_file ⇒ Object
83 84 85 |
# File 'lib/rugular/tasks/build.rb', line 83 def create_application_css_file `sass .application.sass dist/application.css -r sass-globbing` end |
#create_application_js_file ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rugular/tasks/build.rb', line 38 def create_application_js_file File.open('dist/application.js', 'w') do |file| file.write( Uglifier.compile( Rugular::JavascriptFiles.ordered_array.map do |javascript_file| text = File.read(javascript_file).gsub('templateUrl', 'template') CoffeeScript.compile(text) end.join ) ) end end |
#inject_backend_urls ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/rugular/tasks/build.rb', line 68 def inject_backend_urls Rugular::BackendURLInjector.inject_urls( config_file: 'config.yaml', constant_file: 'dist/application.js', environment: :production ) end |
#inline_template_url_files ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rugular/tasks/build.rb', line 54 def inline_template_url_files (Dir.glob("**/*.haml") - ["src/index.haml"]).each do |haml_file| haml_html = ::Haml::Engine.new(File.read(haml_file), {}).render html = haml_html.tr("\n", '').gsub("'", "\'").gsub('"', '\"') html_filename = haml_file.gsub('src/', '').gsub('haml', 'html') IO.write('dist/application.js', File.open('dist/application.js') do |f| f.read.gsub(html_filename, html) end) end end |
#write_dist_index_html_file ⇒ Object
20 21 22 23 24 |
# File 'lib/rugular/tasks/build.rb', line 20 def write_dist_index_html_file File.open('dist/index.html', 'w') do |file| file.write ::Haml::Engine.new(File.read('src/index.haml')).render end end |