elliottcable-echoe 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +69 -0
- data/LICENSE +184 -0
- data/MIT-LICENSE +21 -0
- data/Manifest +113 -0
- data/README +114 -0
- data/Rakefile +15 -0
- data/TODO +4 -0
- data/echoe.gemspec +37 -0
- data/lib/echoe/client.rb +25 -0
- data/lib/echoe/extensions.rb +57 -0
- data/lib/echoe/platform.rb +36 -0
- data/lib/echoe/rubygems.rb +41 -0
- data/lib/echoe.rb +717 -0
- data/vendor/rake/CHANGES +400 -0
- data/vendor/rake/MIT-LICENSE +21 -0
- data/vendor/rake/README +285 -0
- data/vendor/rake/Rakefile +418 -0
- data/vendor/rake/TODO +20 -0
- data/vendor/rake/bin/rake +31 -0
- data/vendor/rake/doc/example/Rakefile1 +38 -0
- data/vendor/rake/doc/example/Rakefile2 +35 -0
- data/vendor/rake/doc/example/a.c +6 -0
- data/vendor/rake/doc/example/b.c +6 -0
- data/vendor/rake/doc/example/main.c +11 -0
- data/vendor/rake/doc/glossary.rdoc +51 -0
- data/vendor/rake/doc/jamis.rb +591 -0
- data/vendor/rake/doc/proto_rake.rdoc +127 -0
- data/vendor/rake/doc/rake.1.gz +0 -0
- data/vendor/rake/doc/rakefile.rdoc +534 -0
- data/vendor/rake/doc/rational.rdoc +151 -0
- data/vendor/rake/doc/release_notes/rake-0.4.14.rdoc +23 -0
- data/vendor/rake/doc/release_notes/rake-0.4.15.rdoc +35 -0
- data/vendor/rake/doc/release_notes/rake-0.5.0.rdoc +53 -0
- data/vendor/rake/doc/release_notes/rake-0.5.3.rdoc +78 -0
- data/vendor/rake/doc/release_notes/rake-0.5.4.rdoc +46 -0
- data/vendor/rake/doc/release_notes/rake-0.6.0.rdoc +141 -0
- data/vendor/rake/doc/release_notes/rake-0.7.0.rdoc +119 -0
- data/vendor/rake/doc/release_notes/rake-0.7.1.rdoc +59 -0
- data/vendor/rake/doc/release_notes/rake-0.7.2.rdoc +121 -0
- data/vendor/rake/doc/release_notes/rake-0.7.3.rdoc +47 -0
- data/vendor/rake/doc/release_notes/rake-0.8.0.rdoc +114 -0
- data/vendor/rake/doc/release_notes/rake-0.8.2.rdoc +165 -0
- data/vendor/rake/doc/release_notes/rake-0.8.3.rdoc +112 -0
- data/vendor/rake/install.rb +88 -0
- data/vendor/rake/lib/rake/classic_namespace.rb +8 -0
- data/vendor/rake/lib/rake/clean.rb +33 -0
- data/vendor/rake/lib/rake/contrib/compositepublisher.rb +24 -0
- data/vendor/rake/lib/rake/contrib/ftptools.rb +153 -0
- data/vendor/rake/lib/rake/contrib/publisher.rb +75 -0
- data/vendor/rake/lib/rake/contrib/rubyforgepublisher.rb +18 -0
- data/vendor/rake/lib/rake/contrib/sshpublisher.rb +47 -0
- data/vendor/rake/lib/rake/contrib/sys.rb +209 -0
- data/vendor/rake/lib/rake/gempackagetask.rb +103 -0
- data/vendor/rake/lib/rake/loaders/makefile.rb +35 -0
- data/vendor/rake/lib/rake/packagetask.rb +185 -0
- data/vendor/rake/lib/rake/rake_test_loader.rb +5 -0
- data/vendor/rake/lib/rake/rdoctask.rb +147 -0
- data/vendor/rake/lib/rake/ruby182_test_unit_fix.rb +23 -0
- data/vendor/rake/lib/rake/runtest.rb +23 -0
- data/vendor/rake/lib/rake/tasklib.rb +23 -0
- data/vendor/rake/lib/rake/testtask.rb +161 -0
- data/vendor/rake/lib/rake/win32.rb +54 -0
- data/vendor/rake/lib/rake.rb +2468 -0
- data/vendor/rake/test/capture_stdout.rb +26 -0
- data/vendor/rake/test/check_expansion.rb +5 -0
- data/vendor/rake/test/contrib/test_sys.rb +47 -0
- data/vendor/rake/test/data/chains/Rakefile +15 -0
- data/vendor/rake/test/data/default/Rakefile +19 -0
- data/vendor/rake/test/data/dryrun/Rakefile +22 -0
- data/vendor/rake/test/data/file_creation_task/Rakefile +33 -0
- data/vendor/rake/test/data/imports/Rakefile +19 -0
- data/vendor/rake/test/data/imports/deps.mf +1 -0
- data/vendor/rake/test/data/multidesc/Rakefile +17 -0
- data/vendor/rake/test/data/namespace/Rakefile +57 -0
- data/vendor/rake/test/data/rakelib/test1.rb +3 -0
- data/vendor/rake/test/data/rbext/rakefile.rb +3 -0
- data/vendor/rake/test/data/sample.mf +12 -0
- data/vendor/rake/test/data/statusreturn/Rakefile +8 -0
- data/vendor/rake/test/data/unittest/Rakefile +1 -0
- data/vendor/rake/test/filecreation.rb +32 -0
- data/vendor/rake/test/functional.rb +15 -0
- data/vendor/rake/test/in_environment.rb +30 -0
- data/vendor/rake/test/rake_test_setup.rb +10 -0
- data/vendor/rake/test/reqfile.rb +3 -0
- data/vendor/rake/test/reqfile2.rb +3 -0
- data/vendor/rake/test/session_functional.rb +337 -0
- data/vendor/rake/test/shellcommand.rb +3 -0
- data/vendor/rake/test/test_application.rb +694 -0
- data/vendor/rake/test/test_clean.rb +14 -0
- data/vendor/rake/test/test_definitions.rb +82 -0
- data/vendor/rake/test/test_earlytime.rb +35 -0
- data/vendor/rake/test/test_extension.rb +63 -0
- data/vendor/rake/test/test_file_creation_task.rb +62 -0
- data/vendor/rake/test/test_file_task.rb +139 -0
- data/vendor/rake/test/test_filelist.rb +618 -0
- data/vendor/rake/test/test_fileutils.rb +250 -0
- data/vendor/rake/test/test_ftp.rb +59 -0
- data/vendor/rake/test/test_invocation_chain.rb +75 -0
- data/vendor/rake/test/test_makefile_loader.rb +25 -0
- data/vendor/rake/test/test_multitask.rb +45 -0
- data/vendor/rake/test/test_namespace.rb +36 -0
- data/vendor/rake/test/test_package_task.rb +116 -0
- data/vendor/rake/test/test_pathmap.rb +209 -0
- data/vendor/rake/test/test_rake.rb +41 -0
- data/vendor/rake/test/test_require.rb +33 -0
- data/vendor/rake/test/test_rules.rb +347 -0
- data/vendor/rake/test/test_task_arguments.rb +89 -0
- data/vendor/rake/test/test_task_manager.rb +170 -0
- data/vendor/rake/test/test_tasklib.rb +12 -0
- data/vendor/rake/test/test_tasks.rb +371 -0
- data/vendor/rake/test/test_test_task.rb +75 -0
- data/vendor/rake/test/test_top_level_functions.rb +84 -0
- data/vendor/rake/test/test_win32.rb +57 -0
- metadata +195 -0
data/lib/echoe.rb
ADDED
@@ -0,0 +1,717 @@
|
|
1
|
+
Dir[File.join(File.expand_path(File.join( File.dirname(__FILE__), '..', 'vendor' )), '*')].each do |gem|
|
2
|
+
if File.directory? gem
|
3
|
+
($:.unshift File.join(gem, 'lib')).uniq!
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
$HERE = File.dirname(__FILE__)
|
8
|
+
require "#{$HERE}/echoe/platform"
|
9
|
+
require "#{$HERE}/echoe/extensions"
|
10
|
+
|
11
|
+
require 'rake'
|
12
|
+
require 'rake/clean'
|
13
|
+
require 'rake/contrib/sshpublisher'
|
14
|
+
require 'rake/gempackagetask'
|
15
|
+
require 'rake/rdoctask'
|
16
|
+
require 'rake/testtask'
|
17
|
+
require 'rbconfig'
|
18
|
+
require 'open-uri'
|
19
|
+
|
20
|
+
require 'rubygems'
|
21
|
+
require "#{$HERE}/echoe/rubygems"
|
22
|
+
|
23
|
+
require 'rubyforge'
|
24
|
+
require "#{$HERE}/echoe/client"
|
25
|
+
|
26
|
+
require 'highline/import'
|
27
|
+
|
28
|
+
begin; require 'rcov/rcovtask'; rescue LoadError; end
|
29
|
+
begin; require 'load_multi_rails_rake_tasks'; rescue LoadError; end
|
30
|
+
|
31
|
+
=begin rdoc
|
32
|
+
|
33
|
+
Echoe includes some optional accessors for more advanced gem configuration.
|
34
|
+
|
35
|
+
For example, a simple <tt>Rakefile</tt> might look like this:
|
36
|
+
|
37
|
+
require 'echoe'
|
38
|
+
|
39
|
+
Echoe.new("uncapitalizer") do |p|
|
40
|
+
p.author = "Evan Weaver"
|
41
|
+
p.summary = "A library that uncapitalizes strings."
|
42
|
+
p.url = "http://www.uncapitalizer.com"
|
43
|
+
p.docs_host = "uncapitalizer.com:~/www/files/doc/"
|
44
|
+
p.runtime_dependencies = ["string_tools >=1.4.0"]
|
45
|
+
end
|
46
|
+
|
47
|
+
See below for the full list.
|
48
|
+
|
49
|
+
== Signing gems
|
50
|
+
|
51
|
+
Echoe supports signing gems. First, create yourself a public and private key:
|
52
|
+
gem cert --build you@yourmail.com
|
53
|
+
|
54
|
+
Move them somewhere secret, and add the following environment variables in your <tt>.bash_profile</tt> or similar:
|
55
|
+
export GEM_PRIVATE_KEY='/secret/path/to/gem-private_key.pem'
|
56
|
+
export GEM_CERTIFICATE_CHAIN='/secret/path/to/gem-public_cert.pem'
|
57
|
+
|
58
|
+
Make sure your environment is up-to-date:
|
59
|
+
source ~/.bash_profile
|
60
|
+
|
61
|
+
Upload your <tt>public_cert.pem</tt> file to your website or Rubyforge project, and tell your users to add that certificate to their system via:
|
62
|
+
gem cert --add /path/to/public_cert.pem
|
63
|
+
|
64
|
+
Finally, package and release your project as normal. Now users can install your gem via:
|
65
|
+
sudo gem install gemname -P HighSecurity
|
66
|
+
|
67
|
+
Note that you can also set the key and certificate locations in the Rakefile itself. Finally, you can add <tt>p.require_signed = true</tt> to your <tt>Rakefile</tt> so that you don't accidentally release an unsigned gem if your key is missing.
|
68
|
+
|
69
|
+
== Metadependencies
|
70
|
+
|
71
|
+
Echoe does not force packages to depend on Echoe itself. Instead, it generates a <tt>gemspec</tt> from your <tt>Rakefile</tt> and includes that. Downstream repackagers can use the <tt>gemspec</tt> as-is to build new versions of your gem even without Echoe.
|
72
|
+
|
73
|
+
However, Echoe is added to the <tt>development_dependencies</tt> array so that users can automatically install it via <tt>gem install --development</tt> if they prefer. You can override this behavior by setting <tt>p.development_dependencies = []</tt>.
|
74
|
+
|
75
|
+
== Cross-packaging
|
76
|
+
|
77
|
+
Echoe supports platform Rake targets to allow you to cross-package your gems. Just write the spec assuming <tt>RUBY_PLATFORM</tt> will be what you need it to be for each architecture, and then invoke Rake with the platform name when you're cross-packaging.
|
78
|
+
|
79
|
+
For example, on JRuby, <tt>rake package</tt> will build a generic <tt>-ruby</tt> type gem. But if you want to include a Java-specific extension, you can do one of two things. You can package from within JRuby by checking if <tt>RUBY_PLATFORM =~ /java/</tt> and setting <tt>p.platform = jruby</tt>, or you can run <tt>rake java package</tt>, which will set <tt>RUBY_PLATFORM</tt> and <tt>p.platform</tt> for you.
|
80
|
+
|
81
|
+
This way you can run <tt>rake java package</tt>, <tt>rake aix install</tt>, or whatever task you need and Echoe will behave just like you're packaging from within the target platform.
|
82
|
+
|
83
|
+
== Test environment setup and teardown
|
84
|
+
|
85
|
+
For some applications, you may need to setup and teardown environment state for the entire test suite. This is especially common for integration tests that may need to spawn an external daemon. To support this, you can add a file <tt>tests/setup.rb</tt> and it will be silently executed before the entire suite runs. Add a similar file <tt>tests/teardown.rb</tt> in your app to be executed at the end of the entire run.
|
86
|
+
|
87
|
+
Note; these files will only get executed if you run the tests via <tt>rake</tt>. Also, you can set the environment variable <tt>VERBOSE=1</tt> to not hide the setup/teardown output.
|
88
|
+
|
89
|
+
== Accessor options
|
90
|
+
|
91
|
+
Descriptive options:
|
92
|
+
|
93
|
+
* <tt>author</tt> - Your name.
|
94
|
+
* <tt>email</tt> - Your email address.
|
95
|
+
* <tt>description</tt> - A more detailed description of the library.
|
96
|
+
* <tt>summary</tt> - A shorter description of the library.
|
97
|
+
* <tt>url</tt> - A url for the library.
|
98
|
+
* <tt>install_message</tt> - A message to display after the gem is installed.
|
99
|
+
|
100
|
+
Versioning options:
|
101
|
+
|
102
|
+
* <tt>version</tt> - A string for the version number. Parsed from CHANGELOG otherwise.
|
103
|
+
* <tt>changes</tt> - A string describing the most recent changes. Parsed from CHANGELOG otherwise.
|
104
|
+
|
105
|
+
Common packaging options:
|
106
|
+
|
107
|
+
* <tt>runtime_dependencies</tt> - An array of runtime dependencies for this gem. For example, <tt>['mongrel', 'activesupport >= 2.0.2']</tt>.
|
108
|
+
* <tt>development_dependencies</tt> - An array of development dependencies for this gem. For example, <tt>['rake >=0.7.1']</tt>.
|
109
|
+
* <tt>extension_pattern</tt> - A filename array, glob array, or regex for extension files that need to be run at install time. Defaults to <tt>"ext/**/extconf.rb"</tt>.
|
110
|
+
|
111
|
+
Testing options:
|
112
|
+
|
113
|
+
* <tt>clean_pattern</tt> - A filename array, glob array, or regex for files that should be removed when <tt>rake clean</tt> is run.
|
114
|
+
* <tt>test_pattern</tt> - A filename array, glob array, or regex for test runners. Overridden by <tt>"test/test_all.rb"</tt>, if it exists.
|
115
|
+
* <tt>rcov_options</tt> - Any extra flags to pass to RCov when coverage reports are run.
|
116
|
+
|
117
|
+
Uncommon packaging options:
|
118
|
+
* <tt>platform</tt> - What platform this gem is for.
|
119
|
+
* <tt>manifest_name</tt> - The name of the manifest file. Defaults to <tt>Manifest</tt>.
|
120
|
+
* <tt>need_gem</tt> - Whether to generate a gem package. Defaults to <tt>true</tt>.
|
121
|
+
* <tt>need_tar_gz</tt> - Whether to generate a <tt>.tar.gz</tt> package. Defaults to <tt>true</tt>.
|
122
|
+
* <tt>need_tgz</tt> - Whether to generate a <tt>.tgz</tt> package. Defaults to <tt>false</tt>.
|
123
|
+
* <tt>need_zip</tt> - Whether to generate a <tt>.zip</tt> package. Defaults to <tt>false</tt>.
|
124
|
+
* <tt>include_rakefile</tt> - Include the Rakefile directly within the package. Defaults to <tt>true</tt>.
|
125
|
+
* <tt>include_gemspec</tt> - Include the generated gemspec file within the package. Defaults to <tt>true</tt>.
|
126
|
+
* <tt>ruby_version</tt> - Version string for which Ruby to require (for example, <tt>'>= 1.8.4'</tt>.
|
127
|
+
* <tt>eval</tt> - Accepts a proc to be evaluated in the context of the Gem::Specification object. This allows you to set more unusual gemspec options.
|
128
|
+
* <tt>ignore_pattern</tt> - A filename array, glob array, or regex for pathnames that should be ignored when building the manifest.
|
129
|
+
* <tt>executable_pattern</tt> - A filename array, glob array, or regex for files that should be installed as wrapped executables.
|
130
|
+
|
131
|
+
Security options:
|
132
|
+
|
133
|
+
* <tt>private_key</tt> - The path to your gem private key. Defaults to ENV['GEM_PRIVATE_KEY'], if available. This accessor is not published in the resulting gemspec.
|
134
|
+
* <tt>certificate_chain</tt> - An array representing your certificate authorization chain. If no one else has signed your certificate, just set it to your own cert. Defaults to ENV['GEM_CERTIFICATE_CHAIN'], if available. This accessor is not published in the resulting gemspec.
|
135
|
+
* <tt>require_signed</tt> - Force Echoe to refuse to package your gem if it's not properly signed. Default false.
|
136
|
+
|
137
|
+
Publishing options:
|
138
|
+
|
139
|
+
* <tt>project</tt> - The name of the Rubyforge project to upload to. Defaults to the name of the gem.
|
140
|
+
* <tt>docs_host</tt> - A host and filesystem path to publish the documentation to. Defaults to the Rubyforge project.
|
141
|
+
|
142
|
+
Documentation options:
|
143
|
+
|
144
|
+
* <tt>rdoc_pattern</tt> - A filename array, glob array, or regex for filenames that should be passed to RDoc.
|
145
|
+
* <tt>rdoc_template</tt> - A path to an RDoc template. Defaults to the generic template.
|
146
|
+
|
147
|
+
=end
|
148
|
+
|
149
|
+
class Echoe
|
150
|
+
|
151
|
+
# user-configurable
|
152
|
+
attr_accessor :author, :changes, :clean_pattern, :description, :email, :runtime_dependencies, :development_dependencies, :need_tgz, :need_tar_gz, :need_gem, :need_zip, :rdoc_pattern, :project, :summary, :test_pattern, :url, :version, :docs_host, :rdoc_template, :manifest_name, :install_message, :extension_pattern, :private_key, :certificate_chain, :require_signed, :ruby_version, :platform, :ignore_pattern, :executable_pattern, :changelog, :rcov_options, :gemspec_format
|
153
|
+
|
154
|
+
# best left alone
|
155
|
+
attr_accessor :name, :lib_files, :test_files, :bin_files, :spec, :rdoc_options, :rubyforge_name, :has_rdoc, :include_gemspec, :include_rakefile, :gemspec_name, :retain_gemspec, :rakefile_name, :eval, :files, :changelog_patterns, :rubygems_version, :use_sudo, :gem_bin
|
156
|
+
|
157
|
+
# legacy
|
158
|
+
attr_accessor :extra_deps, :rdoc_files, :extensions, :dependencies
|
159
|
+
|
160
|
+
def initialize(name, _version = nil)
|
161
|
+
# Defaults
|
162
|
+
|
163
|
+
self.name = name
|
164
|
+
self.project = name.downcase
|
165
|
+
self.changelog = "CHANGELOG"
|
166
|
+
self.url = ""
|
167
|
+
self.author = ""
|
168
|
+
self.email = ""
|
169
|
+
self.clean_pattern = ["pkg", "doc", 'build/*', '**/coverage', '**/*.o', '**/*.so', '**/*.a', '**/*.log', "{ext,lib}/*.{bundle,so,obj,pdb,lib,def,exp}", "ext/Makefile", "{ext,lib}/**/*.{bundle,so,obj,pdb,lib,def,exp}", "ext/**/Makefile", "pkg", "*.gem", ".config"]
|
170
|
+
self.test_pattern = File.exist?("test/test_all.rb") ? "test/test_all.rb" : ['test/**/test_*.rb', 'test/**/*_test.rb']
|
171
|
+
self.ignore_pattern = /^(pkg|doc)|\.svn|CVS|\.bzr|\.DS|\.git/
|
172
|
+
|
173
|
+
self.changelog_patterns = {
|
174
|
+
:version => [
|
175
|
+
/^\s*v([\d\.]+)(\.|\s|$)/,
|
176
|
+
/\s*\*\s*([\d\.]+)\s*\*\s*$/
|
177
|
+
],
|
178
|
+
:changes => [
|
179
|
+
/^\s*v([\d\.]+\. .*)/,
|
180
|
+
/\*\s*[\d\.]+\s*\*\s*(.*)\*\s*[\d\.]+\s*\*$/m
|
181
|
+
]
|
182
|
+
}
|
183
|
+
|
184
|
+
self.description = ""
|
185
|
+
self.summary = ""
|
186
|
+
self.install_message = nil
|
187
|
+
self.executable_pattern = /^bin\//
|
188
|
+
self.has_rdoc = true
|
189
|
+
self.use_sudo = !Platform.windows?
|
190
|
+
self.gem_bin = "gem#{Platform.suffix}"
|
191
|
+
self.rcov_options = []
|
192
|
+
self.rdoc_pattern = /^(lib|bin|tasks|ext)|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/
|
193
|
+
|
194
|
+
self.gemspec_format = :ruby
|
195
|
+
|
196
|
+
title = (name.downcase == name ? name.capitalize : name)
|
197
|
+
self.rdoc_options = ['--line-numbers', '--inline-source', '--title', title]
|
198
|
+
|
199
|
+
readme = Dir['*'].detect { |filename| filename =~ /^readme/i }
|
200
|
+
self.rdoc_options += ['--main', readme] if readme
|
201
|
+
|
202
|
+
self.runtime_dependencies = []
|
203
|
+
self.development_dependencies = [] # These appear to not work at all
|
204
|
+
self.manifest_name = "Manifest"
|
205
|
+
self.extension_pattern = ["ext/**/extconf.rb", "ext/extconf.rb"]
|
206
|
+
self.private_key = ENV['GEM_PRIVATE_KEY']
|
207
|
+
self.require_signed = false
|
208
|
+
self.certificate_chain = ENV['GEM_CERTIFICATE_CHAIN'].to_s.split(/\,\s*/).compact
|
209
|
+
|
210
|
+
self.need_gem = true
|
211
|
+
self.need_tar_gz = true
|
212
|
+
self.need_tgz = false
|
213
|
+
self.need_zip = false
|
214
|
+
self.platform = $platform
|
215
|
+
|
216
|
+
self.include_rakefile = true
|
217
|
+
self.include_gemspec = true
|
218
|
+
self.gemspec_name = "#{name}.gemspec"
|
219
|
+
self.retain_gemspec = false
|
220
|
+
self.rakefile_name = "Rakefile"
|
221
|
+
self.rubygems_version = ">= 1.2"
|
222
|
+
|
223
|
+
yield self if block_given?
|
224
|
+
|
225
|
+
# legacy compatibility
|
226
|
+
self.runtime_dependencies = dependencies if dependencies and runtime_dependencies.empty?
|
227
|
+
self.runtime_dependencies = extra_deps if extra_deps and runtime_dependencies.empty?
|
228
|
+
self.project = rubyforge_name if rubyforge_name
|
229
|
+
self.rdoc_pattern = rdoc_files if rdoc_files
|
230
|
+
self.extension_pattern = extensions if extensions
|
231
|
+
|
232
|
+
# read manifest
|
233
|
+
begin
|
234
|
+
self.files = File.read(manifest_name).split +
|
235
|
+
[(gemspec_name if include_gemspec)] +
|
236
|
+
[(rakefile_name if include_rakefile)]
|
237
|
+
self.files = files.compact.uniq
|
238
|
+
rescue Errno::ENOENT
|
239
|
+
unless ARGV.include? "manifest"
|
240
|
+
puts "Missing manifest. You can build one with 'rake manifest'."
|
241
|
+
exit 1
|
242
|
+
else
|
243
|
+
self.files = []
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
# snag version and changeset
|
248
|
+
self.version ||= _version
|
249
|
+
unless version
|
250
|
+
if File.exist? changelog
|
251
|
+
parsed = Array(changelog_patterns[:version]).map do |pattern|
|
252
|
+
open(changelog) do |log|
|
253
|
+
log.read[pattern, 1]
|
254
|
+
end
|
255
|
+
end.compact.first
|
256
|
+
raise "Could not parse version from #{changelog}" unless parsed
|
257
|
+
self.version = parsed.chomp(".").strip
|
258
|
+
else
|
259
|
+
raise "No #{changelog} found, and no version supplied in Rakefile."
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
self.changes = if File.exist? changelog
|
264
|
+
Array(changelog_patterns[:changes]).map do |pattern|
|
265
|
+
open(changelog) do |log|
|
266
|
+
log.read[pattern, 1]
|
267
|
+
end
|
268
|
+
end.compact.first or ""
|
269
|
+
else
|
270
|
+
""
|
271
|
+
end
|
272
|
+
|
273
|
+
# set some post-defaults
|
274
|
+
self.certificate_chain = Array(certificate_chain).map {|file| File.expand_path(file)}
|
275
|
+
self.private_key = File.expand_path(private_key) if private_key
|
276
|
+
self.description = summary if description.empty?
|
277
|
+
self.summary = description if summary.empty?
|
278
|
+
self.clean_pattern = apply_pattern(clean_pattern)
|
279
|
+
self.extension_pattern = apply_pattern(extension_pattern, files)
|
280
|
+
self.ignore_pattern = apply_pattern(ignore_pattern)
|
281
|
+
self.rdoc_pattern = apply_pattern(rdoc_pattern, files) - [manifest_name]
|
282
|
+
self.executable_pattern = apply_pattern(executable_pattern, files)
|
283
|
+
self.test_pattern = apply_pattern(test_pattern)
|
284
|
+
|
285
|
+
define_tasks
|
286
|
+
end
|
287
|
+
|
288
|
+
def apply_pattern(pattern, files = nil)
|
289
|
+
files ||= Dir['**/**']
|
290
|
+
case pattern
|
291
|
+
when String, Array
|
292
|
+
files & (Array(pattern).map do |p|
|
293
|
+
Dir.glob(p)
|
294
|
+
end.flatten)
|
295
|
+
when Regexp
|
296
|
+
files.select do |file|
|
297
|
+
file =~ pattern
|
298
|
+
end
|
299
|
+
when FileList
|
300
|
+
pattern.each do |ignorefile|
|
301
|
+
ignorefiles = File.open(ignorefile).to_a.map(&:chomp)
|
302
|
+
files = files.select do |file|
|
303
|
+
ignorefiles.map { |i| File.fnmatch(i, file) }.include?(true)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
files
|
307
|
+
else
|
308
|
+
[]
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
def define_tasks
|
313
|
+
|
314
|
+
### Packaging and Installing
|
315
|
+
|
316
|
+
self.spec = Gem::Specification.new do |s|
|
317
|
+
s.name = name
|
318
|
+
s.version = version
|
319
|
+
# s.specification_version = 3
|
320
|
+
s.summary = summary
|
321
|
+
s.author = Array(author).join(", ")
|
322
|
+
s.email = email
|
323
|
+
s.homepage = url
|
324
|
+
s.rubyforge_project = project
|
325
|
+
s.post_install_message = install_message if install_message
|
326
|
+
s.description = description
|
327
|
+
s.required_ruby_version = ruby_version
|
328
|
+
s.required_rubygems_version = rubygems_version if rubygems_version
|
329
|
+
s.platform = platform
|
330
|
+
s.rdoc_options = rdoc_options
|
331
|
+
s.extra_rdoc_files = rdoc_pattern
|
332
|
+
|
333
|
+
if private_key and File.exist? private_key
|
334
|
+
s.signing_key = private_key
|
335
|
+
s.cert_chain = certificate_chain
|
336
|
+
end
|
337
|
+
|
338
|
+
runtime_dependencies.each do |dep|
|
339
|
+
dep = dep.split(" ") if dep.is_a? String
|
340
|
+
s.add_runtime_dependency(*dep)
|
341
|
+
end
|
342
|
+
|
343
|
+
development_dependencies.each do |dep|
|
344
|
+
dep = dep.split(" ") if dep.is_a? String
|
345
|
+
s.add_development_dependency(*dep)
|
346
|
+
end
|
347
|
+
|
348
|
+
s.files = files
|
349
|
+
|
350
|
+
s.bindir = if executable_pattern.any?
|
351
|
+
executable_pattern[0].split("/")[0]
|
352
|
+
else
|
353
|
+
"bin"
|
354
|
+
end
|
355
|
+
|
356
|
+
s.executables = executable_pattern.map do |file|
|
357
|
+
file[(s.bindir.length + 1)..-1]
|
358
|
+
end
|
359
|
+
|
360
|
+
dirs = Dir['{lib,ext}']
|
361
|
+
s.extensions = extension_pattern if extension_pattern.any?
|
362
|
+
s.require_paths = dirs unless dirs.empty?
|
363
|
+
s.has_rdoc = has_rdoc
|
364
|
+
|
365
|
+
if File.exist? "test/test_all.rb"
|
366
|
+
s.test_file = "test/test_all.rb"
|
367
|
+
else
|
368
|
+
s.test_files = test_pattern
|
369
|
+
end
|
370
|
+
|
371
|
+
if eval
|
372
|
+
s.instance_eval &eval
|
373
|
+
end
|
374
|
+
|
375
|
+
end
|
376
|
+
|
377
|
+
self.lib_files = spec.files.grep(/^lib/)
|
378
|
+
self.bin_files = spec.files.grep(/^bin/)
|
379
|
+
self.test_files = spec.files.grep(/^test/)
|
380
|
+
|
381
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
382
|
+
pkg.need_tar = @need_tgz
|
383
|
+
pkg.need_tar_gz = @need_tar_gz
|
384
|
+
pkg.need_zip = @need_zip
|
385
|
+
end
|
386
|
+
|
387
|
+
desc "Display Echoe's knowledge of your system"
|
388
|
+
task :details do
|
389
|
+
(self.instance_variables.sort - ['@spec']).each do |var|
|
390
|
+
puts "#{var}: #{instance_variable_get(var).inspect}"
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
task :build_gemspec do
|
395
|
+
# Construct the gemspec file, if needed.
|
396
|
+
if include_gemspec
|
397
|
+
File.open(gemspec_name, 'w') do |f|
|
398
|
+
case gemspec_format
|
399
|
+
when :yaml
|
400
|
+
spec.to_yaml.split("\n").each do |line|
|
401
|
+
# Don't publish any information about the private key or certificate chain
|
402
|
+
f.puts line unless line =~ /signing_key|cert_chain|\.pem/
|
403
|
+
end
|
404
|
+
when :ruby
|
405
|
+
f.puts spec.to_ruby
|
406
|
+
else
|
407
|
+
raise "Unknown gemspec format #{gemspec_format.inspect}. Supported formats: :ruby and :yaml"
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
# Chain it to the gemspec task prerequisite
|
414
|
+
task gemspec_name.to_sym => [:build_gemspec]
|
415
|
+
|
416
|
+
task :package do
|
417
|
+
# Chain some cleanup tasks to the default :package task.
|
418
|
+
# Remove the gemfile if it wasn't actually requested.
|
419
|
+
unless @need_gem
|
420
|
+
puts " Gem file not requested. Removed."
|
421
|
+
system "rm pkg/*.gem"
|
422
|
+
end
|
423
|
+
# Remove the generated gemspec once the packaging is done, to discourage people from modifying it by hand.
|
424
|
+
if include_gemspec and File.exist? gemspec_name and not retain_gemspec
|
425
|
+
File.delete gemspec_name
|
426
|
+
end
|
427
|
+
|
428
|
+
# Test signing status
|
429
|
+
if private_key and File.exist? private_key
|
430
|
+
puts "Signing gem."
|
431
|
+
else
|
432
|
+
raise "Key required, but not found. Maybe you forget to set ENV['GEM_PRIVATE_KEY']?" if require_signed
|
433
|
+
puts "Private key not found; gem will not be signed."
|
434
|
+
end
|
435
|
+
puts "Targeting \"#{platform}\" platform."
|
436
|
+
end
|
437
|
+
|
438
|
+
desc 'Install the gem'
|
439
|
+
task :install => [:clean, :package, :uninstall] do
|
440
|
+
system "#{'sudo' if use_sudo} #{gem_bin} install pkg/*.gem -P MediumSecurity --no-update-sources"
|
441
|
+
end
|
442
|
+
|
443
|
+
namespace :install do
|
444
|
+
desc 'Install the gem including development dependencies'
|
445
|
+
task :development => [:clean, :package, :uninstall] do
|
446
|
+
system "#{'sudo' if use_sudo} #{gem_bin} install pkg/*.gem -P MediumSecurity --no-update-sources --development"
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
desc 'Uninstall the gem'
|
451
|
+
task :uninstall do
|
452
|
+
system "#{'sudo' if use_sudo} #{gem_bin} uninstall #{name} -a -I -x"
|
453
|
+
end
|
454
|
+
|
455
|
+
desc 'Package and upload the release to Rubyforge'
|
456
|
+
task :release => [:clean, :package] do |t|
|
457
|
+
|
458
|
+
say "\n"
|
459
|
+
if agree "Release #{name}-#{version} to Rubyforge? "
|
460
|
+
pkg = "pkg/#{name}-#{version}"
|
461
|
+
pkg_gem = pkg + ".gem"
|
462
|
+
pkg_tar = pkg + ".tgz"
|
463
|
+
pkg_tar_gz = pkg + ".tar.gz"
|
464
|
+
pkg_zip = pkg + ".zip"
|
465
|
+
|
466
|
+
rf = RubyForge.new.configure
|
467
|
+
puts "Logging in"
|
468
|
+
rf.login
|
469
|
+
|
470
|
+
c = rf.userconfig
|
471
|
+
c["release_notes"] = description if description
|
472
|
+
c["release_changes"] = changes if changes
|
473
|
+
c["preformatted"] = false
|
474
|
+
|
475
|
+
files = [(@need_tgz ? pkg_tar : nil),
|
476
|
+
(@need_tar_gz ? pkg_tar_gz : nil),
|
477
|
+
(@need_zip ? pkg_zip : nil),
|
478
|
+
(@need_gem ? pkg_gem : nil)].compact
|
479
|
+
|
480
|
+
puts "Releasing #{name} v. #{version}"
|
481
|
+
self.version = self.version.to_s.ljust(3)
|
482
|
+
|
483
|
+
rf.add_release project, name, version, *files
|
484
|
+
end
|
485
|
+
|
486
|
+
end
|
487
|
+
|
488
|
+
### Extension building
|
489
|
+
|
490
|
+
task :lib do
|
491
|
+
directory "lib"
|
492
|
+
end
|
493
|
+
|
494
|
+
if extension_pattern.any?
|
495
|
+
|
496
|
+
desc "Compile the binary extension module"
|
497
|
+
task :compile => [:lib] do
|
498
|
+
extension_pattern.each do |extension|
|
499
|
+
ext_dir = File.dirname(extension)
|
500
|
+
lib_target = nil
|
501
|
+
Dir.chdir(ext_dir) do
|
502
|
+
ruby File.basename(extension)
|
503
|
+
system(RUBY_PLATFORM =~ /win32/ ? 'nmake' : 'make')
|
504
|
+
lib_target = open('Makefile').readlines.grep(/target_prefix = /).first.split('=').last.chomp("\n").strip
|
505
|
+
end
|
506
|
+
Dir["#{ext_dir}/*.#{Config::CONFIG['DLEXT']}"].each do |file|
|
507
|
+
dir = "lib/#{lib_target}/".gsub('//', '/')
|
508
|
+
mkdir_p dir
|
509
|
+
cp file, dir
|
510
|
+
end
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
514
|
+
task :test => [:compile]
|
515
|
+
|
516
|
+
end
|
517
|
+
|
518
|
+
### Cross-platform targets
|
519
|
+
|
520
|
+
Gem::Specification::PLATFORM_CROSS_TARGETS.each do |target|
|
521
|
+
task target do
|
522
|
+
reset_target target
|
523
|
+
end
|
524
|
+
end
|
525
|
+
|
526
|
+
### Documentation
|
527
|
+
|
528
|
+
Rake::RDocTask.new(:docs) do |rd|
|
529
|
+
# rd.main = Dir['*'].detect {|f| f =~ /^readme/i}
|
530
|
+
rd.options += Array(rdoc_options)
|
531
|
+
|
532
|
+
rd.rdoc_dir = 'doc'
|
533
|
+
rd.rdoc_files.push(*rdoc_pattern)
|
534
|
+
|
535
|
+
if rdoc_template
|
536
|
+
rd.template = rdoc_template
|
537
|
+
elsif ENV['RDOC_TEMPLATE']
|
538
|
+
rd.template = ENV['RDOC_TEMPLATE']
|
539
|
+
end
|
540
|
+
end
|
541
|
+
|
542
|
+
task :doc => [:redocs]
|
543
|
+
|
544
|
+
desc "Publish documentation to #{docs_host ? "'#{docs_host}'" : "rubyforge"}"
|
545
|
+
task :publish_docs => [:clean, :docs] do
|
546
|
+
|
547
|
+
local_dir = 'doc'
|
548
|
+
remote_dir_name = project
|
549
|
+
remote_dir_name += "/#{name}" if project != name
|
550
|
+
|
551
|
+
unless docs_host
|
552
|
+
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
|
553
|
+
pub = Rake::SshDirPublisher.new "#{config["username"]}@rubyforge.org",
|
554
|
+
"/var/www/gforge-projects/#{remote_dir_name}",
|
555
|
+
local_dir
|
556
|
+
if project != name then
|
557
|
+
def pub.upload
|
558
|
+
begin
|
559
|
+
super
|
560
|
+
rescue
|
561
|
+
# project directory probably doesn't exist, transfer as a whole
|
562
|
+
cmd = "scp -qr #{local_dir} #{host}:#{remote_dir}"
|
563
|
+
puts "Uploading: #{cmd}"
|
564
|
+
system(cmd)
|
565
|
+
end
|
566
|
+
end
|
567
|
+
end
|
568
|
+
pub.upload
|
569
|
+
else
|
570
|
+
# you may need ssh keys configured for this to work
|
571
|
+
host, dir = docs_host.split(":")
|
572
|
+
dir.chomp!("/")
|
573
|
+
|
574
|
+
# XXX too dangerous?
|
575
|
+
cmd = "ssh #{host} 'rm -rf #{dir}/#{remote_dir_name}'"
|
576
|
+
puts "Deleting existing docs: #{cmd}"
|
577
|
+
system(cmd)
|
578
|
+
|
579
|
+
cmd = "scp -qr #{local_dir} #{host}:#{dir}/#{remote_dir_name}"
|
580
|
+
puts "Uploading: #{cmd}"
|
581
|
+
system(cmd)
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
585
|
+
desc 'Generate a release announcement, edit it, and post it to Rubyforge.'
|
586
|
+
task :announce do
|
587
|
+
|
588
|
+
filename = "/tmp/#{name}_#{version}_announcement.txt"
|
589
|
+
|
590
|
+
if !File.exist?(filename) or agree "Overwrite existing announcement file? "
|
591
|
+
File.open(filename, 'w') do |f|
|
592
|
+
f.write "Subject: #{name.capitalize} #{version}\n\n"
|
593
|
+
f.write "#{name.capitalize} has been updated to #{version}. #{name.capitalize} is #{summary.uncapitalize}\n\n"
|
594
|
+
f.write "Changes in this version: #{changes.sub(/^\s*[\w\d\.]+\s+/, '').uncapitalize}\n\n" unless changes.empty?
|
595
|
+
f.write "More information is available at #{url} .\n\n" unless url.empty?
|
596
|
+
end
|
597
|
+
end
|
598
|
+
|
599
|
+
begin
|
600
|
+
editor = ENV['EDITOR'] || 'nano'
|
601
|
+
system("#{editor} #{filename}") or raise "Editor '#{editor}' failed to start"
|
602
|
+
puts File.open(filename).read
|
603
|
+
end while !agree "Done editing? "
|
604
|
+
|
605
|
+
if agree "Publish announcement to Rubyforge? "
|
606
|
+
File.open(filename).readlines.detect { |line| line =~ /Subject: (.*)/ }
|
607
|
+
subject = $1 or raise "Subject line seems to have disappeared"
|
608
|
+
|
609
|
+
body = File.open(filename).readlines.reject { |line| line =~ /Subject: / }.join.gsub("\n\n\n", "\n\n")
|
610
|
+
|
611
|
+
rf = RubyForge.new.configure
|
612
|
+
rf.login
|
613
|
+
rf.post_news(project, subject, body)
|
614
|
+
puts "Published."
|
615
|
+
File.delete filename
|
616
|
+
end
|
617
|
+
end
|
618
|
+
|
619
|
+
### Clean
|
620
|
+
|
621
|
+
desc 'Clean up auto-generated files'
|
622
|
+
task :clean do
|
623
|
+
puts "Cleaning"
|
624
|
+
clean_pattern.each do |file|
|
625
|
+
if File.exist?(file)
|
626
|
+
puts "- #{file}"
|
627
|
+
rm_rf file
|
628
|
+
end
|
629
|
+
end
|
630
|
+
end
|
631
|
+
|
632
|
+
### Manifest
|
633
|
+
|
634
|
+
desc "Build a Manifest list"
|
635
|
+
task :manifest => [:clean] do
|
636
|
+
puts "Building Manifest"
|
637
|
+
old_files = files
|
638
|
+
files = []
|
639
|
+
Dir['**/**'].each do |file|
|
640
|
+
next unless file
|
641
|
+
next if ignore_pattern.include?(file)
|
642
|
+
next if File.directory?(file)
|
643
|
+
next if !include_rakefile and file == rakefile_name
|
644
|
+
files << file
|
645
|
+
end
|
646
|
+
|
647
|
+
files << rakefile_name if include_rakefile
|
648
|
+
files << manifest_name
|
649
|
+
files.uniq!
|
650
|
+
|
651
|
+
File.open(manifest_name, 'w').puts(files)
|
652
|
+
|
653
|
+
(files | old_files).sort.each do |file|
|
654
|
+
next if file == gemspec_name
|
655
|
+
sign = " "
|
656
|
+
if old_files.include?(file) and !files.include?(file)
|
657
|
+
sign = "-"
|
658
|
+
elsif files.include?(file) and !old_files.include?(file)
|
659
|
+
sign = "+"
|
660
|
+
end
|
661
|
+
puts "#{sign} #{file}"
|
662
|
+
end
|
663
|
+
end
|
664
|
+
|
665
|
+
task :build_manifest => :manifest
|
666
|
+
|
667
|
+
### Testing
|
668
|
+
|
669
|
+
if test_pattern.any?
|
670
|
+
|
671
|
+
Rake::TestTask.new(:test_inner) do |t|
|
672
|
+
t.libs = ['lib', 'ext', 'bin', 'test']
|
673
|
+
t.test_files = test_pattern
|
674
|
+
t.verbose = true
|
675
|
+
end
|
676
|
+
|
677
|
+
desc "Run the test suite"
|
678
|
+
task :test do
|
679
|
+
if File.exist? 'test/setup.rb'
|
680
|
+
Echoe.silence do
|
681
|
+
puts "Setting up test environment"
|
682
|
+
system("ruby test/setup.rb")
|
683
|
+
end
|
684
|
+
end
|
685
|
+
begin
|
686
|
+
test = Rake::Task[:test_inner]
|
687
|
+
if test.respond_to? :already_invoked=
|
688
|
+
# Method provided by MultiRails
|
689
|
+
test.already_invoked = false
|
690
|
+
end
|
691
|
+
test.invoke
|
692
|
+
ensure
|
693
|
+
if File.exist? 'test/teardown.rb'
|
694
|
+
Echoe.silence do
|
695
|
+
puts "Tearing down test environment"
|
696
|
+
system("ruby test/teardown.rb")
|
697
|
+
end
|
698
|
+
end
|
699
|
+
end
|
700
|
+
end
|
701
|
+
|
702
|
+
end
|
703
|
+
|
704
|
+
task :default => :test
|
705
|
+
|
706
|
+
if defined? Rcov
|
707
|
+
Rcov::RcovTask.new(:coverage) do |t|
|
708
|
+
t.test_files = test_pattern
|
709
|
+
t.rcov_opts << rcov_options if rcov_options
|
710
|
+
t.verbose = true
|
711
|
+
end
|
712
|
+
task :rcov => :coverage
|
713
|
+
end
|
714
|
+
|
715
|
+
end
|
716
|
+
end
|
717
|
+
|