rtask 006 → 007

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/History.txt +4 -0
  2. data/README.txt +1 -1
  3. data/Rakefile +1 -1
  4. data/bin/rtask +50 -12
  5. data/lib/rtask.rb +77 -29
  6. metadata +11 -2
@@ -1,3 +1,7 @@
1
+ == 006: 2008-04-12
2
+ * Keita Yamaguchi:
3
+ * Added version checker
4
+
1
5
  == 005: 2008-04-11
2
6
  * Keita Yamaguchi:
3
7
  * Renamed bin/rtask.rb to bin/rtask
data/README.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  = RTask
2
2
 
3
3
  Author:: Keita Yamaguchi(山口 慶太) <keita.yamaguchi@gmail.com>
4
- Copyright:: © Keita Yamaguchi, 20072008. All rights reserved.
4
+ Copyright:: © Keita Yamaguchi, 2007-2008. All rights reserved.
5
5
  License:: Ruby License
6
6
 
7
7
  RTask provides easy way to release Ruby’s gem packages. This also provides useful Rake tasks for releasing packages and uploading documents.
data/Rakefile CHANGED
@@ -2,4 +2,4 @@ require "rubygems"
2
2
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
3
3
  require "rtask"
4
4
 
5
- RTask.new
5
+ RTask.new(:use => :all, :version => RTask::VERSION)
data/bin/rtask CHANGED
@@ -4,24 +4,62 @@ require "rubygems"
4
4
  require "rtask"
5
5
  require "optparse"
6
6
 
7
- $task = RTask.new
7
+ $task = RTask.new(:use => :all)
8
8
 
9
- OptionParser.new(nil, 18) do |opt|
10
- opt.on("-r", "--release", "Release the packages") do
11
- puts "Release"
12
- $task.real_release
13
- exit
9
+ def call_task(name)
10
+ ARGV.clear
11
+ ARGV[0] = name
12
+ Rake.application.init
13
+ # This is ugly, but needed for unknown reason
14
+ # (filetask contains unused empty string).
15
+ # Please teach me if you know about it.
16
+ filetask = Rake.application.instance_eval{@tasks["html/index.html"]}
17
+ filetask.instance_eval do
18
+ @prerequisites.exclude("")
19
+ end
20
+ Rake.application.top_level
21
+ exit
22
+ end
23
+
24
+ OptionParser.new(nil, 24) do |opt|
25
+ opt.on("-r", "--release", RTask::MESSAGE[:release]) do
26
+ call_task "release"
27
+ end
28
+
29
+ opt.on("-p", "--packages", RTask::MESSAGE[:packages]) do
30
+ call_task "packages"
31
+ end
32
+
33
+ opt.on("--gem", RTask::MESSAGE[:gem]) do
34
+ call_task "gem"
35
+ end
36
+
37
+ opt.on("--tgz", RTask::MESSAGE[:tgz]) do
38
+ call_task "tgz"
14
39
  end
15
40
 
16
- opt.on("-p", "--package", "Create gem and tgz packages") do
17
- puts "Create gem and tgz packages"
18
- $task.real_gem
19
- $task.real_tgz
41
+ opt.on("--zip", RTask::MESSAGE[:zip]) do
42
+ call_task "zip"
43
+ end
44
+
45
+ opt.on("--rdoc", "Build the rdoc HTML Files") do
46
+ call_task "rdoc"
47
+ end
48
+
49
+ opt.on("--publish", RTask::MESSAGE[:publish]) do
50
+ call_task "publish"
51
+ end
52
+
53
+ opt.on("-c", "--clean", "Remove packages and temporary products") do
54
+ call_task "clean"
20
55
  end
21
56
 
22
57
  opt.on("-h", "--help", "Show this message") do
23
- puts opt.help
24
- exit
58
+ puts opt.help; exit
59
+ end
60
+
61
+ opt.on("-v", "--version", "Show RTask version") do
62
+ puts RTask::VERSION; exit
25
63
  end
26
64
 
27
65
  opt.parse!(ARGV)
@@ -24,7 +24,8 @@ require 'gemify'
24
24
  # rake tgz # Create the tgz package
25
25
  #
26
26
  class RTask
27
- VERSION = "005"
27
+ VERSION = "007"
28
+ MESSAGE = Hash.new
28
29
 
29
30
  attr_reader :project, :package, :version
30
31
 
@@ -44,20 +45,46 @@ class RTask
44
45
  yield self if block_given?
45
46
  end
46
47
 
47
- # Specifies to use tasks.
48
+ # define task
49
+ def self.define_task(description, rule)
50
+ name = rule
51
+ if rule.kind_of?(Hash)
52
+ name = rule.keys.first
53
+ end
54
+
55
+ MESSAGE[name] = description
56
+
57
+ define_method("register_task_#{name}") do |rtask|
58
+ desc description if description
59
+ task(rule){ rtask.send name if rtask.respond_to?(name) }
60
+ end
61
+ end
62
+
63
+ # Specifies to use tasks
48
64
  def use(*names)
49
65
  if names[0] == :all
50
- names = [:clean, :rdoc, :publish, :release, :gem, :tgz]
66
+ names = [:clean, :rdoc, :publish, :release, :packages]
51
67
  end
52
68
  names.each do |name|
53
- send(name.to_sym)
69
+ register = "register_task_#{name}"
70
+ case name
71
+ when :clean, :rdoc
72
+ send(name)
73
+ when :packages
74
+ send(register, self)
75
+ send("register_task_gem", self)
76
+ send("register_task_tgz", self)
77
+ send("register_task_zip", self)
78
+ else
79
+ send(register, self)
80
+ end
54
81
  end
55
82
  end
56
83
 
57
84
  # Task for cleaning.
58
85
  def clean
59
86
  require 'rake/clean'
60
- CLEAN.include ['**/.*.sw?', '*.gem', '*.tgz', '.config', '**/.DS_Store']
87
+ CLEAN.include ['html', '*.gem', '*.tgz', '*.zip', '.config', '**/.DS_Store']
61
88
  end
62
89
 
63
90
  # Task for generating documents using rdoc.
@@ -66,7 +93,7 @@ class RTask
66
93
  Rake::RDocTask.new do |doc|
67
94
  doc.title = "#{@package}-#{@version} documentation"
68
95
  doc.main = "README.txt"
69
- doc.rdoc_files.include("{README,History,License}.txt", "lib/**/*.rb")
96
+ doc.rdoc_files.include("{README,History,License}.txt", "lib/*.rb")
70
97
  doc.options << "--line-numbers" << "--inline-source" << "-c UTF-8"
71
98
  yield doc if block_given?
72
99
  end
@@ -75,20 +102,14 @@ class RTask
75
102
  # Task for uploading API documentation.
76
103
  def publish
77
104
  require 'rake/contrib/rubyforgepublisher'
78
- desc "Upload API documentation"
79
- task :publish => [:rdoc] do
80
- pub = Rake::RubyForgePublisher.new(@project, @user["username"])
81
- pub.upload
82
- end
105
+ pub = Rake::RubyForgePublisher.new(@project, @user["username"])
106
+ pub.upload
83
107
  end
84
108
 
109
+ define_task "Upload API documentation", :publish => [:rdoc]
110
+
85
111
  # Task for release the package.
86
112
  def release
87
- desc 'Release new gem version'
88
- task :release do real_release end
89
- end
90
-
91
- def real_release #:nodoc:
92
113
  if @lib_version and @version.to_s != @lib_version.to_s
93
114
  puts "Version confilict between the library and in .gemified"
94
115
  puts "library: " + @lib_version.to_s
@@ -98,8 +119,9 @@ class RTask
98
119
  filename = "#{@package}-#{@version}"
99
120
  gem = filename + ".gem"
100
121
  tgz = filename + ".tgz"
122
+ zip = filename + ".zip"
101
123
  if File.exist?(gem) and File.exist?(tgz)
102
- @rubyforge.add_release @project, @package, @version, gem, tgz
124
+ @rubyforge.add_release @project, @package, @version, gem, tgz, zip
103
125
  puts "Released #{gem} and #{tgz}"
104
126
  else
105
127
  puts "Please make gem and tgz files first: rake gem tgz"
@@ -107,24 +129,50 @@ class RTask
107
129
  end
108
130
  end
109
131
 
110
- # Task for creating gem.
111
- def gem
112
- desc "Create the gem package"
113
- task :gem do real_gem end
114
- end
132
+ define_task 'Release new gem', :release => [:packages]
133
+
134
+ # Task for creating packages
135
+ define_task "Create packages", :packages => [:gem, :tgz, :zip]
115
136
 
116
- def real_gem #:nodoc:
137
+ # Task for creating gem
138
+ def gem
117
139
  sh "gemify -I"
118
140
  end
119
141
 
120
- # Task for creating tgz.
121
- def tgz
122
- desc "Create the tgz package"
123
- task :tgz do real_tgz end
124
- end
142
+ define_task "Create the gem package", :gem
125
143
 
126
- def real_tgz #:nodoc:
144
+ # Task for creating tgz
145
+ def tgz
127
146
  tgz = "#{@package}-#{@version}.tgz"
128
147
  sh "tar -T Manifest.txt -c -z -f #{tgz}"
129
148
  end
149
+
150
+ define_task "Create the tgz package", :tgz
151
+
152
+ # Task for creating zip
153
+ def zip
154
+ require "zip/zipfilesystem"
155
+ filename = "#{@package}-#{@version}.zip"
156
+ rm filename if File.exist?(filename)
157
+ Zip::ZipFile.open(filename, Zip::ZipFile::CREATE) do |zip|
158
+ manifest.each do |file|
159
+ zip.file.open(File.join("#{package}-#{@version}", file), "w") do |out|
160
+ out.write(File.open(file).read)
161
+ end
162
+ end
163
+ end
164
+ end
165
+
166
+ define_task "Create the zip package", :zip
167
+
168
+ private
169
+
170
+ def manifest
171
+ manifest = Dir.glob("*Manifest*", File::FNM_CASEFOLD).first
172
+ unless manifest
173
+ puts "Please make manifest"
174
+ exit
175
+ end
176
+ File.read(manifest).split("\n")
177
+ end
130
178
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtask
3
3
  version: !ruby/object:Gem::Version
4
- version: "006"
4
+ version: "007"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keita Yamaguchi
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-12 00:00:00 +09:00
12
+ date: 2008-04-18 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,6 +30,15 @@ dependencies:
30
30
  - !ruby/object:Gem::Version
31
31
  version: "0"
32
32
  version:
33
+ - !ruby/object:Gem::Dependency
34
+ name: rubyzip
35
+ version_requirement:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ version:
33
42
  description:
34
43
  email: keita.yamaguchi@gmail.com
35
44
  executables: