meta_project 0.4.10 → 0.4.11
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +8 -0
- data/README +4 -2
- data/Rakefile +1 -1
- data/lib/meta_project/patois/parser.rb +1 -1
- data/lib/meta_project/project/xforge/session.rb +72 -43
- data/lib/meta_project/project/xforge/xforge_base.rb +1 -1
- data/lib/meta_project/tracker/digit_issues.rb +4 -3
- data/lib/rake/contrib/xforge/base.rb +29 -9
- data/lib/rake/contrib/xforge/news_publisher.rb +75 -16
- data/lib/rake/contrib/xforge/release.rb +93 -48
- metadata +2 -2
data/CHANGES
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
= MetaProject Changelog
|
2
2
|
|
3
|
+
== Version 0.4.11
|
4
|
+
|
5
|
+
This release fixes several bugs in the XForge release code and improves documentation.
|
6
|
+
|
7
|
+
* Fixed #2398: Rake::XForge::Release doesn't allow manual setting of release_notes or release_changes
|
8
|
+
* Fixed #2399: Net::HTTPRequestURITooLong 414 readbody=true
|
9
|
+
* Fixed #2400: Project release always selects the *first* package
|
10
|
+
|
3
11
|
== Version 0.4.10
|
4
12
|
|
5
13
|
This version fixes some bugs in the JIRA and SourceForge APIs.
|
data/README
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= MetaProject 0.4.
|
1
|
+
= MetaProject 0.4.11
|
2
2
|
|
3
3
|
MetaProject (formerly XForge) is a library that allows interaction with various project hosting servers, issue trackers, SCMs and SCM browsers through a common API.
|
4
4
|
|
@@ -100,7 +100,9 @@ and +release_changes+ to the task. Example:
|
|
100
100
|
|
101
101
|
(In alphabetical order)
|
102
102
|
|
103
|
-
[<b>Aslak Hellesoy</b>]
|
103
|
+
[<b>Aslak Hellesoy</b>] Creator and main contributor of this project.
|
104
|
+
|
105
|
+
[<b>Austin Ziegler</b>] Bugfixes and documentation improvements for XForge release code.
|
104
106
|
|
105
107
|
[<b>David Heinemeier Hansson</b>] For the HTTP POST code and the idea to parse XForge ids from project pages.
|
106
108
|
|
data/Rakefile
CHANGED
@@ -24,7 +24,7 @@ require 'rake/rdoctask'
|
|
24
24
|
#
|
25
25
|
# REMEMBER TO KEEP PKG_VERSION IN SYNC WITH THE CHANGES FILE!
|
26
26
|
PKG_NAME = "meta_project"
|
27
|
-
PKG_VERSION = "0.4.
|
27
|
+
PKG_VERSION = "0.4.11"
|
28
28
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
29
29
|
PKG_FILES = FileList[
|
30
30
|
'[A-Z]*',
|
@@ -74,7 +74,7 @@ module MetaProject
|
|
74
74
|
end
|
75
75
|
|
76
76
|
# Parses a patois String and yields commands.
|
77
|
-
# Each operation can be executed with +execute+
|
77
|
+
# TODO: Each operation can be executed with +execute+
|
78
78
|
def parse(msg)
|
79
79
|
msg.scan(@command_pattern) do |cmd_group|
|
80
80
|
cmd = SUPPORTED_COMMANDS[cmd_group[0].downcase]
|
@@ -1,14 +1,12 @@
|
|
1
1
|
module MetaProject
|
2
2
|
module Project
|
3
3
|
module XForge
|
4
|
-
|
5
|
-
#
|
4
|
+
# A Session object allows authenticated interaction with a Project,
|
5
|
+
# such as releasing files.
|
6
6
|
#
|
7
7
|
# A Session object can be obtained via Project.login
|
8
|
-
#
|
9
8
|
class Session
|
10
|
-
|
11
|
-
# Simple enumeration of processors. Used from Session.release
|
9
|
+
# Simple enumeration of processors. Used from Session.release.
|
12
10
|
class Processor
|
13
11
|
I386 = 1000
|
14
12
|
IA64 = 6000
|
@@ -21,7 +19,7 @@ module MetaProject
|
|
21
19
|
OTHER_PLATFORM = 9999
|
22
20
|
end
|
23
21
|
|
24
|
-
BOUNDARY = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
|
22
|
+
BOUNDARY = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor" #:nodoc:
|
25
23
|
|
26
24
|
def initialize(host, project, cookie) # :nodoc:
|
27
25
|
@host = host
|
@@ -29,13 +27,31 @@ module MetaProject
|
|
29
27
|
@headers = { "Cookie" => cookie }
|
30
28
|
end
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
PACKAGE_ID_PATTERN = %r{name="package_id"
|
31
|
+
\s+
|
32
|
+
value="([^"]+)"
|
33
|
+
.*?
|
34
|
+
name="package_name"
|
35
|
+
\s+
|
36
|
+
value="([^"]+)"}mxo #:nodoc:
|
37
|
+
|
38
|
+
# This will get the +package_id+ for the project. This accepts an
|
39
|
+
# optional name of the package that will be searched for results. A
|
40
|
+
# given session will only work for one package.
|
41
|
+
def package_id(name = nil)
|
42
|
+
unless @package_id
|
35
43
|
release_uri = "http://#{@host}/frs/admin/?group_id=#{@project.group_id}"
|
36
44
|
release_data = better_open(release_uri, @headers).read
|
37
|
-
|
38
|
-
|
45
|
+
packages = release_data.scan(PACKAGE_ID_PATTERN)
|
46
|
+
first = packages[0][0]
|
47
|
+
packages = Hash[*packages.map { |el| el.reverse }.flatten]
|
48
|
+
|
49
|
+
if name
|
50
|
+
@package_id = packages[name]
|
51
|
+
else
|
52
|
+
@package_id = first
|
53
|
+
end
|
54
|
+
|
39
55
|
unless @package_id
|
40
56
|
File.open("package_id.html", "w") {|io| io.write(release_data)}
|
41
57
|
raise "Couldn't get package_id from #{release_uri}. I was looking for /#{package_id_pattern.source}/. HTML saved to package_id.html for debugging."
|
@@ -44,11 +60,16 @@ module MetaProject
|
|
44
60
|
@package_id
|
45
61
|
end
|
46
62
|
|
47
|
-
# Creates a new release containing the files specified by
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
|
63
|
+
# Creates a new release containing the files specified by
|
64
|
+
# +filenames+ (Array) and named +release_name+. Optional parameters
|
65
|
+
# are +processor+ (which should be one of the Processor constants),
|
66
|
+
# +release_notes+, +release_changes+ and +preformatted+ which will
|
67
|
+
# appear on the releas page of the associated project. The
|
68
|
+
# +package_name+ parameter will help choose from the possible
|
69
|
+
# multiple packages for a release.
|
70
|
+
def release(release_name, filenames, release_notes = "",
|
71
|
+
release_changes = "", package_name = nil,
|
72
|
+
preformatted = true, processor = Processor::ANY)
|
52
73
|
release_date = Time.now.strftime("%Y-%m-%d %H:%M")
|
53
74
|
release_id = nil
|
54
75
|
|
@@ -56,9 +77,9 @@ module MetaProject
|
|
56
77
|
puts "Files:"
|
57
78
|
puts " " + filenames.join("\n ")
|
58
79
|
puts "\nRelease Notes:\n"
|
59
|
-
puts release_notes
|
80
|
+
puts release_notes.split(/\n/)[0..10].join("\n")
|
60
81
|
puts "\nRelease Changes:\n"
|
61
|
-
puts release_changes
|
82
|
+
puts release_changes.split(/\n/)[0..10].join("\n")
|
62
83
|
puts "\nRelease Settings:\n"
|
63
84
|
puts "Preformatted: #{preformatted}"
|
64
85
|
puts "Processor: #{processor}"
|
@@ -66,13 +87,13 @@ module MetaProject
|
|
66
87
|
|
67
88
|
xfiles = filenames.collect{|filename| XFile.new(filename)}
|
68
89
|
xfiles.each_with_index do |xfile, i|
|
69
|
-
first_file = i==0
|
90
|
+
first_file = (i == 0)
|
70
91
|
puts "Releasing #{xfile.basename}..."
|
71
92
|
release_response = Net::HTTP.start(@host, 80) do |http|
|
72
93
|
query_hash = if first_file then
|
73
94
|
{
|
74
95
|
"group_id" => @project.group_id,
|
75
|
-
"package_id" => package_id,
|
96
|
+
"package_id" => package_id(package_name),
|
76
97
|
"type_id" => xfile.bin_type_id,
|
77
98
|
"processor_id" => processor,
|
78
99
|
|
@@ -86,7 +107,7 @@ module MetaProject
|
|
86
107
|
else
|
87
108
|
{
|
88
109
|
"group_id" => @project.group_id,
|
89
|
-
"package_id" => package_id,
|
110
|
+
"package_id" => package_id(package_name),
|
90
111
|
"type_id" => xfile.bin_type_id,
|
91
112
|
"processor_id" => processor,
|
92
113
|
|
@@ -96,22 +117,22 @@ module MetaProject
|
|
96
117
|
}
|
97
118
|
end
|
98
119
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
"Content-Disposition: form-data; name=\"userfile\"; filename=\"#{xfile.basename}\"",
|
120
|
+
form = [
|
121
|
+
"--#{BOUNDARY}",
|
122
|
+
%Q(Content-Disposition: form-data; name="userfile"; ) +
|
123
|
+
%Q(filename="#{xfile.basename}"),
|
104
124
|
"Content-Type: application/octet-stream",
|
105
125
|
"Content-Transfer-Encoding: binary",
|
106
126
|
"", xfile.data, ""
|
107
|
-
|
127
|
+
]
|
128
|
+
|
129
|
+
data = post_data(form, query_hash)
|
130
|
+
|
131
|
+
headers = @headers.merge("Content-Type" => "multipart/form-data; boundary=#{BOUNDARY}")
|
108
132
|
|
109
|
-
headers = @headers.merge(
|
110
|
-
"Content-Type" => "multipart/form-data; boundary=#{BOUNDARY}"
|
111
|
-
)
|
112
133
|
|
113
134
|
target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
|
114
|
-
http.post(target
|
135
|
+
http.post(target, data, headers)
|
115
136
|
end
|
116
137
|
|
117
138
|
if first_file then
|
@@ -122,6 +143,7 @@ module MetaProject
|
|
122
143
|
puts "Done!"
|
123
144
|
end
|
124
145
|
|
146
|
+
# Publish news relating to a project and a package.
|
125
147
|
def publish_news(subject, details)
|
126
148
|
puts "About to publish news"
|
127
149
|
puts "Subject: '#{subject}'"
|
@@ -132,31 +154,38 @@ module MetaProject
|
|
132
154
|
release_response = Net::HTTP.start(@host, 80) do |http|
|
133
155
|
query_hash = {
|
134
156
|
"group_id" => @project.group_id,
|
135
|
-
"package_id" => package_id,
|
136
157
|
"post_changes" => "y",
|
137
158
|
"summary" => subject,
|
138
159
|
"details" => details
|
139
160
|
}
|
140
161
|
|
141
162
|
target = "/news/submit.php"
|
142
|
-
headers = @headers.merge(
|
143
|
-
"Content-Type" => "multipart/form-data"
|
144
|
-
)
|
145
|
-
http.post(target + query(query_hash), "", headers)
|
163
|
+
headers = @headers.merge("Content-Type" => "multipart/form-data; boundary=#{BOUNDARY}")
|
146
164
|
|
165
|
+
http.post(target, post_data(query_hash), headers)
|
147
166
|
end
|
148
167
|
puts "Done!"
|
149
168
|
end
|
150
169
|
|
151
170
|
private
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
171
|
+
def post_data(*args)
|
172
|
+
form = []
|
173
|
+
args.each do |arg|
|
174
|
+
case arg
|
175
|
+
when Array
|
176
|
+
form << arg
|
177
|
+
when Hash
|
178
|
+
arg.each do |key, value|
|
179
|
+
form <<
|
180
|
+
"--#{BOUNDARY}" <<
|
181
|
+
%Q(Content-Disposition: form-data; name="#{key}") <<
|
182
|
+
"" << value
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
form.flatten.join("\r\n")
|
157
187
|
end
|
158
|
-
|
159
188
|
end
|
160
189
|
end
|
161
190
|
end
|
162
|
-
end
|
191
|
+
end
|
@@ -1,16 +1,17 @@
|
|
1
1
|
module MetaProject
|
2
2
|
module Tracker
|
3
|
-
# This module should be included by trackers that follow a digit-based issue scheme
|
3
|
+
# This module should be included by trackers that follow a digit-based issue scheme.
|
4
|
+
# TODO: Make issue_pattern and command_pattern attributes so they can be modified. Provide examples.
|
4
5
|
module DigitIssues
|
5
6
|
# Patois issue pattern
|
6
7
|
def issue_pattern
|
7
|
-
/\#([\d]+)/
|
8
|
+
@issue_pattern ||= /\#([\d]+)/
|
8
9
|
end
|
9
10
|
module_function :issue_pattern
|
10
11
|
|
11
12
|
# Patois command pattern
|
12
13
|
def command_pattern
|
13
|
-
/([A-Za-z]*).?(\#[\d]+(?:(?:[, &]*|\s?and\s?)\#[\d]+)*)/
|
14
|
+
@command_pattern ||= /([A-Za-z]*).?(\#[\d]+(?:(?:[, &]*|\s?and\s?)\#[\d]+)*)/
|
14
15
|
end
|
15
16
|
module_function :command_pattern
|
16
17
|
|
@@ -1,17 +1,39 @@
|
|
1
1
|
module Rake
|
2
2
|
module XForge
|
3
|
-
|
4
|
-
# Base class for XForge tasks
|
3
|
+
# Base class for XForge tasks.
|
5
4
|
class Base
|
6
|
-
|
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
|
7
29
|
|
8
30
|
def initialize(project)
|
9
31
|
@project = project
|
10
32
|
|
11
33
|
@changes_file = "CHANGES"
|
12
|
-
@version = PKG_VERSION if defined?
|
34
|
+
@version = ::PKG_VERSION if defined?(::PKG_VERSION)
|
13
35
|
|
14
|
-
if
|
36
|
+
if block_given?
|
15
37
|
yield self
|
16
38
|
set_defaults
|
17
39
|
execute
|
@@ -19,12 +41,11 @@ module Rake
|
|
19
41
|
end
|
20
42
|
|
21
43
|
protected
|
22
|
-
|
23
44
|
def set_defaults
|
24
45
|
end
|
25
46
|
|
26
47
|
def user_name
|
27
|
-
|
48
|
+
unless @user_name
|
28
49
|
print "#{@project.host} user: "
|
29
50
|
@user_name = STDIN.gets.chomp
|
30
51
|
end
|
@@ -32,13 +53,12 @@ module Rake
|
|
32
53
|
end
|
33
54
|
|
34
55
|
def password
|
35
|
-
|
56
|
+
unless @password
|
36
57
|
print "#{@project.host} password: "
|
37
58
|
@password = STDIN.gets.chomp
|
38
59
|
end
|
39
60
|
@password
|
40
61
|
end
|
41
|
-
|
42
62
|
end
|
43
63
|
end
|
44
64
|
end
|
@@ -1,19 +1,86 @@
|
|
1
1
|
module Rake
|
2
2
|
module XForge
|
3
|
-
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
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
|
7
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
|
8
56
|
|
9
|
-
|
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
|
10
64
|
|
11
65
|
protected
|
12
|
-
|
13
66
|
def set_defaults
|
14
|
-
|
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
|
15
82
|
|
16
|
-
if
|
83
|
+
if @changes_file && @version
|
17
84
|
begin
|
18
85
|
vp = ::MetaProject::VersionParser.new
|
19
86
|
version = vp.parse(@changes_file, @version)
|
@@ -25,14 +92,6 @@ module Rake
|
|
25
92
|
end
|
26
93
|
end
|
27
94
|
end
|
28
|
-
|
29
|
-
def execute
|
30
|
-
raise "'details' not defined." unless @details
|
31
|
-
raise "'subject' not defined." unless @subject
|
32
|
-
session = @project.login(user_name, password)
|
33
|
-
session.publish_news(@subject, @details)
|
34
|
-
end
|
35
|
-
|
36
95
|
end
|
37
96
|
end
|
38
97
|
end
|
@@ -1,72 +1,127 @@
|
|
1
1
|
module Rake
|
2
2
|
module XForge
|
3
|
-
|
4
|
-
#
|
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
5
|
#
|
6
|
+
# project = MetaProject::Project::XForge::RubyForge.new('xforge')
|
6
7
|
# # Create a new release of the xforge project on Rubyforge.
|
7
|
-
# task :release => [:gem] do
|
8
|
-
# Rake::XForge::Release.new(
|
8
|
+
# task :release => [:gem] do
|
9
|
+
# Rake::XForge::Release.new(project) {}
|
9
10
|
# end
|
10
11
|
#
|
11
|
-
# The previous example will use defaults where it can. It will prompt
|
12
|
-
# and password before it uploads all
|
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.
|
13
15
|
#
|
14
|
-
# While defaults are nice, you may want a little more control. You can
|
16
|
+
# While defaults are nice, you may want a little more control. You can
|
17
|
+
# specify additional attributes:
|
15
18
|
#
|
16
|
-
#
|
17
|
-
# *
|
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
|
19
28
|
#
|
20
29
|
# Example:
|
21
|
-
#
|
30
|
+
# project = MetaProject::Project::XForge::RubyForge.new('xforge')
|
22
31
|
# task :release => [:gem] do
|
23
|
-
# release_files = FileList[
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
# Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new('xforge')) do |xf|
|
29
|
-
# # Never hardcode user name and password in the Rakefile!
|
30
|
-
# xf.user_name = ENV['RUBYFORGE_USER']
|
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']
|
31
37
|
# xf.password = ENV['RUBYFORGE_PASSWORD']
|
32
38
|
# xf.files = release_files.to_a
|
33
|
-
# xf.release_name = "XForge 0.1"
|
34
|
-
# end
|
39
|
+
# xf.release_name = "XForge 0.1"
|
35
40
|
# end
|
36
41
|
#
|
37
42
|
# This can be invoked from the command line:
|
38
43
|
#
|
39
|
-
# rake release RUBYFORGE_USER=
|
44
|
+
# rake release RUBYFORGE_USER=myuser \
|
45
|
+
# RUBYFORGE_PASSWORD=mypassword
|
40
46
|
#
|
41
47
|
# If you don't like blocks, you can do like this:
|
42
48
|
#
|
43
|
-
#
|
44
|
-
#
|
49
|
+
# project = MetaProject::Project::XForge::RubyForge.new('xforge')
|
50
|
+
# task :release => [:gem] do
|
51
|
+
# xf = Rake::XForge::Release.new(project)
|
45
52
|
# ... # Set additional attributes
|
46
|
-
# xf.execute
|
53
|
+
# xf.execute
|
47
54
|
# end
|
48
|
-
#
|
49
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
|
50
87
|
|
51
|
-
|
52
|
-
|
53
|
-
protected
|
54
|
-
|
88
|
+
protected
|
55
89
|
def set_defaults
|
56
|
-
|
57
|
-
|
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
|
58
96
|
end
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
62
115
|
end
|
63
|
-
|
64
|
-
if
|
116
|
+
|
117
|
+
if @changes_file and @version
|
65
118
|
begin
|
66
119
|
vp = ::MetaProject::VersionParser.new
|
67
120
|
version = vp.parse(@changes_file, @version)
|
68
121
|
@release_notes = version.release_notes unless @release_notes
|
69
|
-
|
122
|
+
unless @release_changes
|
123
|
+
@release_changes = %Q[* #{version.release_changes.join("\n* ")}]
|
124
|
+
end
|
70
125
|
rescue => e
|
71
126
|
STDERR.puts("Couldn't parse release info from #{@changes_file}")
|
72
127
|
STDERR.puts(e.message)
|
@@ -74,16 +129,6 @@ module Rake
|
|
74
129
|
end
|
75
130
|
end
|
76
131
|
end
|
77
|
-
|
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, @release_changes)
|
85
|
-
end
|
86
|
-
|
87
132
|
end
|
88
133
|
end
|
89
134
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: meta_project
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.4.
|
7
|
-
date: 2005-09-
|
6
|
+
version: 0.4.11
|
7
|
+
date: 2005-09-09 00:00:00 -04:00
|
8
8
|
summary: Ruby based make-like utility.
|
9
9
|
require_paths:
|
10
10
|
- lib
|