Class: Maximus::Stylestats
- Defined in:
- lib/maximus/statistics/stylestats.rb
Overview
Instance Attribute Summary
Attributes inherited from Statistic
Instance Method Summary collapse
-
#result ⇒ Object
Produces CSS statistics.
Methods inherited from Statistic
Methods included from Helper
#check_default_config_path, #edit_yaml, #file_count, #file_list, #is_rails?, #lines_added_to_range, #node_module_exists, #path_exists?, #prompt, #reporter_path, #root_dir, #truthy?
Constructor Details
This class inherits a constructor from Maximus::Statistic
Instance Method Details
#result ⇒ Object
Produces CSS statistics
7 8 9 10 11 12 13 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 |
# File 'lib/maximus/statistics/stylestats.rb', line 7 def result return if @settings[:stylestats].blank? node_module_exists('stylestats') if @path.blank? @path = is_rails? ? "#{@settings[:root_dir]}/public/assets/**/*.css" : "#{@settings[:root_dir]}/**/*.css" end if @path.is_a?(Array) css_files = @path else compile_scss if @settings[:compile_assets] css_files = find_css end css_files.each do |file| # For Rails, we only want the name of the compiled asset, because we know it'll live in public/assets. # If this isn't Rails, sure, give me the full path because the directory structure is likely unique pretty_name = is_rails? ? file.split('/').pop.gsub(/(-{1}[a-z0-9]{32}*\.{1}){1}/, '.') : file puts "#{'stylestats'.color(:green)}: #{pretty_name}\n\n" # include JSON formatter unless we're in dev stylestats = `stylestats #{file} --config=#{@settings[:stylestats]} #{'--type=json' unless @config.is_dev?}` refine(stylestats, pretty_name) File.delete(file) end destroy_assets if @settings[:compile_assets] @output end |