bvm 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Guy Royse & Alyssa Diaz
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = bvm
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to bvm
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Guy Royse. See LICENSE.txt for
18
+ further details.
19
+
data/bin/bvm ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bvm_runner'
@@ -0,0 +1 @@
1
+ require 'bvm/converter'
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ require 'optparse'
3
+ require 'bvm/converter'
4
+
5
+ converter = Converter.new
6
+
7
+ OptionParser.new do |opts|
8
+ opts.banner = "Usage: bvm [options]"
9
+ opts.on("--jar JARNAME", "Assign this code to the name of JARNAME, defaults to 'jar'") do |jar|
10
+ converter.jar = jar
11
+ end
12
+ opts.on("--size METRIC", "Use this metric for the size of the treemap boxes, defaults to 'ncloc'") do |size|
13
+ converter.size_metric = size
14
+ end
15
+ opts.on("--color METRIC", "Use this metric for the color of the treemap boxes, defaults to 'coverage'") do |color|
16
+ converter.color_metric = color
17
+ end
18
+ opts.on("--color-adjust VALUE", "Add the following value to color metric, defaults to 0, negatives are OK") do |adjust|
19
+ converter.color_adjustment = adjust.to_f
20
+ end
21
+ opts.on("--invert-color", "Inverts the color metric making it negative if positive and vice versa, executes before --color-adjust, defaults to false") do
22
+ invert_color_metric = true
23
+ end
24
+ end.parse!
25
+
26
+ puts converter.convert(STDIN.read)
@@ -0,0 +1,56 @@
1
+ require 'xmlsimple'
2
+
3
+ class Converter
4
+ attr_accessor :jar
5
+ attr_accessor :size_metric
6
+ attr_accessor :color_metric
7
+ attr_accessor :color_adjustment
8
+ attr_accessor :invert_color_metric
9
+
10
+ def initialize
11
+ @jar = 'jar'
12
+ @size_metric = 'ncloc'
13
+ @color_metric = 'coverage'
14
+ @color_adjustment = 0.0
15
+ @invert_color_metric = false
16
+ end
17
+
18
+ def convert(input)
19
+ output = ""
20
+ metrics = parse_xml input
21
+ metrics[:resource].each do |resource|
22
+ output << build_output(resource, @jar, @size_metric, @color_metric, @color_adjustment)
23
+ end
24
+ output
25
+ end
26
+
27
+ def parse_xml(input)
28
+ XmlSimple.xml_in input, { 'GroupTags' => { 'resources' => 'resource' }, 'KeyToSymbol' => true }
29
+ end
30
+
31
+ def build_output(resource, jar, size, color, adjust)
32
+ name = resource[:name]
33
+ size_metric = find_metric resource[:msr], size
34
+ color_metric = find_metric resource[:msr], color
35
+ color_metric *= -1 unless not @invert_color_metric
36
+ color_metric += adjust
37
+ package = parse_package resource[:key][0]
38
+ %Q/#{size_metric},#{color_metric},"#{jar}","#{package}","#{name}"\n/
39
+ end
40
+
41
+ def find_metric(metrics, key)
42
+ found_metric = 0.0
43
+ metrics.each do |metric|
44
+ if key == metric[:key][0] then
45
+ found_metric = metric[:val][0].to_f
46
+ end
47
+ end
48
+ found_metric
49
+ end
50
+
51
+ def parse_package(full_name)
52
+ temp = /^.*\./.match full_name
53
+ /^.*[^\.]/.match(temp.to_s)
54
+ end
55
+
56
+ end
@@ -0,0 +1 @@
1
+ require 'bvm/bvm_runner'
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bvm
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
+ platform: ruby
12
+ authors:
13
+ - Guy Royse
14
+ - Alyssa Diaz
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-03-05 00:00:00 -05:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: xml-simple
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ hash: 15
31
+ segments:
32
+ - 1
33
+ - 0
34
+ - 12
35
+ version: 1.0.12
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 2
49
+ - 3
50
+ - 0
51
+ version: 2.3.0
52
+ type: :development
53
+ version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ name: rspec-core
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 1
63
+ segments:
64
+ - 2
65
+ - 3
66
+ - 1
67
+ version: 2.3.1
68
+ type: :development
69
+ version_requirements: *id003
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec-expectations
72
+ prerelease: false
73
+ requirement: &id004 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 2
81
+ - 3
82
+ - 0
83
+ version: 2.3.0
84
+ type: :development
85
+ version_requirements: *id004
86
+ description: Generates CSV files that can be consumed by Microsoft Treemapper from the Sonar API. Reads stin and stdout.
87
+ email:
88
+ - guy@guyroyse.com
89
+ executables:
90
+ - bvm
91
+ extensions: []
92
+
93
+ extra_rdoc_files: []
94
+
95
+ files:
96
+ - lib/bvm.rb
97
+ - lib/bvm/bvm_runner.rb
98
+ - lib/bvm/converter.rb
99
+ - lib/bvm_runner.rb
100
+ - bin/bvm
101
+ - LICENSE
102
+ - README.md
103
+ has_rdoc: true
104
+ homepage: http://github.com/guyroyse/big-visible-metrics
105
+ licenses:
106
+ - MIT
107
+ post_install_message:
108
+ rdoc_options: []
109
+
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: 3
118
+ segments:
119
+ - 0
120
+ version: "0"
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ hash: 23
127
+ segments:
128
+ - 1
129
+ - 3
130
+ - 6
131
+ version: 1.3.6
132
+ requirements: []
133
+
134
+ rubyforge_project:
135
+ rubygems_version: 1.3.7
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: Generates CSV files from SONAR metrics
139
+ test_files: []
140
+