forked from andyverprauskus/ohcount
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of ssh://averprauskus@ohcount.git.sourceforge.n…
…et/gitroot/ohcount/ohcount
- Loading branch information
Showing
14 changed files
with
187 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env ruby | ||
require 'rexml/document' | ||
require 'rexml/streamlistener' | ||
|
||
class CsprojListener | ||
include REXML::StreamListener | ||
|
||
attr_accessor :callback | ||
def initialize(callback) | ||
@callback = callback | ||
@is_csproj_file = false | ||
end | ||
|
||
def tag_start(name, attrs) | ||
case name | ||
when 'Project' | ||
@is_csproj_file = true | ||
if attrs['xmlns'] and attrs['xmlns'] !~ /^http:\/\/schemas\.microsoft\.com\/developer\// | ||
# False alarm -- it contains a project element, but of another namespace | ||
@is_csproj_file = false | ||
end | ||
when 'Import' | ||
if @is_csproj_file && attrs['Project'] | ||
@callback.call(attrs['Project']) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'rexml/document' | ||
module Ohcount | ||
module Gestalt | ||
class CsprojRule < FileRule | ||
|
||
attr_accessor :import | ||
|
||
def initialize(*args) | ||
@import = args.shift || /.*/ | ||
@import = /^#{Regexp.escape(@import.to_s)}$/ unless @import.is_a? Regexp | ||
|
||
super(args) | ||
end | ||
|
||
def process_source_file(source_file) | ||
if source_file.filename =~ /\.csproj$/ && source_file.language_breakdown('xml') | ||
callback = lambda do |import| | ||
@count += 1 if import =~ @import | ||
end | ||
|
||
begin | ||
REXML::Document.parse_stream(source_file.language_breakdown('xml').code, CsprojListener.new(callback)) | ||
rescue REXML::ParseException | ||
# Malformed XML! -- ignore and move on | ||
end | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,3 @@ def process_source_file(source_file) | |
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
require 'test/unit' | ||
require File.dirname(__FILE__) + '/../test_helper.rb' | ||
require File.dirname(__FILE__) + '/definitions_test' | ||
require File.dirname(__FILE__) + '/file_rule_test' | ||
require File.dirname(__FILE__) + '/filename_rule_test' | ||
require File.dirname(__FILE__) + '/keyword_rule_test' | ||
require File.dirname(__FILE__) + '/rule_test' | ||
require File.dirname(__FILE__) + '/definitions_test' | ||
require File.dirname(__FILE__) + '/java_definitions_test' | ||
require File.dirname(__FILE__) + '/dot_net_definitions_test' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters