Skip to content

Commit 09f7fee

Browse files
committed
add support to ts files in javascripts count
1 parent 805b022 commit 09f7fee

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

lib/rails_stats/code_statistics_calculator.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ class CodeStatisticsCalculator #:nodoc:
1818
end_block_comment: %r{\*/},
1919
method: /function(\s+[_a-zA-Z][\da-zA-Z]*)?\s*\(/,
2020
},
21+
ts: {
22+
line_comment: %r{^\s*//},
23+
begin_block_comment: %r{^\s*/\*},
24+
end_block_comment: %r{\*/},
25+
method: /^\s*function(\s+[_a-zA-Z][\da-zA-Z]*)?\s*\(/,
26+
},
2127
coffee: {
2228
line_comment: /^\s*#/,
2329
begin_block_comment: /^\s*###/,

lib/rails_stats/util.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def calculate_statistics(directories, type = :code, &block)
7575
out
7676
end
7777

78-
def calculate_directory_statistics(directory, pattern = /.*\.(rb|js|coffee|feature)$/)
78+
def calculate_directory_statistics(directory, pattern = /.*\.(rb|js|ts|coffee|feature)$/)
7979
stats = CodeStatisticsCalculator.new
8080

8181
Dir.foreach(directory) do |file_name|

test/dummy/app/javascript/index.ts

Whitespace-only changes.

test/fixtures/console-output.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
| Configuration | 19 | 417 | 111 | 1 | 0 | 0 | 0 |
2525
| Controllers | 1 | 7 | 6 | 1 | 1 | 1 | 4 |
2626
| Helpers | 1 | 3 | 3 | 0 | 0 | 0 | 0 |
27-
| Javascripts | 3 | 27 | 7 | 0 | 0 | 0 | 0 |
27+
| Javascripts | 4 | 27 | 7 | 0 | 0 | 0 | 0 |
2828
| Jobs | 1 | 7 | 2 | 1 | 0 | 0 | 0 |
2929
| Libraries | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
3030
| Mailers | 1 | 4 | 4 | 1 | 0 | 0 | 0 |
@@ -33,11 +33,11 @@
3333
| Spec Support | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
3434
| Test Support | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
3535
+----------------------+---------+---------+---------+---------+---------+-----+-------+
36-
| Code | 33 | 484 | 152 | 10 | 1 | 0 | 150 |
36+
| Code | 34 | 484 | 152 | 10 | 1 | 0 | 150 |
3737
| Tests | 4 | 7 | 6 | 2 | 0 | 0 | 0 |
38-
| Total | 37 | 491 | 158 | 12 | 1 | 0 | 156 |
38+
| Total | 38 | 491 | 158 | 12 | 1 | 0 | 156 |
3939
+----------------------+---------+---------+---------+---------+---------+-----+-------+
40-
Code LOC: 152 Test LOC: 6 Code to Test Ratio: 1:0.0 Files: 37
40+
Code LOC: 152 Test LOC: 6 Code to Test Ratio: 1:0.0 Files: 38
4141

4242
Polymorphic models count: 1 polymorphic associations
4343
Schema Stats: 2 `create_table` calls in schema.rb

0 commit comments

Comments
 (0)