mattknox-jeweler 0.7.0

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.
@@ -0,0 +1,14 @@
1
+ # jeweler 0.6.6
2
+
3
+ * Added support to generator for specifying a description
4
+ * Condensed README.markdown to be less novel-like
5
+ * RDoc is now included in your gemspec
6
+ * Rescue errors that raise in the generator, and display better error message, and exit with a non-zero exit status
7
+
8
+ # jeweler 0.6.5
9
+
10
+ * `jeweler --create-repo foo` now enables gem creation in addition to creating the repository
11
+
12
+ # jeweler 0.6.4
13
+
14
+ * 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,90 @@
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
+ ## Setting up in an existing project
9
+
10
+ It's easy to get up and running. Update your instantiate a `Jeweler::Tasks`, and give it a block with details about your project.
11
+
12
+
13
+ begin
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |s|
16
+ s.name = "the-perfect-gem"
17
+ s.summary = "TODO"
18
+ s.email = "josh@technicalpickles.com"
19
+ s.homepage = "http://github.com/technicalpickles/the-perfect-gem"
20
+ s.description = "TODO"
21
+ s.authors = ["Josh Nichols"]
22
+ end
23
+ rescue LoadError
24
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
25
+ end
26
+
27
+ In this example, `s` is a Gem::Specification object. See the documentation for what possible values you can set on it.
28
+
29
+ ## Kicking off a new project
30
+
31
+ 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).
32
+
33
+ jeweler the-perfect-gem
34
+
35
+ This will prepare a project in the 'the-perfect-gem' directory, setup to use Jeweler.
36
+
37
+ It supports a number of options:
38
+
39
+ * --create-repo: in addition to preparing a project, it create an repo up on GitHub and enable RubyGem generation
40
+ * --shoulda: generate test_helper.rb and empty test ready for shoulda (this is the default)
41
+ * --bacon: generate spec_helper.rb and empty spec ready for bacon
42
+
43
+ ## Gemspec
44
+
45
+ Jeweler handles generating a gemspec file for your project:
46
+
47
+ rake gemspec
48
+
49
+ 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.
50
+
51
+ ## Gem
52
+
53
+ Jeweler gives you tasks for building and installing your gem:
54
+
55
+ rake build
56
+ rake install
57
+
58
+ ## Versioning
59
+
60
+ 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.
61
+
62
+ Initially, your project starts out at 0.0.0. Jeweler provides Rake tasks for bumping the version:
63
+
64
+ rake version:bump:major
65
+ rake version:bump:minor
66
+ rake version:bump:patch
67
+
68
+ ## Releasing
69
+
70
+ Jeweler handles releasing your gem into the wild:
71
+
72
+ rake release
73
+
74
+ It does the following for you:
75
+
76
+ * Regenerate the gemspec to the latest version of your project
77
+ * Push to GitHub (which results in a gem being build)
78
+ * Tag the version and push to GitHub
79
+
80
+ ## Workflow
81
+
82
+ * Hack, commit, hack, commit, etc, etc
83
+ * `rake version:bump:patch release` to do the actual version bump and release
84
+ * Have a delicious scotch
85
+ * Go to [Has My Gem Built Yet](http://hasmygembuiltyet.org) and wait for your gem to be built
86
+
87
+ ## Links
88
+
89
+ * [Bugs](http://technicalpickles.lighthouseapp.com/projects/23560-jeweler/overview)
90
+ * [Donate](http://pledgie.org/campaigns/2604)
data/Rakefile ADDED
@@ -0,0 +1,43 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ begin
4
+ require 'hanna/rdoctask'
5
+ rescue LoadError
6
+ require 'rake/rdoctask'
7
+ end
8
+
9
+ require 'rcov/rcovtask'
10
+
11
+ $:.unshift('lib')
12
+
13
+ begin
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |s|
16
+ s.name = "jeweler"
17
+ s.executables = "jeweler"
18
+ s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
19
+ s.email = "josh@technicalpickles.com"
20
+ s.homepage = "http://github.com/technicalpickles/jeweler"
21
+ s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
22
+ s.authors = ["Josh Nichols"]
23
+ s.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore']
24
+ s.add_dependency 'schacon-git'
25
+ end
26
+ rescue LoadError
27
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
28
+ end
29
+
30
+
31
+ Rake::TestTask.new
32
+
33
+ Rake::RDocTask.new do |rdoc|
34
+ rdoc.rdoc_dir = 'rdoc'
35
+ rdoc.title = 'jeweler'
36
+ rdoc.options << '--line-numbers' << '--inline-source'
37
+ rdoc.rdoc_files.include('README.markdown')
38
+ rdoc.rdoc_files.include('lib/**/*.rb')
39
+ end
40
+
41
+ Rcov::RcovTask.new
42
+
43
+ task :default => :rcov
data/TODO ADDED
@@ -0,0 +1,13 @@
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
+ * Support rspec?
9
+ * Support test/unit
10
+ * Change generated test filename (test_foo not foo_test)
11
+ * Releasing
12
+ * Open hasmygembuiltyet.org
13
+ * enable runcoderun by default
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :patch: 0
3
+ :major: 0
4
+ :minor: 7
data/bin/jeweler ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'optparse'
4
+
5
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
6
+ require 'jeweler'
7
+
8
+ class JewelerOpts < Hash
9
+ attr_reader :opts
10
+
11
+ def initialize(args)
12
+ super()
13
+
14
+ self[:test_style] = :shoulda
15
+
16
+ @opts = OptionParser.new do |o|
17
+ o.banner = "Usage: #{File.basename($0)} [options] reponame\ne.g. #{File.basename($0)} the-perfect-gem"
18
+
19
+ o.on('--bacon', 'generate bacon specs') do
20
+ self[:test_style] = :bacon
21
+ end
22
+
23
+ o.on('--shoulda', 'generate shoulda tests') do
24
+ self[:test_style] = :shoulda
25
+ end
26
+
27
+ o.on('--create-repo', 'create the repository on GitHub') do
28
+ self[:create_repo] = true
29
+ end
30
+
31
+ o.on('--summary [SUMMARY]', 'specify the summary of the project') do |summary|
32
+ self[:summary] = summary
33
+ end
34
+
35
+ o.on_tail('-h', '--help', 'display this help and exit') do
36
+ puts o
37
+ exit
38
+ end
39
+ end
40
+
41
+ @opts.parse!(args)
42
+ end
43
+ end
44
+
45
+ options = JewelerOpts.new(ARGV)
46
+
47
+ unless ARGV.size == 1
48
+ puts options.opts
49
+ exit 1
50
+ end
51
+
52
+ github_repo_name = ARGV.first
53
+
54
+ begin
55
+ generator = Jeweler::Generator.new github_repo_name, options
56
+ generator.run
57
+ rescue Jeweler::NoGitUserName
58
+ $stderr.puts %Q{No user.name found in ~/.gitconfig. Please tell git about yourself (see http://github.com/guides/tell-git-your-user-name-and-email-address for details). For example: git config --global user.name "mad voo"}
59
+ exit 1
60
+ rescue Jeweler::NoGitUserEmail
61
+ $stderr.puts %Q{No user.email found in ~/.gitconfig. Please tell git about yourself (see http://github.com/guides/tell-git-your-user-name-and-email-address for details). For example: git config --global user.email mad.vooo@gmail.com}
62
+ exit 1
63
+ rescue Jeweler::NoGitHubUser
64
+ $stderr.puts %Q{No github.user found in ~/.gitconfig. Please tell git about your GitHub account (see http://github.com/blog/180-local-github-config for details). For example: git config --global github.user defunkt}
65
+ exit 1
66
+ rescue Jeweler::NoGitHubToken
67
+ $stderr.puts %Q{No github.token found in ~/.gitconfig. Please tell git about your GitHub account (see http://github.com/blog/180-local-github-config for details). For example: git config --global github.token 6ef8395fecf207165f1a82178ae1b984}
68
+ exit 1
69
+ rescue Jeweler::FileInTheWay
70
+ $stderr.puts "The directory #{github_repo_name} already exists. Maybe move it out of the way before continuing?"
71
+ exit 1
72
+ end
data/lib/jeweler.rb ADDED
@@ -0,0 +1,231 @@
1
+ require 'date'
2
+ require 'rubygems/builder'
3
+
4
+ require 'jeweler/version'
5
+ require 'jeweler/gemspec'
6
+ require 'jeweler/errors'
7
+ require 'jeweler/generator'
8
+
9
+ require 'jeweler/tasks'
10
+
11
+ # A Jeweler helps you craft the perfect Rubygem. Give him a gemspec, and he takes care of the rest.
12
+ class Jeweler
13
+
14
+ attr_reader :gemspec
15
+ attr_accessor :base_dir
16
+
17
+ def initialize(gemspec, base_dir = '.')
18
+ raise(GemspecError, "Can't create a Jeweler with a nil gemspec") if gemspec.nil?
19
+ @gemspec = gemspec
20
+ @base_dir = base_dir
21
+
22
+ if @gemspec.files.nil? || @gemspec.files.empty?
23
+ @gemspec.files = FileList["[A-Z]*.*", "{bin,generators,lib,test,spec}/**/*"]
24
+ end
25
+
26
+ @gemspec.has_rdoc = true
27
+ @gemspec.rdoc_options << '--inline-source' << '--charset=UTF-8'
28
+ @gemspec.extra_rdoc_files ||= FileList["[A-Z]*.*"]
29
+
30
+ if File.exists?(File.join(base_dir, '.git'))
31
+ @repo = Git.open(base_dir)
32
+ end
33
+
34
+ @version = Jeweler::Version.new(@base_dir)
35
+ end
36
+
37
+ # Major version, as defined by the gemspec's Version module.
38
+ # For 1.5.3, this would return 1.
39
+ def major_version
40
+ @version.major
41
+ end
42
+
43
+ # Minor version, as defined by the gemspec's Version module.
44
+ # For 1.5.3, this would return 5.
45
+ def minor_version
46
+ @version.minor
47
+ end
48
+
49
+ # Patch version, as defined by the gemspec's Version module.
50
+ # For 1.5.3, this would return 5.
51
+ def patch_version
52
+ @version.patch
53
+ end
54
+
55
+ # Human readable version, which is used in the gemspec.
56
+ def version
57
+ @version.to_s
58
+ end
59
+
60
+ # Writes out the gemspec
61
+ def write_gemspec
62
+ self.refresh_version
63
+
64
+ helper = gemspec_helper do |s|
65
+ s.version = self.version
66
+ s.date = Time.now
67
+ end
68
+
69
+ helper.write
70
+
71
+ puts "Generated: #{helper.path}"
72
+ end
73
+
74
+ # Validates the project's gemspec from disk in an environment similar to how
75
+ # GitHub would build from it. See http://gist.github.com/16215
76
+ def validate_gemspec
77
+ begin
78
+ gemspec_helper.parse
79
+ puts "#{gemspec_path} is valid."
80
+ rescue Exception => e
81
+ puts "#{gemspec_path} is invalid. See the backtrace for more details."
82
+ raise
83
+ end
84
+ end
85
+
86
+
87
+ # is the project's gemspec from disk valid?
88
+ def valid_gemspec?
89
+ gemspec_helper.valid?
90
+ end
91
+
92
+ # parses the project's gemspec from disk without extra sanity checks
93
+ def unsafe_parse_gemspec(data = nil)
94
+ data ||= File.read(gemspec_path)
95
+ eval(data, binding, gemspec_path)
96
+ end
97
+
98
+ def build_gem
99
+ parsed_gemspec = unsafe_parse_gemspec()
100
+ Gem::Builder.new(parsed_gemspec).build
101
+
102
+ pkg_dir = File.join(@base_dir, 'pkg')
103
+ FileUtils.mkdir_p pkg_dir
104
+
105
+ gem_filename = File.join(@base_dir, parsed_gemspec.file_name)
106
+ FileUtils.mv gem_filename, pkg_dir
107
+ end
108
+
109
+ def install_gem
110
+ command = "sudo gem install #{gem_path}"
111
+ $stdout.puts "Executing #{command.inspect}:"
112
+ sh command
113
+ end
114
+
115
+ # Bumps the patch version.
116
+ #
117
+ # 1.5.1 -> 1.5.2
118
+ def bump_patch_version(options = {})
119
+ options = version_writing_options(options)
120
+
121
+ @version.bump_patch
122
+ @version.write
123
+
124
+ commit_version if options[:commit]
125
+ end
126
+
127
+ # Bumps the minor version.
128
+ #
129
+ # 1.5.1 -> 1.6.0
130
+ def bump_minor_version(options = {})
131
+ options = version_writing_options(options)
132
+
133
+ @version.bump_minor
134
+ @version.write
135
+
136
+ commit_version if options[:commit]
137
+ end
138
+
139
+ # Bumps the major version.
140
+ #
141
+ # 1.5.1 -> 2.0.0
142
+ def bump_major_version(options = {})
143
+ options = version_writing_options(options)
144
+
145
+ @version.bump_major
146
+ @version.write
147
+
148
+ commit_version if options[:commit]
149
+ end
150
+
151
+ # Bumps the version, to the specific major/minor/patch version, writing out the appropriate version.rb, and then reloads it.
152
+ def write_version(major, minor, patch, options = {})
153
+ options = version_writing_options(options)
154
+
155
+ @version.update_to major, minor, patch
156
+ @version.write
157
+
158
+ @gemspec.version = @version.to_s
159
+
160
+ commit_version if options[:commit]
161
+ end
162
+
163
+
164
+ def release
165
+ @repo.checkout('master')
166
+
167
+ raise "Hey buddy, try committing them files first" if any_pending_changes?
168
+
169
+ write_gemspec()
170
+
171
+ @repo.add(gemspec_path)
172
+ $stdout.puts "Committing #{gemspec_path}"
173
+ @repo.commit("Regenerated gemspec for version #{version}")
174
+
175
+ $stdout.puts "Pushing master to origin"
176
+ @repo.push
177
+
178
+ $stdout.puts "Tagging #{release_tag}"
179
+ @repo.add_tag(release_tag)
180
+
181
+ $stdout.puts "Pushing #{release_tag} to origin"
182
+ @repo.push('origin', release_tag)
183
+ end
184
+
185
+ def release_tag
186
+ @release_tag ||= "v#{version}"
187
+ end
188
+
189
+ protected
190
+
191
+ def version_writing_options(options)
192
+ {:commit => true}.merge(options)
193
+ end
194
+
195
+ def commit_version
196
+ if @repo
197
+ @repo.add('VERSION.yml')
198
+ @repo.commit("Version bump to #{version}", 'VERSION.yml')
199
+ end
200
+ end
201
+
202
+ def refresh_version
203
+ @version.refresh
204
+ end
205
+
206
+ def gemspec_helper(&block)
207
+ GemSpecHelper.new(@gemspec, @base_dir, &block)
208
+ end
209
+
210
+ def gemspec_path
211
+ gemspec_helper.path
212
+ end
213
+
214
+ def gem_path
215
+ parsed_gemspec = unsafe_parse_gemspec()
216
+ File.join(@base_dir, 'pkg', parsed_gemspec.file_name)
217
+ end
218
+
219
+ def any_pending_changes?
220
+ unless ENV['JEWELER_DEBUG'].nil? || ENV['JEWELER_DEBUG'].squeeze == ''
221
+ require 'ruby-debug'; breakpoint
222
+ end
223
+ !(@repo.status.added.empty? && @repo.status.deleted.empty? && @repo.status.changed.empty?)
224
+ end
225
+
226
+ protected
227
+ def any_pending_changes?
228
+ !(@repo.status.added.empty? && @repo.status.deleted.empty? && @repo.status.changed.empty?)
229
+ end
230
+ end
231
+