jeweler2 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +8 -0
- data/ChangeLog.markdown +177 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +217 -0
- data/Rakefile +80 -0
- data/bin/jeweler +5 -0
- data/features/generator/cucumber.feature +103 -0
- data/features/generator/directory_layout.feature +86 -0
- data/features/generator/dotdocument.feature +13 -0
- data/features/generator/env_options.feature +9 -0
- data/features/generator/gemfile.feature +71 -0
- data/features/generator/git.feature +102 -0
- data/features/generator/license.feature +20 -0
- data/features/generator/rakefile.feature +158 -0
- data/features/generator/readme.feature +12 -0
- data/features/generator/test.feature +54 -0
- data/features/generator/test_helper.feature +149 -0
- data/features/placeholder.feature +5 -0
- data/features/step_definitions/debug_steps.rb +6 -0
- data/features/step_definitions/filesystem_steps.rb +70 -0
- data/features/step_definitions/generator_steps.rb +380 -0
- data/features/step_definitions/task_steps.rb +6 -0
- data/features/support/env.rb +42 -0
- data/features/tasks/build_gem.feature +9 -0
- data/features/tasks/version.feature +31 -0
- data/features/tasks/version_bumping.feature +49 -0
- data/jeweler.gemspec +245 -0
- data/jeweler2.gemspec +233 -0
- data/lib/jeweler/commands/build_gem.rb +36 -0
- data/lib/jeweler/commands/check_dependencies.rb +66 -0
- data/lib/jeweler/commands/install_gem.rb +31 -0
- data/lib/jeweler/commands/release_gemspec.rb +82 -0
- data/lib/jeweler/commands/release_to_git.rb +59 -0
- data/lib/jeweler/commands/release_to_rubygems.rb +28 -0
- data/lib/jeweler/commands/validate_gemspec.rb +30 -0
- data/lib/jeweler/commands/version/base.rb +55 -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/write.rb +12 -0
- data/lib/jeweler/commands/write_gemspec.rb +39 -0
- data/lib/jeweler/commands.rb +20 -0
- data/lib/jeweler/errors.rb +8 -0
- data/lib/jeweler/gemcutter_tasks.rb +8 -0
- data/lib/jeweler/gemspec_helper.rb +87 -0
- data/lib/jeweler/generator/application.rb +61 -0
- data/lib/jeweler/generator/bacon_mixin.rb +43 -0
- data/lib/jeweler/generator/github_mixin.rb +29 -0
- data/lib/jeweler/generator/micronaut_mixin.rb +41 -0
- data/lib/jeweler/generator/minitest_mixin.rb +42 -0
- data/lib/jeweler/generator/options.rb +163 -0
- data/lib/jeweler/generator/rdoc_mixin.rb +9 -0
- data/lib/jeweler/generator/riot_mixin.rb +42 -0
- data/lib/jeweler/generator/rspec_mixin.rb +42 -0
- data/lib/jeweler/generator/shindo_mixin.rb +44 -0
- data/lib/jeweler/generator/shoulda_mixin.rb +42 -0
- data/lib/jeweler/generator/testspec_mixin.rb +42 -0
- data/lib/jeweler/generator/testunit_mixin.rb +39 -0
- data/lib/jeweler/generator/yard_mixin.rb +14 -0
- data/lib/jeweler/generator.rb +295 -0
- data/lib/jeweler/rubyforge_tasks.rb +95 -0
- data/lib/jeweler/rubygems_dot_org_tasks.rb +38 -0
- data/lib/jeweler/rubygems_tasks.rb +38 -0
- data/lib/jeweler/specification.rb +110 -0
- data/lib/jeweler/tasks.rb +224 -0
- data/lib/jeweler/templates/.document +5 -0
- data/lib/jeweler/templates/.gitignore +48 -0
- data/lib/jeweler/templates/Gemfile +12 -0
- data/lib/jeweler/templates/LICENSE.txt +20 -0
- data/lib/jeweler/templates/README.rdoc +19 -0
- data/lib/jeweler/templates/Rakefile +9 -0
- data/lib/jeweler/templates/bacon/flunking.rb +7 -0
- data/lib/jeweler/templates/bacon/helper.rb +9 -0
- data/lib/jeweler/templates/bundler_setup.erb +10 -0
- data/lib/jeweler/templates/features/default.feature +9 -0
- data/lib/jeweler/templates/features/support/env.rb +10 -0
- data/lib/jeweler/templates/jeweler_tasks.erb +31 -0
- data/lib/jeweler/templates/micronaut/flunking.rb +7 -0
- data/lib/jeweler/templates/micronaut/helper.rb +18 -0
- data/lib/jeweler/templates/minitest/flunking.rb +7 -0
- data/lib/jeweler/templates/minitest/helper.rb +12 -0
- data/lib/jeweler/templates/other_tasks.erb +86 -0
- data/lib/jeweler/templates/riot/flunking.rb +11 -0
- data/lib/jeweler/templates/riot/helper.rb +4 -0
- data/lib/jeweler/templates/rspec/.rspec +1 -0
- data/lib/jeweler/templates/rspec/flunking.rb +7 -0
- data/lib/jeweler/templates/rspec/helper.rb +12 -0
- data/lib/jeweler/templates/shindo/flunking.rb +8 -0
- data/lib/jeweler/templates/shindo/helper.rb +6 -0
- data/lib/jeweler/templates/shoulda/flunking.rb +7 -0
- data/lib/jeweler/templates/shoulda/helper.rb +11 -0
- data/lib/jeweler/templates/testspec/flunking.rb +7 -0
- data/lib/jeweler/templates/testspec/helper.rb +7 -0
- data/lib/jeweler/templates/testunit/flunking.rb +7 -0
- data/lib/jeweler/templates/testunit/helper.rb +10 -0
- data/lib/jeweler/version.rb +10 -0
- data/lib/jeweler/version_helper.rb +141 -0
- data/lib/jeweler.rb +177 -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-constant/.document +5 -0
- data/test/fixtures/existing-project-with-version-constant/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-constant/LICENSE.txt +20 -0
- data/test/fixtures/existing-project-with-version-constant/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-constant/Rakefile +85 -0
- data/test/fixtures/existing-project-with-version-constant/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-constant/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-constant/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-constant/test/test_helper.rb +10 -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.txt +20 -0
- data/test/fixtures/existing-project-with-version-plaintext/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/Rakefile +84 -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.txt +20 -0
- data/test/fixtures/existing-project-with-version-yaml/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-yaml/Rakefile +84 -0
- data/test/fixtures/existing-project-with-version-yaml/VERSION.yml +4 -0
- data/test/fixtures/existing-project-with-version-yaml/bin/foo_the_ultimate_bin +0 -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 +103 -0
- data/test/jeweler/commands/test_install_gem.rb +35 -0
- data/test/jeweler/commands/test_release_to_gemcutter.rb +39 -0
- data/test/jeweler/commands/test_release_to_git.rb +198 -0
- data/test/jeweler/commands/test_release_to_github.rb +390 -0
- data/test/jeweler/commands/test_validate_gemspec.rb +27 -0
- data/test/jeweler/commands/test_write_gemspec.rb +101 -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 +22 -0
- data/test/jeweler/generator/test_application.rb +120 -0
- data/test/jeweler/generator/test_options.rb +225 -0
- data/test/jeweler/test_gemspec_helper.rb +44 -0
- data/test/jeweler/test_generator.rb +141 -0
- data/test/jeweler/test_generator_initialization.rb +164 -0
- data/test/jeweler/test_generator_mixins.rb +23 -0
- data/test/jeweler/test_specification.rb +237 -0
- data/test/jeweler/test_tasks.rb +50 -0
- data/test/jeweler/test_version_helper.rb +214 -0
- data/test/shoulda_macros/jeweler_macros.rb +35 -0
- data/test/test_helper.rb +178 -0
- data/test/test_jeweler.rb +175 -0
- metadata +343 -0
@@ -0,0 +1,295 @@
|
|
1
|
+
require 'git'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
require 'net/http'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
require 'fileutils'
|
8
|
+
require 'pathname'
|
9
|
+
|
10
|
+
require_relative 'version'
|
11
|
+
|
12
|
+
class Jeweler
|
13
|
+
class NoGitUserName < StandardError
|
14
|
+
end
|
15
|
+
class NoGitUserEmail < StandardError
|
16
|
+
end
|
17
|
+
class FileInTheWay < StandardError
|
18
|
+
end
|
19
|
+
class NoGitHubRepoNameGiven < StandardError
|
20
|
+
end
|
21
|
+
class NoGitHubUser < StandardError
|
22
|
+
end
|
23
|
+
class NoGitHubToken < StandardError
|
24
|
+
end
|
25
|
+
class GitInitFailed < StandardError
|
26
|
+
end
|
27
|
+
|
28
|
+
# Generator for creating a jeweler-enabled project
|
29
|
+
class Generator
|
30
|
+
require_relative 'generator/options'
|
31
|
+
require_relative 'generator/application'
|
32
|
+
|
33
|
+
require_relative 'generator/github_mixin'
|
34
|
+
|
35
|
+
require_relative 'generator/bacon_mixin'
|
36
|
+
require_relative 'generator/micronaut_mixin'
|
37
|
+
require_relative 'generator/minitest_mixin'
|
38
|
+
require_relative 'generator/rspec_mixin'
|
39
|
+
require_relative 'generator/shoulda_mixin'
|
40
|
+
require_relative 'generator/testspec_mixin'
|
41
|
+
require_relative 'generator/testunit_mixin'
|
42
|
+
require_relative 'generator/riot_mixin'
|
43
|
+
require_relative 'generator/shindo_mixin'
|
44
|
+
|
45
|
+
require_relative 'generator/rdoc_mixin'
|
46
|
+
require_relative 'generator/yard_mixin'
|
47
|
+
|
48
|
+
attr_accessor :target_dir, :user_name, :user_email, :summary, :homepage,
|
49
|
+
:description, :project_name, :github_username, :github_token,
|
50
|
+
:repo, :should_create_remote_repo,
|
51
|
+
:testing_framework, :documentation_framework,
|
52
|
+
:should_use_cucumber, :should_use_bundler,
|
53
|
+
:should_setup_rubyforge, :should_use_reek, :should_use_roodi,
|
54
|
+
:development_dependencies,
|
55
|
+
:options,
|
56
|
+
:git_remote
|
57
|
+
|
58
|
+
def initialize(options = {})
|
59
|
+
self.options = options
|
60
|
+
extracted_directory = nil
|
61
|
+
|
62
|
+
self.project_name = options[:project_name]
|
63
|
+
if self.project_name.nil? || self.project_name.squeeze.strip == ""
|
64
|
+
raise NoGitHubRepoNameGiven
|
65
|
+
else
|
66
|
+
path = File.split(self.project_name)
|
67
|
+
|
68
|
+
if path.size > 1
|
69
|
+
extracted_directory = File.join(path[0..-1])
|
70
|
+
self.project_name = path.last
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
self.development_dependencies = []
|
75
|
+
self.testing_framework = options[:testing_framework]
|
76
|
+
self.documentation_framework = options[:documentation_framework]
|
77
|
+
begin
|
78
|
+
generator_mixin_name = "#{self.testing_framework.to_s.capitalize}Mixin"
|
79
|
+
generator_mixin = self.class.const_get(generator_mixin_name)
|
80
|
+
extend generator_mixin
|
81
|
+
rescue NameError => e
|
82
|
+
raise ArgumentError, "Unsupported testing framework (#{testing_framework})"
|
83
|
+
end
|
84
|
+
|
85
|
+
begin
|
86
|
+
generator_mixin_name = "#{self.documentation_framework.to_s.capitalize}Mixin"
|
87
|
+
generator_mixin = self.class.const_get(generator_mixin_name)
|
88
|
+
extend generator_mixin
|
89
|
+
rescue NameError => e
|
90
|
+
raise ArgumentError, "Unsupported documentation framework (#{documentation_framework})"
|
91
|
+
end
|
92
|
+
|
93
|
+
self.target_dir = options[:directory] || extracted_directory || self.project_name
|
94
|
+
|
95
|
+
self.summary = options[:summary] || 'TODO: one-line summary of your gem'
|
96
|
+
self.description = options[:description] || 'TODO: longer description of your gem'
|
97
|
+
self.should_use_cucumber = options[:use_cucumber]
|
98
|
+
self.should_use_reek = options[:use_reek]
|
99
|
+
self.should_use_roodi = options[:use_roodi]
|
100
|
+
self.should_setup_rubyforge = options[:rubyforge]
|
101
|
+
self.should_use_bundler = options[:use_bundler]
|
102
|
+
|
103
|
+
development_dependencies << ["cucumber", ">= 0"] if should_use_cucumber
|
104
|
+
|
105
|
+
# TODO make bundler optional?
|
106
|
+
development_dependencies << ["bundler", "~> 1.0.0"]
|
107
|
+
development_dependencies << ["jeweler", "~> #{Jeweler::Version::STRING}"]
|
108
|
+
development_dependencies << ["rcov", ">= 0"]
|
109
|
+
|
110
|
+
development_dependencies << ["reek", "~> 1.2.8"] if should_use_reek
|
111
|
+
development_dependencies << ["roodi", "~> 2.1.0"] if should_use_roodi
|
112
|
+
|
113
|
+
self.user_name = options[:user_name]
|
114
|
+
self.user_email = options[:user_email]
|
115
|
+
self.homepage = options[:homepage]
|
116
|
+
|
117
|
+
self.git_remote = options[:git_remote]
|
118
|
+
|
119
|
+
raise NoGitUserName unless self.user_name
|
120
|
+
raise NoGitUserEmail unless self.user_email
|
121
|
+
|
122
|
+
extend GithubMixin
|
123
|
+
end
|
124
|
+
|
125
|
+
def run
|
126
|
+
create_files
|
127
|
+
create_version_control
|
128
|
+
$stdout.puts "Jeweler has prepared your gem in #{target_dir}"
|
129
|
+
if should_create_remote_repo
|
130
|
+
create_and_push_repo
|
131
|
+
$stdout.puts "Jeweler has pushed your repo to #{homepage}"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def constant_name
|
136
|
+
self.project_name.split(/[-_]/).collect{|each| each.capitalize }.join
|
137
|
+
end
|
138
|
+
|
139
|
+
def lib_filename
|
140
|
+
"#{project_name}.rb"
|
141
|
+
end
|
142
|
+
|
143
|
+
def require_name
|
144
|
+
self.project_name
|
145
|
+
end
|
146
|
+
|
147
|
+
def file_name_prefix
|
148
|
+
self.project_name.gsub('-', '_')
|
149
|
+
end
|
150
|
+
|
151
|
+
def lib_dir
|
152
|
+
'lib'
|
153
|
+
end
|
154
|
+
|
155
|
+
def feature_filename
|
156
|
+
"#{project_name}.feature"
|
157
|
+
end
|
158
|
+
|
159
|
+
def steps_filename
|
160
|
+
"#{project_name}_steps.rb"
|
161
|
+
end
|
162
|
+
|
163
|
+
def features_dir
|
164
|
+
'features'
|
165
|
+
end
|
166
|
+
|
167
|
+
def features_support_dir
|
168
|
+
File.join(features_dir, 'support')
|
169
|
+
end
|
170
|
+
|
171
|
+
def features_steps_dir
|
172
|
+
File.join(features_dir, 'step_definitions')
|
173
|
+
end
|
174
|
+
|
175
|
+
private
|
176
|
+
|
177
|
+
def create_files
|
178
|
+
unless File.exists?(target_dir) || File.directory?(target_dir)
|
179
|
+
FileUtils.mkdir target_dir
|
180
|
+
else
|
181
|
+
raise FileInTheWay, "The directory #{target_dir} already exists, aborting. Maybe move it out of the way before continuing?"
|
182
|
+
end
|
183
|
+
|
184
|
+
|
185
|
+
output_template_in_target '.gitignore'
|
186
|
+
output_template_in_target 'Rakefile'
|
187
|
+
output_template_in_target 'Gemfile' if should_use_bundler
|
188
|
+
output_template_in_target 'LICENSE.txt'
|
189
|
+
output_template_in_target 'README.rdoc'
|
190
|
+
output_template_in_target '.document'
|
191
|
+
|
192
|
+
mkdir_in_target lib_dir
|
193
|
+
touch_in_target File.join(lib_dir, lib_filename)
|
194
|
+
|
195
|
+
mkdir_in_target test_dir
|
196
|
+
output_template_in_target File.join(testing_framework.to_s, 'helper.rb'),
|
197
|
+
File.join(test_dir, test_helper_filename)
|
198
|
+
output_template_in_target File.join(testing_framework.to_s, 'flunking.rb'),
|
199
|
+
File.join(test_dir, test_filename)
|
200
|
+
|
201
|
+
|
202
|
+
if testing_framework == :rspec
|
203
|
+
output_template_in_target File.join(testing_framework.to_s, '.rspec'),
|
204
|
+
'.rspec'
|
205
|
+
|
206
|
+
end
|
207
|
+
|
208
|
+
if should_use_cucumber
|
209
|
+
mkdir_in_target features_dir
|
210
|
+
output_template_in_target File.join(%w(features default.feature)), File.join('features', feature_filename)
|
211
|
+
|
212
|
+
mkdir_in_target features_support_dir
|
213
|
+
output_template_in_target File.join(features_support_dir, 'env.rb')
|
214
|
+
|
215
|
+
mkdir_in_target features_steps_dir
|
216
|
+
touch_in_target File.join(features_steps_dir, steps_filename)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def render_template(source)
|
221
|
+
template_contents = File.read(File.join(template_dir, source))
|
222
|
+
template = ERB.new(template_contents, nil, '<>')
|
223
|
+
|
224
|
+
# squish extraneous whitespace from some of the conditionals
|
225
|
+
template.result(binding).gsub(/\n\n\n+/, "\n\n")
|
226
|
+
end
|
227
|
+
|
228
|
+
def output_template_in_target(source, destination = source)
|
229
|
+
final_destination = File.join(target_dir, destination)
|
230
|
+
template_result = render_template(source)
|
231
|
+
|
232
|
+
File.open(final_destination, 'w') {|file| file.write(template_result)}
|
233
|
+
|
234
|
+
$stdout.puts "\tcreate\t#{destination}"
|
235
|
+
end
|
236
|
+
|
237
|
+
def template_dir
|
238
|
+
File.join(File.dirname(__FILE__), 'templates')
|
239
|
+
end
|
240
|
+
|
241
|
+
def mkdir_in_target(directory)
|
242
|
+
final_destination = File.join(target_dir, directory)
|
243
|
+
|
244
|
+
FileUtils.mkdir final_destination
|
245
|
+
|
246
|
+
$stdout.puts "\tcreate\t#{directory}"
|
247
|
+
end
|
248
|
+
|
249
|
+
def touch_in_target(destination)
|
250
|
+
final_destination = File.join(target_dir, destination)
|
251
|
+
FileUtils.touch final_destination
|
252
|
+
$stdout.puts "\tcreate\t#{destination}"
|
253
|
+
end
|
254
|
+
|
255
|
+
def create_version_control
|
256
|
+
Dir.chdir(target_dir) do
|
257
|
+
begin
|
258
|
+
@repo = Git.init()
|
259
|
+
rescue Git::GitExecuteError => e
|
260
|
+
raise GitInitFailed, "Encountered an error during gitification. Maybe the repo already exists, or has already been pushed to?"
|
261
|
+
end
|
262
|
+
|
263
|
+
begin
|
264
|
+
@repo.add('.')
|
265
|
+
rescue Git::GitExecuteError => e
|
266
|
+
#raise GitAddFailed, "There was some problem adding this directory to the git changeset"
|
267
|
+
raise
|
268
|
+
end
|
269
|
+
|
270
|
+
begin
|
271
|
+
@repo.commit "Initial commit to #{project_name}."
|
272
|
+
rescue Git::GitExecuteError => e
|
273
|
+
raise
|
274
|
+
end
|
275
|
+
|
276
|
+
begin
|
277
|
+
@repo.add_remote('origin', git_remote)
|
278
|
+
rescue Git::GitExecuteError => e
|
279
|
+
puts "Encountered an error while adding origin remote. Maybe you have some weird settings in ~/.gitconfig?"
|
280
|
+
raise
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
def create_and_push_repo
|
286
|
+
Net::HTTP.post_form URI.parse('http://github.com/api/v2/yaml/repos/create'),
|
287
|
+
'login' => github_username,
|
288
|
+
'token' => github_token,
|
289
|
+
'description' => summary,
|
290
|
+
'name' => project_name
|
291
|
+
# TODO do a HEAD request to see when it's ready?
|
292
|
+
@repo.push('origin')
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
class Jeweler
|
5
|
+
# Rake tasks for putting a Jeweler gem on Rubyforge.
|
6
|
+
#
|
7
|
+
# Jeweler::Tasks.new needs to be used before this.
|
8
|
+
#
|
9
|
+
# Basic usage:
|
10
|
+
#
|
11
|
+
# Jeweler::RubyforgeTasks.new
|
12
|
+
#
|
13
|
+
# Easy enough, right?
|
14
|
+
#
|
15
|
+
# There are a few options you can tweak:
|
16
|
+
#
|
17
|
+
# * project: the rubyforge project to operate on. This defaults to whatever you specified in your gemspec. Defaults to your gem name.
|
18
|
+
# * remote_doc_path: the place to upload docs to on Rubyforge under /var/www/gforge-projects/#{project}/
|
19
|
+
#
|
20
|
+
# See also http://wiki.github.com/technicalpickles/jeweler/rubyforge
|
21
|
+
class RubyforgeTasks < ::Rake::TaskLib
|
22
|
+
# The RubyForge project to interact with. Defaults to whatever is in your jeweler gemspec.
|
23
|
+
attr_accessor :project
|
24
|
+
# The path to upload docs to. It is relative to /var/www/gforge-projects/#{project}/, and defaults to your gemspec's name
|
25
|
+
attr_accessor :remote_doc_path
|
26
|
+
# Task to be used for generating documentation, before they are uploaded. Defaults to rdoc.
|
27
|
+
attr_accessor :doc_task
|
28
|
+
|
29
|
+
attr_accessor :jeweler
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
yield self if block_given?
|
33
|
+
|
34
|
+
$stderr.puts "Releasing gems to Rubyforge is deprecated. See details at http://wiki.github.com/technicalpickles/jeweler/migrating-from-releasing-gems-to-rubyforge"
|
35
|
+
|
36
|
+
define
|
37
|
+
end
|
38
|
+
|
39
|
+
def jeweler
|
40
|
+
@jeweler ||= Rake.application.jeweler
|
41
|
+
end
|
42
|
+
|
43
|
+
def remote_doc_path
|
44
|
+
@remote_doc_path ||= jeweler.gemspec.name
|
45
|
+
end
|
46
|
+
|
47
|
+
def project
|
48
|
+
@project ||= jeweler.gemspec.rubyforge_project
|
49
|
+
end
|
50
|
+
|
51
|
+
def define
|
52
|
+
namespace :rubyforge do
|
53
|
+
namespace :release do
|
54
|
+
desc "Release the current gem version to RubyForge."
|
55
|
+
task :gem do
|
56
|
+
$stderr.puts "DEPRECATION: Releasing gems to RubyForge is deprecated. You should see about releasing to Gemcutter instead: http://wiki.github.com/technicalpickles/jeweler/gemcutter"
|
57
|
+
end
|
58
|
+
|
59
|
+
if publish_documentation?
|
60
|
+
desc "Publish docs to RubyForge."
|
61
|
+
task :docs => doc_task do
|
62
|
+
config = YAML.load(
|
63
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
64
|
+
)
|
65
|
+
|
66
|
+
host = "#{config['username']}@rubyforge.org"
|
67
|
+
remote_dir = "/var/www/gforge-projects/#{project}/#{remote_doc_path}"
|
68
|
+
|
69
|
+
local_dir = case self.doc_task.to_sym
|
70
|
+
when :rdoc then 'rdoc'
|
71
|
+
when :yardoc then 'doc'
|
72
|
+
when 'doc:app'.to_sym then 'doc/app'
|
73
|
+
else
|
74
|
+
raise "Unsure what to run to generate documentation. Please set doc_task and re-run."
|
75
|
+
end
|
76
|
+
|
77
|
+
sh %{rsync --archive --verbose --delete #{local_dir}/ #{host}:#{remote_dir}}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
if publish_documentation?
|
83
|
+
desc "Release RDoc documentation to RubyForge"
|
84
|
+
task :release => "rubyforge:release:docs"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
task :release => 'rubyforge:release'
|
89
|
+
end
|
90
|
+
|
91
|
+
def publish_documentation?
|
92
|
+
! (doc_task == false || doc_task == :none)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
class Jeweler
|
5
|
+
# Rake tasks for putting a Jeweler gem on Gemcutter.
|
6
|
+
#
|
7
|
+
# Jeweler::Tasks.new needs to be used before this.
|
8
|
+
#
|
9
|
+
# Basic usage:
|
10
|
+
#
|
11
|
+
# Jeweler::RubygemsDotOrgTasks.new
|
12
|
+
#
|
13
|
+
# Easy enough, right?
|
14
|
+
class RubygemsDotOrgTasks < ::Rake::TaskLib
|
15
|
+
attr_accessor :jeweler
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
yield self if block_given?
|
19
|
+
|
20
|
+
define
|
21
|
+
end
|
22
|
+
|
23
|
+
def jeweler
|
24
|
+
@jeweler ||= Rake.application.jeweler
|
25
|
+
end
|
26
|
+
|
27
|
+
def define
|
28
|
+
namespace :gemcutter do
|
29
|
+
desc "Release gem to Gemcutter"
|
30
|
+
task :release => [:gemspec, :build] do
|
31
|
+
jeweler.release_gem_to_rubygems
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
task :release => 'gemcutter:release'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
class Jeweler
|
5
|
+
# Rake tasks for putting a Jeweler gem on Gemcutter.
|
6
|
+
#
|
7
|
+
# Jeweler::Tasks.new needs to be used before this.
|
8
|
+
#
|
9
|
+
# Basic usage:
|
10
|
+
#
|
11
|
+
# Jeweler::RubygemsDotOrgTasks.new
|
12
|
+
#
|
13
|
+
# Easy enough, right?
|
14
|
+
class RubygemsDotOrgTasks < ::Rake::TaskLib
|
15
|
+
attr_accessor :jeweler
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
yield self if block_given?
|
19
|
+
|
20
|
+
define
|
21
|
+
end
|
22
|
+
|
23
|
+
def jeweler
|
24
|
+
@jeweler ||= Rake.application.jeweler
|
25
|
+
end
|
26
|
+
|
27
|
+
def define
|
28
|
+
namespace :rubygems do
|
29
|
+
desc "Release gem to Gemcutter"
|
30
|
+
task :release => [:gemspec, :build] do
|
31
|
+
jeweler.release_gem_to_rubygems
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
task :release => 'rubygems:release'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
|
2
|
+
require 'rubygems/specification'
|
3
|
+
|
4
|
+
class Jeweler
|
5
|
+
# Extend a Gem::Specification instance with this module to give it Jeweler
|
6
|
+
# super-cow powers.
|
7
|
+
#
|
8
|
+
# [files] a Rake::FileList of anything that is in git and not gitignored. You can include/exclude this default set, or override it entirely
|
9
|
+
# [extra_rdoc_files] a Rake::FileList including files like README*, ChangeLog*, and LICENSE*
|
10
|
+
# [executables] uses anything found in the bin/ directory.
|
11
|
+
module Specification
|
12
|
+
def self.filelist_attribute(name)
|
13
|
+
code = %{
|
14
|
+
def #{name}
|
15
|
+
if @#{name} && @#{name}.class != FileList
|
16
|
+
@#{name} = FileList[@#{name}]
|
17
|
+
end
|
18
|
+
@#{name} ||= FileList[]
|
19
|
+
end
|
20
|
+
def #{name}=(value)
|
21
|
+
@#{name} = FileList[value]
|
22
|
+
end
|
23
|
+
}
|
24
|
+
|
25
|
+
module_eval code, __FILE__, __LINE__ - 9
|
26
|
+
end
|
27
|
+
|
28
|
+
filelist_attribute :files
|
29
|
+
filelist_attribute :extra_rdoc_files
|
30
|
+
|
31
|
+
# Assigns the Jeweler defaults to the Gem::Specification
|
32
|
+
def set_jeweler_defaults(base_dir, git_base_dir = nil)
|
33
|
+
base_dir = File.expand_path(base_dir)
|
34
|
+
git_base_dir = if git_base_dir
|
35
|
+
File.expand_path(git_base_dir)
|
36
|
+
else
|
37
|
+
base_dir
|
38
|
+
end
|
39
|
+
can_git = git_base_dir && base_dir.include?(git_base_dir) && File.directory?(File.join(git_base_dir, '.git'))
|
40
|
+
|
41
|
+
Dir.chdir(git_base_dir) do
|
42
|
+
repo = if can_git
|
43
|
+
require 'git'
|
44
|
+
Git.open(git_base_dir)
|
45
|
+
end
|
46
|
+
|
47
|
+
if blank?(files) && repo
|
48
|
+
base_dir_with_trailing_separator = File.join(base_dir, "")
|
49
|
+
|
50
|
+
ignored_files = repo.lib.ignored_files + [".gitignore"]
|
51
|
+
self.files = (repo.ls_files(base_dir).keys - ignored_files).compact.map do |file|
|
52
|
+
File.expand_path(file).sub(base_dir_with_trailing_separator, "")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
if blank?(executables) && repo
|
57
|
+
self.executables = (repo.ls_files(File.join(base_dir, 'bin')).keys - repo.lib.ignored_files).map do |file|
|
58
|
+
File.basename(file)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if blank?(extensions)
|
63
|
+
self.extensions = FileList['ext/**/{extconf,mkrf_conf}.rb']
|
64
|
+
end
|
65
|
+
|
66
|
+
if blank?(extra_rdoc_files)
|
67
|
+
self.extra_rdoc_files = FileList['README*', 'ChangeLog*', 'LICENSE*', 'TODO']
|
68
|
+
end
|
69
|
+
|
70
|
+
if File.exist?('Gemfile')
|
71
|
+
require 'bundler'
|
72
|
+
bundler = Bundler.load
|
73
|
+
bundler.dependencies_for(:default, :runtime).each do |dependency|
|
74
|
+
self.add_dependency dependency.name, *dependency.requirement.as_list
|
75
|
+
end
|
76
|
+
bundler.dependencies_for(:development).each do |dependency|
|
77
|
+
self.add_development_dependency dependency.name, *dependency.requirement.as_list
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Used by Specification#to_ruby to generate a ruby-respresentation of a Gem::Specification
|
85
|
+
def ruby_code(obj)
|
86
|
+
case obj
|
87
|
+
when Rake::FileList then obj.uniq.to_a.inspect
|
88
|
+
else super
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def blank?(value)
|
95
|
+
value.nil? || value.empty?
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
# Workaround for cloning/duping a Gem::Specification
|
102
|
+
# documented in http://github.com/technicalpickles/jeweler/issues#issue/73
|
103
|
+
Gem::Specification.class_eval do
|
104
|
+
def initialize_copy(original)
|
105
|
+
super
|
106
|
+
|
107
|
+
self.files = original.files.to_a
|
108
|
+
self.extra_rdoc_files = original.extra_rdoc_files.to_a
|
109
|
+
end
|
110
|
+
end
|