corundum 0.0.26 → 0.0.27

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ #! /bin/env ruby
1
2
  # vi: set ft=ruby:
2
3
  require 'optparse'
3
4
  require 'corundum/configuration-store'
@@ -23,6 +23,7 @@ module Corundum
23
23
  :finished_dir => nil,
24
24
  :package_dir => "pkg",
25
25
  :doc_dir => "rubydoc",
26
+ :qa_rejections => nil,
26
27
  :browser => Corundum.user_preferences["browser"],
27
28
  :finished_files => nested.nil_fields(:build, :qa, :package, :release, :press),
28
29
  :files => nested.nil_fields(:code, :test, :docs),
@@ -55,6 +56,8 @@ module Corundum
55
56
  @finished_files.release ||= File::join( finished_dir, "release_#{gemspec.version}")
56
57
  @finished_files.press ||= File::join( finished_dir, "press_#{gemspec.version}")
57
58
 
59
+ @qa_rejections ||= []
60
+
58
61
  @files.code ||= gemspec.files.grep(%r{^lib/})
59
62
  @files.test ||= gemspec.files.grep(%r{^spec/})
60
63
  @files.docs ||= gemspec.files.grep(%r{^doc/})
@@ -92,10 +95,18 @@ module Corundum
92
95
  task :preflight
93
96
 
94
97
  desc "Run quality assurance tasks"
95
- task :qa => [:preflight, finished_files.qa]
98
+ task :qa => [:preflight, finished_files.qa] do
99
+ require 'corundum/qa-report'
100
+ puts QA::ReportFormatter.new(qa_rejections).to_s
101
+
102
+ unless qa_rejections.all?(&:passed)
103
+ fail "There are QA tests that failed"
104
+ end
105
+ end
106
+
96
107
  file finished_files.qa =>
97
108
  [finished_dir] + file_lists.project + file_lists.code + file_lists.test do |task|
98
- Rake::Task[:qa].invoke #because I don't want this to be needed if it's not
109
+ Rake::Task[:qa].invoke
99
110
  touch task.name
100
111
  end
101
112
 
@@ -75,10 +75,10 @@ module Corundum
75
75
 
76
76
  task :reinstall => [:uninstall, :install]
77
77
 
78
- task :dependencies_available do
78
+ task :dependencies_available => :is_unpushed do
79
79
  checker = Gem::SpecFetcher.new
80
80
  gemspec.runtime_dependencies.each do |dep|
81
- fulfilling = checker.find_matching(dep,false,false,false)
81
+ fulfilling = checker.find_matching(dep,true,false,false)
82
82
  if fulfilling.empty?
83
83
  fail "Dependency #{dep} is unfulfilled remotely"
84
84
  else
@@ -8,49 +8,48 @@ module Corundum
8
8
  setting :comments, false
9
9
  setting :accept_token, /#ok/
10
10
  setting :files
11
+ setting :qa_rejections
11
12
 
12
13
  def default_configuration(core)
13
14
  super
15
+ core.copy_settings_to(self)
14
16
  self.files = core.file_lists.code
15
17
  end
16
18
 
17
19
  def define
18
20
  in_namespace do
19
- task type do
21
+ task type do |task|
22
+ require 'corundum/qa-report'
23
+
20
24
  word_regexp = %r{#{words.map{|word| "\\b#{word}\\b"}.join("|")}}
21
- line_regexp = comments ? %r{\A\s*#.*#{word_regexp}} : word_regexp
25
+ line_regexp = case comments
26
+ when true, :only
27
+ %r{\A\s*#.*#{word_regexp}}
28
+ when false, :both
29
+ word_regexp
30
+ when :ignore
31
+ %r{\A\s*[^#]*#{word_regexp}} #this will fail like "Stuff #{interp}" <word>
32
+ end
33
+
22
34
  unless accept_token.nil?
23
35
  line_regexp = /#{line_regexp}(?:.(?!#{accept_token}))*\s*\Z/
24
-
25
- end
26
-
27
- found_words = Hash.new do |h,k|
28
- h[k] = 0
29
36
  end
30
37
 
31
- files_with_words = Hash.new do |h,k|
32
- h[k] = {}
33
- end
34
-
35
-
38
+ rejections = QA::Report.new("Content: #{type}")
39
+ qa_rejections << rejections
36
40
  files.each do |filename|
37
-
38
41
  File::open(filename) do |file|
39
- file.grep(line_regexp) do |line|
42
+ file.each_line.with_index do |line, line_number|
43
+ next unless line_regexp =~ line
40
44
  line.scan(word_regexp) do |word|
41
- files_with_words[filename][word] = true
42
- found_words[word] += 1
45
+ rejections << QA::Rejection.new(word, file, line_number+1)
43
46
  end
44
47
  end
45
48
  end
46
49
  end
47
50
 
48
- total = found_words.values.inject{|acc, num| acc + num} || 0
49
-
50
- if total > limit
51
- require 'pp'
52
- report = PP::pp([files_with_words, found_words], "")
53
- fail "Exceeded limits on words: #{words.join(",")}. Full report:\n#{report}"
51
+ if rejections.length > limit
52
+ rejections.fail "Maximum allowed uses: #{limit}"
54
53
  end
55
54
  end
56
55
  end
@@ -7,6 +7,7 @@ module Corundum
7
7
  title "RSpec run output"
8
8
 
9
9
  settings(
10
+ :qa_rejections => nil,
10
11
  :sub_dir => "rspec",
11
12
  :pattern => './spec{,/*/**}/*_spec.rb',
12
13
  :rspec_opts => nil,
@@ -24,6 +25,7 @@ module Corundum
24
25
  def default_configuration(toolkit)
25
26
  super
26
27
  self.qa_finished_path = toolkit.finished_files.qa
28
+ self.qa_rejections = toolkit.qa_rejections
27
29
  end
28
30
 
29
31
  def resolve_configuration
@@ -53,11 +55,38 @@ module Corundum
53
55
 
54
56
  desc "Generate specifications documentation"
55
57
  doc_task(:doc) do |t|
56
- t.rspec_opts = %w{-o /dev/null -f h -o} + [t.doc_path]
57
- t.failure_message = "Failed generating specification docs"
58
+ t.rspec_opts = %w{-o /dev/null --failure-exit-code 0 -f h -o} + [t.doc_path]
58
59
  end
59
60
  file entry_path => :doc
60
61
 
62
+ task :verify => :doc do |task|
63
+ require 'nokogiri'
64
+ require 'corundum/qa-report'
65
+
66
+ doc = Nokogiri::parse(File::read(entry_path))
67
+
68
+ rejections = QA::Report.new("RSpec")
69
+ qa_rejections << rejections
70
+
71
+ def class_xpath(name)
72
+ "contains(concat(' ', normalize-space(@class), ' '), '#{name}')"
73
+ end
74
+
75
+ fails_path = "//*[" + %w{example failed}.map{|kind| class_xpath(kind)}.join(" and ") + "]"
76
+ doc.xpath(fails_path).each do |node|
77
+ backtrace_line = node.xpath(".//*[#{class_xpath("backtrace")}]").contents.split("\n").last
78
+ file,line,_ = backtrace_line.split(":")
79
+ label = "fail"
80
+ value = node.xpath(".//[#{class_xpath("message")}]").contents.gsub(/\s+/m, " ")
81
+
82
+ rejections.add(label, file, line, value)
83
+ end
84
+
85
+ unless rejections.empty?
86
+ rejections.fail "Spec fails, none allowed"
87
+ end
88
+ end
89
+
61
90
  desc "Run only failing examples listed in last_run"
62
91
  test_task(:quick) do |t|
63
92
  examples = []
@@ -80,7 +109,7 @@ module Corundum
80
109
  desc "Run failing examples if any exist, otherwise, run the whole suite"
81
110
  task root_task => in_namespace(:quick)
82
111
 
83
- task :qa => in_namespace(:doc)
112
+ task :qa => in_namespace(:verify)
84
113
  end
85
114
  end
86
115
  end
@@ -25,11 +25,14 @@ module Corundum
25
25
 
26
26
  setting(:test_options, [])
27
27
 
28
+ setting :qa_rejections, nil
29
+
28
30
  def default_configuration(toolkit, testlib)
29
31
  super(toolkit)
30
32
  self.test_lib = testlib
31
33
  self.code_files = toolkit.files.code
32
34
  self.all_files = toolkit.file_lists.project + toolkit.file_lists.code + toolkit.file_lists.test
35
+ self.qa_rejections = toolkit.qa_rejections
33
36
  end
34
37
 
35
38
  def resolve_configuration
@@ -84,18 +87,26 @@ module Corundum
84
87
 
85
88
  task :verify_coverage => :generate_report do
86
89
  require 'nokogiri'
90
+ require 'corundum/qa-report'
87
91
 
88
92
  doc = Nokogiri::parse(File::read(entry_path))
89
93
 
90
94
  coverage_total_xpath = "//span[@class='covered_percent']/span"
91
95
  percentage = doc.xpath(coverage_total_xpath).first.content.to_f
92
96
 
93
- raise "Coverage must be at least #{threshold} but was #{percentage}" if percentage < threshold
94
- puts "Coverage is #{percentage}% (required: #{threshold}%)"
97
+ report = QA::Report.new("Coverage")
98
+ report.add("percentage", entry_path, nil, percentage)
99
+ report.add("threshold", entry_path, nil, threshold)
100
+ qa_rejections << report
101
+
102
+ if percentage < threshold
103
+ report.fail "Coverage below threshold"
104
+ end
95
105
  end
96
106
 
97
107
  task :find_stragglers => :generate_report do
98
108
  require 'nokogiri'
109
+ require 'corundum/qa-report'
99
110
 
100
111
  doc = Nokogiri::parse(File::read(entry_path))
101
112
 
@@ -105,12 +116,17 @@ module Corundum
105
116
  end
106
117
  need_coverage = @code_files.find_all(&coverage_filter)
107
118
 
108
- not_listed = covered_files - need_coverage
109
- not_covered = need_coverage - covered_files
110
- unless not_listed.empty? and not_covered.empty?
111
- raise ["Covered files and gemspec manifest don't match:",
112
- "Not in gemspec: #{not_listed.inspect}",
113
- "Not covered: #{not_covered.inspect}"].join("\n")
119
+ report = QA::Report.new("Stragglers")
120
+ (covered_files - need_coverage).each do |file|
121
+ report.add("Not in gemspec", file)
122
+ end
123
+
124
+ (need_coverage - covered_files).each do |file|
125
+ report.add("Not covered", file)
126
+ end
127
+
128
+ unless report.empty?
129
+ report.fail "Covered files and gemspec manifest don't match"
114
130
  end
115
131
  end
116
132
  end
metadata CHANGED
@@ -1,244 +1,252 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corundum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.26
5
4
  prerelease:
5
+ version: 0.0.27
6
6
  platform: ruby
7
7
  authors:
8
8
  - Judson Lester
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-30 00:00:00.000000000 Z
12
+ date: 2013-08-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
+ prerelease: false
16
+ type: :development
15
17
  name: corundum
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
+ version_requirements: !ruby/object:Gem::Requirement
18
19
  requirements:
19
20
  - - ~>
20
21
  - !ruby/object:Gem::Version
21
22
  version: 0.0.1
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
23
  none: false
24
+ requirement: !ruby/object:Gem::Requirement
26
25
  requirements:
27
26
  - - ~>
28
27
  - !ruby/object:Gem::Version
29
28
  version: 0.0.1
29
+ none: false
30
30
  - !ruby/object:Gem::Dependency
31
+ prerelease: false
32
+ type: :runtime
31
33
  name: rake-rubygems
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
+ version_requirements: !ruby/object:Gem::Requirement
34
35
  requirements:
35
36
  - - ! '>='
36
37
  - !ruby/object:Gem::Version
37
38
  version: 0.2.0
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
39
  none: false
40
+ requirement: !ruby/object:Gem::Requirement
42
41
  requirements:
43
42
  - - ! '>='
44
43
  - !ruby/object:Gem::Version
45
44
  version: 0.2.0
45
+ none: false
46
46
  - !ruby/object:Gem::Dependency
47
+ prerelease: false
48
+ type: :runtime
47
49
  name: rdoc
48
- requirement: !ruby/object:Gem::Requirement
49
- none: true
50
+ version_requirements: !ruby/object:Gem::Requirement
50
51
  requirements:
51
52
  - - ! '>='
52
53
  - !ruby/object:Gem::Version
53
54
  version: '0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
55
  none: true
56
+ requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - ! '>='
60
59
  - !ruby/object:Gem::Version
61
60
  version: '0'
61
+ none: true
62
62
  - !ruby/object:Gem::Dependency
63
+ prerelease: false
64
+ type: :runtime
63
65
  name: yard
64
- requirement: !ruby/object:Gem::Requirement
65
- none: true
66
+ version_requirements: !ruby/object:Gem::Requirement
66
67
  requirements:
67
68
  - - ! '>='
68
69
  - !ruby/object:Gem::Version
69
70
  version: '0'
70
- type: :runtime
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
71
  none: true
72
+ requirement: !ruby/object:Gem::Requirement
74
73
  requirements:
75
74
  - - ! '>='
76
75
  - !ruby/object:Gem::Version
77
76
  version: '0'
77
+ none: true
78
78
  - !ruby/object:Gem::Dependency
79
+ prerelease: false
80
+ type: :runtime
79
81
  name: mailfactory
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
+ version_requirements: !ruby/object:Gem::Requirement
82
83
  requirements:
83
84
  - - ~>
84
85
  - !ruby/object:Gem::Version
85
- version: 1.4.0
86
86
  segments:
87
87
  - 1
88
88
  - 4
89
89
  - 0
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
90
+ version: 1.4.0
93
91
  none: false
92
+ requirement: !ruby/object:Gem::Requirement
94
93
  requirements:
95
94
  - - ~>
96
95
  - !ruby/object:Gem::Version
97
- version: 1.4.0
98
96
  segments:
99
97
  - 1
100
98
  - 4
101
99
  - 0
100
+ version: 1.4.0
101
+ none: false
102
102
  - !ruby/object:Gem::Dependency
103
+ prerelease: false
104
+ type: :runtime
103
105
  name: rspec
104
- requirement: !ruby/object:Gem::Requirement
105
- none: false
106
+ version_requirements: !ruby/object:Gem::Requirement
106
107
  requirements:
107
108
  - - ! '>='
108
109
  - !ruby/object:Gem::Version
109
- version: '2.0'
110
110
  segments:
111
111
  - 2
112
112
  - 0
113
- type: :runtime
114
- prerelease: false
115
- version_requirements: !ruby/object:Gem::Requirement
113
+ version: '2.0'
116
114
  none: false
115
+ requirement: !ruby/object:Gem::Requirement
117
116
  requirements:
118
117
  - - ! '>='
119
118
  - !ruby/object:Gem::Version
120
- version: '2.0'
121
119
  segments:
122
120
  - 2
123
121
  - 0
122
+ version: '2.0'
123
+ none: false
124
124
  - !ruby/object:Gem::Dependency
125
+ prerelease: false
126
+ type: :runtime
125
127
  name: simplecov
126
- requirement: !ruby/object:Gem::Requirement
127
- none: false
128
+ version_requirements: !ruby/object:Gem::Requirement
128
129
  requirements:
129
130
  - - ! '>='
130
131
  - !ruby/object:Gem::Version
131
- version: 0.5.4
132
132
  segments:
133
133
  - 0
134
134
  - 5
135
135
  - 4
136
- type: :runtime
137
- prerelease: false
138
- version_requirements: !ruby/object:Gem::Requirement
136
+ version: 0.5.4
139
137
  none: false
138
+ requirement: !ruby/object:Gem::Requirement
140
139
  requirements:
141
140
  - - ! '>='
142
141
  - !ruby/object:Gem::Version
143
- version: 0.5.4
144
142
  segments:
145
143
  - 0
146
144
  - 5
147
145
  - 4
146
+ version: 0.5.4
147
+ none: false
148
148
  - !ruby/object:Gem::Dependency
149
+ prerelease: false
150
+ type: :runtime
149
151
  name: bundler
150
- requirement: !ruby/object:Gem::Requirement
151
- none: true
152
+ version_requirements: !ruby/object:Gem::Requirement
152
153
  requirements:
153
154
  - - ! '>='
154
155
  - !ruby/object:Gem::Version
155
156
  version: '0'
156
- type: :runtime
157
- prerelease: false
158
- version_requirements: !ruby/object:Gem::Requirement
159
157
  none: true
158
+ requirement: !ruby/object:Gem::Requirement
160
159
  requirements:
161
160
  - - ! '>='
162
161
  - !ruby/object:Gem::Version
163
162
  version: '0'
163
+ none: true
164
164
  - !ruby/object:Gem::Dependency
165
+ prerelease: false
166
+ type: :runtime
165
167
  name: nokogiri
166
- requirement: !ruby/object:Gem::Requirement
167
- none: true
168
+ version_requirements: !ruby/object:Gem::Requirement
168
169
  requirements:
169
170
  - - ! '>='
170
171
  - !ruby/object:Gem::Version
171
172
  version: '0'
172
- type: :runtime
173
- prerelease: false
174
- version_requirements: !ruby/object:Gem::Requirement
175
173
  none: true
174
+ requirement: !ruby/object:Gem::Requirement
176
175
  requirements:
177
176
  - - ! '>='
178
177
  - !ruby/object:Gem::Version
179
178
  version: '0'
179
+ none: true
180
180
  - !ruby/object:Gem::Dependency
181
+ prerelease: false
182
+ type: :runtime
181
183
  name: mattock
182
- requirement: !ruby/object:Gem::Requirement
183
- none: false
184
+ version_requirements: !ruby/object:Gem::Requirement
184
185
  requirements:
185
186
  - - ! '>='
186
187
  - !ruby/object:Gem::Version
188
+ segments:
189
+ - 0
190
+ - 4
191
+ - 0
187
192
  version: 0.4.0
188
- type: :runtime
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
193
  none: false
194
+ requirement: !ruby/object:Gem::Requirement
192
195
  requirements:
193
196
  - - ! '>='
194
197
  - !ruby/object:Gem::Version
198
+ segments:
199
+ - 0
200
+ - 4
201
+ - 0
195
202
  version: 0.4.0
203
+ none: false
196
204
  - !ruby/object:Gem::Dependency
205
+ prerelease: false
206
+ type: :runtime
197
207
  name: sass
198
- requirement: !ruby/object:Gem::Requirement
199
- none: false
208
+ version_requirements: !ruby/object:Gem::Requirement
200
209
  requirements:
201
210
  - - ! '>='
202
211
  - !ruby/object:Gem::Version
203
- version: '3.1'
204
212
  segments:
205
213
  - 3
206
214
  - 1
207
- type: :runtime
208
- prerelease: false
209
- version_requirements: !ruby/object:Gem::Requirement
215
+ version: '3.1'
210
216
  none: false
217
+ requirement: !ruby/object:Gem::Requirement
211
218
  requirements:
212
219
  - - ! '>='
213
220
  - !ruby/object:Gem::Version
214
- version: '3.1'
215
221
  segments:
216
222
  - 3
217
223
  - 1
224
+ version: '3.1'
225
+ none: false
218
226
  - !ruby/object:Gem::Dependency
227
+ prerelease: false
228
+ type: :runtime
219
229
  name: compass
220
- requirement: !ruby/object:Gem::Requirement
221
- none: false
230
+ version_requirements: !ruby/object:Gem::Requirement
222
231
  requirements:
223
232
  - - ! '>='
224
233
  - !ruby/object:Gem::Version
225
- version: 0.12.1
226
234
  segments:
227
235
  - 0
228
236
  - 12
229
237
  - 1
230
- type: :runtime
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
238
+ version: 0.12.1
233
239
  none: false
240
+ requirement: !ruby/object:Gem::Requirement
234
241
  requirements:
235
242
  - - ! '>='
236
243
  - !ruby/object:Gem::Version
237
- version: 0.12.1
238
244
  segments:
239
245
  - 0
240
246
  - 12
241
247
  - 1
248
+ version: 0.12.1
249
+ none: false
242
250
  description: ! " A corundum is a synthetic gemstone - including synthetic rubies.
243
251
  \ Ergo: a tool for synthesizing gems.\n\n Corundum starts with the outlook that
244
252
  gemspecs are relatively easy to work with, and that the opinion of the RubyGems
@@ -406,24 +414,24 @@ licenses:
406
414
  post_install_message:
407
415
  rdoc_options:
408
416
  - --title
409
- - corundum-0.0.26 RDoc
417
+ - corundum-0.0.27 RDoc
410
418
  require_paths:
411
419
  - lib/
412
420
  required_ruby_version: !ruby/object:Gem::Requirement
413
- none: false
414
421
  requirements:
415
422
  - - ! '>='
416
423
  - !ruby/object:Gem::Version
417
- version: '0'
418
424
  segments:
419
425
  - 0
420
- hash: -761370339
421
- required_rubygems_version: !ruby/object:Gem::Requirement
426
+ hash: -169787983
427
+ version: '0'
422
428
  none: false
429
+ required_rubygems_version: !ruby/object:Gem::Requirement
423
430
  requirements:
424
431
  - - ! '>='
425
432
  - !ruby/object:Gem::Version
426
433
  version: '0'
434
+ none: false
427
435
  requirements: []
428
436
  rubyforge_project: corundum
429
437
  rubygems_version: 1.8.24