jeweler 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.markdown +64 -0
- data/LICENSE +20 -0
- data/README.markdown +164 -0
- data/Rakefile +89 -0
- data/TODO +11 -0
- data/VERSION.yml +4 -0
- data/bin/jeweler +8 -0
- data/lib/jeweler.rb +154 -0
- data/lib/jeweler/commands.rb +12 -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 +59 -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/write.rb +12 -0
- data/lib/jeweler/commands/write_gemspec.rb +39 -0
- data/lib/jeweler/errors.rb +20 -0
- data/lib/jeweler/gemspec_helper.rb +51 -0
- data/lib/jeweler/generator.rb +347 -0
- data/lib/jeweler/generator/application.rb +45 -0
- data/lib/jeweler/generator/options.rb +68 -0
- data/lib/jeweler/tasks.rb +119 -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 +125 -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 +11 -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 +83 -0
- data/test/fixtures/bar/VERSION.yml +4 -0
- data/test/fixtures/existing-project-with-version/LICENSE +20 -0
- data/test/fixtures/existing-project-with-version/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version/Rakefile +82 -0
- data/test/fixtures/existing-project-with-version/VERSION.yml +4 -0
- data/test/fixtures/existing-project-with-version/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version/test/test_helper.rb +10 -0
- data/test/geminstaller.yml +12 -0
- data/test/generators/initialization_test.rb +146 -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 +180 -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 +113 -0
- data/test/test_gemspec_helper.rb +36 -0
- data/test/test_generator.rb +183 -0
- data/test/test_helper.rb +118 -0
- data/test/test_jeweler.rb +177 -0
- data/test/test_options.rb +96 -0
- data/test/test_tasks.rb +41 -0
- data/test/test_version_helper.rb +115 -0
- data/test/version_tmp/VERSION.yml +4 -0
- metadata +171 -0
data/ChangeLog.markdown
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# jeweler x.y.z
|
2
|
+
|
3
|
+
* 'rake install' now will 'rake build' first
|
4
|
+
* Support for releasing to RubyForge, thanks to jtrupiano
|
5
|
+
* Steps towards Ruby 1.9 support, thanks to rsanheim
|
6
|
+
|
7
|
+
# jeweler 0.9.1 2009-03-05
|
8
|
+
|
9
|
+
* Tasks:
|
10
|
+
* Fixed populating default spec's extra_rdoc_files
|
11
|
+
* Removed redudant gem building/installing tasks. Use rake build and rake install
|
12
|
+
* Generator:
|
13
|
+
* Added support for micronaut
|
14
|
+
* Generate nicer block variable names in Rakefile
|
15
|
+
* Cucumber generation now places steps in features/step_features, to follow cucumber standards
|
16
|
+
|
17
|
+
* shoulda and test/unit test_helpers no longers require mocha
|
18
|
+
* Rakefile uses more readable block variable names
|
19
|
+
* .gitignore now includes pkg and coverage directories
|
20
|
+
* Avoid puts'ing in Rakefile when LoadError occurs. Instead, define a task that aborts with instructions to install.
|
21
|
+
* Cucumber is now optional. Generate stories using --cucumber
|
22
|
+
* Bacon's 'test' task is now 'spec'
|
23
|
+
* Generate README.rdoc instead of just a plain text README
|
24
|
+
* Updated year in README.rdoc and COPYRIGHT to be based on the current year instead of hardcoded
|
25
|
+
|
26
|
+
# jeweler 0.8.1 2009-02-03
|
27
|
+
|
28
|
+
* Fixed minitest generator
|
29
|
+
|
30
|
+
# jeweler 0.8.0 2009-02-03
|
31
|
+
|
32
|
+
* Generator:
|
33
|
+
* Supports these new testing frameworks:
|
34
|
+
* test/unit
|
35
|
+
* minitest
|
36
|
+
* rspec
|
37
|
+
* Added support for cucumber
|
38
|
+
* Creating a new gem is now more verbose, and will show files/directories created
|
39
|
+
* Binaries will now be automatically detected in 'bin'
|
40
|
+
|
41
|
+
# jeweler 0.7.2 2009-01-29
|
42
|
+
|
43
|
+
* Added rake task 'version:bump' which is shorthand for 'version:bump:patch'
|
44
|
+
* Generated projects no longer assume RCov is installed.
|
45
|
+
|
46
|
+
# jeweler 0.7.1 2009-01-26
|
47
|
+
|
48
|
+
* Fixed yaml not being required
|
49
|
+
* Automatically add files in bin as executables in gemspec
|
50
|
+
|
51
|
+
# jeweler 0.7.0 2009-01-19
|
52
|
+
|
53
|
+
* Added support to generator for specifying a description
|
54
|
+
* Condensed README.markdown to be less novel-like
|
55
|
+
* RDoc is now included in your gemspec
|
56
|
+
* Rescue errors that raise in the generator, and display better error message, and exit with a non-zero exit status
|
57
|
+
|
58
|
+
# jeweler 0.6.5 2009-01-14
|
59
|
+
|
60
|
+
* `jeweler --create-repo foo` now enables gem creation in addition to creating the repository
|
61
|
+
|
62
|
+
# jeweler 0.6.4 2009-01-13
|
63
|
+
|
64
|
+
* Added tasks `build` and `install` as shortcuts for `gem:build` and `gem:install`
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Josh Nichols
|
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.
|
data/README.markdown
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
# Jeweler: Craft the perfect RubyGem
|
2
|
+
|
3
|
+
Jeweler provides two things:
|
4
|
+
|
5
|
+
* Rake tasks for managing gems and versioning of a <a href="http://github.com">GitHub</a> project
|
6
|
+
* A generator for creating kickstarting a new project
|
7
|
+
|
8
|
+
## Installing
|
9
|
+
|
10
|
+
# Run the following if you haven't done so before:
|
11
|
+
gem sources -a http://gems.github.com
|
12
|
+
# Install the gem:
|
13
|
+
sudo gem install technicalpickles-jeweler
|
14
|
+
|
15
|
+
## Using in an existing project
|
16
|
+
|
17
|
+
It's easy to get up and running. Update your instantiate a `Jeweler::Tasks`, and give it a block with details about your project.
|
18
|
+
|
19
|
+
begin
|
20
|
+
require 'jeweler'
|
21
|
+
Jeweler::Tasks.new do |s|
|
22
|
+
s.name = "the-perfect-gem"
|
23
|
+
s.summary = "TODO"
|
24
|
+
s.email = "josh@technicalpickles.com"
|
25
|
+
s.homepage = "http://github.com/technicalpickles/the-perfect-gem"
|
26
|
+
s.description = "TODO"
|
27
|
+
s.authors = ["Josh Nichols"]
|
28
|
+
end
|
29
|
+
rescue LoadError
|
30
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
31
|
+
end
|
32
|
+
|
33
|
+
In this example, `s` is a Gem::Specification object. See the [GemSpec reference](http://www.rubygems.org/read/chapter/20) for values of interest.
|
34
|
+
|
35
|
+
## Using to start a new project
|
36
|
+
|
37
|
+
Jeweler provides a generator. It requires you to [setup your name and email for git](http://github.com/guides/tell-git-your-user-name-and-email-address) and [your username and token for GitHub](http://github.com/guides/local-github-config).
|
38
|
+
|
39
|
+
jeweler the-perfect-gem
|
40
|
+
|
41
|
+
This will prepare a project in the 'the-perfect-gem' directory, setup to use Jeweler.
|
42
|
+
|
43
|
+
It supports a number of options:
|
44
|
+
|
45
|
+
* --create-repo: in addition to preparing a project, it create an repo up on GitHub and enable RubyGem generation
|
46
|
+
* --testunit: generate test_helper.rb and test ready for test/unit
|
47
|
+
* --minitest: generate test_helper.rb and test ready for minitest
|
48
|
+
* --shoulda: generate test_helper.rb and test ready for shoulda (this is the default)
|
49
|
+
* --rspec: generate spec_helper.rb and spec ready for rspec
|
50
|
+
* --bacon: generate spec_helper.rb and spec ready for bacon
|
51
|
+
* --rubyfoge: setup releasing to rubyforge
|
52
|
+
|
53
|
+
## Gemspec
|
54
|
+
|
55
|
+
Jeweler handles generating a gemspec file for your project:
|
56
|
+
|
57
|
+
rake gemspec
|
58
|
+
|
59
|
+
This creates a gemspec for your project. It's based on the info you give `Jeweler::Tasks`, the current version of your project, and some defaults that Jeweler provides.
|
60
|
+
|
61
|
+
## Gem
|
62
|
+
|
63
|
+
Jeweler gives you tasks for building and installing your gem:
|
64
|
+
|
65
|
+
rake build
|
66
|
+
rake install
|
67
|
+
|
68
|
+
## Versioning
|
69
|
+
|
70
|
+
Jeweler tracks the version of your project. It assumes you will be using a version in the format `x.y.z`. `x` is the 'major' version, `y` is the 'minor' version, and `z` is the patch version.
|
71
|
+
|
72
|
+
Initially, your project starts out at 0.0.0. Jeweler provides Rake tasks for bumping the version:
|
73
|
+
|
74
|
+
rake version:bump:major
|
75
|
+
rake version:bump:minor
|
76
|
+
rake version:bump:patch
|
77
|
+
|
78
|
+
## Releasing to GitHub
|
79
|
+
|
80
|
+
Jeweler handles releasing your gem into the wild:
|
81
|
+
|
82
|
+
rake release
|
83
|
+
|
84
|
+
It does the following for you:
|
85
|
+
|
86
|
+
* Regenerate the gemspec to the latest version of your project
|
87
|
+
* Push to GitHub (which results in a gem being build)
|
88
|
+
* Tag the version and push to GitHub
|
89
|
+
|
90
|
+
## Releasing to RubyForge
|
91
|
+
|
92
|
+
Jeweler can also handle releasing to [RubyForge](http://rubyforge.org). There are a few steps you need to do before doing any RubyForge releases with Jeweler:
|
93
|
+
|
94
|
+
* [Create an account on RubyForge](http://rubyforge.org/account/register.php)
|
95
|
+
* Request a project on RubyForge. This involves waiting for a project approval, which can take any amount of time from a few hours to a week
|
96
|
+
* You might want to create an umbrella project where you can publish your gems, instead of one project per gem
|
97
|
+
* Install the RubyForge gem: sudo gem install rubyforge
|
98
|
+
* Run 'rubyforge setup' and fill in your username and password for RubyForge
|
99
|
+
* Run 'rubyforge config' to pull down information about your projects
|
100
|
+
* Run 'rubyforge login' to make sure you are able to login
|
101
|
+
|
102
|
+
With this in place, you now update your Jeweler::Tasks to setup `rubyforge_project` with the RubyForge project you've just created. (Note, using `jeweler --rubyforge` when generating the project does this for you automatically.)
|
103
|
+
|
104
|
+
begin
|
105
|
+
require 'jeweler'
|
106
|
+
Jeweler::Tasks.new do |s|
|
107
|
+
s.name = "the-perfect-gem"
|
108
|
+
s.summary = "TODO"
|
109
|
+
s.email = "josh@technicalpickles.com"
|
110
|
+
s.homepage = "http://github.com/technicalpickles/the-perfect-gem"
|
111
|
+
s.description = "TODO"
|
112
|
+
s.authors = ["Josh Nichols"]
|
113
|
+
s.rubyforge_project = 'the-perfect-gem' # This line would be new
|
114
|
+
end
|
115
|
+
rescue LoadError
|
116
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
117
|
+
end
|
118
|
+
|
119
|
+
# These are new tasks
|
120
|
+
begin
|
121
|
+
require 'rake/contrib/sshpublisher'
|
122
|
+
namespace :rubyforge do
|
123
|
+
|
124
|
+
desc "Release gem and RDoc documentation to RubyForge"
|
125
|
+
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
126
|
+
|
127
|
+
namespace :release do
|
128
|
+
desc "Publish RDoc to RubyForge."
|
129
|
+
task :docs => [:rdoc] do
|
130
|
+
config = YAML.load(
|
131
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
132
|
+
)
|
133
|
+
|
134
|
+
host = "#{config['username']}@rubyforge.org"
|
135
|
+
remote_dir = "/var/www/gforge-projects/the-perfect-gem/"
|
136
|
+
local_dir = 'rdoc'
|
137
|
+
|
138
|
+
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
rescue LoadError
|
143
|
+
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
144
|
+
end
|
145
|
+
|
146
|
+
Now you must initially create a 'package' for your gem in your 'project':
|
147
|
+
|
148
|
+
$ rake rubyforge:setup
|
149
|
+
|
150
|
+
With all that setup out of the way, you can now release to RubyForge with impunity. This would release the current version of your gem, and upload the rdoc as your project's webpage.
|
151
|
+
|
152
|
+
$ rake rubyforge:release
|
153
|
+
|
154
|
+
## Workflow
|
155
|
+
|
156
|
+
* Hack, commit, hack, commit, etc, etc
|
157
|
+
* `rake version:bump:patch release` to do the actual version bump and release
|
158
|
+
* Have a delicious scotch
|
159
|
+
* Install [gemstalker](http://github.com/technicalpickles/gemstalker), and use it to know when gem is built. It typically builds in a few minutes, but won't be installable for another 15 minutes.
|
160
|
+
|
161
|
+
## Links
|
162
|
+
|
163
|
+
* [Bugs](http://technicalpickles.lighthouseapp.com/projects/23560-jeweler/overview)
|
164
|
+
* [Donate](http://pledgie.org/campaigns/2604)
|
data/Rakefile
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift('lib')
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
gem.name = "jeweler"
|
9
|
+
gem.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
10
|
+
gem.email = "josh@technicalpickles.com"
|
11
|
+
gem.homepage = "http://github.com/technicalpickles/jeweler"
|
12
|
+
gem.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
13
|
+
gem.authors = ["Josh Nichols"]
|
14
|
+
gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.document', 'lib/jeweler/templates/.gitignore']
|
15
|
+
gem.add_dependency "peterwald-git"
|
16
|
+
gem.rubyforge_project = "pickles"
|
17
|
+
end
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.pattern = 'test/**/test_*.rb'
|
25
|
+
test.libs << 'test'
|
26
|
+
test.verbose = true
|
27
|
+
#test.ruby_opts << '-rtest_helper'
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'rake/rdoctask'
|
31
|
+
Rake::RDocTask.new do |rdoc|
|
32
|
+
rdoc.rdoc_dir = 'rdoc'
|
33
|
+
rdoc.title = 'jeweler'
|
34
|
+
rdoc.rdoc_files.include('README.markdown')
|
35
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
36
|
+
end
|
37
|
+
|
38
|
+
begin
|
39
|
+
require 'rcov/rcovtask'
|
40
|
+
Rcov::RcovTask.new(:rcov) do |rcov|
|
41
|
+
rcov.libs << 'test'
|
42
|
+
rcov.pattern = 'test/**/test_*.rb'
|
43
|
+
end
|
44
|
+
rescue LoadError
|
45
|
+
task :rcov do
|
46
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
begin
|
51
|
+
require 'cucumber/rake/task'
|
52
|
+
Cucumber::Rake::Task.new(:features)
|
53
|
+
rescue LoadError
|
54
|
+
task :features do
|
55
|
+
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
begin
|
60
|
+
require 'rake/contrib/sshpublisher'
|
61
|
+
namespace :rubyforge do
|
62
|
+
|
63
|
+
desc "Release gem and RDoc documentation to RubyForge"
|
64
|
+
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
65
|
+
|
66
|
+
namespace :release do
|
67
|
+
desc "Publish RDoc to RubyForge."
|
68
|
+
task :docs => [:rdoc] do
|
69
|
+
config = YAML.load(
|
70
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
71
|
+
)
|
72
|
+
|
73
|
+
host = "#{config['username']}@rubyforge.org"
|
74
|
+
remote_dir = "/var/www/gforge-projects/pickles"
|
75
|
+
local_dir = 'rdoc'
|
76
|
+
|
77
|
+
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
rescue LoadError
|
82
|
+
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
83
|
+
end
|
84
|
+
|
85
|
+
if ENV["RUN_CODE_RUN"] == "true"
|
86
|
+
task :default => [:test, :features]
|
87
|
+
else
|
88
|
+
task :default => :test
|
89
|
+
end
|
data/TODO
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
* use some sort of logger instead of stdout and stderr
|
2
|
+
* jeweler --delete-repo
|
3
|
+
* output gemspec as yaml
|
4
|
+
* move interactions with github into separate class
|
5
|
+
* use Net::HTTP.post_form instead of `` for enabling gem creation
|
6
|
+
* Generators
|
7
|
+
* Rails generator for making a plugin that's Jeweler enabled
|
8
|
+
* Change generated test filename (test_foo not foo_test)
|
9
|
+
* Releasing
|
10
|
+
* Have a way to check if the gem is built yet
|
11
|
+
* Option for enabling
|
data/VERSION.yml
ADDED
data/bin/jeweler
ADDED
data/lib/jeweler.rb
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'rubygems/user_interaction'
|
3
|
+
require 'rubygems/builder'
|
4
|
+
require 'rubyforge'
|
5
|
+
|
6
|
+
require 'jeweler/errors'
|
7
|
+
require 'jeweler/version_helper'
|
8
|
+
require 'jeweler/gemspec_helper'
|
9
|
+
require 'jeweler/generator'
|
10
|
+
require 'jeweler/generator/options'
|
11
|
+
require 'jeweler/generator/application'
|
12
|
+
|
13
|
+
require 'jeweler/commands'
|
14
|
+
|
15
|
+
require 'jeweler/tasks'
|
16
|
+
|
17
|
+
# A Jeweler helps you craft the perfect Rubygem. Give him a gemspec, and he takes care of the rest.
|
18
|
+
class Jeweler
|
19
|
+
|
20
|
+
attr_reader :gemspec, :gemspec_helper, :version_helper
|
21
|
+
attr_accessor :base_dir, :output, :repo, :commit, :rubyforge
|
22
|
+
|
23
|
+
def initialize(gemspec, base_dir = '.')
|
24
|
+
raise(GemspecError, "Can't create a Jeweler with a nil gemspec") if gemspec.nil?
|
25
|
+
|
26
|
+
@base_dir = base_dir
|
27
|
+
@gemspec = fill_in_gemspec_defaults(gemspec)
|
28
|
+
@repo = Git.open(base_dir) if in_git_repo?
|
29
|
+
@version_helper = Jeweler::VersionHelper.new(@base_dir)
|
30
|
+
@output = $stdout
|
31
|
+
@commit = true
|
32
|
+
@gemspec_helper = GemSpecHelper.new(@gemspec, base_dir)
|
33
|
+
@rubyforge = RubyForge.new
|
34
|
+
end
|
35
|
+
|
36
|
+
# Major version, as defined by the gemspec's Version module.
|
37
|
+
# For 1.5.3, this would return 1.
|
38
|
+
def major_version
|
39
|
+
@version_helper.major
|
40
|
+
end
|
41
|
+
|
42
|
+
# Minor version, as defined by the gemspec's Version module.
|
43
|
+
# For 1.5.3, this would return 5.
|
44
|
+
def minor_version
|
45
|
+
@version_helper.minor
|
46
|
+
end
|
47
|
+
|
48
|
+
# Patch version, as defined by the gemspec's Version module.
|
49
|
+
# For 1.5.3, this would return 5.
|
50
|
+
def patch_version
|
51
|
+
@version_helper.patch
|
52
|
+
end
|
53
|
+
|
54
|
+
# Human readable version, which is used in the gemspec.
|
55
|
+
def version
|
56
|
+
@version_helper.to_s
|
57
|
+
end
|
58
|
+
|
59
|
+
# Writes out the gemspec
|
60
|
+
def write_gemspec
|
61
|
+
Jeweler::Commands::WriteGemspec.build_for(self).run
|
62
|
+
end
|
63
|
+
|
64
|
+
# Validates the project's gemspec from disk in an environment similar to how
|
65
|
+
# GitHub would build from it. See http://gist.github.com/16215
|
66
|
+
def validate_gemspec
|
67
|
+
Jeweler::Commands::ValidateGemspec.build_for(self).run
|
68
|
+
end
|
69
|
+
|
70
|
+
# is the project's gemspec from disk valid?
|
71
|
+
def valid_gemspec?
|
72
|
+
gemspec_helper.valid?
|
73
|
+
end
|
74
|
+
|
75
|
+
def build_gem
|
76
|
+
Jeweler::Commands::BuildGem.build_for(self).run
|
77
|
+
end
|
78
|
+
|
79
|
+
def install_gem
|
80
|
+
Jeweler::Commands::InstallGem.build_for(self).run
|
81
|
+
end
|
82
|
+
|
83
|
+
# Bumps the patch version.
|
84
|
+
#
|
85
|
+
# 1.5.1 -> 1.5.2
|
86
|
+
def bump_patch_version()
|
87
|
+
Jeweler::Commands::Version::BumpPatch.build_for(self).run
|
88
|
+
end
|
89
|
+
|
90
|
+
# Bumps the minor version.
|
91
|
+
#
|
92
|
+
# 1.5.1 -> 1.6.0
|
93
|
+
def bump_minor_version()
|
94
|
+
Jeweler::Commands::Version::BumpMinor.build_for(self).run
|
95
|
+
end
|
96
|
+
|
97
|
+
# Bumps the major version.
|
98
|
+
#
|
99
|
+
# 1.5.1 -> 2.0.0
|
100
|
+
def bump_major_version()
|
101
|
+
Jeweler::Commands::Version::BumpMajor.build_for(self).run
|
102
|
+
end
|
103
|
+
|
104
|
+
# Bumps the version, to the specific major/minor/patch version, writing out the appropriate version.rb, and then reloads it.
|
105
|
+
def write_version(major, minor, patch, options = {})
|
106
|
+
command = Jeweler::Commands::Version::Write.build_for(self)
|
107
|
+
command.major = major
|
108
|
+
command.minor = minor
|
109
|
+
command.patch = patch
|
110
|
+
|
111
|
+
command.run
|
112
|
+
end
|
113
|
+
|
114
|
+
def release
|
115
|
+
Jeweler::Commands::Release.build_for(self).run
|
116
|
+
end
|
117
|
+
|
118
|
+
def release_gem_to_rubyforge
|
119
|
+
Jeweler::Commands::ReleaseToRubyforge.build_for(self).run
|
120
|
+
end
|
121
|
+
|
122
|
+
def setup_rubyforge
|
123
|
+
Jeweler::Commands::SetupRubyforge.build_for(self).run
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
def in_git_repo?
|
128
|
+
File.exists?(File.join(self.base_dir, '.git'))
|
129
|
+
end
|
130
|
+
|
131
|
+
protected
|
132
|
+
|
133
|
+
def fill_in_gemspec_defaults(gemspec)
|
134
|
+
if gemspec.files.nil? || gemspec.files.empty?
|
135
|
+
gemspec.files = FileList["[A-Z]*.*", "{bin,generators,lib,test,spec}/**/*"]
|
136
|
+
end
|
137
|
+
|
138
|
+
if gemspec.executables.nil? || gemspec.executables.empty?
|
139
|
+
gemspec.executables = Dir["#{@base_dir}/bin/*"].map do |f|
|
140
|
+
File.basename(f)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
gemspec.has_rdoc = true
|
145
|
+
gemspec.rdoc_options << '--inline-source' << '--charset=UTF-8'
|
146
|
+
|
147
|
+
if gemspec.extra_rdoc_files.nil? || gemspec.extra_rdoc_files.empty?
|
148
|
+
gemspec.extra_rdoc_files = FileList["README*", "ChangeLog*", "LICENSE*"]
|
149
|
+
end
|
150
|
+
|
151
|
+
gemspec
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|