Class: CodeStats
- Inherits:
-
Object
show all
- Defined in:
- lib/code_stats.rb,
lib/code_stats/code_stats.rb
Defined Under Namespace
Modules: Languages
Classes: FileSet, Project, Report
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.file_size_limit ⇒ Object
Returns the value of attribute file_size_limit.
14
15
16
|
# File 'lib/code_stats.rb', line 14
def file_size_limit
@file_size_limit
end
|
Class Method Details
.analyze(*args) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/code_stats/code_stats.rb', line 12
def analyze *args
options = args.
paths = args
paths.collect!{|path| Dir[path]}.flatten!
puts <<-TEXT
please wait, analyzing:
#{paths.join("\n ")}
TEXT
projects = paths.collect do |path|
project = Project.new path, options
project.analyze!
project
end
projects.sort{|a, b| b.characters_count <=> a.characters_count}
end
|
.analyze_and_report(*args) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/code_stats/code_stats.rb', line 30
def analyze_and_report *args
options = args.
paths = args
options.validate_options! *(FileSet::AVAILIABLE_OPTIONS + Project::AVAILIABLE_OPTIONS)
project_options = options.select{|k, v| Project::AVAILIABLE_OPTIONS.include? k}
lang_options = options.select{|k, v| FileSet::AVAILIABLE_OPTIONS.include? k}
projects = analyze *(paths << project_options)
report = Report.new(*(projects << lang_options)).render
report_file = "./projects_statistics.html".to_file
report_file.write! report
puts "done, statistics are in #{report_file}"
Kernel.exec "open #{report_file}"
end
|
.extensions ⇒ Object
12
|
# File 'lib/code_stats.rb', line 12
def extensions; @extensions ||= {} end
|
.know?(extension) ⇒ Boolean
3
4
5
|
# File 'lib/code_stats/code_stats.rb', line 3
def know? extension
extensions.include? extension
end
|
.parse(text, extension) ⇒ Object
7
8
9
10
|
# File 'lib/code_stats/code_stats.rb', line 7
def parse text, extension
language = extensions[extension] || raise("no language for :#{extension} extension!")
language.new text
end
|