javaparse 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
1
1
  module JavaParse
2
-
3
- JAVA_COMMENTS_RE = /^\s*\/\/|^\s*\/\*|^\s*\*/
4
-
2
+
5
3
  class JavaUnit
6
4
 
7
- attr_reader :file_name, :body, :head, :loc, :bloc, :cloc, :all_lines
5
+ include LineCounter, MethodGraber
6
+
7
+ attr_reader :file_name, :unit_name, :body, :head, :methods, :loc, :bloc, :cloc, :all_lines
8
8
 
9
9
  def initialize(java_file_path)
10
10
  @file_path = java_file_path
@@ -13,6 +13,7 @@ module JavaParse
13
13
  @content = File.open(@file_path) { |file| file.read }
14
14
  validate_unit
15
15
  @head, @body = partition_unit
16
+ @methods = grab_methods(@body)
16
17
  count_lines
17
18
  end
18
19
 
@@ -39,21 +40,6 @@ module JavaParse
39
40
  raise RuntimeError, "Mismatch between filename and declared name for #{@file_path}" unless unit_declaration_line
40
41
  end
41
42
 
42
- def count_lines
43
- @all_lines, @loc, @bloc, @cloc = 0, 0, 0, 0
44
- @content.each_line { |line|
45
- @all_lines += 1
46
- if line.strip.empty?
47
- @bloc += 1
48
- elsif JAVA_COMMENTS_RE.match(line)
49
- @cloc += 1
50
- else
51
- @loc += 1
52
- end
53
- }
54
- [@loc, @cloc, @bloc, @all_lines]
55
- end
56
-
57
43
  def unit_declaration_line
58
44
  declaration_line_match = /^.*(?<=class|enum|interface)\s*#{@unit_name}.*$/.match(@content)
59
45
  declaration_line_match[0] unless declaration_line_match.nil?
data/lib/javaparse.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  $LOAD_PATH.unshift File.dirname(__FILE__)
2
2
 
3
+ require 'javaparse/line_counter.rb'
4
+ require 'javaparse/method_graber.rb'
3
5
  require 'javaparse/java_unit.rb'
6
+ require 'javaparse/java_method.rb'
4
7
  require 'javaparse/java_section.rb'
5
- require 'javaparse/java_files.rb'
8
+ require 'javaparse/java_files.rb'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: javaparse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-12 00:00:00.000000000 Z
12
+ date: 2012-08-25 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: