code_stats2 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rake_ext'
2
2
 
3
- project(
3
+ project \
4
4
  name: "code_stats",
5
5
  official_name: 'code_stats2',
6
6
  gem: true,
@@ -11,5 +11,4 @@ project(
11
11
  dirs: %w(bin),
12
12
 
13
13
  author: "Alexey Petrushin",
14
- homepage: "http://github.com/alexeypetrushin/code_stats"
15
- )
14
+ homepage: "http://github.com/alexeypetrushin/code_stats"
@@ -46,7 +46,10 @@ module CodeStats::Languages
46
46
 
47
47
  module CComments
48
48
  def code
49
- @code ||= text.substitute(/\/\*.+?\*\/\n?/m, '').substitute(/^\/\/.+?[\n\z]/m, '').substitute(/\/\/.+?$/, '')
49
+ @code ||= text.
50
+ substitute(/\/\*.+?\*\/\n?/m, '').
51
+ substitute(/^\/\/.+?[\n\z]/m, '').
52
+ substitute(/\/\/.+?$/, '')
50
53
  end
51
54
  end
52
55
 
@@ -92,7 +95,10 @@ module CodeStats::Languages
92
95
  extensions :coffee
93
96
 
94
97
  def code
95
- @code ||= text.substitute(/###.+?###\n?/m, '').substitute(/^#.+?[\n\z]/m, '').substitute(/#.+?$/, '')
98
+ @code ||= text.
99
+ substitute(/###.+?###\n?/m, '').
100
+ substitute(/^#.+?[\n\z]/m, '').
101
+ substitute(/#.+?$/, '')
96
102
  end
97
103
  end
98
104
 
@@ -139,4 +145,16 @@ module CodeStats::Languages
139
145
  @code ||= text.substitute(/^;.+?[\n\z]/m, '').substitute(/;.+?$/, '')
140
146
  end
141
147
  end
148
+
149
+ class Scala < Java
150
+ extensions :scala
151
+ end
152
+
153
+ class Html < Abstract
154
+ extensions :html, :xhtml
155
+
156
+ def code
157
+ @code ||= text.substitute(/<!--.+?-->\n?/m, '')
158
+ end
159
+ end
142
160
  end
@@ -4,7 +4,7 @@ class CodeStats::Project
4
4
 
5
5
  AVAILIABLE_OPTIONS = [:spec_filter, :skip_filter]
6
6
  DEFAUL_SPEC_FILTER = /\/tests?\/|\/specs?\//
7
- DEFAUL_SKIP_FILTER = /\/docs?\/|\/(s|ex)amples?\/|\/guides?\/|\/.git\/|\/tmp\/|\/old\/|database\.php/
7
+ DEFAUL_SKIP_FILTER = /\/docs?\/|\/(s|ex)amples?\/|\/guides?\/|\/.git\/|\/tmp\/|\/old\/|database\.php|\/vendor\//
8
8
 
9
9
  def initialize path, options = {}
10
10
  @path, @name = path, path.to_entry.name
@@ -29,7 +29,7 @@ comment_a
29
29
  */
30
30
  // comment_b
31
31
  // comment_b2
32
- code_b // comment_b3
32
+ code_b// comment_b3
33
33
  JAVA
34
34
  end
35
35
  end
@@ -49,7 +49,7 @@ comment_a
49
49
  */
50
50
  // comment_b
51
51
  // comment_b2
52
- code_b // comment_b3
52
+ code_b// comment_b3
53
53
  JAVA_SCRIPT
54
54
  end
55
55
 
@@ -89,7 +89,7 @@ describe "Ruby" do
89
89
  code_a
90
90
  # comment_a
91
91
  # comment_a2
92
- code_b # comment_b3
92
+ code_b# comment_b3
93
93
  RUBY
94
94
  end
95
95
  end
@@ -109,7 +109,7 @@ comment_a
109
109
  */
110
110
  // comment_b
111
111
  // comment_b2
112
- code_b // comment_b3
112
+ code_b// comment_b3
113
113
  CPP
114
114
  end
115
115
  end
@@ -129,7 +129,7 @@ comment_a2
129
129
  ###
130
130
  # comment_b
131
131
  # comment_b2
132
- code_b # comment_b3
132
+ code_b# comment_b3
133
133
  COFFEE_SCRIPT
134
134
  end
135
135
  end
@@ -143,7 +143,7 @@ describe "Yaml" do
143
143
  code_a
144
144
  # comment_a
145
145
  # comment_a2
146
- code_b # comment_b3
146
+ code_b# comment_b3
147
147
  YAML
148
148
  end
149
149
  end
@@ -201,7 +201,7 @@ comment_a
201
201
  */
202
202
  // comment_b
203
203
  // comment_b2
204
- code_b // comment_b3
204
+ code_b// comment_b3
205
205
  PHP
206
206
  end
207
207
  end
@@ -215,7 +215,7 @@ describe "Python" do
215
215
  code_a
216
216
  # comment_a
217
217
  # comment_a2
218
- code_b # comment_b3
218
+ code_b# comment_b3
219
219
  PYTHON
220
220
  end
221
221
  end
@@ -229,7 +229,46 @@ describe "Clojure" do
229
229
  code_a
230
230
  ; comment_a
231
231
  ; comment_a2
232
- code_b ; comment_b3
232
+ code_b; comment_b3
233
233
  CLOJURE
234
234
  end
235
+ end
236
+
237
+ describe "Scala" do
238
+ it_should_behave_like "language"
239
+
240
+ before do
241
+ @extension = :scala
242
+ @script = <<-SCALA
243
+ code_a
244
+ /*
245
+ comment_a
246
+ */
247
+ /*
248
+ * comment_a2
249
+ */
250
+ // comment_b
251
+ // comment_b2
252
+ code_b// comment_b3
253
+ SCALA
254
+ end
255
+ end
256
+
257
+ describe "Html" do
258
+ it_should_behave_like "language"
259
+
260
+ before do
261
+ @extension = :html
262
+ @script = <<-HTML
263
+ code_a
264
+ <!--
265
+ comment_a
266
+ -->
267
+ <!--
268
+ comment_a2
269
+ -->
270
+ code_b<!-- comment_b3 -->
271
+
272
+ HTML
273
+ end
235
274
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_stats2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-04 00:00:00.000000000Z
12
+ date: 2012-03-03 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby_ext
16
- requirement: &2829590 !ruby/object:Gem::Requirement
16
+ requirement: &70218106161240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.4'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2829590
24
+ version_requirements: *70218106161240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: vfs
27
- requirement: &2829350 !ruby/object:Gem::Requirement
27
+ requirement: &70218106160220 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.3'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2829350
35
+ version_requirements: *70218106160220
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: haml
38
- requirement: &2829110 !ruby/object:Gem::Requirement
38
+ requirement: &70218106159260 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.1'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2829110
46
+ version_requirements: *70218106159260
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: tilt
49
- requirement: &2828870 !ruby/object:Gem::Requirement
49
+ requirement: &70218106158380 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '1.3'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2828870
57
+ version_requirements: *70218106158380
58
58
  description:
59
59
  email:
60
60
  executables:
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 1.8.6
110
+ rubygems_version: 1.8.10
111
111
  signing_key:
112
112
  specification_version: 3
113
113
  summary: Language-agnostic Code Statistics