primary()
click to toggle source
# File lib/compass/commands/project_structure.rb, line 72 def primary; false; end
# File lib/compass/commands/project_structure.rb, line 68 def description(command) "Report statistics about your stylesheets" end
# File lib/compass/commands/project_structure.rb, line 24 def initialize(working_path, options) super assert_project_directory_exists! end
# File lib/compass/commands/project_structure.rb, line 57 def option_parser(arguments) parser = Compass::Exec::CommandOptionParser.new(arguments) parser.extend(Compass::Exec::GlobalOptionsParser) parser.extend(Compass::Exec::ProjectOptionsParser) parser.extend(StructureOptionsParser) end
# File lib/compass/commands/project_structure.rb, line 74 def parse!(arguments) parser = option_parser(arguments) parser.parse! parse_arguments!(parser, arguments) parser.options end
# File lib/compass/commands/project_structure.rb, line 81 def parse_arguments!(parser, arguments) if arguments.size > 0 parser.options[:project_name] = arguments.shift if File.directory?(arguments.first) parser.options[:sass_files] = arguments end end
# File lib/compass/commands/project_stats.rb, line 123 def css_columns(css_file) if File.exists?(css_file) cf = Compass::Stats::CssFile.new(css_file) cf.analyze! %(selector_count prop_count file_size).map do |t| cf.send(t).to_s end else return [ '--', '--' , '--'] end rescue LoadError => e @missing_css_parser = e.message =~ /iconv/ ? "iconv" : "css_parser" return [ 'DISABLED', 'DISABLED', 'DISABLED' ] end
# File lib/compass/commands/project_stats.rb, line 110 def filename_columns(sass_file) filename = Compass.deprojectize(sass_file, working_path) [filename] end
# File lib/compass/commands/project_stats.rb, line 87 def format_kb(v) return v unless v =~ /^\d+$/ v = Integer(v) if v < 1024 "#{v} B" else v = v / 1024.0 "#{v.ceil} KB" end end
# File lib/compass/commands/project_stats.rb, line 73 def pad(c, max, options = {}) options[:align] ||= :left if c == :- filler = '-' c = '' else filler = ' ' end c = send(:"format_#{options[:formatter]}", c) if options[:formatter] spaces = max - c.size filled = filler * [spaces,0].max "#{options[:left]}#{filled if options[:align] == :right}#{c}#{filled if options[:align] == :left}#{options[:right]}" end
# File lib/compass/commands/project_structure.rb, line 29 def perform @compiler = new_compiler_instance (options[:sass_files] || sorted_sass_files).each do |sass_file| print_tree(Compass.projectize(sass_file)) end end
# File lib/compass/commands/project_structure.rb, line 36 def print_tree(file, depth = 0, importer = @compiler.importer) puts ((depth > 0 ? "| " : " ") * depth) + "+- " + Compass.deprojectize(file) @compiler.staleness_checker.send(:compute_dependencies, file, importer).each do |(dep, dep_importer)| print_tree(dep, depth + 1, dep_importer)# unless Compass.deprojectize(dep)[0...1] == "/" end end
# File lib/compass/commands/project_stats.rb, line 115 def sass_columns(sass_file) sf = Compass::Stats::SassFile.new(sass_file) sf.analyze! %(rule_count prop_count mixin_def_count mixin_count file_size).map do |t| sf.send(t).to_s end end
# File lib/compass/commands/project_structure.rb, line 43 def sorted_sass_files sass_files = @compiler.sass_files sass_files.map! do |s| filename = Compass.deprojectize(s, File.join(Compass.configuration.project_path, Compass.configuration.sass_dir)) [s, File.dirname(filename), File.basename(filename)] end sass_files = sass_files.sort_by do |s,d,f| File.join(d, f[0] == __ ? f[1..-1] : f) end sass_files.map!{|s,d,f| s} end
Generated with the Darkfish Rdoc Generator 2.