class Rugular::Abstract
Public Instance Methods
bower_json()
click to toggle source
# File lib/rugular/tasks/abstract.rb, line 29 def bower_json @_json ||= JSON.parse(File.read('bower.json')).to_h end
check_for_rugular_directory()
click to toggle source
# File lib/rugular/tasks/abstract.rb, line 22 def check_for_rugular_directory ::Rugular::AppChecker.check_for_rugular_directory( task_name: self.class.name, root_directory: destination_root ) end
increment_bower_version_if_file_exists()
click to toggle source
# File lib/rugular/tasks/abstract.rb, line 33 def increment_bower_version_if_file_exists return unless File.exists? "release/#{app_name}.js" new_bower_json = bower_json.tap do |json| json['version'] = next_version end File.open('bower.json', 'w') do |file| file.write new_bower_json end end
inline_template_url_files()
click to toggle source
# File lib/rugular/tasks/abstract.rb, line 55 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(release_js, File.open(release_js) do |f| f.read.gsub(html_filename, html) end) IO.write(release_min_js, File.open(release_js) do |f| f.read.gsub(html_filename, html) end) end end
write_application_css_file()
click to toggle source
# File lib/rugular/tasks/abstract.rb, line 73 def write_application_css_file `sass .application.sass release/#{app_name}.css -r sass-globbing` end
write_release_js_files()
click to toggle source
# File lib/rugular/tasks/abstract.rb, line 45 def write_release_js_files File.open(release_js, 'w') do |file| file.write(one_coffeescript_file) end File.open(release_min_js, 'w') do |file| file.write(Uglifier.compile(one_coffeescript_file)) end end
Private Instance Methods
app_name()
click to toggle source
# File lib/rugular/tasks/abstract.rb, line 79 def app_name destination_root.split('/').last end
javascript_files()
click to toggle source
# File lib/rugular/tasks/abstract.rb, line 93 def javascript_files if options[:c] ::Rugular::JavascriptFiles.component_array else ::Rugular::JavascriptFiles.ordered_array end end
next_version()
click to toggle source
# File lib/rugular/tasks/abstract.rb, line 87 def next_version next_patch = previous_version.split('.').last.to_i + 1 (previous_version.split('.')[0..-2] << next_patch).join('.') end
one_coffeescript_file()
click to toggle source
# File lib/rugular/tasks/abstract.rb, line 109 def one_coffeescript_file @_one_coffeescript_file ||= javascript_files.map do |javascript_file| CoffeeScript.compile( File.read(javascript_file).gsub('templateUrl', 'template') ) end.join end
previous_version()
click to toggle source
# File lib/rugular/tasks/abstract.rb, line 83 def previous_version bower_json.fetch('version') end
release_js()
click to toggle source
# File lib/rugular/tasks/abstract.rb, line 101 def release_js "release/#{app_name}.js" end
release_min_js()
click to toggle source
# File lib/rugular/tasks/abstract.rb, line 105 def release_min_js "release/#{app_name}.min.js" end