Sha256: 23f959fed0cfaccb5d10f1391ef23ee86ff9d8672fc52aecfcbd795014b50592

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

# encoding: utf-8

d 'Display statistics'
command :stats do |c|
	c.desc "Display stats about macros"
	c.switch [:m, :macros]
	c.desc "Display stats about snippets"
	c.switch [:s, :snippets]
	c.desc "Display stats about bookmarks"
	c.switch [:b, :bookmarks]
	c.desc "Display stats about links"
	c.switch [:l, :links]
	c.desc "Display stats about project files"
	c.switch [:f, :files]
	c.desc "Display stats about a single macro"
	c.flag :macro
	c.desc "Display stats about a single bookmark"
	c.flag :bookmark
	c.desc "Display stats about links matching a regular expression"
	c.flag :link
	c.desc "Display stats about a single snippet"
	c.flag :snippet
	c.action do |global_options, options, args|
		Glyph.info "Collecting stats..."
		Glyph.run 'generate:document'
		analyzer = Glyph::Analyzer.new
		no_switches = true
		[[:m, :macros], [:s, :snippets], [:b, :bookmarks], [:l, :links], [:f, :files]].each do |s|
			if options[s[0]] then
				analyzer.stats_for s[1]
			 	no_switches = false
			end	
		end
		no_flags = true
		[:macro, :bookmark, :link, :snippet].each do |f|
			if options[f] then
				analyzer.stats_for :snippets if f == :snippet
				analyzer.stats_for f, options[f] 
				no_flags = false
			end
		end
		analyzer.stats_for :global if no_switches && no_flags 
		puts "====================================="
		puts "#{Glyph['document.title']} - Statistics"
		puts "====================================="
		puts
		reporter = Glyph::Reporter.new(analyzer.stats)
		reporter.detailed = false if no_switches && no_flags 
		reporter.display
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
glyph-0.5.3.1 lib/glyph/commands/stats.rb
glyph-0.5.2 lib/glyph/commands/stats.rb