corundum 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/Specifications +1 -1
- data/doc/coverage/index.html +1163 -247
- data/lib/corundum/simplecov.rb +15 -8
- data/lib/corundum/tasklibs.rb +1 -0
- data/lib/corundum/version_control.rb +4 -1
- data/lib/corundum/version_control/git.rb +105 -0
- data/lib/corundum/version_control/monotone.rb +45 -13
- metadata +5 -4
data/lib/corundum/simplecov.rb
CHANGED
@@ -15,6 +15,10 @@ module Corundum
|
|
15
15
|
setting(:config_path, nil)
|
16
16
|
setting(:filters, ["./spec"])
|
17
17
|
|
18
|
+
setting(:coverage_filter, proc do |path|
|
19
|
+
/\.rb$/ =~ path
|
20
|
+
end)
|
21
|
+
|
18
22
|
setting(:threshold, 80)
|
19
23
|
setting(:groups, {})
|
20
24
|
setting(:code_files, toolkit.files.code)
|
@@ -26,23 +30,25 @@ module Corundum
|
|
26
30
|
@report_path ||= File::join(report_dir, "index.html")
|
27
31
|
end
|
28
32
|
|
29
|
-
def
|
30
|
-
filters.map do |pattern|
|
33
|
+
def filter_lines
|
34
|
+
return filters.map do |pattern|
|
31
35
|
"add_filter \"#{pattern}\""
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
35
|
-
def
|
39
|
+
def group_lines
|
40
|
+
lines = []
|
36
41
|
groups.each_pair do |group, pattern|
|
37
|
-
"add_group \"#{group}\", \"#{pattern}\""
|
42
|
+
lines << "add_group \"#{group}\", \"#{pattern}\""
|
38
43
|
end
|
44
|
+
lines
|
39
45
|
end
|
40
46
|
|
41
47
|
def config_file_contents
|
42
48
|
contents = ["SimpleCov.start do"]
|
43
49
|
contents << " coverage_dir \"#{report_dir}\""
|
44
|
-
contents +=
|
45
|
-
contents +=
|
50
|
+
contents += filter_lines.map{|line| " " + line}
|
51
|
+
contents += group_lines.map{|line| " " + line}
|
46
52
|
contents << "end"
|
47
53
|
return contents.join("\n")
|
48
54
|
end
|
@@ -97,9 +103,10 @@ module Corundum
|
|
97
103
|
"//table[@class='file_list']//td//a[@class='src_link']").map do |link|
|
98
104
|
link.content
|
99
105
|
end
|
106
|
+
need_coverage = @code_files.find_all(&coverage_filter)
|
100
107
|
|
101
|
-
not_listed = covered_files -
|
102
|
-
not_covered =
|
108
|
+
not_listed = covered_files - need_coverage
|
109
|
+
not_covered = need_coverage - covered_files
|
103
110
|
unless not_listed.empty? and not_covered.empty?
|
104
111
|
raise ["Covered files and gemspec manifest don't match:",
|
105
112
|
"Not in gemspec: #{not_listed.inspect}",
|
data/lib/corundum/tasklibs.rb
CHANGED
@@ -9,13 +9,16 @@ module Corundum
|
|
9
9
|
def default_configuration(toolkit)
|
10
10
|
setting(:gemspec, toolkit.gemspec)
|
11
11
|
setting(:build_finished_file, toolkit.finished_files.build)
|
12
|
+
setting(:gemspec_files, toolkit.files.code + toolkit.files.test)
|
12
13
|
setting(:tag, toolkit.gemspec.version.to_s)
|
13
14
|
end
|
14
15
|
|
15
16
|
def define
|
16
17
|
in_namespace do
|
17
18
|
task :not_tagged
|
18
|
-
task :
|
19
|
+
task :gemspec_files_added
|
20
|
+
task :workspace_committed
|
21
|
+
task :is_checked_in => %w{gemspec_files_added workspace_committed}
|
19
22
|
task :tag
|
20
23
|
task :check_in => :tag
|
21
24
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'corundum/version_control'
|
2
|
+
|
3
|
+
module Corundum
|
4
|
+
class Git < VersionControl
|
5
|
+
def default_configuration(*args)
|
6
|
+
super
|
7
|
+
setting(:branch, nil)
|
8
|
+
end
|
9
|
+
|
10
|
+
def resolve_configuration
|
11
|
+
@branch ||= guess_branch
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def git_command(*args)
|
16
|
+
result = ""
|
17
|
+
pid = nil
|
18
|
+
command = "git --no-pager #{args.join(" ")}"
|
19
|
+
puts command if verbose
|
20
|
+
pipe = IO.popen(command)
|
21
|
+
pid = pipe.pid
|
22
|
+
Process::wait(pid)
|
23
|
+
result = pipe.read
|
24
|
+
pipe.close
|
25
|
+
unless $?.exitstatus == 0
|
26
|
+
fail "Git exited with status #{$?.exitstatus}: \n#{result}"
|
27
|
+
end
|
28
|
+
return result.split("\n")
|
29
|
+
end
|
30
|
+
|
31
|
+
def guess_branch
|
32
|
+
puts "Guessing branch - configure Git > branch"
|
33
|
+
branch = git_command("branch").grep(/^\*/).sub(/\*\s*/,"").chomp
|
34
|
+
puts " Guessed: #{branch}"
|
35
|
+
return branch
|
36
|
+
end
|
37
|
+
|
38
|
+
def define
|
39
|
+
super
|
40
|
+
|
41
|
+
in_namespace do
|
42
|
+
task :on_branch do
|
43
|
+
current_branch = git_command("branch").grep(/^\*/).first.sub(/\*\s*/,"").chomp
|
44
|
+
unless current_branch == branch
|
45
|
+
fail "Current branch \"#{current_branch}\" is not #{branch}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
task :not_tagged => :on_branch do
|
50
|
+
tags = git_command("tag", "-l", tag)
|
51
|
+
unless tags.empty?
|
52
|
+
fail "Tag #{tag} already exists in branch #{branch}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
task :workspace_committed => :on_branch do
|
57
|
+
diffs = git_command("diff", "--stat", "HEAD")
|
58
|
+
unless diffs.empty?
|
59
|
+
fail "Workspace not committed:\n #{diffs.join(" \n")}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
task :gemspec_files_added => :on_branch do
|
64
|
+
list = git_command(%w{ls-tree -r HEAD})
|
65
|
+
list.map! do |line|
|
66
|
+
line.split(/\s+/)[3]
|
67
|
+
end
|
68
|
+
|
69
|
+
missing = gemspec_files - list
|
70
|
+
unless missing.empty?
|
71
|
+
fail "Gemspec files not in version control: #{missing.join(", ")}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
task :is_pulled do
|
76
|
+
fetch = git_command("fetch", "--dry-run")
|
77
|
+
unless fetch.empty?
|
78
|
+
fail "Remote branch has unpulled changes"
|
79
|
+
end
|
80
|
+
|
81
|
+
remote = git_command("config", "--get", "branch.#{branch}.remote").first
|
82
|
+
merge = git_command("config", "--get", "branch.#{branch}.merge").first.split("/").last
|
83
|
+
|
84
|
+
ancestor = git_command("merge-base", branch, "#{remote}/#{merge}").first
|
85
|
+
remote_rev = File::read(".git/refs/remotes/#{remote}/#{merge}").chomp
|
86
|
+
|
87
|
+
unless ancestor == remote_rev
|
88
|
+
fail "Unmerged changes with remote branch #{remote}/#{merge}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
task :is_checked_in => :is_pulled
|
92
|
+
|
93
|
+
task :tag => :on_branch do
|
94
|
+
git_command("tag", tag)
|
95
|
+
end
|
96
|
+
|
97
|
+
task :push => :on_branch do
|
98
|
+
git_command("push")
|
99
|
+
end
|
100
|
+
|
101
|
+
task :check_in => [:push]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -3,10 +3,6 @@ require 'strscan'
|
|
3
3
|
|
4
4
|
module Corundum
|
5
5
|
class Monotone < VersionControl
|
6
|
-
def default_namespace
|
7
|
-
:monotone
|
8
|
-
end
|
9
|
-
|
10
6
|
def default_configuration(*args)
|
11
7
|
super
|
12
8
|
setting(:branch, nil)
|
@@ -17,13 +13,17 @@ module Corundum
|
|
17
13
|
end
|
18
14
|
|
19
15
|
def mtn_automate(cmd, *args)
|
20
|
-
result = ""
|
21
16
|
command = "mtn automate #{cmd} #{args.join(" ")}"
|
22
17
|
puts command if verbose
|
23
|
-
IO.popen(command)
|
24
|
-
|
18
|
+
pipe = IO.popen(command)
|
19
|
+
pid = pipe.pid
|
20
|
+
Process.wait(pid)
|
21
|
+
result = pipe.read
|
22
|
+
pipe.close
|
23
|
+
unless $?.exitstatus == 0
|
24
|
+
fail "Monotone failed with exit status #{$?.exitstatus}: \n#{result}"
|
25
25
|
end
|
26
|
-
result
|
26
|
+
return result
|
27
27
|
end
|
28
28
|
|
29
29
|
def parse_basic_io(string)
|
@@ -87,10 +87,30 @@ module Corundum
|
|
87
87
|
certs["branch"].first
|
88
88
|
end
|
89
89
|
|
90
|
+
def stanzas(first_item, items)
|
91
|
+
stanzas = []
|
92
|
+
current_stanza = {}
|
93
|
+
items.each do |name, value|
|
94
|
+
if name == first_item
|
95
|
+
current_stanza = {}
|
96
|
+
stanzas << current_stanza
|
97
|
+
end
|
98
|
+
current_stanza[name] = value
|
99
|
+
end
|
100
|
+
return stanzas
|
101
|
+
end
|
102
|
+
|
90
103
|
def define
|
91
104
|
super
|
92
105
|
|
93
106
|
in_namespace do
|
107
|
+
task :on_branch do
|
108
|
+
branches = parse_certs(mtn_automate("certs", base_revision))["branch"] || []
|
109
|
+
unless branches.include?(branch)
|
110
|
+
fail "Not on branch #{branch}"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
94
114
|
task :not_tagged do
|
95
115
|
items = parse_basic_io(mtn_automate("tags", branch))
|
96
116
|
tags = items.find{|pair| pair[0] == "tag" && pair[1] == tag}
|
@@ -99,7 +119,7 @@ module Corundum
|
|
99
119
|
end
|
100
120
|
end
|
101
121
|
|
102
|
-
task :
|
122
|
+
task :workspace_committed => :on_branch do
|
103
123
|
items = parse_basic_io(mtn_automate("inventory"))
|
104
124
|
changed = items.find{|pair| pair[0] == "changes"}
|
105
125
|
unless changed.nil?
|
@@ -107,7 +127,21 @@ module Corundum
|
|
107
127
|
end
|
108
128
|
end
|
109
129
|
|
110
|
-
task :
|
130
|
+
task :gemspec_files_added => :on_branch do
|
131
|
+
items = stanzas("path", parse_basic_io(mtn_automate("inventory")))
|
132
|
+
items.delete_if{|item| item["status"] == "unknown"}
|
133
|
+
known_paths = items.each_with_object({}) do |item, hash|
|
134
|
+
hash[item["path"]] = true
|
135
|
+
end
|
136
|
+
|
137
|
+
files = gemspec_files.dup
|
138
|
+
files.delete_if{|path| known_paths[path]}
|
139
|
+
unless files.empty?
|
140
|
+
fail "Gemspec files not in version control: #{files.join(" ")}"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
task :tag => :on_branch do
|
111
145
|
mtn_automate("cert", base_revision, "tag", tag)
|
112
146
|
end
|
113
147
|
|
@@ -115,9 +149,7 @@ module Corundum
|
|
115
149
|
mtn_automate("sync")
|
116
150
|
end
|
117
151
|
|
118
|
-
task :check_in =>
|
119
|
-
|
120
|
-
task :is_checked_in => [:is_committed]
|
152
|
+
task :check_in => [:sync]
|
121
153
|
end
|
122
154
|
end
|
123
155
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: corundum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Judson Lester
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-12-
|
13
|
+
date: 2011-12-13 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: corundum
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- lib/corundum/rubyforge.rb
|
197
197
|
- lib/corundum/version_control.rb
|
198
198
|
- lib/corundum/version_control/monotone.rb
|
199
|
+
- lib/corundum/version_control/git.rb
|
199
200
|
- lib/corundum.rb
|
200
201
|
- doc/README
|
201
202
|
- doc/Specifications
|
@@ -264,7 +265,7 @@ rdoc_options:
|
|
264
265
|
- --main
|
265
266
|
- doc/README
|
266
267
|
- --title
|
267
|
-
- corundum-0.0.
|
268
|
+
- corundum-0.0.5 RDoc
|
268
269
|
require_paths:
|
269
270
|
- lib/
|
270
271
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -272,7 +273,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
272
273
|
requirements:
|
273
274
|
- - ">="
|
274
275
|
- !ruby/object:Gem::Version
|
275
|
-
hash:
|
276
|
+
hash: 4506387
|
276
277
|
segments:
|
277
278
|
- 0
|
278
279
|
version: "0"
|