flex-source-inspector 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/README.md +9 -1
- data/features/FlexSourceInspector.feature +0 -4
- data/lib/flex-source-inspector/cli.rb +1 -0
- data/lib/flex-source-inspector/version.rb +1 -1
- data/lib/flex-source-inspector.rb +42 -7
- data/spec/data/ApplicationOne_link-report.xml +2 -2668
- data/spec/data/ApplicationTwo_link-report.xml +4 -2668
- data/spec/data/swc_link_report.xml +7 -0
- data/spec/flex-source-inspector_spec.rb +12 -6
- metadata +33 -23
- data/spec/data/LinkReportTestProject/.actionScriptProperties +0 -17
- data/spec/data/LinkReportTestProject/.flexProperties +0 -2
- data/spec/data/LinkReportTestProject/.project +0 -18
- data/spec/data/LinkReportTestProject/.settings/org.eclipse.core.resources.prefs +0 -4
- data/spec/data/LinkReportTestProject/link-reports/ApplicationOne_link-report.xml +0 -2671
- data/spec/data/LinkReportTestProject/link-reports/ApplicationTwo_link-report.xml +0 -2671
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -5,4 +5,12 @@ given a source folder and an array of link reports, it will return a list of fil
|
|
5
5
|
### Usage
|
6
6
|
flex-source-inpsector inspect /path/to/flex-src linkreport_one.xml [...linkreport_n.xml]
|
7
7
|
|
8
|
-
|
8
|
+
|
9
|
+
### Building
|
10
|
+
read: https://github.com/radar/guides/blob/master/gem-development.md
|
11
|
+
|
12
|
+
### Run Tests
|
13
|
+
rspec spec/flex-source-inspector_spec.rb
|
14
|
+
|
15
|
+
### Install Gem Locally
|
16
|
+
rake install
|
@@ -3,10 +3,6 @@ Feature: FlexSourceInspector
|
|
3
3
|
As a CLI
|
4
4
|
I want to be as objective as possible
|
5
5
|
|
6
|
-
Scenario: i can ping
|
7
|
-
When I run "flex-source-inspector ping"
|
8
|
-
Then the output should contain "pong"
|
9
|
-
|
10
6
|
Scenario: link report one
|
11
7
|
When I run "flex-source-inspector inspect ../../spec/data/LinkReportTestProject/flex-src ../../spec/data/ApplicationOne_link-report.xml"
|
12
8
|
Then the output should contain "NotUsedOne.as"
|
@@ -10,6 +10,7 @@ module FlexSourceInspector
|
|
10
10
|
desc "inspect path_to_flex_src, path_to_link_reports [, ... path_to_link_report]", "pass in the path to the flex src, and 1..* paths to link-report xml files"
|
11
11
|
def inspect( src_folder, *link_reports)
|
12
12
|
puts FlexSourceInspector::Inspector.inspect( src_folder, *link_reports )
|
13
|
+
puts "----"
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
@@ -3,13 +3,10 @@ require "rexml/document"
|
|
3
3
|
|
4
4
|
module FlexSourceInspector
|
5
5
|
class Inspector
|
6
|
-
def self.ping()
|
7
|
-
"pong"
|
8
|
-
end
|
9
6
|
|
10
7
|
def self.inspect( src_folder, *link_reports)
|
11
8
|
|
12
|
-
puts "
|
9
|
+
puts ">-- inspect --"
|
13
10
|
puts "pwd: #{Dir.pwd}"
|
14
11
|
|
15
12
|
raise "FlexSourceInspector::Error source folder doesn't exist #{src_folder}" unless File.exists? src_folder
|
@@ -21,6 +18,7 @@ module FlexSourceInspector
|
|
21
18
|
|
22
19
|
puts ""
|
23
20
|
puts "src folder: #{src_folder}"
|
21
|
+
puts ""
|
24
22
|
|
25
23
|
link_reports.each{|report|
|
26
24
|
puts "reading: #{report}"
|
@@ -28,13 +26,14 @@ module FlexSourceInspector
|
|
28
26
|
|
29
27
|
file = File.open( report )
|
30
28
|
doc = REXML::Document.new file
|
31
|
-
|
29
|
+
|
32
30
|
doc.elements.each("//script"){ |script|
|
33
31
|
name = script.attributes["name"]
|
34
32
|
add_to_used( used, project_files, name, src_folder )
|
35
33
|
}
|
36
34
|
}
|
37
|
-
|
35
|
+
puts ""
|
36
|
+
puts ""
|
38
37
|
unused = project_files - used
|
39
38
|
unused.join "\n"
|
40
39
|
end
|
@@ -42,8 +41,44 @@ module FlexSourceInspector
|
|
42
41
|
def self.add_to_used(used, project_files, class_declaration, src_folder)
|
43
42
|
project_files.each{ |file|
|
44
43
|
cleaned = file.gsub( src_folder, "")
|
45
|
-
used << file if
|
44
|
+
used << file if is_declared?(cleaned, class_declaration)
|
46
45
|
}
|
47
46
|
end
|
47
|
+
|
48
|
+
###
|
49
|
+
# A declaration can either be:
|
50
|
+
# "/Path/to/file/com/MyClass.as"
|
51
|
+
# or
|
52
|
+
# "/Path/to/My.swc(com.MyClass)"
|
53
|
+
# We check to see if either declaration matches the given file.
|
54
|
+
###
|
55
|
+
def self.is_declared?( file_name, declaration )
|
56
|
+
|
57
|
+
# Check for a direct file declaration
|
58
|
+
if declaration.include? file_name
|
59
|
+
return true
|
60
|
+
end
|
61
|
+
|
62
|
+
# Check for a swc declaration
|
63
|
+
class_name = convert_to_class_name file_name
|
64
|
+
|
65
|
+
if declaration.include? class_name
|
66
|
+
return true
|
67
|
+
end
|
68
|
+
false
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.convert_to_class_name( file_name )
|
72
|
+
out = file_name
|
73
|
+
out.gsub!("/", ".")
|
74
|
+
out.gsub!(".as", "")
|
75
|
+
out.gsub!(".mxml", "")
|
76
|
+
if out[0] == "."
|
77
|
+
out = out[1..out.length]
|
78
|
+
end
|
79
|
+
out.gsub!(/(.*)\.(.*)/, '\1:\2' )
|
80
|
+
out
|
81
|
+
end
|
82
|
+
|
48
83
|
end
|
49
84
|
end
|