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
- #check_for_rugular_directory ⇒ Object
- #compile_bower_javascript ⇒ Object
- #copy_fonts ⇒ Object
- #copy_images ⇒ Object
- #create_application_js_file ⇒ Object
- #inline_template_url_files ⇒ Object
- #write_dist_index_html_file ⇒ Object
Instance Method Details
#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: self.class.name, root_directory: 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_javascript)) end end |
#copy_fonts ⇒ Object
66 67 68 |
# File 'lib/rugular/tasks/build.rb', line 66 def copy_fonts FileUtils.cp_r('src/fonts', 'dist') end |
#copy_images ⇒ Object
62 63 64 |
# File 'lib/rugular/tasks/build.rb', line 62 def copy_images FileUtils.cp_r('src/images', 'dist') end |
#create_application_js_file ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rugular/tasks/build.rb', line 32 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 |
#inline_template_url_files ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rugular/tasks/build.rb', line 48 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 |