corundum 0.3.9 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjMxMDhiMDI0ZTVkNDdlMTA3ODA1NTY5MDNlYWMwODk2MDFmYWNmNg==
4
+ NTc0ZDU1MjUxZGYyMGE5YThlYzBkMTRhMmIwNzBjMDA1NjViMmJhMg==
5
5
  data.tar.gz: !binary |-
6
- NDNiMzU0NzFlOTljY2QzYjI4Y2Q5ZmRkODM0MGEwYzEyZmQ5ZWJmNQ==
6
+ ZDE0NzFhN2ZlODViMjNhZjc1NWEwNzdlNmU2MmRjMWFkYTgxMzVjMA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- N2NiOWVmZDUyMTA5ODgxNDg2ZTJhMWQwYmMyODU0YjU4NmUzMTJmMTZkYzYw
10
- ZTAyY2E4MWMzZDJlNzk2ZjZlZWM2NzE3MmIzM2QyN2ExZTMyOTM4OGJjZjEz
11
- NWZhYzg1Y2JlZjIxOTcyZGJjZmYzYjBlMDk5NDU3ZGI1NDNlMWQ=
9
+ NDkwYmUwNGMzYmQxMzQxMTgzMWI2NWY5NTQ3NDgwZGVjMjMxMGQ1MzNkNTll
10
+ N2JlYzg1ZDk2YzY3M2ViN2VkNzA2YmQ3ZTY5ZDQyNzI5NWMxOTM0YWM4ZTlj
11
+ YWM0YjA4ZGJjYmEwNzEzY2ZjNzMxMWI4ZDlhNjNiYjYzYWRlMjg=
12
12
  data.tar.gz: !binary |-
13
- ZWRiMmFlZGUwNTM5ZWFiMzQ5ZThkZDJiNzM5MGIxODRhMjhmYzM3YzI4MzFh
14
- OTlhNjY1ODJkMDFlYjA1ZWU5NzcwMmVjZjA1ODc5MTViNDk3YTY0MzAzMTQx
15
- YzU0YTFkZGNmMzEzZTBmM2Y5OWEyMmE5YmE0ZWZjODc4ZTY3MjA=
13
+ NmNlMTE0MDY2ZTFlNjJlZmI5OWU3YWFmOGJjODU4YWEyZjc0ODYxMjY1Mjk5
14
+ Mjk5MmFhMDQyMzkzMWU2MjkwM2I0MjY0MTJiMzlkYjA3MjY5OTI2ZDBiMDFl
15
+ YmFiNDExMDk1ZWMwNDdhYzc1ZGY1MGNkYjdlY2MyNDk4NmVhNmE=
data/lib/corundum/core.rb CHANGED
@@ -16,18 +16,19 @@ module Corundum
16
16
  # [release] push the gem out to the world
17
17
  # [press] send out notifications that the gem has been published
18
18
  class Core < Mattock::TaskLib
19
+ dir(:package, "pkg",
20
+ path(:build_file))
21
+
22
+ dir(:corundum_dir, "corundum",
23
+ dir(:finished_dir, "finished",
24
+ path(:qa_file), path(:release_file)))
25
+
19
26
  settings(
20
27
  :gemspec => nil,
21
28
  :gemspec_path => nil,
22
- :corundum_dir => "corundum",
23
- :finished_dir => nil,
24
- :package_dir => "pkg",
25
- :doc_dir => "rubydoc",
26
29
  :qa_rejections => nil,
27
30
  :browser => Corundum.user_preferences["browser"],
28
- :finished_files => nested.nil_fields(:build, :qa, :package, :release, :press),
29
31
  :files => nested.nil_fields(:code, :test, :docs),
30
- :rubyforge => nested.nil_fields(:group_id, :package_id, :release_name, :home_page, :project_page),
31
32
  :email => nested(
32
33
  :servers => [ nested({ :server => "ruby-lang.org", :helo => "gmail.com" }) ],
33
34
  :announce_to_email => "ruby-talk@ruby-lang.org"
@@ -40,40 +41,29 @@ module Corundum
40
41
  :file_patterns => nested( :code => [%r{^lib/}], :test => [%r{^spec/}, %r{^test/}], :docs => [%r{^doc/}])
41
42
  )
42
43
 
43
- def load_gemspec
44
- @gemspec_path ||= guess_gemspec
45
- @gemspec ||= Gem::Specification::load(gemspec_path)
46
- return gemspec
47
- end
48
-
49
44
  def resolve_configuration
50
45
  super
51
- load_gemspec
52
46
 
53
- self.finished_dir ||= File::join(corundum_dir, "finished")
54
- @finished_files.build ||= File::join( package_dir, "#{gemspec.full_name}.gem")
47
+ self.gemspec_path ||= guess_gemspec
48
+ self.gemspec ||= Gem::Specification::load(gemspec_path)
49
+
50
+ self.qa_rejections ||= []
55
51
 
56
- @finished_files.qa ||= File::join( finished_dir, "qa_#{gemspec.version}")
57
- @finished_files.release ||= File::join( finished_dir, "release_#{gemspec.version}")
58
- @finished_files.press ||= File::join( finished_dir, "press_#{gemspec.version}")
52
+ build_file.relative_path ||= gemspec.full_name + ".gem"
53
+ qa_file.relative_path ||= "qa-" + gemspec.full_name.to_s
54
+ release_file.relative_path ||= "release-" + gemspec.full_name.to_s
59
55
 
60
- @qa_rejections ||= []
56
+ resolve_paths
61
57
 
62
- @files.code ||= file_patterns.code.map{ |pattern| gemspec.files.grep(pattern) }.flatten
63
- @files.test ||= file_patterns.test.map{ |pattern| gemspec.files.grep(pattern) }.flatten
64
- @files.docs ||= file_patterns.docs.map{ |pattern| gemspec.files.grep(pattern) }.flatten
58
+ self.files.code ||= file_patterns.code.map{ |pattern| gemspec.files.grep(pattern) }.flatten
59
+ self.files.test ||= file_patterns.test.map{ |pattern| gemspec.files.grep(pattern) }.flatten
60
+ self.files.docs ||= file_patterns.docs.map{ |pattern| gemspec.files.grep(pattern) }.flatten
65
61
 
66
- @file_lists.project << gemspec_path
67
- @file_lists.all ||=
62
+ self.file_lists.project << gemspec_path
63
+ self.file_lists.all ||=
68
64
  file_lists.code +
69
65
  file_lists.test +
70
66
  file_lists.docs
71
-
72
- @rubyforge.group_id ||= gemspec.rubyforge_project
73
- @rubyforge.package_id ||= gemspec.name.downcase
74
- @rubyforge.release_name ||= gemspec.full_name
75
- @rubyforge.home_page ||= gemspec.homepage
76
- @rubyforge.project_page ||= "http://rubyforge.org/project/#{gemspec.rubyforge_project}/"
77
67
  end
78
68
 
79
69
  def guess_gemspec
@@ -90,17 +80,17 @@ module Corundum
90
80
 
91
81
  def define
92
82
  in_namespace do
93
- directory finished_dir
83
+ directory finished_dir.abspath
94
84
 
95
85
  desc "Run preflight checks"
96
86
  task :preflight
97
87
 
98
- task :run_quality_assurance => [:preflight, finished_files.qa]
88
+ task :run_quality_assurance => [ :preflight, qa_file.abspath ]
99
89
 
100
90
  task :run_continuous_integration
101
91
 
102
92
  desc "Run quality assurance tasks"
103
- task :qa => :run_quality_assurance do
93
+ qa_task = task :qa => :run_quality_assurance do
104
94
  require 'corundum/qa-report'
105
95
  puts QA::ReportFormatter.new(qa_rejections).to_s
106
96
  unless qa_rejections.all?(&:passed)
@@ -119,32 +109,26 @@ module Corundum
119
109
  end
120
110
  end
121
111
 
122
-
123
- file finished_files.qa =>
124
- [finished_dir] + file_lists.project + file_lists.code + file_lists.test do |task|
125
- Rake::Task[:qa].invoke
112
+ file qa_file.abspath =>
113
+ [finished_dir.abspath] + file_lists.project + file_lists.code + file_lists.test do |task|
114
+ qa_task.invoke
126
115
  touch task.name
127
116
  end
128
117
 
129
118
  desc "Build the package"
130
- task :build => [finished_files.qa, :preflight, finished_files.build]
131
- file finished_files.build =>
132
- [finished_dir] + file_lists.code + file_lists.project do |task|
133
- Rake::Task[:build].invoke
119
+ build_task = task :build => [qa_file.abspath, :preflight, build_file.abspath]
120
+ file build_file.abspath.tap{|value| puts "#{__FILE__}:#{__LINE__} => #{value.inspect}"} =>
121
+ [finished_dir.abspath] + file_lists.code + file_lists.project do |task|
122
+ puts "\n#{__FILE__}:#{__LINE__} => #{task.name.inspect}"
123
+ build_task.invoke
124
+ puts "\n#{__FILE__}:#{__LINE__} => #{task.name.inspect}"
134
125
  touch task.name
135
126
  end
136
127
 
137
128
  desc "Push package out to the world"
138
- task :release => [finished_files.build, :preflight, finished_files.release]
139
- file finished_files.release => [finished_dir] do |task|
140
- Rake::Task[:release].invoke
141
- touch task.name
142
- end
143
-
144
- desc "Announce publication"
145
- task :press => [finished_files.release, finished_files.press]
146
- file finished_files.press => [finished_dir] do |task|
147
- Rake::Task[:press].invoke
129
+ release_task = task(:release => [ build_file.abspath, :preflight, release_file.abspath ])
130
+ file release_file.abspath => [ build_file, finished_dir] do |task|
131
+ release_task.invoke
148
132
  touch task.name
149
133
  end
150
134
  end
@@ -6,24 +6,15 @@ module Corundum
6
6
  setting :browser
7
7
  setting :gemspec
8
8
 
9
- #TODO update to use new paths DSL
10
- setting :corundum_dir
11
- setting :docs_root
12
-
13
- setting :target_dir
14
- setting :sub_dir
15
-
16
- setting :entry_file, "index.html"
17
-
18
- #The path from the project root to the entry file
19
- #Resolves if unset to target_dir + entry_file
20
- setting :entry_path
9
+ dir(:corundum_dir,
10
+ dir(:docs_root, "docs",
11
+ dir(:target_dir,
12
+ path(:entry_path, "index.html"))))
21
13
 
22
14
  #The URL path from this documentation root
23
15
  #Resolves if unset to sub_dir + entry_file
24
16
  setting :entry_link
25
17
 
26
-
27
18
  def self.title(name)
28
19
  setting :title, name
29
20
  end
@@ -35,31 +26,20 @@ module Corundum
35
26
 
36
27
  def resolve_configuration
37
28
  super
38
- if field_unset?(:docs_root)
39
- self.docs_root = File::join(corundum_dir, "docs")
40
- end
41
-
42
- if field_unset?(:target_dir)
43
- self.target_dir = File::join(docs_root, sub_dir)
44
- else
45
- self.sub_dir = target_dir.sub(/^#{docs_root}\//,"")
46
- end
47
-
48
- if field_unset?(:entry_path)
49
- self.entry_path = File::join(target_dir, entry_file)
50
- end
51
29
 
52
30
  if field_unset?(:entry_link)
53
- self.entry_link = File::join(sub_dir, entry_file)
31
+ self.entry_link = File::join(target_dir.relpath, entry_path.relpath)
54
32
  end
33
+
34
+ resolve_paths
55
35
  end
56
36
 
57
- def entry_point(under = nil)
58
- File::join(under || target_dir, entry_file)
37
+ def entry_point
38
+ entry_path.abspath
59
39
  end
60
40
 
61
41
  def define
62
- directory target_dir
42
+ directory target_dir.abspath
63
43
 
64
44
  in_namespace do
65
45
  desc "Open up a browser to view your documentation"
@@ -3,27 +3,26 @@ require 'mattock/tasklib'
3
3
  module Corundum
4
4
  class GemBuilding < Mattock::TaskLib
5
5
  setting(:gemspec)
6
- setting(:qa_finished_file)
7
- setting(:package_dir, "pkg")
6
+ setting(:package)
7
+ setting(:qa_file)
8
8
 
9
9
  def default_configuration(toolkit)
10
10
  super
11
- self.gemspec = toolkit.gemspec
12
- self.qa_finished_file = toolkit.finished_files.qa
11
+ toolkit.copy_settings_to(self)
13
12
  end
14
13
 
15
14
  def define
16
15
  require 'rubygems/package_task'
17
16
 
18
17
  in_namespace do
19
- package = Gem::PackageTask.new(gemspec) do |t|
18
+ Gem::PackageTask.new(gemspec) do |t|
20
19
  t.need_tar_gz = true
21
20
  t.need_tar_bz2 = true
22
- t.package_dir = package_dir
21
+ t.package_dir = package.abspath
23
22
  end
24
23
 
25
24
  task(:package).prerequisites.each do |package_type|
26
- file package_type => qa_finished_file
25
+ file package_type => qa_file
27
26
  end
28
27
  end
29
28
 
@@ -8,24 +8,22 @@ module Corundum
8
8
  setting(:gem_path, nil)
9
9
  setting(:build)
10
10
  setting(:gemspec)
11
- setting(:build_finished_path)
12
- setting(:gem_name)
13
- setting(:package_dir)
14
11
  setting(:qa_rejections)
15
12
 
13
+ dir(:package,
14
+ path(:gem_path),
15
+ path(:build_file))
16
+
16
17
  def default_configuration(toolkit, build)
17
18
  super
19
+ toolkit.copy_settings_to(self)
18
20
  self.build = build
19
- self.gemspec = toolkit.gemspec
20
- self.build_finished_path = toolkit.finished_files.build
21
- self.gem_name = toolkit.gemspec.full_name
22
- self.package_dir = build.package_dir
23
- self.qa_rejections = toolkit.qa_rejections
24
21
  end
25
22
 
26
23
  def resolve_configuration
27
24
  super
28
- self.gem_path ||= File::join(package_dir, gemspec.file_name)
25
+ gem_path.relative_path = gemspec.file_name
26
+ resolve_paths
29
27
  end
30
28
 
31
29
  module CommandTweaks
@@ -90,7 +88,7 @@ module Corundum
90
88
  def define
91
89
  in_namespace do
92
90
  task :uninstall do |t|
93
- when_writing("Uninstalling #{gem_name}") do
91
+ when_writing("Uninstalling #{gemfile.full_name}") do
94
92
  require "rubygems/commands/uninstall_command"
95
93
  uninstall = get_command Gem::Commands::UninstallCommand
96
94
  uninstall.options[:args] = [gem_path]
@@ -157,10 +155,10 @@ module Corundum
157
155
  task :push => [:dependencies_available, :is_unpushed] do
158
156
  require "rubygems/commands/push_command"
159
157
  push = get_command(Gem::Commands::PushCommand)
160
- push.options[:args] = [gem_path]
158
+ push.options[:args] = [gem_path.abspath]
161
159
  push.execute
162
160
  end
163
- task :push => build_finished_path
161
+ task :push => build_file.abspath.tap{|value| puts "#{__FILE__}:#{__LINE__} => #{value.inspect}"}
164
162
  end
165
163
  task :release => in_namespace(:push)
166
164
  task :preflight => in_namespace(:is_unpushed)
@@ -13,6 +13,7 @@ module Corundum
13
13
  "gender" => ["bitch", "cocksucker", "cunt", "dyke", "faggot", "tranny"], #ok
14
14
  "issues" => ["XXX", "TODO"], #ok
15
15
  }
16
+ CANONICAL_WORD_SETS = WORD_SETS.keys
16
17
  [
17
18
  ["debug", "debugging"],
18
19
  ["profanity", "swearing"],
@@ -24,6 +25,14 @@ module Corundum
24
25
  WORD_SETS[other] = WORD_SETS[name]
25
26
  end
26
27
 
28
+ def self.all_sets(core)
29
+ CANONICAL_WORD_SETS.each do |word_set|
30
+ self.new(core) do |qc|
31
+ qc.type = word_set
32
+ end
33
+ end
34
+ end
35
+
27
36
  default_namespace :content
28
37
  setting :type, :debugging
29
38
  setting :words
@@ -9,9 +9,7 @@ module Corundum
9
9
  end
10
10
  end
11
11
 
12
- setting :runner_command
13
-
14
- required_fields :pattern, :ruby_opts,
12
+ runtime_required_fields :runner_command, :pattern, :ruby_opts,
15
13
  :warning, :rspec_path, :rspec_opts, :failure_message, :files_to_run,
16
14
  :file_dependencies
17
15
 
@@ -20,20 +18,28 @@ module Corundum
20
18
  rspec.copy_settings_to(self)
21
19
  end
22
20
 
23
- def resolve_configuration
21
+ def resolve_runtime_configuration
24
22
  self.rspec_path = %x"which #{rspec_path}".chomp
25
23
 
26
24
  ruby_command.options << ruby_opts if ruby_opts
27
25
  ruby_command.options << "-w" if warning
28
26
 
29
27
  self.runner_command = cmd(rspec_path) do |cmd|
30
- cmd.options << rspec_opts
28
+ cmd.options << all_rspec_options
31
29
  cmd.options << files_to_run
32
30
  end
33
31
 
34
32
  self.command = ruby_command - runner_command
35
33
 
36
34
  super
35
+ end
36
+
37
+ def all_rspec_options
38
+ rspec_opts
39
+ end
40
+
41
+ def resolve_configuration
42
+ super
37
43
 
38
44
  if task_args.last.is_a? Hash
39
45
  key = task_args.last.keys.first
@@ -46,16 +52,19 @@ module Corundum
46
52
  end
47
53
 
48
54
  class RSpecReportTask < RSpecTask
49
- setting :target_dir
50
- setting :doc_file, "index.html"
51
- setting :doc_path
55
+ dir(:target_dir, path(:doc_path, "index.html"))
56
+
57
+ setting(:formats, {})
52
58
 
53
59
  def timestamp
54
- if File.exist?(doc_path)
55
- File.mtime(doc_path.to_s)
56
- else
57
- Rake::EARLY
58
- end
60
+ return Rake::EARLY if formats.empty?
61
+ formats.values.map do |path|
62
+ if File.exist?(path.to_s)
63
+ File.mtime(path.to_s)
64
+ else
65
+ Rake::EARLY
66
+ end
67
+ end.min
59
68
  end
60
69
 
61
70
  def out_of_date?(stamp)
@@ -63,12 +72,22 @@ module Corundum
63
72
  end
64
73
 
65
74
  def needed?
66
- ! File.exist?(doc_path) || out_of_date?(timestamp)
75
+ ! File.exist?(doc_path.abspath) || out_of_date?(timestamp)
67
76
  end
68
77
 
69
78
  def default_configuration(rspec)
70
79
  super
71
- self.doc_path = File::join(target_dir, doc_file)
80
+ end
81
+
82
+ def all_rspec_options
83
+ super + formats.inject([]) do |list, (format, target)|
84
+ list + ["--format", format, "--out", target]
85
+ end
86
+ end
87
+
88
+ def resolve_configuration
89
+ super
90
+ resolve_paths
72
91
  end
73
92
  end
74
93
  end
@@ -8,7 +8,6 @@ module Corundum
8
8
 
9
9
  settings(
10
10
  :qa_rejections => nil,
11
- :sub_dir => "rspec",
12
11
  :pattern => './spec{,/*/**}/*_spec.rb',
13
12
  :warning => false,
14
13
  :verbose => true,
@@ -19,19 +18,27 @@ module Corundum
19
18
  :files_to_run => "spec"
20
19
  )
21
20
 
21
+ dir(:target_dir,
22
+ path(:json_report, "rspec.json"),
23
+ path(:doc_path, "index.html"))
24
+
22
25
  setting :rspec_path
23
26
 
24
27
  required_fields :gemspec_path, :qa_finished_path, :file_lists, :file_dependencies
25
28
 
29
+ attr_reader :report_task
30
+
26
31
  def default_configuration(toolkit)
27
32
  super
28
- self.qa_finished_path = toolkit.finished_files.qa
33
+ target_dir.relative_path = "rspec"
34
+ self.qa_finished_path = toolkit.qa_file.abspath
29
35
  self.qa_rejections = toolkit.qa_rejections
30
36
  self.file_dependencies = file_lists.code + file_lists.test + file_lists.project
31
37
  end
32
38
 
33
39
  def resolve_configuration
34
40
  self.rspec_path ||= %x"which #{rspec_program}".chomp
41
+ resolve_paths
35
42
  super
36
43
  end
37
44
 
@@ -54,33 +61,29 @@ module Corundum
54
61
  test_task(:all)
55
62
 
56
63
  desc "Generate specifications documentation"
57
- docn = doc_task(:doc => file_dependencies) do |t|
58
- t.rspec_opts = %w{-o /dev/null --failure-exit-code 0 -f h -o} + [t.doc_path]
64
+ @report_task = doc_task(:doc => file_dependencies) do |t|
65
+ t.rspec_opts += %w{-o /dev/null --failure-exit-code 0}
66
+ t.formats["html"] = doc_path
67
+ t.formats["json"] = json_report
59
68
  end
60
- file entry_path => :doc
69
+ file entry_point => :doc
70
+ file json_report => :doc
61
71
 
62
- task :verify => entry_path do |task|
63
- require 'nokogiri'
72
+ task :verify => json_report do |task|
73
+ require 'json'
64
74
  require 'corundum/qa-report'
65
75
 
66
- doc = Nokogiri::parse(File::read(entry_path))
76
+ doc = JSON::parse(File::read(json_report.to_s))
67
77
 
68
- rejections = QA::Report.new("RSpec[#{entry_path}]")
78
+ rejections = QA::Report.new("RSpec[#{json_report}]")
69
79
  qa_rejections << rejections
70
80
 
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 =
78
- node.xpath(".//*[#{class_xpath("backtrace")}]").first.content.split("\n").first
79
- file,line,_ = backtrace_line.split(":")
80
- label = "fail"
81
- value = node.xpath(".//*[#{class_xpath("message")}]").first.content.gsub(/\s+/m, " ")
82
-
83
- rejections.add(label, file, line, value)
81
+ doc["examples"].find_all do |example|
82
+ example["status"] == "failed"
83
+ end.each do |failed|
84
+ file,line,_ = failed["exception"]["backtrace"].first.split(":", 3)
85
+ value = failed["exception"]["message"]
86
+ rejections.add("fail", file, line, value)
84
87
  end
85
88
 
86
89
  unless rejections.empty?