corundum 0.0.1 → 0.0.2
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 +1437 -1571
- data/lib/corundum.rb +53 -63
- data/lib/corundum/configurable.rb +54 -0
- data/lib/corundum/email.rb +17 -30
- data/lib/corundum/gem_building.rb +7 -12
- data/lib/corundum/gemcutter.rb +25 -28
- data/lib/corundum/gemspec_sanity.rb +3 -8
- data/lib/corundum/rspec.rb +23 -23
- data/lib/corundum/rubyforge.rb +8 -42
- data/lib/corundum/simplecov.rb +29 -37
- data/lib/corundum/tasklib.rb +17 -17
- data/lib/corundum/version_control.rb +5 -10
- data/lib/corundum/version_control/monotone.rb +11 -9
- data/lib/corundum/yardoc.rb +11 -11
- metadata +5 -4
@@ -6,19 +6,14 @@ module Corundum
|
|
6
6
|
:gemspec_sanity
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
def default_configuration(namespace, toolkit_config)
|
14
|
-
@configuration.namespace = namespace
|
15
|
-
@configuration.gemspec = toolkit_config.gemspec
|
9
|
+
def default_configuration(toolkit)
|
10
|
+
setting(:gemspec, toolkit.gemspec)
|
16
11
|
end
|
17
12
|
|
18
13
|
def define
|
19
14
|
in_namespace do
|
20
15
|
task :files_exist do
|
21
|
-
missing =
|
16
|
+
missing = gemspec.files.find_all do |path|
|
22
17
|
not File::exists?(path)
|
23
18
|
end
|
24
19
|
|
data/lib/corundum/rspec.rb
CHANGED
@@ -7,36 +7,35 @@ module Corundum
|
|
7
7
|
#collaboration of those two.
|
8
8
|
#
|
9
9
|
class RSpec < TaskLib
|
10
|
-
def
|
11
|
-
|
10
|
+
def default_namespace
|
11
|
+
:rspec
|
12
12
|
end
|
13
13
|
|
14
|
-
def default_configuration(
|
15
|
-
|
16
|
-
:pattern =>
|
14
|
+
def default_configuration(toolkit)
|
15
|
+
setting(:task_options, nested(
|
16
|
+
:pattern => './spec{,/*/**}/*_spec.rb',
|
17
17
|
:ruby_opts => nil,
|
18
|
+
:rspec_configs => nil,
|
18
19
|
:rspec_opts => nil,
|
19
20
|
:warning => false,
|
20
21
|
:verbose => true,
|
21
22
|
:fail_on_error => true,
|
22
23
|
:ruby_opts => [],
|
24
|
+
:rspec_path => 'rspec',
|
23
25
|
:rspec_opts => %w{--format documentation --out last_run --color --format documentation},
|
24
26
|
:failure_message => "Spec examples failed.",
|
25
|
-
:files_to_run =>
|
26
|
-
)
|
27
|
+
:files_to_run => "spec"
|
28
|
+
))
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
@configuration.qa_finished_path = toolkit_config.qa_finished_path
|
30
|
+
setting(:gemspec_path, toolkit.gemspec_path)
|
31
|
+
setting(:qa_finished_path, toolkit.finished_files.qa)
|
31
32
|
end
|
32
33
|
|
33
34
|
def resolve_configuration
|
34
|
-
|
35
|
-
@
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@configuration.task_options.pattern ||= './spec{,/*/**}/*_spec.rb'
|
39
|
-
@configuration.task_options.files_to_run ||= "spec"
|
35
|
+
#XXX Que?
|
36
|
+
@task_options.rspec_configs = task_options.rspec_opts
|
37
|
+
@task_options.rspec_opts = []
|
38
|
+
@task_options.rspec_path = %x"which #{task_options.rspec_path}".chomp
|
40
39
|
end
|
41
40
|
|
42
41
|
#XXX some point in the future, there needs to be a composible command
|
@@ -45,7 +44,7 @@ module Corundum
|
|
45
44
|
cmd_parts = []
|
46
45
|
cmd_parts << RUBY
|
47
46
|
cmd_parts << options.ruby_opts
|
48
|
-
cmd_parts << "-w" if options.warning
|
47
|
+
cmd_parts << "-w" if options.warning
|
49
48
|
if /^1\.8/ =~ RUBY_VERSION
|
50
49
|
cmd_parts << "-S"
|
51
50
|
end
|
@@ -66,7 +65,7 @@ module Corundum
|
|
66
65
|
end
|
67
66
|
|
68
67
|
def custom_options
|
69
|
-
options =
|
68
|
+
options = task_options.dup
|
70
69
|
yield(options)
|
71
70
|
return options
|
72
71
|
end
|
@@ -75,7 +74,7 @@ module Corundum
|
|
75
74
|
options = if block_given?
|
76
75
|
custom_options{|options| yield(options) if block_given?}
|
77
76
|
else
|
78
|
-
|
77
|
+
task_options
|
79
78
|
end
|
80
79
|
task name do
|
81
80
|
RakeFileUtils.send(:verbose, verbose) do
|
@@ -86,7 +85,8 @@ module Corundum
|
|
86
85
|
cmd = full_command(options)
|
87
86
|
puts cmd if options.verbose
|
88
87
|
success = system(cmd)
|
89
|
-
rescue
|
88
|
+
rescue Object => ex
|
89
|
+
p ex
|
90
90
|
puts options.failure_message if options.failure_message
|
91
91
|
end
|
92
92
|
raise("ruby #{cmd} failed") if options.fail_on_error unless success
|
@@ -96,9 +96,6 @@ module Corundum
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def define
|
99
|
-
desc "Run failing examples if any exist, otherwise, run the whole suite"
|
100
|
-
task @configuration.namespace => "#{@configuration.namespace}:quick"
|
101
|
-
|
102
99
|
in_namespace do
|
103
100
|
desc "Always run every spec"
|
104
101
|
define_spec_task(:all)
|
@@ -129,6 +126,9 @@ module Corundum
|
|
129
126
|
end
|
130
127
|
end
|
131
128
|
|
129
|
+
desc "Run failing examples if any exist, otherwise, run the whole suite"
|
130
|
+
task root_task => in_namespace(:quick)
|
131
|
+
|
132
132
|
task :qa => in_namespace(:doc)
|
133
133
|
end
|
134
134
|
end
|
data/lib/corundum/rubyforge.rb
CHANGED
@@ -7,32 +7,21 @@ require 'corundum/tasklib'
|
|
7
7
|
module Corundum
|
8
8
|
class Publishing < TaskLib
|
9
9
|
def default_namespace
|
10
|
-
:
|
10
|
+
:rubyforge
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
|
13
|
+
def default_configuration(toolkit)
|
14
|
+
setting(:ns, ns)
|
15
|
+
setting(:rubyforge, nested(:package_id => nil, :group_id => nil, :release_name => nil))
|
16
|
+
setting(:package_dir, nil)
|
17
|
+
setting(:gemspec, nil)
|
15
18
|
end
|
16
19
|
|
17
|
-
def default_configuration(namespace, toolkit_config)
|
18
|
-
end
|
19
|
-
|
20
|
-
def initialize(ns = :publish)
|
21
|
-
@ns = ns
|
22
|
-
@rubyforge = OpenStruct.new(:package_id => nil, :group_id => nil, :release_name => nil)
|
23
|
-
@package_dir = nil
|
24
|
-
@gemspec = nil
|
25
|
-
yield self if block_given?
|
26
|
-
define
|
27
|
-
end
|
28
|
-
|
29
|
-
attr_accessor :ns, :rubyforge, :package_dir, :gemspec
|
30
|
-
|
31
20
|
def define
|
32
21
|
desc "Publish the gem and its documentation to Rubyforge and Gemcutter"
|
33
|
-
task
|
22
|
+
task root_task => in_namespace(:docs, :rubyforge)
|
34
23
|
|
35
|
-
|
24
|
+
in_namespace do
|
36
25
|
desc 'Publish RDoc to RubyForge'
|
37
26
|
task :docs do
|
38
27
|
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
|
@@ -70,26 +59,3 @@ module Corundum
|
|
70
59
|
end
|
71
60
|
end
|
72
61
|
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
module Corundum
|
77
|
-
class Email < TaskLib
|
78
|
-
def define
|
79
|
-
desc 'Announce release on RubyForge and email'
|
80
|
-
task @configuration.namespace => ["#{@configuration.namespace.to_s}:rubyforge", "#{@configuration.namespace.to_s}:email"]
|
81
|
-
namespace @configuration.namespace do
|
82
|
-
desc 'Post announcement to rubyforge.'
|
83
|
-
task :rubyforge do
|
84
|
-
require 'rubyforge'
|
85
|
-
subject, title, body = announcement
|
86
|
-
|
87
|
-
forge = RubyForge.new
|
88
|
-
forge.configure
|
89
|
-
forge.post_news(@configuration.rubyforge[:group_id], subject, "#{title}\n\n#{body}")
|
90
|
-
puts "Posted to rubyforge"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
data/lib/corundum/simplecov.rb
CHANGED
@@ -6,49 +6,41 @@ module Corundum
|
|
6
6
|
:coverage
|
7
7
|
end
|
8
8
|
|
9
|
-
def default_configuration(
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
)
|
23
|
-
@configuration.groups = {}
|
24
|
-
|
25
|
-
@configuration.all_files = toolkit_config.file_lists.code + toolkit_config.file_lists.test
|
9
|
+
def default_configuration(toolkit, testlib)
|
10
|
+
setting(:test_lib, testlib)
|
11
|
+
setting(:browser, toolkit.browser)
|
12
|
+
setting(:report_dir, "doc/coverage")
|
13
|
+
setting(:report_path, nil)
|
14
|
+
setting(:config_file, ".simplecov")
|
15
|
+
setting(:config_path, nil)
|
16
|
+
setting(:filters, ["./spec"])
|
17
|
+
|
18
|
+
setting(:threshold, 80)
|
19
|
+
setting(:groups, {})
|
20
|
+
setting(:code_files, toolkit.files.code)
|
21
|
+
setting(:all_files, toolkit.file_lists.code + toolkit.file_lists.test)
|
26
22
|
end
|
27
23
|
|
28
24
|
def resolve_configuration
|
29
|
-
@
|
30
|
-
@
|
31
|
-
end
|
32
|
-
|
33
|
-
def receive_tasklibs(toolkit, test_lib)
|
34
|
-
@toolkit,@test_lib = toolkit, test_lib
|
25
|
+
@config_path ||= File::expand_path(config_file, Rake::original_dir)
|
26
|
+
@report_path ||= File::join(report_dir, "index.html")
|
35
27
|
end
|
36
28
|
|
37
29
|
def filters
|
38
|
-
|
30
|
+
filters.map do |pattern|
|
39
31
|
"add_filter \"#{pattern}\""
|
40
32
|
end
|
41
33
|
end
|
42
34
|
|
43
35
|
def groups
|
44
|
-
|
36
|
+
groups.each_pair do |group, pattern|
|
45
37
|
"add_group \"#{group}\", \"#{pattern}\""
|
46
38
|
end
|
47
39
|
end
|
48
40
|
|
49
41
|
def config_file_contents
|
50
42
|
contents = ["SimpleCov.start do"]
|
51
|
-
contents << " coverage_dir \"#{
|
43
|
+
contents << " coverage_dir \"#{report_dir}\""
|
52
44
|
contents += filters.map{|line| " " + line}
|
53
45
|
contents += groups.map{|line| " " + line}
|
54
46
|
contents << "end"
|
@@ -60,7 +52,7 @@ module Corundum
|
|
60
52
|
file "Rakefile"
|
61
53
|
|
62
54
|
task :example_config do
|
63
|
-
$stderr.puts "Try this in #{
|
55
|
+
$stderr.puts "Try this in #{config_path}"
|
64
56
|
$stderr.puts
|
65
57
|
puts config_file_contents
|
66
58
|
end
|
@@ -69,45 +61,45 @@ module Corundum
|
|
69
61
|
File::exists?(File::join(Rake::original_dir, ".simplecov")) or fail "No .simplecov"
|
70
62
|
end
|
71
63
|
|
72
|
-
directory File::dirname(
|
73
|
-
file
|
64
|
+
directory File::dirname(report_path)
|
65
|
+
file report_path => all_files do
|
74
66
|
options = @test_lib.custom_options do |options|
|
75
67
|
options.rspec_opts += %w{-r simplecov}
|
76
68
|
end
|
77
69
|
sh @test_lib.full_command(options)
|
78
70
|
end
|
79
71
|
|
80
|
-
task :generate_report => [:preflight,
|
72
|
+
task :generate_report => [:preflight, report_path]
|
81
73
|
|
82
74
|
desc "View coverage in browser"
|
83
75
|
task :view => :generate_report do
|
84
|
-
sh "#{
|
76
|
+
sh "#{browser} #{report_path}"
|
85
77
|
end
|
86
78
|
|
87
79
|
task :verify_coverage => :generate_report do
|
88
80
|
require 'nokogiri'
|
89
81
|
|
90
|
-
doc = Nokogiri::parse(File::read(
|
82
|
+
doc = Nokogiri::parse(File::read(report_path))
|
91
83
|
|
92
84
|
coverage_total_xpath = "//span[@class='covered_percent']/span"
|
93
85
|
percentage = doc.xpath(coverage_total_xpath).first.content.to_f
|
94
86
|
|
95
|
-
raise "Coverage must be at least #{
|
96
|
-
puts "Coverage is #{percentage}% (required: #{
|
87
|
+
raise "Coverage must be at least #{threshold} but was #{percentage}" if percentage < threshold
|
88
|
+
puts "Coverage is #{percentage}% (required: #{threshold}%)"
|
97
89
|
end
|
98
90
|
|
99
91
|
task :find_stragglers => :generate_report do
|
100
92
|
require 'nokogiri'
|
101
93
|
|
102
|
-
doc = Nokogiri::parse(File::read(
|
94
|
+
doc = Nokogiri::parse(File::read(report_path))
|
103
95
|
|
104
96
|
covered_files = doc.xpath(
|
105
97
|
"//table[@class='file_list']//td//a[@class='src_link']").map do |link|
|
106
98
|
link.content
|
107
99
|
end
|
108
100
|
|
109
|
-
not_listed = covered_files - @
|
110
|
-
not_covered = @
|
101
|
+
not_listed = covered_files - @code_files
|
102
|
+
not_covered = @code_files - covered_files
|
111
103
|
unless not_listed.empty? and not_covered.empty?
|
112
104
|
raise ["Covered files and gemspec manifest don't match:",
|
113
105
|
"Not in gemspec: #{not_listed.inspect}",
|
data/lib/corundum/tasklib.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
require 'rake/tasklib'
|
3
|
+
require 'corundum/configurable'
|
3
4
|
|
4
5
|
module Corundum
|
5
6
|
class TaskLib < Rake::TaskLib
|
6
|
-
|
7
|
+
include Configurable
|
7
8
|
|
8
|
-
def
|
9
|
-
end
|
10
|
-
|
11
|
-
def default_configuration(namespace, *tasklib_configs)
|
9
|
+
def default_configuration(*tasklibs)
|
12
10
|
end
|
13
11
|
|
14
12
|
def resolve_configuration
|
@@ -17,37 +15,39 @@ module Corundum
|
|
17
15
|
def in_namespace(*tasknames)
|
18
16
|
if tasknames.empty?
|
19
17
|
if block_given?
|
20
|
-
if @
|
18
|
+
if @namespace_name.nil?
|
21
19
|
yield
|
22
20
|
else
|
23
|
-
namespace @
|
21
|
+
namespace @namespace_name do
|
24
22
|
yield
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
28
26
|
else
|
29
27
|
tasknames.map do |taskname|
|
30
|
-
[@
|
28
|
+
[@namespace_name, taskname].compact.join(":")
|
31
29
|
end
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
33
|
+
def root_task
|
34
|
+
@namespace_name || :default
|
35
|
+
end
|
36
|
+
|
35
37
|
def default_namespace
|
36
38
|
nil
|
37
39
|
end
|
38
40
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
receive_tasklibs(*tasklibs)
|
41
|
+
def [](taskname)
|
42
|
+
in_namespace(taskname).first
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
default_configuration(default_namespace, *configs)
|
45
|
+
def initialize(*tasklibs)
|
46
|
+
setting(:namespace_name, default_namespace)
|
48
47
|
|
48
|
+
default_configuration(*tasklibs)
|
49
49
|
|
50
|
-
yield
|
50
|
+
yield self if block_given?
|
51
51
|
|
52
52
|
resolve_configuration
|
53
53
|
|
@@ -6,15 +6,10 @@ module Corundum
|
|
6
6
|
:version_control
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def default_configuration(namespace, toolkit_config)
|
14
|
-
@configuration.namespace = namespace
|
15
|
-
@configuration.gemspec = toolkit_config.gemspec
|
16
|
-
@configuration.build_finished_file = toolkit_config.finished_files.build
|
17
|
-
@configuration.tag = toolkit_config.gemspec.version
|
9
|
+
def default_configuration(toolkit)
|
10
|
+
setting(:gemspec, toolkit.gemspec)
|
11
|
+
setting(:build_finished_file, toolkit.finished_files.build)
|
12
|
+
setting(:tag, toolkit.gemspec.version.to_s)
|
18
13
|
end
|
19
14
|
|
20
15
|
def define
|
@@ -28,7 +23,7 @@ module Corundum
|
|
28
23
|
task :preflight => in_namespace(:not_tagged)
|
29
24
|
task :build => in_namespace(:is_checked_in)
|
30
25
|
in_namespace(:tag, :check_in).each do |taskname|
|
31
|
-
task taskname =>
|
26
|
+
task taskname => build_finished_file
|
32
27
|
end
|
33
28
|
task :release => in_namespace(:tag, :check_in)
|
34
29
|
end
|
@@ -9,16 +9,18 @@ module Corundum
|
|
9
9
|
|
10
10
|
def default_configuration(*args)
|
11
11
|
super
|
12
|
-
|
12
|
+
setting(:branch, nil)
|
13
13
|
end
|
14
14
|
|
15
15
|
def resolve_configuration
|
16
|
-
@
|
16
|
+
@branch ||= guess_branch
|
17
17
|
end
|
18
18
|
|
19
19
|
def mtn_automate(cmd, *args)
|
20
20
|
result = ""
|
21
|
-
|
21
|
+
command = "mtn automate #{cmd} #{args.join(" ")}"
|
22
|
+
puts command if verbose
|
23
|
+
IO.popen(command) do |pipe|
|
22
24
|
result = pipe.read
|
23
25
|
end
|
24
26
|
result
|
@@ -75,7 +77,7 @@ module Corundum
|
|
75
77
|
end
|
76
78
|
|
77
79
|
def base_revision
|
78
|
-
mtn_automate("get_base_revision_id")
|
80
|
+
mtn_automate("get_base_revision_id").chomp
|
79
81
|
end
|
80
82
|
|
81
83
|
def guess_branch
|
@@ -90,10 +92,10 @@ module Corundum
|
|
90
92
|
|
91
93
|
in_namespace do
|
92
94
|
task :not_tagged do
|
93
|
-
items = parse_basic_io(mtn_automate("tags",
|
94
|
-
tags = items.find{|pair| pair[0] == "tag" && pair[1] ==
|
95
|
+
items = parse_basic_io(mtn_automate("tags", branch))
|
96
|
+
tags = items.find{|pair| pair[0] == "tag" && pair[1] == tag}
|
95
97
|
unless tags.nil?
|
96
|
-
fail "Tag #{
|
98
|
+
fail "Tag #{tag} already exists in branch #{branch}"
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
@@ -106,11 +108,11 @@ module Corundum
|
|
106
108
|
end
|
107
109
|
|
108
110
|
task :tag do
|
109
|
-
mtn_automate("cert", base_revision, "tag",
|
111
|
+
mtn_automate("cert", base_revision, "tag", tag)
|
110
112
|
end
|
111
113
|
|
112
114
|
task :commit do
|
113
|
-
|
115
|
+
sh "mtn commit --branch #{branch} --message \"Automatic commit: gem built at version #{gemspec.version}\""
|
114
116
|
end
|
115
117
|
|
116
118
|
task :sync do
|