corundum 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,64 +7,69 @@ module Corundum
7
7
  extend Rake::DSL
8
8
 
9
9
  class Toolkit < TaskLib
10
- def default_configuration(namespace)
11
- @configuration.marshal_load(
12
- :namespace => namespace,
10
+ def default_configuration
11
+ settings(
13
12
  :finished_dir => "corundum",
14
- :finished_files => OpenStruct.new,
13
+ :finished_files => nested(
14
+ :build => nil,
15
+ :qa => nil,
16
+ :package => nil,
17
+ :release => nil,
18
+ :press => nil),
15
19
 
16
20
  :browser => "chromium",
17
21
  :gemspec => nil,
18
22
  :gemspec_path => nil,
19
- :email => OpenStruct.new(
20
- :servers => [ OpenStruct.new({ :server => "ruby-lang.org", :helo => "gmail.com" }) ],
23
+ :email => nested(
24
+ :servers => [ nested({ :server => "ruby-lang.org", :helo => "gmail.com" }) ],
21
25
  :announce_to_email => "ruby-talk@ruby-lang.org"
22
26
  ),
23
27
  :package_dir => "pkg",
24
- :files => OpenStruct.new(:code => nil, :test => nil, :docs => nil),
25
- :file_lists => OpenStruct.new(:code => nil, :test => nil, :docs => nil, :all => nil),
26
- :rubyforge => OpenStruct.new(),
28
+ :files => nested(:code => nil, :test => nil, :docs => nil),
29
+ :file_lists => nested(:code => nil, :test => nil, :docs => nil, :all => nil),
30
+ :rubyforge => nested().nil_fields(:group_id, :package_id,
31
+ :release_name, :home_page, :project_page),
27
32
  :doc_dir => "rubydoc"
28
33
  )
29
34
  end
30
35
 
31
36
  def load_gemspec
32
- @configuration.gemspec_path ||= guess_gemspec
33
- @configuration.gemspec ||= Gem::Specification::load(@configuration.gemspec_path)
34
- return @configuration.gemspec
37
+ @gemspec_path ||= guess_gemspec
38
+ @gemspec ||= Gem::Specification::load(gemspec_path)
39
+ return gemspec
35
40
  end
36
41
 
37
42
  def resolve_configuration
38
43
  load_gemspec
39
44
 
40
- @configuration.finished_files.build ||= File::join(
41
- @configuration.finished_dir, "build_#{@configuration.gemspec.version}")
42
- @configuration.finished_files.qa ||= File::join(
43
- @configuration.finished_dir, "qa_#{@configuration.gemspec.version}")
44
- @configuration.finished_files.package ||= File::join(
45
- @configuration.finished_dir, "package_#{@configuration.gemspec.version}")
46
- @configuration.finished_files.release ||= File::join(
47
- @configuration.finished_dir, "release_#{@configuration.gemspec.version}")
48
- @configuration.finished_files.press ||= File::join(
49
- @configuration.finished_dir, "press_#{@configuration.gemspec.version}")
50
-
51
- @configuration.files.code ||= @configuration.gemspec.files.grep(%r{^lib/})
52
- @configuration.files.test ||= @configuration.gemspec.files.grep(%r{^spec/})
53
- @configuration.files.docs ||= @configuration.gemspec.files.grep(%r{^doc/})
54
-
55
- @configuration.file_lists.code ||= FileList['lib/**/*.rb']
56
- @configuration.file_lists.test ||= FileList['test/**/*.rb','spec/**/*.rb','features/**/*.rb']
57
- @configuration.file_lists.docs ||= FileList['doc/**/*.rb']
58
- @configuration.file_lists.all ||=
59
- @configuration.file_lists.code +
60
- @configuration.file_lists.test +
61
- @configuration.file_lists.docs
62
-
63
- @configuration.rubyforge.group_id ||= @configuration.gemspec.rubyforge_project
64
- @configuration.rubyforge.package_id ||= @configuration.gemspec.name.downcase
65
- @configuration.rubyforge.release_name ||= @configuration.gemspec.full_name
66
- @configuration.rubyforge.home_page ||= @configuration.gemspec.homepage
67
- @configuration.rubyforge.project_page ||= "http://rubyforge.org/project/#{@configuration.gemspec.rubyforge_project}/"
45
+ @finished_files.build ||= File::join(
46
+ finished_dir, "build_#{gemspec.version}")
47
+ @finished_files.qa ||= File::join(
48
+ finished_dir, "qa_#{gemspec.version}")
49
+ @finished_files.package ||= File::join(
50
+ finished_dir, "package_#{gemspec.version}")
51
+ @finished_files.release ||= File::join(
52
+ finished_dir, "release_#{gemspec.version}")
53
+ @finished_files.press ||= File::join(
54
+ finished_dir, "press_#{gemspec.version}")
55
+
56
+ @files.code ||= gemspec.files.grep(%r{^lib/})
57
+ @files.test ||= gemspec.files.grep(%r{^spec/})
58
+ @files.docs ||= gemspec.files.grep(%r{^doc/})
59
+
60
+ @file_lists.code ||= FileList['lib/**/*.rb']
61
+ @file_lists.test ||= FileList['test/**/*.rb','spec/**/*.rb','features/**/*.rb']
62
+ @file_lists.docs ||= FileList['doc/**/*.rb']
63
+ @file_lists.all ||=
64
+ file_lists.code +
65
+ file_lists.test +
66
+ file_lists.docs
67
+
68
+ @rubyforge.group_id ||= gemspec.rubyforge_project
69
+ @rubyforge.package_id ||= gemspec.name.downcase
70
+ @rubyforge.release_name ||= gemspec.full_name
71
+ @rubyforge.home_page ||= gemspec.homepage
72
+ @rubyforge.project_page ||= "http://rubyforge.org/project/#{gemspec.rubyforge_project}/"
68
73
  end
69
74
 
70
75
  def guess_gemspec
@@ -81,50 +86,35 @@ module Corundum
81
86
 
82
87
  def define
83
88
  in_namespace do
84
- directory @configuration.finished_dir
89
+ directory finished_dir
85
90
 
86
91
  desc "Run preflight checks"
87
92
  task :preflight
88
93
 
89
94
  desc "Run quality assurance tasks"
90
95
  task :qa => :preflight
91
- file @configuration.finished_files.qa => [:qa, @configuration.finished_dir] do |task|
96
+ file finished_files.qa => [:qa, finished_dir] do |task|
92
97
  touch task.name
93
98
  end
94
99
 
95
100
  desc "Build the package"
96
- task :build => @configuration.finished_files.qa
97
- file @configuration.finished_files.build => [:build, @configuration.finished_dir] do |task|
101
+ task :build => finished_files.qa
102
+ file finished_files.build => [:build, finished_dir] do |task|
98
103
  touch task.name
99
104
  end
100
105
 
101
106
  desc "Push package out to the world"
102
- task :release => @configuration.finished_files.build
103
- file @configuration.finished_files.release => [:release, @configuration.finished_dir] do |task|
107
+ task :release => finished_files.build
108
+ file finished_files.release => [:release, finished_dir] do |task|
104
109
  touch task.name
105
110
  end
106
111
 
107
112
  desc "Announce publication"
108
- task :press => @configuration.finished_files.release
109
- file @configuration.finished_files.press => [:press, @configuration.finished_dir] do |task|
113
+ task :press => finished_files.release
114
+ file finished_files.press => [:press, finished_dir] do |task|
110
115
  touch task.name
111
116
  end
112
117
  end
113
118
  end
114
-
115
- def old_define
116
-
117
- task @publishing.namespace => "#{@gem_building.namespace}:push"
118
- task "#{@publishing.namespace}:docs" => "#{@documentation.namespace}:docs"
119
- task "#{@publishing.namespace}:rubyforge" => ["#{@quality_assurance.namespace}:sign_off", "#{@gem_building.namespace}:package"]
120
-
121
- require 'corundum/press'
122
- Press.new(@press.namespace) do |press|
123
- press.rubyforge = @rubyforge
124
- press.gemspec = @configuration.gemspec
125
- press.announce_to_email = @email.announce_to_email
126
- press.email_servers = @email.servers
127
- end
128
- end
129
119
  end
130
120
  end
@@ -0,0 +1,54 @@
1
+
2
+
3
+ module Corundum
4
+ module Configurable
5
+ def local_attrs
6
+ @local_attrs ||=
7
+ begin
8
+ mod = Module.new
9
+ extend mod
10
+ mod
11
+ end
12
+ end
13
+
14
+ def local_attrs=(mod)
15
+ extend mod
16
+ @local_attrs = mod
17
+ end
18
+
19
+ def setting(name, default_value = nil)
20
+ local_attrs.instance_eval do
21
+ attr_accessor(name)
22
+ end
23
+ instance_variable_set("@#{name}", default_value)
24
+ end
25
+
26
+ def dup
27
+ result = super
28
+ result.extend Configurable
29
+ result.local_attrs = @local_attrs
30
+ result
31
+ end
32
+
33
+ def settings(hash)
34
+ hash.each_pair do |name, value|
35
+ setting(name, value)
36
+ end
37
+ return self
38
+ end
39
+
40
+ def nested(hash=nil)
41
+ obj = Object.new
42
+ obj.extend Configurable
43
+ obj.settings(hash || {})
44
+ return obj
45
+ end
46
+
47
+ def nil_fields(*names)
48
+ names.each do |name|
49
+ setting(name, nil)
50
+ end
51
+ return self
52
+ end
53
+ end
54
+ end
@@ -6,26 +6,13 @@ module Corundum
6
6
  :email
7
7
  end
8
8
 
9
- def receive_tasklibs(toolkit)
10
- @toolkit = toolkit
11
- end
12
-
13
- def default_configuration(namespace, toolkit_config)
14
- @configuration.namespace = namespace
15
- @configuration.rubyforge = toolkit_config.rubyforge
16
- @configuration.email_servers = []
17
- @configuration.gemspec = toolkit_config.gemspec
18
- @configuration.announce_to_email = nil
19
- @configuration.urls = OpenStruct.new
20
- end
21
-
22
- def resolve_configuration
23
- @configuration.urls.home_page ||=
24
- @configuration.gemspec.homepage
25
-
26
- @configuration.urls.project_page ||=
27
- @configuration.rubyforge.project_page
28
-
9
+ def default_configuration(toolkit)
10
+ setting(:rubyforge, toolkit.rubyforge)
11
+ setting(:email_servers, [])
12
+ setting(:gemspec, toolkit.gemspec)
13
+ setting(:announce_to_email, nil)
14
+ setting(:urls, nested(:home_page => toolkit.gemspec.homepage,
15
+ :project_page => toolkit.rubyforge.project_page))
29
16
  end
30
17
 
31
18
  def announcement
@@ -38,28 +25,28 @@ module Corundum
38
25
  rescue Exception
39
26
  end
40
27
 
41
- urls = "Project: #{@configuration.urls.project_page}\n" +
42
- "Homepage: #{@configuration.urls.home_page}"
28
+ urls = "Project: #{urls.project_page}\n" +
29
+ "Homepage: #{urls.home_page}"
43
30
 
44
- subject = "#{@configuration.gemspec.name} #{@configuration.gemspec.version} Released"
45
- title = "#{@configuration.gemspec.name} version #{@configuration.gemspec.version} has been released!"
46
- body = "#{@configuration.gemspec.description}\n\n#{changes}\n\n#{urls}"
31
+ subject = "#{gemspec.name} #{gemspec.version} Released"
32
+ title = "#{gemspec.name} version #{gemspec.version} has been released!"
33
+ body = "#{gemspec.description}\n\n#{changes}\n\n#{urls}"
47
34
 
48
35
  return subject, title, body
49
36
  end
50
37
 
51
38
  def define
52
39
  desc 'Announce release on email'
53
- task @configuration.namespace => ["#{@configuration.namespace.to_s}:rubyforge", "#{@configuration.namespace.to_s}:email"]
54
- namespace @configuration.namespace do
40
+ task root_task => in_namespace("rubyforge", "email")
41
+ in_namespace do
55
42
  file "email.txt" do |t|
56
43
  require 'mailfactory'
57
44
 
58
45
  subject, title, body= announcement
59
46
 
60
47
  mail = MailFactory.new
61
- mail.To = @configuration.announce_to_email
62
- mail.From = @configuration.gemspec.email
48
+ mail.To = announce_to_email
49
+ mail.From = gemspec.email
63
50
  mail.Subject = "[ANN] " + subject
64
51
  mail.text = [title, body].join("\n\n")
65
52
 
@@ -71,7 +58,7 @@ module Corundum
71
58
  task :email => "email.txt" do
72
59
  require 'net/smtp'
73
60
 
74
- @configuration.email_servers.each do |server_config|
61
+ email_servers.each do |server_config|
75
62
  begin
76
63
  File::open("email.txt", "r") do |email|
77
64
  Net::SMTP.start(server_config[:server], 25, server_config[:helo], server_config[:username], server_config[:password]) do |smtp|
@@ -2,29 +2,24 @@ require 'corundum/tasklib'
2
2
 
3
3
  module Corundum
4
4
  class GemBuilding < TaskLib
5
- def receive_tasklibs(toolkit)
6
- @toolkit = toolkit
7
- end
8
-
9
- def default_configuration(namespace, toolkit_config)
10
- @configuration.namespace = namespace || :package
11
- @configuration.gemspec = toolkit_config.gemspec
12
- @configuration.qa_finished_file = toolkit_config.finished_files.qa
13
- @configuration.package_dir = "pkg"
5
+ def default_configuration(toolkit)
6
+ setting(:gemspec, toolkit.gemspec)
7
+ setting(:qa_finished_file, toolkit.finished_files.qa)
8
+ setting(:package_dir, "pkg")
14
9
  end
15
10
 
16
11
  def define
17
12
  require 'rubygems/package_task'
18
13
 
19
14
  in_namespace do
20
- package = Gem::PackageTask.new(@configuration.gemspec) do |t|
15
+ package = Gem::PackageTask.new(gemspec) do |t|
21
16
  t.need_tar_gz = true
22
17
  t.need_tar_bz2 = true
23
- t.package_dir = @configuration.package_dir
18
+ t.package_dir = package_dir
24
19
  end
25
20
 
26
21
  task(:package).prerequisites.each do |package_type|
27
- file package_type => @configuration.qa_finished_file
22
+ file package_type => qa_finished_file
28
23
  end
29
24
  end
30
25
 
@@ -2,25 +2,21 @@ require 'corundum/tasklib'
2
2
 
3
3
  module Corundum
4
4
  class GemCutter < TaskLib
5
- def receive_tasklibs(toolkit, build)
6
- @toolkit = toolkit
7
- @build = build
5
+ def default_namespace
6
+ :gemcutter
8
7
  end
9
8
 
10
- def default_configuration(namespace, toolkit_config, build_config)
11
- @configuration.namespace = namespace || :gemcutter
12
- @configuration.gemspec = toolkit_config.gemspec
13
- @configuration.build_finished_path = toolkit_config.finished_files.build
14
- @configuration.gem_path = nil
15
- @configuration.gem_name = nil
16
- @configuration.package_dir = build_config.package_dir
9
+ def default_configuration(toolkit, build)
10
+ setting(:build, build)
11
+ setting(:gemspec, toolkit.gemspec)
12
+ setting(:build_finished_path, toolkit.finished_files.build)
13
+ setting(:gem_path, nil)
14
+ setting(:gem_name, toolkit.gemspec.full_name)
15
+ setting(:package_dir, build.package_dir)
17
16
  end
18
17
 
19
18
  def resolve_configuration
20
- @configuration.gem_path ||=
21
- File::join(@configuration.package_dir, @configuration.gemspec.file_name)
22
-
23
- @configuration.gem_name ||= @configuration.gemspec.full_name
19
+ @gem_path ||= File::join(package_dir, gemspec.file_name)
24
20
  end
25
21
 
26
22
  module CommandTweaks
@@ -30,16 +26,16 @@ module Corundum
30
26
  end
31
27
 
32
28
  def gem_list=(list)
33
- @configuration.gems = list
29
+ gems = list
34
30
  end
35
31
 
36
32
  def get_all_gem_names
37
- return @configuration.gems if defined?(@configuration.gems)
33
+ return gems if defined?(gems)
38
34
  super
39
35
  end
40
36
 
41
37
  def get_one_gem_name
42
- return @configuration.gems.first if defined?(@configuration.gems)
38
+ return gems.first if defined?(gems)
43
39
  super
44
40
  end
45
41
  end
@@ -54,19 +50,19 @@ module Corundum
54
50
  def define
55
51
  in_namespace do
56
52
  task :uninstall do |t|
57
- when_writing("Uninstalling #{@configuration.gem_name}") do
53
+ when_writing("Uninstalling #{gem_name}") do
58
54
  require "rubygems/commands/uninstall_command"
59
55
  uninstall = get_command Gem::Commands::UninstallCommand
60
- uninstall.options[:args] = [@configuration.gem_path]
56
+ uninstall.options[:args] = [gem_path]
61
57
  uninstall.execute
62
58
  end
63
59
  end
64
60
 
65
- task :install => [@configuration.gem_path] do |t|
66
- when_writing("Installing #{@configuration.gem_path}") do
61
+ task :install => [gem_path] do |t|
62
+ when_writing("Installing #{gem_path}") do
67
63
  require "rubygems/commands/install_command"
68
64
  install = get_command Gem::Commands::InstallCommand
69
- install.options[:args] = [@configuration.gem_path]
65
+ install.options[:args] = [gem_path]
70
66
  install.execute
71
67
  end
72
68
  end
@@ -75,7 +71,7 @@ module Corundum
75
71
 
76
72
  task :dependencies_available do
77
73
  checker = Gem::SpecFetcher.new
78
- @configuration.gemspec.runtime_dependencies.each do |dep|
74
+ gemspec.runtime_dependencies.each do |dep|
79
75
  fulfilling = checker.find_matching(dep,false,false,false)
80
76
  if fulfilling.empty?
81
77
  fail "Dependency #{dep} is unfulfilled remotely"
@@ -87,10 +83,11 @@ module Corundum
87
83
 
88
84
  task :is_unpushed do
89
85
  checker = Gem::SpecFetcher.new
90
- dep = Gem::Dependency.new(@configuration.gemspec.name, "= #{@configuration.gemspec.version}")
91
- fulfilling = checker.find_matching(dep,false,false,true)
86
+ dep = Gem::Dependency.new(gemspec.name, "= #{gemspec.version}")
87
+ fulfilling = checker.find_matching(dep,false,false,false)
92
88
  unless fulfilling.empty?
93
- fail "Gem #{@configuration.gemspec.full_name} is already pushed"
89
+ p fulfilling
90
+ fail "Gem #{gemspec.full_name} is already pushed"
94
91
  end
95
92
  end
96
93
 
@@ -98,10 +95,10 @@ module Corundum
98
95
  task :push => [:dependencies_available, :is_unpushed] do
99
96
  require "rubygems/commands/push_command"
100
97
  push = get_command(Gem::Commands::PushCommand)
101
- push.options[:args] = [@configuration.gem_path]
98
+ push.options[:args] = [gem_path]
102
99
  push.execute
103
100
  end
104
- task :push => @configuration.build_finished_path
101
+ task :push => build_finished_path
105
102
  end
106
103
  task :release => in_namespace(:push)
107
104
  task :preflight => in_namespace(:dependencies_available, :is_unpushed)