rabal 0.2.3 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/{CHANGES → HISTORY} +23 -7
  2. data/README +96 -66
  3. data/bin/rabal +6 -7
  4. data/gemspec.rb +47 -0
  5. data/lib/rabal.rb +63 -19
  6. data/lib/rabal/application.rb +4 -4
  7. data/lib/rabal/plugin/foundation.rb +4 -3
  8. data/lib/rabal/version.rb +16 -14
  9. data/resources/trees/bin/rabal.project +7 -8
  10. data/resources/trees/core/HISTORY.erb +4 -0
  11. data/resources/trees/core/README.erb +6 -0
  12. data/resources/trees/core/Rakefile.erb +53 -7
  13. data/resources/trees/core/gemspec.rb.erb +48 -0
  14. data/resources/trees/core/lib/rabal.project.rb.erb +52 -20
  15. data/resources/trees/core/lib/rabal.project/version.rb.erb +21 -13
  16. data/resources/trees/core/tasks/announce.rake.erb +36 -54
  17. data/resources/trees/core/tasks/config.rb.erb +107 -0
  18. data/resources/trees/core/tasks/distribution.rake.erb +19 -13
  19. data/resources/trees/core/tasks/documentation.rake.erb +25 -19
  20. data/resources/trees/core/tasks/utils.rb.erb +80 -0
  21. data/resources/trees/ext/tasks/extension.rake.erb +42 -10
  22. data/resources/trees/rubyforge/tasks/rubyforge.rake.erb +48 -40
  23. data/resources/trees/spec/spec/rabal.project_spec.rb.erb +10 -10
  24. data/resources/trees/spec/tasks/rspec.rake.erb +23 -18
  25. data/resources/trees/test/tasks/testunit.rake.erb +14 -9
  26. data/resources/trees/test/test/rabal.project_test.rb.erb +6 -6
  27. data/resources/trees/website/tasks/site.rake.erb +5 -5
  28. data/spec/application_spec.rb +3 -3
  29. data/spec/bin_plugin_spec.rb +1 -1
  30. data/spec/core_plugin_spec.rb +1 -1
  31. data/spec/license_plugin_spec.rb +1 -1
  32. data/spec/plugin_tree_spec.rb +1 -1
  33. data/spec/spec_helper.rb +3 -6
  34. data/spec/spec_plugin_spec.rb +1 -1
  35. data/spec/test_plugin_spec.rb +1 -1
  36. data/tasks/announce.rake +40 -0
  37. data/tasks/config.rb +99 -0
  38. data/tasks/distribution.rake +45 -0
  39. data/tasks/documentation.rake +31 -0
  40. data/tasks/rspec.rake +29 -0
  41. data/tasks/rubyforge.rake +52 -0
  42. data/tasks/utils.rb +80 -0
  43. metadata +105 -59
  44. data/Rakefile +0 -12
  45. data/lib/rabal/specification.rb +0 -128
  46. data/resources/trees/core/CHANGES.erb +0 -4
  47. data/resources/trees/core/lib/rabal.project/gemspec.rb.erb +0 -51
  48. data/resources/trees/core/lib/rabal.project/specification.rb.erb +0 -128
  49. data/resources/trees/core/tasks/setup.rb.erb +0 -40
@@ -46,7 +46,7 @@ module Rabal
46
46
  # only going to happen if run from outside a gem. Basically
47
47
  # while Jeremy is testing.
48
48
  if not plugin_manager.loaded?("rabal") then
49
- plugin_manager.gems["rabal"] = ROOT_DIR
49
+ plugin_manager.gems["rabal"] = Rabal.root_dir
50
50
  end
51
51
 
52
52
 
@@ -93,9 +93,9 @@ module Rabal
93
93
  def main
94
94
  return @main if @main
95
95
  @main = Main.new(app_argv) {
96
-
97
- description Rabal::SPEC.description
98
- author Rabal::SPEC.author
96
+
97
+ description "Rabal is the Ruby Architecture for Building Applications and Libraries."
98
+ author "Jeremy Hinegardner <jeremy@hinegardner.org>"
99
99
  version Rabal::VERSION
100
100
 
101
101
  # Project, the whole reason rabal exists
@@ -1,6 +1,7 @@
1
1
  require 'gem_plugin'
2
2
  require 'highline/import'
3
3
  require 'rabal/logger'
4
+ require 'fattr'
4
5
 
5
6
  module Rabal
6
7
  module Plugin
@@ -35,7 +36,7 @@ module Rabal
35
36
 
36
37
  # allows Plugin::Base to store the registration
37
38
  # information in the class variable.
38
- attribute :register_as => nil
39
+ fattr :register_as => nil
39
40
 
40
41
  # part of the mini DSL for describing a Plugin
41
42
  def parameter(pname,description,block = nil)
@@ -58,8 +59,8 @@ module Rabal
58
59
  @use_always = d
59
60
  end
60
61
 
61
- attribute :description => "I Need a Description"
62
- attribute :register_path
62
+ fattr :description => "I Need a Description"
63
+ fattr :register_path
63
64
 
64
65
  def use_name
65
66
  name.split("::").last.dashify
@@ -1,21 +1,23 @@
1
1
  require 'rabal'
2
2
 
3
3
  module Rabal
4
- class Version
5
- MAJOR = 0
6
- MINOR = 2
7
- BUILD = 3
4
+ module Version
5
+ MAJOR = 0
6
+ MINOR = 3
7
+ BUILD = 3
8
8
 
9
- class << self
10
- def to_a
11
- [MAJOR, MINOR, BUILD]
12
- end
9
+ def to_a
10
+ [MAJOR, MINOR, BUILD]
11
+ end
13
12
 
14
- def to_s
15
- to_a.join(".")
16
- end
17
- end
18
- end
19
- VERSION = Version.to_s
13
+ def to_s
14
+ to_a.join(".")
15
+ end
16
+ module_function :to_a
17
+ module_function :to_s
18
+
19
+ STRING = Version.to_s
20
+ end
21
+ VERSION = Version.to_s
20
22
  end
21
23
 
@@ -1,12 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- begin
4
- require '<%= project_name %>'
5
- rescue LoadError
6
- path = File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
7
- raise if $:.include?(path)
8
- $: << path
9
- retry
10
- end
3
+ #--
4
+ # Copyright (c) <%= Date.today.year %> <% author %>
5
+ # All rights reserved. See LICENSE and/or COPYING for details.
6
+ #++
7
+
8
+ $: << File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
9
+ require '<%= project_name %>'
11
10
 
12
11
  puts "I am the killer app <%= project_name %> at version #{<%= project_name.camelize %>::VERSION}!"
@@ -0,0 +1,4 @@
1
+ = Changelog
2
+ == Version 0.0.1
3
+
4
+ * Initial public release
@@ -13,3 +13,9 @@
13
13
  == CREDITS
14
14
 
15
15
  == LICENSE
16
+
17
+ Copyright (c) <% Date.today.year %> <%= author %>
18
+
19
+ All rights reserved.
20
+
21
+ See LICENSE and/or COPYING for details.
@@ -1,14 +1,60 @@
1
- # make sure our project's ./lib directory is added to the ruby search path
2
- $: << File.join(File.dirname(__FILE__),"lib")
1
+ #--
2
+ # Copyright (c) <%= Date.today.year %> <%= author %>
3
+ # All rights reserved. See LICENSE and/or COPYING for details.
4
+ #++
3
5
 
6
+ #-------------------------------------------------------------------------------
7
+ # make sure our project's top level directory and the lib directory are added to
8
+ # the ruby search path.
9
+ #-------------------------------------------------------------------------------
10
+ $: << File.expand_path(File.join(File.dirname(__FILE__),"lib"))
11
+ $: << File.expand_path(File.dirname(__FILE__))
12
+
13
+
14
+ #-------------------------------------------------------------------------------
15
+ # load the global project configuration and add in the top level clean and
16
+ # clobber tasks so that other tasks can utilize those constants if necessary
17
+ # This loads up the defaults for the whole project configuration
18
+ #-------------------------------------------------------------------------------
4
19
  require 'rubygems'
5
- require 'rake/gempackagetask'
20
+ require 'tasks/config.rb'
6
21
  require 'rake/clean'
7
- require 'rake/rdoctask'
8
- require 'rake/contrib/sshpublisher'
9
22
 
10
- require '<%= project_name.underscore %>'
23
+ #-------------------------------------------------------------------------------
24
+ # Main configuration for the project, these overwrite the items that are in
25
+ # tasks/config.rb
26
+ #-------------------------------------------------------------------------------
27
+ require '<%= project_name %>'
28
+ Configuration.for("project") {
29
+ name "<%= project_name %>"
30
+ version <%= project_name.camelize %>::VERSION
31
+ author "<%= author %>"
32
+ email "<%= email %>"
33
+ homepage "http://<%= project_name %>.rubyforge.org/"
34
+ }
11
35
 
12
- load 'tasks/setup.rb'
36
+ #-------------------------------------------------------------------------------
37
+ # load up all the project tasks and setup the default task to be the
38
+ # test:default task.
39
+ #-------------------------------------------------------------------------------
40
+ Configuration.for("packaging").files.tasks.each do |tasklib|
41
+ import tasklib
42
+ end
43
+ task :default => 'test:default'
13
44
 
45
+ #-------------------------------------------------------------------------------
46
+ # Finalize the loading of all pending imports and update the top level clobber
47
+ # task to depend on all possible sub-level tasks that have a name like
48
+ # ':clobber' in other namespaces. This allows us to say:
49
+ #
50
+ # rake clobber
51
+ #
52
+ # and it will get everything.
53
+ #-------------------------------------------------------------------------------
54
+ Rake.application.load_imports
55
+ Rake.application.tasks.each do |t|
56
+ if t.name =~ /:clobber/ then
57
+ task :clobber => [t.name]
58
+ end
59
+ end
14
60
 
@@ -0,0 +1,48 @@
1
+ require 'rubygems'
2
+ require '<%= project_name %>/version'
3
+ require 'tasks/config'
4
+
5
+ <%= project_name.camelize %>::GEM_SPEC = Gem::Specification.new do |spec|
6
+ proj = Configuration.for('project')
7
+ spec.name = proj.name
8
+ spec.version = <%= project_name.camelize %>::VERSION
9
+
10
+ spec.author = proj.author
11
+ spec.email = proj.email
12
+ spec.homepage = proj.homepage
13
+ spec.summary = proj.summary
14
+ spec.description = proj.description
15
+ spec.platform = Gem::Platform::RUBY
16
+
17
+
18
+ pkg = Configuration.for('packaging')
19
+ spec.files = pkg.files.all
20
+ spec.executables = pkg.files.bin.collect { |b| File.basename(b) }
21
+
22
+ # add dependencies here
23
+ # spec.add_dependency("rake", ">= 0.8.1")
24
+ spec.add_dependency("configuration", ">= 0.0.5")
25
+
26
+ if ext_conf = Configuration.for_if_exist?("extension") then
27
+ spec.extensions << ext_conf.configs
28
+ spec.extensions.flatten!
29
+ spec.require_paths << "ext"
30
+ end
31
+
32
+ if rdoc = Configuration.for_if_exist?('rdoc') then
33
+ spec.has_rdoc = true
34
+ spec.extra_rdoc_files = pkg.files.rdoc
35
+ spec.rdoc_options = rdoc.options + [ "--main" , rdoc.main_page ]
36
+ else
37
+ spec.has_rdoc = false
38
+ end
39
+
40
+ if test = Configuration.for_if_exist?('testing') then
41
+ spec.test_files = test.files
42
+ end
43
+
44
+ if rf = Configuration.for_if_exist?('rubyforge') then
45
+ spec.rubyforge_project = rf.project
46
+ end
47
+
48
+ end
@@ -1,25 +1,57 @@
1
+ #--
2
+ # Copyright (c) <%= Date.today.year %> <%= author %>
3
+ # All rights reserved. See LICENSE and/or COPYING for details.
4
+ #++
5
+
1
6
  module <%= project_name.camelize %>
2
-
3
- ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__),".."))
4
- LIB_DIR = File.join(ROOT_DIR,"lib").freeze
5
- RESOURCE_DIR = File.join(ROOT_DIR,"resources").freeze
6
7
 
7
- #
8
- # Utility method to require all files ending in .rb in the directory
9
- # with the same name as this file minus .rb
10
- #
11
- def require_all_libs_relative_to(fname)
12
- prepend = File.basename(fname,".rb")
13
- search_me = File.join(File.dirname(fname),prepend)
14
-
15
- Dir.entries(search_me).each do |rb|
16
- if File.extname(rb) == ".rb" then
17
- require "#{prepend}/#{File.basename(rb,".rb")}"
18
- end
19
- end
8
+ # The root directory of the project is considered to be the parent directory
9
+ # of the 'lib' directory.
10
+ #
11
+ # returns:: [String] The full expanded path of the parent directory of 'lib'
12
+ # going up the path from the current file. Trailing
13
+ # File::SEPARATOR is guaranteed.
14
+ #
15
+ def self.root_dir
16
+ unless @root_dir
17
+ path_parts = ::File.expand_path(__FILE__).split(::File::SEPARATOR)
18
+ lib_index = path_parts.rindex("lib")
19
+ @root_dir = path_parts[0...lib_index].join(::File::SEPARATOR) + ::File::SEPARATOR
20
20
  end
21
- module_function :require_all_libs_relative_to
21
+ return @root_dir
22
+ end
22
23
 
23
- end
24
+ # returns:: [String] The full expanded path of the +config+ directory
25
+ # below _root_dir_. All parameters passed in are joined onto the
26
+ # result. Trailing File::SEPARATOR is guaranteed if _args_ are
27
+ # *not* present.
28
+ #
29
+ def self.config_path(*args)
30
+ self.sub_path("config", *args)
31
+ end
32
+
33
+ # returns:: [String] The full expanded path of the +data+ directory below
34
+ # _root_dir_. All parameters passed in are joined onto the
35
+ # result. Trailing File::SEPARATOR is guaranteed if
36
+ # _*args_ are *not* present.
37
+ #
38
+ def self.data_path(*args)
39
+ self.sub_path("data", *args)
40
+ end
24
41
 
25
- <%= project_name.camelize %>.require_all_libs_relative_to(__FILE__)
42
+ # returns:: [String] The full expanded path of the +lib+ directory below
43
+ # _root_dir_. All parameters passed in are joined onto the
44
+ # result. Trailing File::SEPARATOR is guaranteed if
45
+ # _*args_ are *not* present.
46
+ #
47
+ def self.lib_path(*args)
48
+ self.sub_path("lib", *args)
49
+ end
50
+
51
+ def self.sub_path(sub,*args)
52
+ sp = ::File.join(root_dir, sub) + File::SEPARATOR
53
+ sp = ::File.join(sp, *args) if args
54
+ end
55
+
56
+ end
57
+ require '<%= project_name %>/version'
@@ -1,18 +1,26 @@
1
+ #--
2
+ # Copyright (c) <%= Date.today.year %> <%= author %>
3
+ # All rights reserved. See LICENSE and/or COPYING for details
4
+ #++
5
+
1
6
  module <%= project_name.camelize %>
2
- class Version
3
- MAJOR = 0
4
- MINOR = 0
5
- BUILD = 1
7
+ module Version
8
+ MAJOR = 0
9
+ MINOR = 0
10
+ BUILD = 1
6
11
 
7
- class << self
8
- def to_a
9
- [MAJOR, MINOR, BUILD]
10
- end
12
+ def to_a
13
+ [MAJOR, MINOR, BUILD]
14
+ end
11
15
 
12
- def to_s
13
- to_a.join(".")
14
- end
15
- end
16
+ def to_s
17
+ to_a.join(".")
16
18
  end
17
- VERSION = Version.to_s
19
+
20
+ module_function :to_a
21
+ module_function :to_s
22
+
23
+ STRING = Version.to_s
24
+ end
25
+ VERSION = Version.to_s
18
26
  end
@@ -1,57 +1,39 @@
1
- #-----------------------------------------------------------------------
2
- # Announcement tasks
3
- # - create a basic email template that can be used to send email to
4
- # rubytalk.
5
- #-----------------------------------------------------------------------
6
- def changes
7
- change_file = File.expand_path(File.join(<%= project_name.camelize %>::ROOT_DIR,"CHANGES"))
8
- sections = File.read(change_file).split(/^(?===)/)
9
- end
10
-
11
- def last_changeset
12
- changes[1]
13
- end
14
-
15
- def announcement
16
- urls = " #{<%= project_name.camelize %>::SPEC.homepage}"
17
- subject = "#{<%= project_name.camelize %>::SPEC.name} #{<%= project_name.camelize %>::VERSION} Released"
18
- title = "#{<%= project_name.camelize %>::SPEC.name} version #{<%= project_name.camelize %>::VERSION} has been released."
19
- body = <<BODY
20
- #{<%= project_name.camelize %>::SPEC.description.rstrip}
21
-
22
- {{ Changelog for Version #{<%= project_name.camelize %>::VERSION} }}
23
-
24
- #{last_changeset.rstrip}
25
-
26
- BODY
27
-
28
- return subject, title, body, urls
29
- end
1
+ require 'tasks/config'
2
+ #-------------------------------------------------------------------------------
3
+ # announcement methods
4
+ #-------------------------------------------------------------------------------
30
5
 
6
+ proj_config = Configuration.for('project')
31
7
  namespace :announce do
32
- desc "create email for ruby-talk"
33
- task :email do
34
- subject, title, body, urls = announcement
8
+ desc "create email for ruby-talk"
9
+ task :email do
10
+ info = Utils.announcement
11
+
12
+ File.open("email.txt", "w") do |mail|
13
+ mail.puts "From: #{proj_config.author} <#{proj_config.email}>"
14
+ mail.puts "To: ruby-talk@ruby-lang.org"
15
+ mail.puts "Date: #{Time.now.rfc2822}"
16
+ mail.puts "Subject: [ANN] #{info[:subject]}"
17
+ mail.puts
18
+ mail.puts info[:title]
19
+ mail.puts
20
+ mail.puts " gem install #{<%= project_name.camelize %>::GEM_SPEC.name}"
21
+ mail.puts
22
+ mail.puts info[:urls]
23
+ mail.puts
24
+ mail.puts info[:description]
25
+ mail.puts
26
+ mail.puts "{{ Release notes for Version #{<%= project_name.camelize %>::VERSION} }}"
27
+ mail.puts
28
+ mail.puts info[:release_notes]
29
+ mail.puts
30
+ end
31
+ puts "Created the following as email.txt:"
32
+ puts "-" * 72
33
+ puts File.read("email.txt")
34
+ puts "-" * 72
35
+ end
36
+
37
+ CLOBBER << "email.txt"
38
+ end
35
39
 
36
- File.open("email.txt", "w") do |mail|
37
- mail.puts "From: #{<%= project_name.camelize %>::SPEC.author} <#{<%= project_name.camelize %>::SPEC.email}>"
38
- mail.puts "To: ruby-talk@ruby-lang.org"
39
- mail.puts "Date: #{Time.now.rfc2822}"
40
- mail.puts "Subject: [ANN] #{subject}"
41
- mail.puts
42
- mail.puts title
43
- mail.puts
44
- mail.puts urls
45
- mail.puts
46
- mail.puts body
47
- mail.puts
48
- mail.puts urls
49
- end
50
- puts "Created the following as email.txt:"
51
- puts "-" * 72
52
- puts File.read("email.txt")
53
- puts "-" * 72
54
- end
55
-
56
- CLOBBER << "email.txt"
57
- end