class Rugular::Build

Public Instance Methods

add_template_application_sass_file() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/rugular/tasks/build.rb, line 91
def copy_fonts
  FileUtils.cp_r('src/fonts', 'dist')
end
copy_images() click to toggle source
# File lib/rugular/tasks/build.rb, line 87
def copy_images
  FileUtils.cp_r('src/images', 'dist')
end
create_application_css_file() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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

Private Instance Methods

bower_and_vendor_javascript() click to toggle source
# File lib/rugular/tasks/build.rb, line 97
def bower_and_vendor_javascript
  bower_javascript + vendor_javascript
end
bower_css() click to toggle source
# File lib/rugular/tasks/build.rb, line 113
def bower_css
  bower_yaml.fetch('bower_components').fetch('css').map do |filename|
    File.read('bower_components/' + filename)
  end.join
end
bower_javascript() click to toggle source
# File lib/rugular/tasks/build.rb, line 101
def bower_javascript
  bower_yaml.fetch('bower_components').fetch('js').map do |filename|
    File.read('bower_components/' + filename)
  end.join
end
bower_yaml() click to toggle source
# File lib/rugular/tasks/build.rb, line 120
def bower_yaml
  YAML.load(File.read('src/bower_components.yaml'))
end
lib_directory() click to toggle source
# File lib/rugular/tasks/build.rb, line 124
def lib_directory
  __dir__.chomp('tasks')
end
vendor_javascript() click to toggle source
# File lib/rugular/tasks/build.rb, line 107
def vendor_javascript
  bower_yaml.fetch('vendor').fetch('coffee').map do |filename|
    CoffeeScript.compile(File.read('vendor/' + filename))
  end.join
end