meta_project 0.4.12 → 0.4.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/CHANGES +283 -277
  2. data/MIT-LICENSE +21 -21
  3. data/README +130 -126
  4. data/Rakefile +152 -152
  5. data/doc/base_attrs.rdoc +2 -2
  6. data/lib/meta_project.rb +11 -11
  7. data/lib/meta_project/core_ext/open_uri.rb +22 -22
  8. data/lib/meta_project/core_ext/pathname.rb +36 -36
  9. data/lib/meta_project/core_ext/string.rb +4 -4
  10. data/lib/meta_project/http/multipart.rb +31 -31
  11. data/lib/meta_project/patois/parser.rb +98 -98
  12. data/lib/meta_project/project.rb +4 -4
  13. data/lib/meta_project/project/base.rb +8 -8
  14. data/lib/meta_project/project/codehaus.rb +1 -1
  15. data/lib/meta_project/project/codehaus/codehaus_project_svn.rb +30 -30
  16. data/lib/meta_project/project/trac.rb +1 -1
  17. data/lib/meta_project/project/trac/trac_project.rb +53 -53
  18. data/lib/meta_project/project/xforge.rb +5 -5
  19. data/lib/meta_project/project/xforge/ruby_forge.rb +46 -46
  20. data/lib/meta_project/project/xforge/session.rb +177 -177
  21. data/lib/meta_project/project/xforge/source_forge.rb +49 -49
  22. data/lib/meta_project/project/xforge/xfile.rb +44 -44
  23. data/lib/meta_project/project/xforge/xforge_base.rb +81 -81
  24. data/lib/meta_project/project_analyzer.rb +35 -35
  25. data/lib/meta_project/release/freshmeat.rb +267 -267
  26. data/lib/meta_project/release/raa.rb +572 -572
  27. data/lib/meta_project/scm_web.rb +1 -1
  28. data/lib/meta_project/scm_web/browser.rb +111 -111
  29. data/lib/meta_project/scm_web/pathname.rb +88 -88
  30. data/lib/meta_project/tracker.rb +6 -6
  31. data/lib/meta_project/tracker/base.rb +23 -23
  32. data/lib/meta_project/tracker/digit_issues.rb +33 -33
  33. data/lib/meta_project/tracker/issue.rb +56 -56
  34. data/lib/meta_project/tracker/jira.rb +2 -2
  35. data/lib/meta_project/tracker/jira/jira_issues.rb +34 -34
  36. data/lib/meta_project/tracker/jira/jira_tracker.rb +148 -123
  37. data/lib/meta_project/tracker/trac.rb +1 -1
  38. data/lib/meta_project/tracker/trac/trac_tracker.rb +32 -32
  39. data/lib/meta_project/tracker/xforge.rb +3 -3
  40. data/lib/meta_project/tracker/xforge/ruby_forge_tracker.rb +17 -17
  41. data/lib/meta_project/tracker/xforge/source_forge_tracker.rb +17 -17
  42. data/lib/meta_project/tracker/xforge/xforge_tracker.rb +190 -190
  43. data/lib/meta_project/version_parser.rb +52 -52
  44. data/lib/rake/contrib/xforge.rb +3 -3
  45. data/lib/rake/contrib/xforge/base.rb +64 -64
  46. data/lib/rake/contrib/xforge/news_publisher.rb +97 -97
  47. data/lib/rake/contrib/xforge/release.rb +134 -134
  48. metadata +4 -3
@@ -1,52 +1,52 @@
1
- module MetaProject
2
- class VersionParser
3
- def parse(changes_file, version)
4
- release_notes_first = nil
5
- changes_first = nil
6
- changes_last = nil
7
-
8
- lines = File.open(changes_file).readlines
9
- state = nil
10
- lines.each_with_index do |line, n|
11
- # parse state
12
- if (line =~ /^==/ && state == :in_release_notes && state != :done)
13
- changes_first = changes_last = n
14
- state = :done
15
- end
16
- if line =~ /#{version}/ && state.nil?
17
- state = :in_release_notes
18
- release_notes_first = n+1
19
- end
20
- if (line =~ /^\*/ && state == :in_release_notes)
21
- state = :in_changes
22
- changes_first = changes_last = n
23
- end
24
- if (line =~ /^\*/ && state == :in_changes)
25
- changes_last = n
26
- end
27
- if (line =~ /^==/ && state == :in_changes)
28
- state = :done
29
- end
30
- end
31
-
32
- release_notes = lines[release_notes_first..changes_first-1].join("")
33
- raise "Release notes for #{version} couldn't be parsed from #{changes_file}" if release_notes.strip == ""
34
-
35
- release_changes = lines[changes_first..changes_last].collect do |line|
36
- line.length >= 2 ? line[2..-1].chomp : line
37
- end
38
- raise "Release changes for #{version} couldn't be parsed from #{changes_file}" if release_changes.length == 0
39
-
40
- Version.new(release_notes, release_changes)
41
- end
42
- end
43
-
44
- class Version
45
- attr_reader :release_notes # String
46
- attr_reader :release_changes # Array of String
47
-
48
- def initialize(release_notes, release_changes)
49
- @release_notes, @release_changes = release_notes, release_changes
50
- end
51
- end
52
- end
1
+ module MetaProject
2
+ class VersionParser
3
+ def parse(changes_file, version)
4
+ release_notes_first = nil
5
+ changes_first = nil
6
+ changes_last = nil
7
+
8
+ lines = File.open(changes_file).readlines
9
+ state = nil
10
+ lines.each_with_index do |line, n|
11
+ # parse state
12
+ if (line =~ /^==/ && state == :in_release_notes && state != :done)
13
+ changes_first = changes_last = n
14
+ state = :done
15
+ end
16
+ if line =~ /#{version}/ && state.nil?
17
+ state = :in_release_notes
18
+ release_notes_first = n+1
19
+ end
20
+ if (line =~ /^\*/ && state == :in_release_notes)
21
+ state = :in_changes
22
+ changes_first = changes_last = n
23
+ end
24
+ if (line =~ /^\*/ && state == :in_changes)
25
+ changes_last = n
26
+ end
27
+ if (line =~ /^==/ && state == :in_changes)
28
+ state = :done
29
+ end
30
+ end
31
+
32
+ release_notes = lines[release_notes_first..changes_first-1].join("")
33
+ raise "Release notes for #{version} couldn't be parsed from #{changes_file}" if release_notes.strip == ""
34
+
35
+ release_changes = lines[changes_first..changes_last].collect do |line|
36
+ line.length >= 2 ? line[2..-1].chomp : line
37
+ end
38
+ raise "Release changes for #{version} couldn't be parsed from #{changes_file}" if release_changes.length == 0
39
+
40
+ Version.new(release_notes, release_changes)
41
+ end
42
+ end
43
+
44
+ class Version
45
+ attr_reader :release_notes # String
46
+ attr_reader :release_changes # Array of String
47
+
48
+ def initialize(release_notes, release_changes)
49
+ @release_notes, @release_changes = release_notes, release_changes
50
+ end
51
+ end
52
+ end
@@ -1,3 +1,3 @@
1
- require 'rake/contrib/xforge/base'
2
- require 'rake/contrib/xforge/release'
3
- require 'rake/contrib/xforge/news_publisher'
1
+ require 'rake/contrib/xforge/base'
2
+ require 'rake/contrib/xforge/release'
3
+ require 'rake/contrib/xforge/news_publisher'
@@ -1,64 +1,64 @@
1
- module Rake
2
- module XForge
3
- # Base class for XForge tasks.
4
- class Base
5
- # The user name for the xForge login of a release administrator of the
6
- # project being released. This should NOT be stored in the Rakefile.
7
- attr_accessor :user_name
8
- # The password for the xForge login of a release administrator of the
9
- # project being released. This should NOT be stored in the Rakefile.
10
- attr_accessor :password
11
- # The CHANGES file. If this file exists, it is parsed according to the
12
- # standard CHANGES version parsing routines. See CHANGES FORMAT below
13
- # for more information. Defaults to CHANGES if unset. #version must
14
- # also be set.
15
- #
16
- # === CHANGES FORMAT
17
- # The CHANGES file is essentially an RDoc-format changelog in the
18
- # form:
19
- #
20
- # == Version VERSION-Pattern
21
- #
22
- # RELEASE NOTES
23
- #
24
- # * Change 1
25
- # * Change 2
26
- attr_accessor :changes_file
27
- # Modifies the release version and affects CHANGES file parsing.
28
- attr_accessor :version
29
-
30
- def initialize(project)
31
- @project = project
32
-
33
- @changes_file = "CHANGES"
34
- @version = ::PKG_VERSION if defined?(::PKG_VERSION)
35
-
36
- if block_given?
37
- yield self
38
- set_defaults
39
- execute
40
- end
41
- end
42
-
43
- protected
44
- def set_defaults
45
- end
46
-
47
- def user_name
48
- unless @user_name
49
- print "#{@project.host} user: "
50
- @user_name = STDIN.gets.chomp
51
- end
52
- @user_name
53
- end
54
-
55
- def password
56
- unless @password
57
- print "#{@project.host} password: "
58
- @password = STDIN.gets.chomp
59
- end
60
- @password
61
- end
62
- end
63
- end
64
- end
1
+ module Rake
2
+ module XForge
3
+ # Base class for XForge tasks.
4
+ class Base
5
+ # The user name for the xForge login of a release administrator of the
6
+ # project being released. This should NOT be stored in the Rakefile.
7
+ attr_accessor :user_name
8
+ # The password for the xForge login of a release administrator of the
9
+ # project being released. This should NOT be stored in the Rakefile.
10
+ attr_accessor :password
11
+ # The CHANGES file. If this file exists, it is parsed according to the
12
+ # standard CHANGES version parsing routines. See CHANGES FORMAT below
13
+ # for more information. Defaults to CHANGES if unset. #version must
14
+ # also be set.
15
+ #
16
+ # === CHANGES FORMAT
17
+ # The CHANGES file is essentially an RDoc-format changelog in the
18
+ # form:
19
+ #
20
+ # == Version VERSION-Pattern
21
+ #
22
+ # RELEASE NOTES
23
+ #
24
+ # * Change 1
25
+ # * Change 2
26
+ attr_accessor :changes_file
27
+ # Modifies the release version and affects CHANGES file parsing.
28
+ attr_accessor :version
29
+
30
+ def initialize(project)
31
+ @project = project
32
+
33
+ @changes_file = "CHANGES"
34
+ @version = ::PKG_VERSION if defined?(::PKG_VERSION)
35
+
36
+ if block_given?
37
+ yield self
38
+ set_defaults
39
+ execute
40
+ end
41
+ end
42
+
43
+ protected
44
+ def set_defaults
45
+ end
46
+
47
+ def user_name
48
+ unless @user_name
49
+ print "#{@project.host} user: "
50
+ @user_name = STDIN.gets.chomp
51
+ end
52
+ @user_name
53
+ end
54
+
55
+ def password
56
+ unless @password
57
+ print "#{@project.host} password: "
58
+ @password = STDIN.gets.chomp
59
+ end
60
+ @password
61
+ end
62
+ end
63
+ end
64
+ end
@@ -1,97 +1,97 @@
1
- module Rake
2
- module XForge
3
- # This Rake task publishes news entries for a project. Publishing news
4
- # is a good way to make your project visible on the main RubyForge page.
5
- #
6
- # project = MetaProject::Project::XForge::RubyForge.new('xforge')
7
- # # Create a new news item for the xforge project on Rubyforge.
8
- # task :news => [:gem] do
9
- # Rake::XForge::NewsPublisher.new(project) {}
10
- # end
11
- #
12
- # The previous example will use defaults where it can. It will prompt
13
- # you for your xForge user name and password before it posts a news item
14
- # about the project with a default subject and news details.
15
- #
16
- # While defaults are nice, you may want a little more control. You can
17
- # specify additional attributes:
18
- #
19
- # * #user_name
20
- # * #password
21
- # * #changes_file
22
- # * #version
23
- # * #subject
24
- # * #details
25
- #
26
- # Example:
27
- # project = MetaProject::Project::XForge::RubyForge.new('xforge')
28
- # task :news => [:gem] do
29
- # Rake::XForge::NewsPublisher.new(project) do |xf|
30
- # # Never hardcode user name and password in the Rakefile!
31
- # xf.user_name = ENV['RUBYFORGE_USER']
32
- # xf.password = ENV['RUBYFORGE_PASSWORD']
33
- # xf.subject = "XForge 0.1 Released"
34
- # xf.details = "Today, XForge 0.1 was released to the ..."
35
- # end
36
- # end
37
- #
38
- # This can be invoked from the command line:
39
- #
40
- # rake news RUBYFORGE_USER=myuser \
41
- # RUBYFORGE_PASSWORD=mypassword
42
- #
43
- # If you don't like blocks, you can do like this:
44
- #
45
- # task :news => [:gem] do
46
- # xf = Rake::XForge::NewsPublisher.new(project)
47
- # ... # Set additional attributes
48
- # xf.execute
49
- # end
50
- class NewsPublisher < Base
51
- # A plain-text headline for the news byte to be published.
52
- attr_accessor :subject
53
- # The plain-text news to be published. Hyperlinks are usually
54
- # converted to hyperlinks by the xForge software.
55
- attr_accessor :details
56
-
57
- # Runs the news publisher task.
58
- def execute
59
- raise "'details' not defined." unless @details
60
- raise "'subject' not defined." unless @subject
61
- session = @project.login(user_name, password)
62
- session.publish_news(@subject, @details)
63
- end
64
-
65
- protected
66
- def set_defaults
67
- unless @subject
68
- if defined?(::PKG_NAME)
69
- if defined?(::PKG_VERSION)
70
- @subject = "#{::PKG_NAME} #{::PKG_VERSION} released"
71
- elsif defined?(@version)
72
- @subject = "#{::PKG_NAME} #{@version} released"
73
- end
74
- else
75
- if defined?(::PKG_VERSION)
76
- @subject = "#{@project.name} #{::PKG_VERSION} released"
77
- elsif defined?(@version)
78
- @subject = "#{@project.name} #{@version} released"
79
- end
80
- end
81
- end
82
-
83
- if @changes_file && @version
84
- begin
85
- vp = ::MetaProject::VersionParser.new
86
- version = vp.parse(@changes_file, @version)
87
- @details = version.release_notes unless @details
88
- rescue => e
89
- STDERR.puts("Couldn't parse release info from #{@changes_file}")
90
- STDERR.puts(e.message)
91
- STDERR.puts(e.backtrace.join("\n"))
92
- end
93
- end
94
- end
95
- end
96
- end
97
- end
1
+ module Rake
2
+ module XForge
3
+ # This Rake task publishes news entries for a project. Publishing news
4
+ # is a good way to make your project visible on the main RubyForge page.
5
+ #
6
+ # project = MetaProject::Project::XForge::RubyForge.new('xforge')
7
+ # # Create a new news item for the xforge project on Rubyforge.
8
+ # task :news => [:gem] do
9
+ # Rake::XForge::NewsPublisher.new(project) {}
10
+ # end
11
+ #
12
+ # The previous example will use defaults where it can. It will prompt
13
+ # you for your xForge user name and password before it posts a news item
14
+ # about the project with a default subject and news details.
15
+ #
16
+ # While defaults are nice, you may want a little more control. You can
17
+ # specify additional attributes:
18
+ #
19
+ # * #user_name
20
+ # * #password
21
+ # * #changes_file
22
+ # * #version
23
+ # * #subject
24
+ # * #details
25
+ #
26
+ # Example:
27
+ # project = MetaProject::Project::XForge::RubyForge.new('xforge')
28
+ # task :news => [:gem] do
29
+ # Rake::XForge::NewsPublisher.new(project) do |xf|
30
+ # # Never hardcode user name and password in the Rakefile!
31
+ # xf.user_name = ENV['RUBYFORGE_USER']
32
+ # xf.password = ENV['RUBYFORGE_PASSWORD']
33
+ # xf.subject = "XForge 0.1 Released"
34
+ # xf.details = "Today, XForge 0.1 was released to the ..."
35
+ # end
36
+ # end
37
+ #
38
+ # This can be invoked from the command line:
39
+ #
40
+ # rake news RUBYFORGE_USER=myuser \
41
+ # RUBYFORGE_PASSWORD=mypassword
42
+ #
43
+ # If you don't like blocks, you can do like this:
44
+ #
45
+ # task :news => [:gem] do
46
+ # xf = Rake::XForge::NewsPublisher.new(project)
47
+ # ... # Set additional attributes
48
+ # xf.execute
49
+ # end
50
+ class NewsPublisher < Base
51
+ # A plain-text headline for the news byte to be published.
52
+ attr_accessor :subject
53
+ # The plain-text news to be published. Hyperlinks are usually
54
+ # converted to hyperlinks by the xForge software.
55
+ attr_accessor :details
56
+
57
+ # Runs the news publisher task.
58
+ def execute
59
+ raise "'details' not defined." unless @details
60
+ raise "'subject' not defined." unless @subject
61
+ session = @project.login(user_name, password)
62
+ session.publish_news(@subject, @details)
63
+ end
64
+
65
+ protected
66
+ def set_defaults
67
+ unless @subject
68
+ if defined?(::PKG_NAME)
69
+ if defined?(::PKG_VERSION)
70
+ @subject = "#{::PKG_NAME} #{::PKG_VERSION} released"
71
+ elsif defined?(@version)
72
+ @subject = "#{::PKG_NAME} #{@version} released"
73
+ end
74
+ else
75
+ if defined?(::PKG_VERSION)
76
+ @subject = "#{@project.name} #{::PKG_VERSION} released"
77
+ elsif defined?(@version)
78
+ @subject = "#{@project.name} #{@version} released"
79
+ end
80
+ end
81
+ end
82
+
83
+ if @changes_file && @version
84
+ begin
85
+ vp = ::MetaProject::VersionParser.new
86
+ version = vp.parse(@changes_file, @version)
87
+ @details = version.release_notes unless @details
88
+ rescue => e
89
+ STDERR.puts("Couldn't parse release info from #{@changes_file}")
90
+ STDERR.puts(e.message)
91
+ STDERR.puts(e.backtrace.join("\n"))
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
@@ -1,134 +1,134 @@
1
- module Rake
2
- module XForge
3
- # This Rake task releases files to RubyForge and other GForge instaces
4
- # or SourceForge clones. In its most simple usage it looks like:
5
- #
6
- # project = MetaProject::Project::XForge::RubyForge.new('xforge')
7
- # # Create a new release of the xforge project on Rubyforge.
8
- # task :release => [:gem] do
9
- # Rake::XForge::Release.new(project) {}
10
- # end
11
- #
12
- # The previous example will use defaults where it can. It will prompt
13
- # you for your xForge user name and password before it uploads all
14
- # gems under the pkg folder and creates a RubyForge release.
15
- #
16
- # While defaults are nice, you may want a little more control. You can
17
- # specify additional attributes:
18
- #
19
- # * #user_name
20
- # * #password
21
- # * #changes_file
22
- # * #version
23
- # * #files
24
- # * #release_name
25
- # * #release_notes
26
- # * #release_changes
27
- # * #package_name
28
- #
29
- # Example:
30
- # project = MetaProject::Project::XForge::RubyForge.new('xforge')
31
- # task :release => [:gem] do
32
- # release_files = FileList[ 'pkg/*.gem', 'CHANGES' ]
33
- #
34
- # Rake::XForge::Release.new(project) do |xf|
35
- # # Never hardcode user name and password in the Rakefile!
36
- # xf.user_name = ENV['RUBYFORGE_USER']
37
- # xf.password = ENV['RUBYFORGE_PASSWORD']
38
- # xf.files = release_files.to_a
39
- # xf.release_name = "XForge 0.1"
40
- # end
41
- #
42
- # This can be invoked from the command line:
43
- #
44
- # rake release RUBYFORGE_USER=myuser \
45
- # RUBYFORGE_PASSWORD=mypassword
46
- #
47
- # If you don't like blocks, you can do like this:
48
- #
49
- # project = MetaProject::Project::XForge::RubyForge.new('xforge')
50
- # task :release => [:gem] do
51
- # xf = Rake::XForge::Release.new(project)
52
- # ... # Set additional attributes
53
- # xf.execute
54
- # end
55
- class Release < Base
56
- # An array of files that should be uploaded to xForge. If this is not
57
- # provided, the Rake task will default to one of two values. If the
58
- # constant ::PKG_FILE_NAME is defined, then @files is
59
- # ["pkg/#{PKG_FILE_NAME}.gem"]. Otherwise, it is all .gem files under
60
- # the pkg directory.
61
- attr_accessor :files
62
- # The name of the release. If this is unset, MetaProject will try to
63
- # set it with the values of ::PKG_NAME and ::PKG_VERSION, #version, or
64
- # the project name.
65
- attr_accessor :release_name
66
- # Optional unless the CHANGES file is in a format different than
67
- # expected. You can set the release notes with this value.
68
- attr_accessor :release_notes
69
- # Optional unless the CHANGES file is in a format different than
70
- # expected. You can set the change notes with this value.
71
- attr_accessor :release_changes
72
- # Optional package name. This is *necessary* for projects that have
73
- # more than one released package. If not defined, then the *first*
74
- # package ID that is found on the xForge release page will be used.
75
- attr_accessor :package_name
76
-
77
- # Runs the release task.
78
- def execute
79
- raise "'release_name' not defined." unless @release_name
80
- raise "'files' not defined." unless @files
81
- raise "'release_notes' not defined." unless @release_notes
82
- raise "'release_changes' not defined." unless @release_changes
83
- session = @project.login(user_name, password)
84
- session.release(@release_name, @files, @release_notes,
85
- @release_changes, @package_name)
86
- end
87
-
88
- protected
89
- def set_defaults
90
- unless @files
91
- if defined?(::PKG_FILE_NAME)
92
- @files = ["pkg/#{PKG_FILE_NAME}.gem"]
93
- else
94
- @files = Dir["pkg/**/*.gem"]
95
- end
96
- end
97
-
98
- unless @release_name
99
- if defined?(::PKG_NAME)
100
- if defined?(::PKG_VERSION)
101
- @release_name = "#{::PKG_NAME}-#{::PKG_VERSION}"
102
- elsif @version
103
- @release_name = "#{::PKG_NAME}-#{@version}"
104
- end
105
- else
106
- if defined?(::PKG_VERSION)
107
- @release_name = "#{@package.name}-#{::PKG_VERSION}"
108
- elsif @version
109
- @release_name = "#{@package.name}-#{@version}"
110
- end
111
- end
112
- unless @release_name
113
- raise "Cannot set release name. There is no version set."
114
- end
115
- end
116
-
117
- if @changes_file and @version
118
- begin
119
- vp = ::MetaProject::VersionParser.new
120
- version = vp.parse(@changes_file, @version)
121
- @release_notes = version.release_notes unless @release_notes
122
- unless @release_changes
123
- @release_changes = %Q[* #{version.release_changes.join("\n* ")}]
124
- end
125
- rescue => e
126
- STDERR.puts("Couldn't parse release info from #{@changes_file}")
127
- STDERR.puts(e.message)
128
- STDERR.puts(e.backtrace.join("\n"))
129
- end
130
- end
131
- end
132
- end
133
- end
134
- end
1
+ module Rake
2
+ module XForge
3
+ # This Rake task releases files to RubyForge and other GForge instaces
4
+ # or SourceForge clones. In its most simple usage it looks like:
5
+ #
6
+ # project = MetaProject::Project::XForge::RubyForge.new('xforge')
7
+ # # Create a new release of the xforge project on Rubyforge.
8
+ # task :release => [:gem] do
9
+ # Rake::XForge::Release.new(project) {}
10
+ # end
11
+ #
12
+ # The previous example will use defaults where it can. It will prompt
13
+ # you for your xForge user name and password before it uploads all
14
+ # gems under the pkg folder and creates a RubyForge release.
15
+ #
16
+ # While defaults are nice, you may want a little more control. You can
17
+ # specify additional attributes:
18
+ #
19
+ # * #user_name
20
+ # * #password
21
+ # * #changes_file
22
+ # * #version
23
+ # * #files
24
+ # * #release_name
25
+ # * #release_notes
26
+ # * #release_changes
27
+ # * #package_name
28
+ #
29
+ # Example:
30
+ # project = MetaProject::Project::XForge::RubyForge.new('xforge')
31
+ # task :release => [:gem] do
32
+ # release_files = FileList[ 'pkg/*.gem', 'CHANGES' ]
33
+ #
34
+ # Rake::XForge::Release.new(project) do |xf|
35
+ # # Never hardcode user name and password in the Rakefile!
36
+ # xf.user_name = ENV['RUBYFORGE_USER']
37
+ # xf.password = ENV['RUBYFORGE_PASSWORD']
38
+ # xf.files = release_files.to_a
39
+ # xf.release_name = "XForge 0.1"
40
+ # end
41
+ #
42
+ # This can be invoked from the command line:
43
+ #
44
+ # rake release RUBYFORGE_USER=myuser \
45
+ # RUBYFORGE_PASSWORD=mypassword
46
+ #
47
+ # If you don't like blocks, you can do like this:
48
+ #
49
+ # project = MetaProject::Project::XForge::RubyForge.new('xforge')
50
+ # task :release => [:gem] do
51
+ # xf = Rake::XForge::Release.new(project)
52
+ # ... # Set additional attributes
53
+ # xf.execute
54
+ # end
55
+ class Release < Base
56
+ # An array of files that should be uploaded to xForge. If this is not
57
+ # provided, the Rake task will default to one of two values. If the
58
+ # constant ::PKG_FILE_NAME is defined, then @files is
59
+ # ["pkg/#{PKG_FILE_NAME}.gem"]. Otherwise, it is all .gem files under
60
+ # the pkg directory.
61
+ attr_accessor :files
62
+ # The name of the release. If this is unset, MetaProject will try to
63
+ # set it with the values of ::PKG_NAME and ::PKG_VERSION, #version, or
64
+ # the project name.
65
+ attr_accessor :release_name
66
+ # Optional unless the CHANGES file is in a format different than
67
+ # expected. You can set the release notes with this value.
68
+ attr_accessor :release_notes
69
+ # Optional unless the CHANGES file is in a format different than
70
+ # expected. You can set the change notes with this value.
71
+ attr_accessor :release_changes
72
+ # Optional package name. This is *necessary* for projects that have
73
+ # more than one released package. If not defined, then the *first*
74
+ # package ID that is found on the xForge release page will be used.
75
+ attr_accessor :package_name
76
+
77
+ # Runs the release task.
78
+ def execute
79
+ raise "'release_name' not defined." unless @release_name
80
+ raise "'files' not defined." unless @files
81
+ raise "'release_notes' not defined." unless @release_notes
82
+ raise "'release_changes' not defined." unless @release_changes
83
+ session = @project.login(user_name, password)
84
+ session.release(@release_name, @files, @release_notes,
85
+ @release_changes, @package_name)
86
+ end
87
+
88
+ protected
89
+ def set_defaults
90
+ unless @files
91
+ if defined?(::PKG_FILE_NAME)
92
+ @files = ["pkg/#{PKG_FILE_NAME}.gem"]
93
+ else
94
+ @files = Dir["pkg/**/*.gem"]
95
+ end
96
+ end
97
+
98
+ unless @release_name
99
+ if defined?(::PKG_NAME)
100
+ if defined?(::PKG_VERSION)
101
+ @release_name = "#{::PKG_NAME}-#{::PKG_VERSION}"
102
+ elsif @version
103
+ @release_name = "#{::PKG_NAME}-#{@version}"
104
+ end
105
+ else
106
+ if defined?(::PKG_VERSION)
107
+ @release_name = "#{@package.name}-#{::PKG_VERSION}"
108
+ elsif @version
109
+ @release_name = "#{@package.name}-#{@version}"
110
+ end
111
+ end
112
+ unless @release_name
113
+ raise "Cannot set release name. There is no version set."
114
+ end
115
+ end
116
+
117
+ if @changes_file and @version
118
+ begin
119
+ vp = ::MetaProject::VersionParser.new
120
+ version = vp.parse(@changes_file, @version)
121
+ @release_notes = version.release_notes unless @release_notes
122
+ unless @release_changes
123
+ @release_changes = %Q[* #{version.release_changes.join("\n* ")}]
124
+ end
125
+ rescue => e
126
+ STDERR.puts("Couldn't parse release info from #{@changes_file}")
127
+ STDERR.puts(e.message)
128
+ STDERR.puts(e.backtrace.join("\n"))
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end
134
+ end