gohanlonllc-jeweler 0.11.1.20090513153819
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/ChangeLog.markdown +83 -0
- data/LICENSE +20 -0
- data/README.markdown +170 -0
- data/ROADMAP +12 -0
- data/Rakefile +106 -0
- data/VERSION.yml +5 -0
- data/bin/jeweler +8 -0
- data/features/generator/cucumber.feature +83 -0
- data/features/generator/directory_layout.feature +76 -0
- data/features/generator/dotdocument.feature +14 -0
- data/features/generator/env_options.feature +9 -0
- data/features/generator/git.feature +94 -0
- data/features/generator/license.feature +11 -0
- data/features/generator/rakefile.feature +110 -0
- data/features/generator/readme.feature +12 -0
- data/features/generator/test.feature +41 -0
- data/features/generator/test_helper.feature +49 -0
- data/features/placeholder.feature +5 -0
- data/features/step_definitions/debug_steps.rb +6 -0
- data/features/step_definitions/filesystem_steps.rb +65 -0
- data/features/step_definitions/generator_steps.rb +251 -0
- data/features/step_definitions/task_steps.rb +6 -0
- data/features/support/env.rb +19 -0
- data/features/tasks/build_gem.feature +9 -0
- data/features/tasks/version.feature +24 -0
- data/features/tasks/version_bumping.feature +33 -0
- data/jeweler.gemspec +205 -0
- data/lib/jeweler/commands/build_gem.rb +31 -0
- data/lib/jeweler/commands/install_gem.rb +26 -0
- data/lib/jeweler/commands/release.rb +83 -0
- data/lib/jeweler/commands/release_to_rubyforge.rb +51 -0
- data/lib/jeweler/commands/setup_rubyforge.rb +38 -0
- data/lib/jeweler/commands/validate_gemspec.rb +30 -0
- data/lib/jeweler/commands/version/base.rb +41 -0
- data/lib/jeweler/commands/version/bump_major.rb +13 -0
- data/lib/jeweler/commands/version/bump_minor.rb +12 -0
- data/lib/jeweler/commands/version/bump_patch.rb +14 -0
- data/lib/jeweler/commands/version/bump_timestamp.rb +14 -0
- data/lib/jeweler/commands/version/write.rb +12 -0
- data/lib/jeweler/commands/write_gemspec.rb +39 -0
- data/lib/jeweler/commands.rb +13 -0
- data/lib/jeweler/errors.rb +20 -0
- data/lib/jeweler/gemspec_helper.rb +76 -0
- data/lib/jeweler/generator/application.rb +54 -0
- data/lib/jeweler/generator/bacon_mixin.rb +39 -0
- data/lib/jeweler/generator/micronaut_mixin.rb +38 -0
- data/lib/jeweler/generator/minitest_mixin.rb +39 -0
- data/lib/jeweler/generator/options.rb +77 -0
- data/lib/jeweler/generator/rspec_mixin.rb +39 -0
- data/lib/jeweler/generator/shoulda_mixin.rb +39 -0
- data/lib/jeweler/generator/testunit_mixin.rb +39 -0
- data/lib/jeweler/generator.rb +284 -0
- data/lib/jeweler/rubyforge_tasks.rb +46 -0
- data/lib/jeweler/specification.rb +65 -0
- data/lib/jeweler/tasks.rb +131 -0
- data/lib/jeweler/templates/.document +5 -0
- data/lib/jeweler/templates/.gitignore +5 -0
- data/lib/jeweler/templates/LICENSE +20 -0
- data/lib/jeweler/templates/README.rdoc +7 -0
- data/lib/jeweler/templates/Rakefile +102 -0
- data/lib/jeweler/templates/bacon/flunking.rb +7 -0
- data/lib/jeweler/templates/bacon/helper.rb +8 -0
- data/lib/jeweler/templates/features/default.feature +9 -0
- data/lib/jeweler/templates/features/support/env.rb +8 -0
- data/lib/jeweler/templates/micronaut/flunking.rb +7 -0
- data/lib/jeweler/templates/micronaut/helper.rb +17 -0
- data/lib/jeweler/templates/minitest/flunking.rb +7 -0
- data/lib/jeweler/templates/minitest/helper.rb +11 -0
- data/lib/jeweler/templates/rspec/flunking.rb +7 -0
- data/lib/jeweler/templates/rspec/helper.rb +9 -0
- data/lib/jeweler/templates/shoulda/flunking.rb +7 -0
- data/lib/jeweler/templates/shoulda/helper.rb +10 -0
- data/lib/jeweler/templates/testunit/flunking.rb +7 -0
- data/lib/jeweler/templates/testunit/helper.rb +9 -0
- data/lib/jeweler/version_helper.rb +140 -0
- data/lib/jeweler.rb +155 -0
- data/test/fixtures/bar/VERSION.yml +4 -0
- data/test/fixtures/bar/bin/foo_the_ultimate_bin +1 -0
- data/test/fixtures/bar/hey_include_me_in_gemspec +0 -0
- data/test/fixtures/bar/lib/foo_the_ultimate_lib.rb +1 -0
- data/test/fixtures/existing-project-with-version-plaintext/.document +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/LICENSE +20 -0
- data/test/fixtures/existing-project-with-version-plaintext/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/Rakefile +82 -0
- data/test/fixtures/existing-project-with-version-plaintext/VERSION +1 -0
- data/test/fixtures/existing-project-with-version-plaintext/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-plaintext/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-plaintext/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/test/test_helper.rb +10 -0
- data/test/fixtures/existing-project-with-version-yaml/.document +5 -0
- data/test/fixtures/existing-project-with-version-yaml/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-yaml/LICENSE +20 -0
- data/test/fixtures/existing-project-with-version-yaml/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-yaml/Rakefile +82 -0
- data/test/fixtures/existing-project-with-version-yaml/VERSION.yml +4 -0
- data/test/fixtures/existing-project-with-version-yaml/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-yaml/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-yaml/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-yaml/test/test_helper.rb +10 -0
- data/test/geminstaller.yml +12 -0
- data/test/jeweler/commands/test_build_gem.rb +72 -0
- data/test/jeweler/commands/test_install_gem.rb +21 -0
- data/test/jeweler/commands/test_release.rb +405 -0
- data/test/jeweler/commands/test_release_to_rubyforge.rb +157 -0
- data/test/jeweler/commands/test_setup_rubyforge.rb +88 -0
- data/test/jeweler/commands/test_validate_gemspec.rb +27 -0
- data/test/jeweler/commands/test_write_gemspec.rb +92 -0
- data/test/jeweler/commands/version/test_base.rb +32 -0
- data/test/jeweler/commands/version/test_bump_major.rb +22 -0
- data/test/jeweler/commands/version/test_bump_minor.rb +19 -0
- data/test/jeweler/commands/version/test_bump_patch.rb +20 -0
- data/test/jeweler/commands/version/test_write.rb +23 -0
- data/test/shoulda_macros/jeweler_macros.rb +35 -0
- data/test/test_application.rb +139 -0
- data/test/test_gemspec_helper.rb +40 -0
- data/test/test_generator.rb +154 -0
- data/test/test_generator_initialization.rb +113 -0
- data/test/test_generator_mixins.rb +18 -0
- data/test/test_helper.rb +133 -0
- data/test/test_jeweler.rb +174 -0
- data/test/test_options.rb +116 -0
- data/test/test_specification.rb +61 -0
- data/test/test_tasks.rb +51 -0
- data/test/test_version_helper.rb +153 -0
- metadata +229 -0
@@ -0,0 +1,284 @@
|
|
1
|
+
require 'git'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
require 'net/http'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
require 'jeweler/generator/bacon_mixin'
|
8
|
+
require 'jeweler/generator/micronaut_mixin'
|
9
|
+
require 'jeweler/generator/minitest_mixin'
|
10
|
+
require 'jeweler/generator/rspec_mixin'
|
11
|
+
require 'jeweler/generator/shoulda_mixin'
|
12
|
+
require 'jeweler/generator/testunit_mixin'
|
13
|
+
|
14
|
+
class Jeweler
|
15
|
+
class NoGitUserName < StandardError
|
16
|
+
end
|
17
|
+
class NoGitUserEmail < StandardError
|
18
|
+
end
|
19
|
+
class FileInTheWay < StandardError
|
20
|
+
end
|
21
|
+
class NoGitHubRepoNameGiven < StandardError
|
22
|
+
end
|
23
|
+
class NoGitHubUser < StandardError
|
24
|
+
end
|
25
|
+
class NoGitHubToken < StandardError
|
26
|
+
end
|
27
|
+
class GitInitFailed < StandardError
|
28
|
+
end
|
29
|
+
|
30
|
+
class Generator
|
31
|
+
attr_accessor :target_dir, :user_name, :user_email, :summary, :testing_framework,
|
32
|
+
:project_name, :github_username, :github_token,
|
33
|
+
:repo, :should_create_repo, :should_use_cucumber, :should_setup_rubyforge
|
34
|
+
|
35
|
+
DEFAULT_TESTING_FRAMEWORK = :shoulda
|
36
|
+
|
37
|
+
def initialize(project_name, options = {})
|
38
|
+
if project_name.nil? || project_name.squeeze.strip == ""
|
39
|
+
raise NoGitHubRepoNameGiven
|
40
|
+
end
|
41
|
+
|
42
|
+
self.project_name = project_name
|
43
|
+
|
44
|
+
self.testing_framework = (options[:testing_framework] || DEFAULT_TESTING_FRAMEWORK).to_sym
|
45
|
+
begin
|
46
|
+
generator_mixin_name = "#{self.testing_framework.to_s.capitalize}Mixin"
|
47
|
+
generator_mixin = self.class.const_get(generator_mixin_name)
|
48
|
+
extend generator_mixin
|
49
|
+
rescue NameError => e
|
50
|
+
raise ArgumentError, "Unsupported testing framework (#{testing_framework})"
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
self.target_dir = options[:directory] || self.project_name
|
55
|
+
|
56
|
+
self.should_create_repo = options[:create_repo]
|
57
|
+
self.summary = options[:summary] || 'TODO'
|
58
|
+
self.should_use_cucumber = options[:use_cucumber]
|
59
|
+
self.should_setup_rubyforge = options[:rubyforge]
|
60
|
+
|
61
|
+
use_user_git_config
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
def run
|
66
|
+
create_files
|
67
|
+
gitify
|
68
|
+
$stdout.puts "Jeweler has prepared your gem in #{target_dir}"
|
69
|
+
if should_create_repo
|
70
|
+
create_and_push_repo
|
71
|
+
$stdout.puts "Jeweler has pushed your repo to #{project_homepage}"
|
72
|
+
enable_gem_for_repo
|
73
|
+
$stdout.puts "Jeweler has enabled gem building for your repo"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def git_remote
|
78
|
+
"git@github.com:#{github_username}/#{project_name}.git"
|
79
|
+
end
|
80
|
+
|
81
|
+
def project_homepage
|
82
|
+
"http://github.com/#{github_username}/#{project_name}"
|
83
|
+
end
|
84
|
+
|
85
|
+
def constant_name
|
86
|
+
self.project_name.split(/[-_]/).collect{|each| each.capitalize }.join
|
87
|
+
end
|
88
|
+
|
89
|
+
def lib_filename
|
90
|
+
"#{project_name}.rb"
|
91
|
+
end
|
92
|
+
|
93
|
+
def require_name
|
94
|
+
self.project_name
|
95
|
+
end
|
96
|
+
|
97
|
+
def file_name_prefix
|
98
|
+
self.project_name.gsub('-', '_')
|
99
|
+
end
|
100
|
+
|
101
|
+
def lib_dir
|
102
|
+
'lib'
|
103
|
+
end
|
104
|
+
|
105
|
+
def feature_filename
|
106
|
+
"#{project_name}.feature"
|
107
|
+
end
|
108
|
+
|
109
|
+
def steps_filename
|
110
|
+
"#{project_name}_steps.rb"
|
111
|
+
end
|
112
|
+
|
113
|
+
def features_dir
|
114
|
+
'features'
|
115
|
+
end
|
116
|
+
|
117
|
+
def features_support_dir
|
118
|
+
File.join(features_dir, 'support')
|
119
|
+
end
|
120
|
+
|
121
|
+
def features_steps_dir
|
122
|
+
File.join(features_dir, 'step_definitions')
|
123
|
+
end
|
124
|
+
|
125
|
+
protected
|
126
|
+
|
127
|
+
# This is in a separate method so we can stub it out during testing
|
128
|
+
def read_git_config
|
129
|
+
# we could just use Git::Base's .config, but that relies on a repo being around already
|
130
|
+
# ... which we don't have yet, since this is part of a sanity check
|
131
|
+
lib = Git::Lib.new(nil, nil)
|
132
|
+
config = lib.parse_config '~/.gitconfig'
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
136
|
+
def create_files
|
137
|
+
unless File.exists?(target_dir) || File.directory?(target_dir)
|
138
|
+
FileUtils.mkdir target_dir
|
139
|
+
else
|
140
|
+
raise FileInTheWay, "The directory #{target_dir} already exists, aborting. Maybe move it out of the way before continuing?"
|
141
|
+
end
|
142
|
+
|
143
|
+
|
144
|
+
output_template_in_target '.gitignore'
|
145
|
+
output_template_in_target 'Rakefile'
|
146
|
+
output_template_in_target 'LICENSE'
|
147
|
+
output_template_in_target 'README.rdoc'
|
148
|
+
output_template_in_target '.document'
|
149
|
+
|
150
|
+
mkdir_in_target lib_dir
|
151
|
+
touch_in_target File.join(lib_dir, lib_filename)
|
152
|
+
|
153
|
+
mkdir_in_target test_dir
|
154
|
+
output_template_in_target File.join(testing_framework.to_s, 'helper.rb'), File.join(test_dir, test_helper_filename)
|
155
|
+
output_template_in_target File.join(testing_framework.to_s, 'flunking.rb'), File.join(test_dir, test_filename)
|
156
|
+
|
157
|
+
if should_use_cucumber
|
158
|
+
mkdir_in_target features_dir
|
159
|
+
output_template_in_target File.join(%w(features default.feature)), File.join('features', feature_filename)
|
160
|
+
|
161
|
+
mkdir_in_target features_support_dir
|
162
|
+
output_template_in_target File.join(features_support_dir, 'env.rb')
|
163
|
+
|
164
|
+
mkdir_in_target features_steps_dir
|
165
|
+
touch_in_target File.join(features_steps_dir, steps_filename)
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
def use_user_git_config
|
171
|
+
git_config = self.read_git_config
|
172
|
+
|
173
|
+
unless git_config.has_key? 'user.name'
|
174
|
+
raise NoGitUserName
|
175
|
+
end
|
176
|
+
|
177
|
+
unless git_config.has_key? 'user.email'
|
178
|
+
raise NoGitUserEmail
|
179
|
+
end
|
180
|
+
|
181
|
+
unless git_config.has_key? 'github.user'
|
182
|
+
raise NoGitHubUser
|
183
|
+
end
|
184
|
+
|
185
|
+
if should_create_repo
|
186
|
+
unless git_config.has_key? 'github.token'
|
187
|
+
raise NoGitHubToken
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
self.user_name = git_config['user.name']
|
192
|
+
self.user_email = git_config['user.email']
|
193
|
+
self.github_username = git_config['github.user']
|
194
|
+
self.github_token = git_config['github.token']
|
195
|
+
end
|
196
|
+
|
197
|
+
def output_template_in_target(source, destination = source)
|
198
|
+
final_destination = File.join(target_dir, destination)
|
199
|
+
|
200
|
+
template_contents = File.read(File.join(template_dir, source))
|
201
|
+
template = ERB.new(template_contents, nil, '<>')
|
202
|
+
|
203
|
+
template_result = template.result(binding)
|
204
|
+
|
205
|
+
File.open(final_destination, 'w') {|file| file.write(template_result)}
|
206
|
+
|
207
|
+
$stdout.puts "\tcreate\t#{destination}"
|
208
|
+
end
|
209
|
+
|
210
|
+
def template_dir
|
211
|
+
File.join(File.dirname(__FILE__), 'templates')
|
212
|
+
end
|
213
|
+
|
214
|
+
def mkdir_in_target(directory)
|
215
|
+
final_destination = File.join(target_dir, directory)
|
216
|
+
|
217
|
+
FileUtils.mkdir final_destination
|
218
|
+
|
219
|
+
$stdout.puts "\tcreate\t#{directory}"
|
220
|
+
end
|
221
|
+
|
222
|
+
def touch_in_target(destination)
|
223
|
+
final_destination = File.join(target_dir, destination)
|
224
|
+
FileUtils.touch final_destination
|
225
|
+
$stdout.puts "\tcreate\t#{destination}"
|
226
|
+
end
|
227
|
+
|
228
|
+
def gitify
|
229
|
+
saved_pwd = Dir.pwd
|
230
|
+
Dir.chdir(target_dir)
|
231
|
+
begin
|
232
|
+
begin
|
233
|
+
@repo = Git.init()
|
234
|
+
rescue Git::GitExecuteError => e
|
235
|
+
raise GitInitFailed, "Encountered an error during gitification. Maybe the repo already exists, or has already been pushed to?"
|
236
|
+
end
|
237
|
+
|
238
|
+
begin
|
239
|
+
@repo.add('.')
|
240
|
+
rescue Git::GitExecuteError => e
|
241
|
+
#raise GitAddFailed, "There was some problem adding this directory to the git changeset"
|
242
|
+
raise
|
243
|
+
end
|
244
|
+
|
245
|
+
begin
|
246
|
+
@repo.commit "Initial commit to #{project_name}."
|
247
|
+
rescue Git::GitExecuteError => e
|
248
|
+
raise
|
249
|
+
end
|
250
|
+
|
251
|
+
begin
|
252
|
+
@repo.add_remote('origin', git_remote)
|
253
|
+
rescue Git::GitExecuteError => e
|
254
|
+
puts "Encountered an error while adding origin remote. Maybe you have some weird settings in ~/.gitconfig?"
|
255
|
+
raise
|
256
|
+
end
|
257
|
+
ensure
|
258
|
+
Dir.chdir(saved_pwd)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
def create_and_push_repo
|
263
|
+
Net::HTTP.post_form URI.parse('http://github.com/repositories'),
|
264
|
+
'login' => github_username,
|
265
|
+
'token' => github_token,
|
266
|
+
'repository[description]' => summary,
|
267
|
+
'repository[name]' => project_name
|
268
|
+
# TODO do a HEAD request to see when it's ready
|
269
|
+
@repo.push('origin')
|
270
|
+
end
|
271
|
+
|
272
|
+
def enable_gem_for_repo
|
273
|
+
url = "https://github.com/#{github_username}/#{project_name}/update"
|
274
|
+
`curl -F 'login=#{github_username}' -F 'token=#{github_token}' -F 'field=repository_rubygem' -F 'value=1' #{url} 2>/dev/null`
|
275
|
+
# FIXME use NET::HTTP instead of curl
|
276
|
+
#Net::HTTP.post_form URI.parse(url),
|
277
|
+
#'login' => github_username,
|
278
|
+
#'token' => github_token,
|
279
|
+
#'field' => 'repository_rubygem',
|
280
|
+
#'value' => '1'
|
281
|
+
end
|
282
|
+
|
283
|
+
end
|
284
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
require 'rake/contrib/sshpublisher'
|
4
|
+
|
5
|
+
|
6
|
+
class Jeweler
|
7
|
+
class RubyforgeTasks < ::Rake::TaskLib
|
8
|
+
attr_accessor :project, :remote_doc_path
|
9
|
+
attr_accessor :jeweler
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
yield self if block_given?
|
13
|
+
|
14
|
+
self.jeweler = Rake.application.jeweler
|
15
|
+
|
16
|
+
self.remote_doc_path ||= jeweler.gemspec.name
|
17
|
+
self.project ||= jeweler.gemspec.rubyforge_project
|
18
|
+
|
19
|
+
define
|
20
|
+
end
|
21
|
+
|
22
|
+
def define
|
23
|
+
namespace :rubyforge do
|
24
|
+
|
25
|
+
desc "Release gem and RDoc documentation to RubyForge"
|
26
|
+
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
27
|
+
|
28
|
+
namespace :release do
|
29
|
+
desc "Publish RDoc to RubyForge."
|
30
|
+
task :docs => [:rdoc] do
|
31
|
+
config = YAML.load(
|
32
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
33
|
+
)
|
34
|
+
|
35
|
+
host = "#{config['username']}@rubyforge.org"
|
36
|
+
remote_dir = "/var/www/gforge-projects/#{project}/#{remote_doc_path}"
|
37
|
+
local_dir = 'rdoc'
|
38
|
+
|
39
|
+
sh %{rsync -av --delete #{local_dir}/ #{host}:#{remote_dir}}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rubygems/specification'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
# Extend a Gem::Specification instance with this module to give it Jeweler
|
5
|
+
# super-cow powers.
|
6
|
+
module Specification
|
7
|
+
|
8
|
+
def self.filelist_attribute(name)
|
9
|
+
code = %{
|
10
|
+
def #{name}
|
11
|
+
@#{name} ||= FileList[]
|
12
|
+
end
|
13
|
+
def #{name}=(value)
|
14
|
+
@#{name} = FileList[value]
|
15
|
+
end
|
16
|
+
}
|
17
|
+
|
18
|
+
module_eval code, __FILE__, __LINE__ - 9
|
19
|
+
end
|
20
|
+
|
21
|
+
filelist_attribute :files
|
22
|
+
filelist_attribute :test_files
|
23
|
+
filelist_attribute :extra_rdoc_files
|
24
|
+
|
25
|
+
|
26
|
+
# Assigns the Jeweler defaults to the Gem::Specification
|
27
|
+
def set_jeweler_defaults(base_dir)
|
28
|
+
Dir.chdir(base_dir) do
|
29
|
+
if blank?(files) && File.directory?(File.join(base_dir, '.git'))
|
30
|
+
repo = Git.open(base_dir)
|
31
|
+
self.files = repo.ls_files.keys
|
32
|
+
end
|
33
|
+
|
34
|
+
if blank?(test_files)
|
35
|
+
self.test_files = FileList['{spec,test,examples}/**/*.rb']
|
36
|
+
end
|
37
|
+
|
38
|
+
if blank?(executable)
|
39
|
+
self.executables = Dir["bin/*"].map { |f| File.basename(f) }
|
40
|
+
end
|
41
|
+
|
42
|
+
self.has_rdoc = true
|
43
|
+
rdoc_options << '--charset=UTF-8'
|
44
|
+
|
45
|
+
if blank?(extra_rdoc_files)
|
46
|
+
self.extra_rdoc_files = FileList["README*", "ChangeLog*", "LICENSE*"]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Used by Specification#to_ruby to generate a ruby-respresentation of a Gem::Specification
|
52
|
+
def ruby_code(obj)
|
53
|
+
case obj
|
54
|
+
when Rake::FileList then obj.to_a.inspect
|
55
|
+
else super
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def blank?(value)
|
62
|
+
value.nil? || value.empty?
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
class Rake::Application
|
5
|
+
attr_accessor :jeweler
|
6
|
+
end
|
7
|
+
|
8
|
+
class Jeweler
|
9
|
+
class Tasks < ::Rake::TaskLib
|
10
|
+
attr_accessor :gemspec, :jeweler
|
11
|
+
|
12
|
+
def initialize(gemspec = nil, &block)
|
13
|
+
@gemspec = gemspec || Gem::Specification.new
|
14
|
+
@jeweler = Jeweler.new(@gemspec)
|
15
|
+
yield @gemspec if block_given?
|
16
|
+
|
17
|
+
Rake.application.jeweler = @jeweler
|
18
|
+
define
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def define
|
23
|
+
desc "Setup initial version of 0.0.0"
|
24
|
+
task :version_required do
|
25
|
+
unless jeweler.version_exists?
|
26
|
+
abort "Expected VERSION or VERSION.yml to exist. See version:write to create an initial one."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Build gem"
|
31
|
+
task :build do
|
32
|
+
jeweler.build_gem
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Install gem using sudo"
|
36
|
+
task :install => :build do
|
37
|
+
jeweler.install_gem
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Generate and validates gemspec"
|
41
|
+
task :gemspec => ['gemspec:generate', 'gemspec:validate']
|
42
|
+
|
43
|
+
namespace :gemspec do
|
44
|
+
desc "Validates the gemspec"
|
45
|
+
task :validate => :version_required do
|
46
|
+
jeweler.validate_gemspec
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Generates the gemspec, using version from VERSION"
|
50
|
+
task :generate => :version_required do
|
51
|
+
jeweler.write_gemspec
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Displays the current version"
|
56
|
+
task :version => :version_required do
|
57
|
+
$stdout.puts "Current version: #{jeweler.version}"
|
58
|
+
end
|
59
|
+
|
60
|
+
namespace :version do
|
61
|
+
desc "Writes out an explicit version. Respects the following environment variables, or defaults to 0: MAJOR, MINOR, PATCH"
|
62
|
+
task :write do
|
63
|
+
major, minor, patch = ENV['MAJOR'].to_i, ENV['MINOR'].to_i, ENV['PATCH'].to_i
|
64
|
+
jeweler.write_version(major, minor, patch, :announce => false, :commit => false)
|
65
|
+
$stdout.puts "Updated version: #{jeweler.version}"
|
66
|
+
end
|
67
|
+
|
68
|
+
namespace :bump do
|
69
|
+
desc "Bump the gemspec by a major version."
|
70
|
+
task :major => [:version_required, :version] do
|
71
|
+
jeweler.bump_major_version
|
72
|
+
$stdout.puts "Updated version: #{jeweler.version}"
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "Bump the gemspec by a minor version."
|
76
|
+
task :minor => [:version_required, :version] do
|
77
|
+
jeweler.bump_minor_version
|
78
|
+
$stdout.puts "Updated version: #{jeweler.version}"
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Bump the gemspec by a patch version."
|
82
|
+
task :patch => [:version_required, :version] do
|
83
|
+
jeweler.bump_patch_version
|
84
|
+
$stdout.puts "Updated version: #{jeweler.version}"
|
85
|
+
end
|
86
|
+
|
87
|
+
desc "Bump the gemspec by a timestamp."
|
88
|
+
task :timestamp => [:version_required, :version] do
|
89
|
+
jeweler.bump_timestamp_version
|
90
|
+
$stdout.puts "Updated version: #{jeweler.version}"
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
desc "Release the current version. Includes updating the gemspec, pushing, and tagging the release"
|
97
|
+
task :release do
|
98
|
+
jeweler.release
|
99
|
+
end
|
100
|
+
|
101
|
+
namespace :rubyforge do
|
102
|
+
namespace :release do
|
103
|
+
desc "Release the current gem version to RubyForge."
|
104
|
+
task :gem => [:gemspec, :build] do
|
105
|
+
begin
|
106
|
+
jeweler.release_gem_to_rubyforge
|
107
|
+
rescue NoRubyForgeProjectInGemspecError => e
|
108
|
+
abort "Setting up RubyForge requires that you specify a 'rubyforge_project' in your Jeweler::Tasks declaration"
|
109
|
+
rescue MissingRubyForgePackageError => e
|
110
|
+
abort "Rubyforge reported that the #{e.message} package isn't setup. Run rake rubyforge:setup to do so."
|
111
|
+
rescue RubyForgeProjectNotConfiguredError => e
|
112
|
+
abort "RubyForge reported that #{e.message} wasn't configured. This means you need to run 'rubyforge setup', 'rubyforge login', and 'rubyforge configure', or maybe the project doesn't exist on RubyForge"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
desc "Setup a rubyforge project for this gem"
|
118
|
+
task :setup do
|
119
|
+
begin
|
120
|
+
jeweler.setup_rubyforge
|
121
|
+
rescue NoRubyForgeProjectInGemspecError => e
|
122
|
+
abort "Setting up RubyForge requires that you specify a 'rubyforge_project' in your Jeweler::Tasks declaration"
|
123
|
+
rescue RubyForgeProjectNotConfiguredError => e
|
124
|
+
abort "The RubyForge reported that #{e.message} wasn't configured. This means you need to run 'rubyforge setup', 'rubyforge login', and 'rubyforge configure', or maybe the project doesn't exist on RubyForge"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 <%= user_name %>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "<%= project_name %>"
|
8
|
+
gem.summary = %Q{<%= summary %>}
|
9
|
+
gem.email = "<%= user_email %>"
|
10
|
+
gem.homepage = "<%= project_homepage %>"
|
11
|
+
gem.authors = ["<%= user_name %>"]
|
12
|
+
<% if should_setup_rubyforge %>
|
13
|
+
gem.rubyforge_project = "<%= project_name %>"
|
14
|
+
<% end %>
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
|
18
|
+
<% if should_setup_rubyforge %>
|
19
|
+
Jeweler::RubyforgeTasks.new
|
20
|
+
<% end %>
|
21
|
+
rescue LoadError
|
22
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
23
|
+
end
|
24
|
+
|
25
|
+
<% case testing_framework %>
|
26
|
+
<% when :rspec %>
|
27
|
+
require 'spec/rake/spectask'
|
28
|
+
Spec::Rake::SpecTask.new(:<%= test_task %>) do |<%= test_task %>|
|
29
|
+
<%= test_task %>.libs << 'lib' << '<%= test_dir %>'
|
30
|
+
<%= test_task %>.spec_files = FileList['<%= test_pattern %>']
|
31
|
+
end
|
32
|
+
<% when :micronaut %>
|
33
|
+
require 'micronaut/rake_task'
|
34
|
+
Micronaut::RakeTask.new(<%= test_task %>) do |<%= test_task %>|
|
35
|
+
<%= test_task %>.pattern = '<%= test_pattern %>'
|
36
|
+
<%= test_task %>.ruby_opts << '-Ilib -I<%= test_dir %>'
|
37
|
+
end
|
38
|
+
<% else %>
|
39
|
+
require 'rake/testtask'
|
40
|
+
Rake::TestTask.new(:<%= test_task %>) do |<%= test_task %>|
|
41
|
+
<%= test_task %>.libs << 'lib' << '<%= test_dir %>'
|
42
|
+
<%= test_task %>.pattern = '<%= test_pattern %>'
|
43
|
+
<%= test_task %>.verbose = true
|
44
|
+
end
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
<% case testing_framework %>
|
48
|
+
<% when :rspec %>
|
49
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
50
|
+
spec.libs << 'lib' << 'spec'
|
51
|
+
spec.pattern = '<%= test_pattern %>'
|
52
|
+
spec.rcov = true
|
53
|
+
end
|
54
|
+
<% when :micronaut %>
|
55
|
+
Micronaut::RakeTask.new(:rcov) do |examples|
|
56
|
+
examples.pattern = '<%= test_pattern %>'
|
57
|
+
examples.rcov_opts = '-Ilib -I<%= test_dir %>'
|
58
|
+
examples.rcov = true
|
59
|
+
end
|
60
|
+
<% else %>
|
61
|
+
begin
|
62
|
+
require 'rcov/rcovtask'
|
63
|
+
Rcov::RcovTask.new do |<%= test_task %>|
|
64
|
+
<%= test_task %>.libs << '<%= test_dir %>'
|
65
|
+
<%= test_task %>.pattern = '<%= test_pattern %>'
|
66
|
+
<%= test_task %>.verbose = true
|
67
|
+
end
|
68
|
+
rescue LoadError
|
69
|
+
task :rcov do
|
70
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
<% end %>
|
74
|
+
|
75
|
+
<% if should_use_cucumber %>
|
76
|
+
begin
|
77
|
+
require 'cucumber/rake/task'
|
78
|
+
Cucumber::Rake::Task.new(:features)
|
79
|
+
rescue LoadError
|
80
|
+
task :features do
|
81
|
+
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
<% end %>
|
85
|
+
|
86
|
+
task :default => :<%= default_task %>
|
87
|
+
|
88
|
+
require 'rake/rdoctask'
|
89
|
+
Rake::RDocTask.new do |rdoc|
|
90
|
+
if File.exist?('VERSION.yml')
|
91
|
+
config = YAML.load(File.read('VERSION.yml'))
|
92
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
93
|
+
else
|
94
|
+
version = ""
|
95
|
+
end
|
96
|
+
|
97
|
+
rdoc.rdoc_dir = 'rdoc'
|
98
|
+
rdoc.title = "<%= project_name %> #{version}"
|
99
|
+
rdoc.rdoc_files.include('README*')
|
100
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
101
|
+
end
|
102
|
+
|