jeweler 1.8.2 → 2.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +2 -0
- data/.semver +5 -0
- data/.travis.yml +5 -3
- data/ChangeLog.markdown +30 -0
- data/Gemfile +32 -25
- data/Gemfile.lock +117 -46
- data/README.markdown +36 -10
- data/README.org +374 -0
- data/Rakefile +23 -28
- data/bin/jeweler +1 -0
- data/features/generator/gemfile.feature +1 -0
- data/features/generator/test.feature +2 -2
- data/features/step_definitions/debug_steps.rb +0 -1
- data/features/step_definitions/filesystem_steps.rb +2 -3
- data/features/step_definitions/generator_steps.rb +44 -66
- data/features/step_definitions/task_steps.rb +1 -2
- data/features/support/env.rb +22 -9
- data/jeweler.gemspec +64 -45
- data/lib/jeweler/commands/build_gem.rb +6 -2
- data/lib/jeweler/commands/check_dependencies.rb +3 -3
- data/lib/jeweler/commands/install_gem.rb +1 -1
- data/lib/jeweler/commands/release_gemspec.rb +17 -14
- data/lib/jeweler/commands/release_to_git.rb +20 -11
- data/lib/jeweler/commands/validate_gemspec.rb +5 -7
- data/lib/jeweler/commands/version/base.rb +8 -13
- data/lib/jeweler/commands/version/bump_major.rb +1 -3
- data/lib/jeweler/commands/version/bump_minor.rb +1 -2
- data/lib/jeweler/commands/version/bump_patch.rb +1 -4
- data/lib/jeweler/commands/write_gemspec.rb +4 -3
- data/lib/jeweler/commands.rb +6 -6
- data/lib/jeweler/gemspec_helper.rb +15 -15
- data/lib/jeweler/generator/application.rb +5 -10
- data/lib/jeweler/generator/bacon_mixin.rb +2 -4
- data/lib/jeweler/generator/github_mixin.rb +1 -10
- data/lib/jeweler/generator/micronaut_mixin.rb +3 -3
- data/lib/jeweler/generator/minitest_mixin.rb +2 -3
- data/lib/jeweler/generator/options.rb +16 -25
- data/lib/jeweler/generator/rdoc_mixin.rb +1 -1
- data/lib/jeweler/generator/riot_mixin.rb +2 -3
- data/lib/jeweler/generator/rspec_mixin.rb +2 -3
- data/lib/jeweler/generator/shindo_mixin.rb +2 -3
- data/lib/jeweler/generator/shoulda_mixin.rb +2 -3
- data/lib/jeweler/generator/testspec_mixin.rb +2 -3
- data/lib/jeweler/generator/testunit_mixin.rb +1 -3
- data/lib/jeweler/generator/yard_mixin.rb +3 -4
- data/lib/jeweler/generator.rb +52 -45
- data/lib/jeweler/rubyforge_tasks.rb +13 -13
- data/lib/jeweler/rubygems_dot_org_tasks.rb +3 -3
- data/lib/jeweler/rubygems_tasks.rb +3 -3
- data/lib/jeweler/specification.rb +22 -11
- data/lib/jeweler/tasks.rb +68 -59
- data/lib/jeweler/templates/Gemfile +1 -1
- data/lib/jeweler/templates/bacon/flunking.rb +3 -3
- data/lib/jeweler/templates/bacon/helper.rb +1 -0
- data/lib/jeweler/templates/features/support/env.rb +1 -0
- data/lib/jeweler/templates/jeweler_tasks.erb +1 -1
- data/lib/jeweler/templates/micronaut/flunking.rb +3 -3
- data/lib/jeweler/templates/micronaut/helper.rb +1 -0
- data/lib/jeweler/templates/minitest/flunking.rb +1 -1
- data/lib/jeweler/templates/minitest/helper.rb +4 -3
- data/lib/jeweler/templates/other_tasks.erb +4 -20
- data/lib/jeweler/templates/riot/flunking.rb +1 -1
- data/lib/jeweler/templates/riot/helper.rb +1 -0
- data/lib/jeweler/templates/rspec/flunking.rb +3 -3
- data/lib/jeweler/templates/rspec/helper.rb +3 -1
- data/lib/jeweler/templates/shindo/flunking.rb +3 -3
- data/lib/jeweler/templates/shindo/helper.rb +1 -0
- data/lib/jeweler/templates/shoulda/helper.rb +1 -0
- data/lib/jeweler/templates/simplecov.erb +16 -0
- data/lib/jeweler/templates/testspec/flunking.rb +3 -3
- data/lib/jeweler/templates/testspec/helper.rb +1 -1
- data/lib/jeweler/templates/testunit/helper.rb +1 -0
- data/lib/jeweler/version.rb +3 -3
- data/lib/jeweler/version_helper.rb +18 -15
- data/lib/jeweler.rb +23 -23
- data/test/fixtures/bar/lib/foo_the_ultimate_lib.rb +1 -1
- data/test/fixtures/existing-project-with-version-constant/Rakefile +18 -20
- data/test/fixtures/existing-project-with-version-constant/existing-project-with-version.gemspec +15 -17
- data/test/fixtures/existing-project-with-version-constant/test/existing_project_with_version_test.rb +2 -2
- data/test/fixtures/existing-project-with-version-plaintext/Rakefile +17 -19
- data/test/fixtures/existing-project-with-version-plaintext/existing-project-with-version.gemspec +15 -17
- data/test/fixtures/existing-project-with-version-plaintext/test/existing_project_with_version_test.rb +2 -2
- data/test/fixtures/existing-project-with-version-yaml/Rakefile +17 -19
- data/test/fixtures/existing-project-with-version-yaml/existing-project-with-version.gemspec +15 -17
- data/test/fixtures/existing-project-with-version-yaml/test/existing_project_with_version_test.rb +2 -2
- data/test/jeweler/commands/test_build_gem.rb +33 -27
- data/test/jeweler/commands/test_install_gem.rb +7 -7
- data/test/jeweler/commands/test_release_to_gemcutter.rb +6 -7
- data/test/jeweler/commands/test_release_to_git.rb +95 -37
- data/test/jeweler/commands/test_release_to_github.rb +161 -97
- data/test/jeweler/commands/test_validate_gemspec.rb +4 -6
- data/test/jeweler/commands/test_write_gemspec.rb +21 -24
- data/test/jeweler/commands/version/test_base.rb +26 -6
- data/test/jeweler/commands/version/test_bump_major.rb +1 -5
- data/test/jeweler/commands/version/test_bump_minor.rb +1 -2
- data/test/jeweler/commands/version/test_bump_patch.rb +1 -3
- data/test/jeweler/commands/version/test_write.rb +1 -3
- data/test/jeweler/generator/test_application.rb +22 -26
- data/test/jeweler/generator/test_options.rb +26 -38
- data/test/jeweler/test_gemspec_helper.rb +7 -7
- data/test/jeweler/test_generator.rb +31 -33
- data/test/jeweler/test_generator_initialization.rb +40 -57
- data/test/jeweler/test_generator_mixins.rb +6 -7
- data/test/jeweler/test_specification.rb +44 -43
- data/test/jeweler/test_tasks.rb +2 -3
- data/test/jeweler/test_version_helper.rb +33 -35
- data/test/shoulda_macros/jeweler_macros.rb +5 -5
- data/test/test_helper.rb +25 -31
- data/test/test_jeweler.rb +28 -29
- metadata +206 -165
data/README.org
ADDED
@@ -0,0 +1,374 @@
|
|
1
|
+
/Jeweler maintenance has now shifted to Fred Mitchell/. I am now
|
2
|
+
maintaining both Jeweler and its fork, juwelier. I will keep Jeweler at
|
3
|
+
least functional with the latest Ruby releases, but put new features in
|
4
|
+
Juwelier. Your input on this is more than welcome.
|
5
|
+
|
6
|
+
* Jeweler: Craft the perfect RubyGem
|
7
|
+
|
8
|
+
[[https://gitter.im/technicalpickles/jeweler?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge][[[https://badges.gitter.im/technicalpickles/jeweler.svg]]]]
|
9
|
+
|
10
|
+
Jeweler provides the noble ruby developer with two primary features:
|
11
|
+
|
12
|
+
- a library for managing and releasing RubyGem projects
|
13
|
+
- a scaffold generator for starting new RubyGem projects
|
14
|
+
|
15
|
+
PLEASE NOTE that if you are starting afresh, please use the successor
|
16
|
+
[[https://github.com/flajann2/juwelier][Juwelier]] I (Fred Mitchell, flajann2) will be maintaining both Jeweler and Juwelier, but will be
|
17
|
+
adding new features to Juwelier, and eventually "merge" this one into
|
18
|
+
Juwelier after some namespace issues are dealt with.
|
19
|
+
|
20
|
+
[[https://travis-ci.org/technicalpickles/jeweler][[[https://travis-ci.org/technicalpickles/jeweler.png]]]]
|
21
|
+
[[https://coveralls.io/r/technicalpickles/jeweler][[[https://coveralls.io/repos/technicalpickles/jeweler/badge.png]]]]
|
22
|
+
[[https://www.versioneye.com/ruby/jeweler/2.0.0][[[https://www.versioneye.com/ruby/jeweler/2.0.0/badge.png]]]]
|
23
|
+
[[https://codeclimate.com/github/technicalpickles/jeweler][[[https://codeclimate.com/github/technicalpickles/jeweler/badges/gpa.svg]]]]
|
24
|
+
|
25
|
+
** Hello, world
|
26
|
+
|
27
|
+
Use RubyGems to install the heck out of jeweler to get started:
|
28
|
+
|
29
|
+
#+BEGIN_EXAMPLE
|
30
|
+
$ gem install jeweler
|
31
|
+
#+END_EXAMPLE
|
32
|
+
|
33
|
+
With jeweler installed, you can use the =jeweler= command to generate a
|
34
|
+
new project. For the most basic use, just give it a name:
|
35
|
+
|
36
|
+
#+BEGIN_EXAMPLE
|
37
|
+
$ jeweler hello-gem
|
38
|
+
#+END_EXAMPLE
|
39
|
+
|
40
|
+
This requires some Git configuration (like name, email, GitHub account,
|
41
|
+
etc), but =jeweler= will prompt along the way.
|
42
|
+
|
43
|
+
Your new =hello-gem= gem is ready in the =hello-gem= directory. Take a
|
44
|
+
peek, and you'll see several files and directories
|
45
|
+
|
46
|
+
- =Rakefile= setup for jeweler, running tests, generating
|
47
|
+
documentation, and releasing to
|
48
|
+
[[http://rubygems.org/][rubygems.org]]
|
49
|
+
- =README.rdoc= with contribution guidelines and copyright info
|
50
|
+
crediting you
|
51
|
+
- =LICENSE= with the MIT licensed crediting you
|
52
|
+
- =Gemfile= with development dependencies filled in
|
53
|
+
- =lib/hello-gem.rb= waiting for you to code
|
54
|
+
- =test/= containing a (failing) shoulda test suite
|
55
|
+
[[http://github.com/thoughtbot/shoulda][shoulda]]
|
56
|
+
|
57
|
+
*** More =jeweler= options
|
58
|
+
|
59
|
+
The =jeweler= command supports a lot of options. Mostly, they are for
|
60
|
+
generating baked in support for this test framework, or that.
|
61
|
+
|
62
|
+
Check out =jeweler --help= for the most up to date options.
|
63
|
+
|
64
|
+
** Hello, rake tasks
|
65
|
+
|
66
|
+
Beyond just editing source code, you'll be interacting with your gem
|
67
|
+
using =rake= a lot. To see all the tasks available with a brief
|
68
|
+
description, you can run:
|
69
|
+
|
70
|
+
#+BEGIN_EXAMPLE
|
71
|
+
$ rake -T
|
72
|
+
#+END_EXAMPLE
|
73
|
+
|
74
|
+
You'll need a version before you can start installing your gem locally.
|
75
|
+
The easiest way is with the =version:write= Rake task. Let's imagine you
|
76
|
+
start with 0.1.0
|
77
|
+
|
78
|
+
#+BEGIN_EXAMPLE
|
79
|
+
$ rake version:write MAJOR=0 MINOR=1 PATCH=0
|
80
|
+
#+END_EXAMPLE
|
81
|
+
|
82
|
+
You can now go forth and develop, now that there's an initial version
|
83
|
+
defined. Eventually, you should install and test the gem:
|
84
|
+
|
85
|
+
#+BEGIN_EXAMPLE
|
86
|
+
$ rake install
|
87
|
+
#+END_EXAMPLE
|
88
|
+
|
89
|
+
The =install= rake task builds the gem and =gem install=s it. You're all
|
90
|
+
set if you're using [[http://rvm.beginrescueend.com/][RVM]], but you may
|
91
|
+
need to run it with sudo if you have a system-installed ruby:
|
92
|
+
|
93
|
+
#+BEGIN_EXAMPLE
|
94
|
+
$ sudo rake install
|
95
|
+
#+END_EXAMPLE
|
96
|
+
|
97
|
+
*** Releasing
|
98
|
+
|
99
|
+
At last, it's time to [[http://shipitsquirrel.github.com/][ship it]]!
|
100
|
+
Make sure you have everything committed and pushed, then go wild:
|
101
|
+
|
102
|
+
#+BEGIN_EXAMPLE
|
103
|
+
$ rake release
|
104
|
+
#+END_EXAMPLE
|
105
|
+
|
106
|
+
This will automatically:
|
107
|
+
|
108
|
+
- Generate =hello-gem.gemspec= and commit it
|
109
|
+
- Use =git= to tag =v0.1.0= and push it
|
110
|
+
- Build =hello-gem-0.1.0.gem= and push it to
|
111
|
+
[[http://rubygems.org/gems/][rubygems.org]]
|
112
|
+
|
113
|
+
=rake release= accepts REMOTE(default: =origin=), LOCAL\_BRANCH(default:
|
114
|
+
=master=), REMOTE\_BRANCH(default: =master=) and BRANCH(default:
|
115
|
+
master)as options.
|
116
|
+
|
117
|
+
#+BEGIN_EXAMPLE
|
118
|
+
$ rake release REMOTE=upstream LOCAL_BRANCH=critical-security-fix REMOTE_BRANCH=v3
|
119
|
+
#+END_EXAMPLE
|
120
|
+
|
121
|
+
This will tag and push the commits on your local branch named
|
122
|
+
=critical-security-fix= to branch named =v3= in remote named =upstream=
|
123
|
+
(if you have commit rights on =upstream=) and release the gem.
|
124
|
+
|
125
|
+
#+BEGIN_EXAMPLE
|
126
|
+
$ rake release BRANCH=v3
|
127
|
+
#+END_EXAMPLE
|
128
|
+
|
129
|
+
If both remote and local branches are the same, use =BRANCH= option to
|
130
|
+
simplify. This will tag and push the commits on your local branch named
|
131
|
+
=v3= to branch named =v3= in remote named =origin= (if you have commit
|
132
|
+
rights on =origin=) and release the gem.
|
133
|
+
|
134
|
+
*** Version bumping
|
135
|
+
|
136
|
+
It feels good to release code. Do it, do it often. But before that, bump
|
137
|
+
the version. Then release it. There's a few ways to update the version:
|
138
|
+
|
139
|
+
#+BEGIN_EXAMPLE
|
140
|
+
# version:write like before
|
141
|
+
$ rake version:write MAJOR=0 MINOR=3 PATCH=0
|
142
|
+
|
143
|
+
# bump just major, ie 0.1.0 -> 1.0.0
|
144
|
+
$ rake version:bump:major
|
145
|
+
|
146
|
+
# bump just minor, ie 0.1.0 -> 0.2.0
|
147
|
+
$ rake version:bump:minor
|
148
|
+
|
149
|
+
# bump just patch, ie 0.1.0 -> 0.1.1
|
150
|
+
$ rake version:bump:patch
|
151
|
+
#+END_EXAMPLE
|
152
|
+
|
153
|
+
Then it's the same =release= we used before:
|
154
|
+
|
155
|
+
#+BEGIN_EXAMPLE
|
156
|
+
$ rake release
|
157
|
+
#+END_EXAMPLE
|
158
|
+
|
159
|
+
** Customizing your gem
|
160
|
+
|
161
|
+
If you've been following along so far, your gem is just a blank slate.
|
162
|
+
You're going to need to make it colorful and full of metadata.
|
163
|
+
|
164
|
+
You can customize your gem by updating your =Rakefile=. With a newly
|
165
|
+
generated project, it will look something like this:
|
166
|
+
|
167
|
+
#+BEGIN_EXAMPLE
|
168
|
+
require 'jeweler'
|
169
|
+
Jeweler::Tasks.new do |gem|
|
170
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
171
|
+
gem.name = "whatwhatwhat"
|
172
|
+
gem.summary = %Q{TODO: one-line summary of your gem}
|
173
|
+
gem.description = %Q{TODO: longer description of your gem}
|
174
|
+
gem.email = "josh@technicalpickles.com"
|
175
|
+
gem.homepage = "http://github.com/technicalpickles/whatwhatwhat"
|
176
|
+
gem.authors = ["Joshua Nichols"]
|
177
|
+
end
|
178
|
+
Jeweler::RubygemsDotOrgTasks.new
|
179
|
+
#+END_EXAMPLE
|
180
|
+
|
181
|
+
It's crucial to understand the =gem= object is just a
|
182
|
+
Gem::Specification. You can read up about it at
|
183
|
+
[[http://guides.rubygems.org/specification-reference/][guides.rubygems.org/specification-reference]].
|
184
|
+
This is the most basic way of specifying a gem, Jeweler-managed or not.
|
185
|
+
Jeweler just exposes this to you, in addition to providing some
|
186
|
+
reasonable defaults, which we'll explore now.
|
187
|
+
|
188
|
+
*** Project information
|
189
|
+
|
190
|
+
#+BEGIN_EXAMPLE
|
191
|
+
gem.name = "whatwhatwhat"
|
192
|
+
#+END_EXAMPLE
|
193
|
+
|
194
|
+
Every gem has a name. Among other things, the gem name is how you are
|
195
|
+
able to =gem install= it.
|
196
|
+
[[http://guides.rubygems.org/specification-reference/#name][Reference]]
|
197
|
+
|
198
|
+
#+BEGIN_EXAMPLE
|
199
|
+
gem.summary = %Q{TODO: one-line summary of your gem}
|
200
|
+
#+END_EXAMPLE
|
201
|
+
|
202
|
+
This is a one line summary of your gem. This is displayed, for example,
|
203
|
+
when you use =gem list --details= or view it on
|
204
|
+
[[http://rubygems.org/gems/][rubygems.org]].
|
205
|
+
|
206
|
+
#+BEGIN_EXAMPLE
|
207
|
+
gem.description = %Q{TODO: longer description of your gem}
|
208
|
+
#+END_EXAMPLE
|
209
|
+
|
210
|
+
Description is a longer description. Scholars ascertain that knowledge
|
211
|
+
of where the description is used was lost centuries ago.
|
212
|
+
|
213
|
+
#+BEGIN_EXAMPLE
|
214
|
+
gem.email = "josh@technicalpickles.com"
|
215
|
+
#+END_EXAMPLE
|
216
|
+
|
217
|
+
This should be a way to get a hold of you regarding the gem.
|
218
|
+
|
219
|
+
#+BEGIN_EXAMPLE
|
220
|
+
gem.homepage = "http://github.com/technicalpickles/whatwhatwhat"
|
221
|
+
#+END_EXAMPLE
|
222
|
+
|
223
|
+
The homepage should have more information about your gem. The jeweler
|
224
|
+
generator guesses this based on the assumption your code lives on
|
225
|
+
[[http://github.com/][GitHub]], using your Git configuration to find
|
226
|
+
your GitHub username. This is displayed by =gem list --details= and on
|
227
|
+
rubygems.org.
|
228
|
+
|
229
|
+
#+BEGIN_EXAMPLE
|
230
|
+
gem.authors = ["Joshua Nichols"]
|
231
|
+
#+END_EXAMPLE
|
232
|
+
|
233
|
+
Hey, this is you, the author (or me in this case). The =jeweler=
|
234
|
+
generator also guesses this from your Git configuration. This is
|
235
|
+
displayed by =gem list --details= and on rubygems.org.
|
236
|
+
|
237
|
+
*** Files
|
238
|
+
|
239
|
+
The quickest way to add more files is to =git add= them. Jeweler uses
|
240
|
+
your Git repository to populate your gem's files by including added and
|
241
|
+
committed and excluding =.gitignore=d. In most cases, this is reasonable
|
242
|
+
enough.
|
243
|
+
|
244
|
+
If you need to tweak the files, that's cool. Jeweler populates
|
245
|
+
=gem.files= as a =Rake::FileList=. It's like a normal array, except you
|
246
|
+
can =include= and =exclude= file globs:
|
247
|
+
|
248
|
+
#+BEGIN_EXAMPLE
|
249
|
+
gem.files.exclude 'tmp' # exclude temporary directory
|
250
|
+
gem.files.include 'lib/foo/bar.rb' # explicitly include lib/foo/bar.rb
|
251
|
+
#+END_EXAMPLE
|
252
|
+
|
253
|
+
If that's not enough, you can just set =gem.files= outright
|
254
|
+
|
255
|
+
#+BEGIN_EXAMPLE
|
256
|
+
gem.files = Dir.glob('lib/**/*.rb')
|
257
|
+
#+END_EXAMPLE
|
258
|
+
|
259
|
+
*** Dependencies
|
260
|
+
|
261
|
+
Dependencies let you define other gems that your gem needs to function.
|
262
|
+
=gem install your-gem= will install your-gem's dependencies along with
|
263
|
+
it, and when you use your-gem in an application, the dependencies will
|
264
|
+
be made available. Use =gem.add_dependency= to register them.
|
265
|
+
[[http://guides.rubygems.org/specification-reference/#add_development_dependency][Reference]]
|
266
|
+
|
267
|
+
#+BEGIN_EXAMPLE
|
268
|
+
gem.add_dependency 'nokogiri'
|
269
|
+
#+END_EXAMPLE
|
270
|
+
|
271
|
+
This will ensure a version of =nokogiri= is installed, but it doesn't
|
272
|
+
require anything more than that. You can provide extra args to be more
|
273
|
+
specific:
|
274
|
+
|
275
|
+
#+BEGIN_EXAMPLE
|
276
|
+
gem.add_dependency 'nokogiri', '= 1.2.1' # exactly version 1.2.1
|
277
|
+
gem.add_dependency 'nokogiri', '>= 1.2.1' # greater than or equal to 1.2.1, ie, 1.2.1, 1.2.2, 1.3.0, 2.0.0, etc
|
278
|
+
gem.add_dependency 'nokogiri', '>= 1.2.1', '< 1.3.0' # greater than or equal to 1.2.1, but less than 1.3.0
|
279
|
+
gem.add_dependency 'nokogiri', '~> 1.2.1' # same thing, but more concise
|
280
|
+
#+END_EXAMPLE
|
281
|
+
|
282
|
+
When specifying which version is required, there's a bit of the
|
283
|
+
condunrum. You want to allow the most versions possible, but you want to
|
284
|
+
be sure they are compatible. Using =>= 1.2.1= is fine most of the time,
|
285
|
+
except until the point that 2.0.0 comes out and totally breaks backwards
|
286
|
+
the API. That's when it's good to use =~> 1.2.1=, which requires any
|
287
|
+
version in the =1.2= family, starting with =1.2.1=.
|
288
|
+
|
289
|
+
*** Executables
|
290
|
+
|
291
|
+
Executables let your gem install shell commands. Just put any executable
|
292
|
+
scripts in the =bin/= directory, make sure they are added using =git=,
|
293
|
+
and Jeweler will take care of the rest.
|
294
|
+
|
295
|
+
When you need more finely grained control over it, you can set it
|
296
|
+
yourself:
|
297
|
+
|
298
|
+
#+BEGIN_EXAMPLE
|
299
|
+
gem.executables = ['foo'] # note, it's the file name relative to `bin/`, not the project root
|
300
|
+
#+END_EXAMPLE
|
301
|
+
|
302
|
+
*** Versioning
|
303
|
+
|
304
|
+
We discussed earlier how to bump the version. The rake tasks are really
|
305
|
+
just convience methods for manipulating the =VERSION= file. It just
|
306
|
+
contains a version string, like =1.2.3=.
|
307
|
+
|
308
|
+
=VERSION= is a convention used by Jeweler, and is used to populate
|
309
|
+
=gem.version=. You can actually set this yourself, and Jeweler won't try
|
310
|
+
to override it:
|
311
|
+
|
312
|
+
#+BEGIN_EXAMPLE
|
313
|
+
gem.version = '1.2.3'
|
314
|
+
#+END_EXAMPLE
|
315
|
+
|
316
|
+
A common pattern is to have this in a version constant in your library.
|
317
|
+
This is convenient, because users of the library can query the version
|
318
|
+
they are using at runtime.
|
319
|
+
|
320
|
+
#+BEGIN_EXAMPLE
|
321
|
+
# in lib/foo/version.rb
|
322
|
+
class Foo
|
323
|
+
module Version
|
324
|
+
MAJOR = 1
|
325
|
+
MINOR = 2
|
326
|
+
PATCH = 3
|
327
|
+
BUILD = 'pre3'
|
328
|
+
|
329
|
+
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
# in Rakefile
|
334
|
+
require 'jeweler'
|
335
|
+
require './lib/foo/version.rb'
|
336
|
+
Jeweler::Tasks.new do |gem|
|
337
|
+
# snip
|
338
|
+
gem.version = Foo::Version::STRING
|
339
|
+
end
|
340
|
+
#+END_EXAMPLE
|
341
|
+
|
342
|
+
*** Rake tasks
|
343
|
+
|
344
|
+
Jeweler lives inside of Rake. As a result, they are dear friends. But,
|
345
|
+
that friendship doesn't interfere with typical Rake operations.
|
346
|
+
|
347
|
+
That means you can define your own namespaces, tasks, or use third party
|
348
|
+
Rake libraries without cause for concern.
|
349
|
+
|
350
|
+
** Contributing to Jeweler
|
351
|
+
|
352
|
+
- Check out the latest master to make sure the feature hasn't been
|
353
|
+
implemented or the bug hasn't been fixed yet
|
354
|
+
- Ask on the [[http://groups.google.com/group/jeweler-rb][mailing
|
355
|
+
list]] for feedback on your proposal, to see if somebody else has
|
356
|
+
done it.
|
357
|
+
- Check out the
|
358
|
+
[[http://github.com/technicalpickles/jeweler/issues][issue tracker]]
|
359
|
+
to make sure someone already hasn't requested it and/or contributed
|
360
|
+
it
|
361
|
+
- Fork the project
|
362
|
+
- Start a feature/bugfix branch
|
363
|
+
- Commit and push until you are happy with your contribution
|
364
|
+
- Make sure to add tests for the feature/bugfix. This is important so I
|
365
|
+
don't break it in a future version unintentionally.
|
366
|
+
- Please try not to mess with the Rakefile, version, or history. If you
|
367
|
+
want to have your own version, or is otherwise necessary, that is
|
368
|
+
fine, but please isolate it to its own commit so I can cherry-pick
|
369
|
+
around it.
|
370
|
+
|
371
|
+
** Copyright
|
372
|
+
|
373
|
+
Copyright (c) 2008-2010 Josh Nichols. Copyright (c) 2016 Fred Mitchell.
|
374
|
+
See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -2,32 +2,34 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'bundler'
|
5
|
+
require 'semver'
|
6
|
+
|
7
|
+
def s_version
|
8
|
+
SemVer.find.format "%M.%m.%p%s"
|
9
|
+
end
|
5
10
|
|
6
11
|
begin
|
7
|
-
Bundler.setup(:default, :development)
|
12
|
+
Bundler.setup(:default, :xzibit, :development)
|
8
13
|
rescue Bundler::BundlerError => e
|
9
14
|
$stderr.puts e.message
|
10
|
-
$stderr.puts
|
15
|
+
$stderr.puts 'Run `bundle install` to install missing gems'
|
11
16
|
exit e.status_code
|
12
17
|
end
|
13
18
|
|
14
|
-
$LOAD_PATH.unshift('lib')
|
15
|
-
|
16
19
|
require 'rake'
|
17
20
|
require 'jeweler'
|
18
21
|
|
19
22
|
Jeweler::Tasks.new do |gem|
|
20
|
-
gem.name =
|
21
|
-
gem.version =
|
22
|
-
gem.homepage =
|
23
|
-
gem.summary =
|
24
|
-
gem.description =
|
25
|
-
gem.
|
26
|
-
gem.
|
27
|
-
gem.
|
23
|
+
gem.name = 'jeweler'
|
24
|
+
gem.version = s_version
|
25
|
+
gem.homepage = 'http://github.com/technicalpickles/jeweler'
|
26
|
+
gem.summary = 'Opinionated tool for creating and managing RubyGem projects'
|
27
|
+
gem.description = 'Simple and opinionated helper for creating Rubygem projects on GitHub'
|
28
|
+
gem.required_ruby_version = '>= 2.2.0'
|
29
|
+
gem.license = 'MIT'
|
30
|
+
gem.authors = ["Fred Mitchell", "Josh Nichols", "Yusuke Murata"]
|
31
|
+
gem.email = ["fred.mitchell@gmx.de", "fred.mitchell@gmx.com", "info@muratayusuke.com"]
|
28
32
|
gem.files.include %w(lib/jeweler/templates/.document lib/jeweler/templates/.gitignore)
|
29
|
-
|
30
|
-
# dependencies defined in Gemfile
|
31
33
|
end
|
32
34
|
|
33
35
|
Jeweler::RubygemsDotOrgTasks.new
|
@@ -46,7 +48,7 @@ namespace :test do
|
|
46
48
|
task :gemspec_dup do
|
47
49
|
gemspec = Rake.application.jeweler.gemspec
|
48
50
|
dupped_gemspec = gemspec.dup
|
49
|
-
|
51
|
+
_cloned_gemspec = gemspec.clone
|
50
52
|
puts gemspec.to_ruby
|
51
53
|
puts dupped_gemspec.to_ruby
|
52
54
|
end
|
@@ -54,28 +56,21 @@ end
|
|
54
56
|
|
55
57
|
require 'yard'
|
56
58
|
YARD::Rake::YardocTask.new do |t|
|
57
|
-
t.files
|
58
|
-
end
|
59
|
-
|
60
|
-
require 'rcov/rcovtask'
|
61
|
-
Rcov::RcovTask.new(:rcov => :check_dependencies) do |rcov|
|
62
|
-
rcov.libs << 'test'
|
63
|
-
rcov.pattern = 'test/**/test_*.rb'
|
59
|
+
t.files = FileList['lib/**/*.rb'].exclude('lib/jeweler/templates/**/*.rb')
|
64
60
|
end
|
65
61
|
|
66
62
|
require 'cucumber/rake/task'
|
67
63
|
Cucumber::Rake::Task.new(:features) do |features|
|
68
|
-
features.cucumber_opts =
|
64
|
+
features.cucumber_opts = 'features --format progress'
|
69
65
|
end
|
70
66
|
namespace :features do
|
71
67
|
Cucumber::Rake::Task.new(:pretty) do |features|
|
72
|
-
features.cucumber_opts =
|
68
|
+
features.cucumber_opts = 'features --format progress'
|
73
69
|
end
|
74
70
|
end
|
75
71
|
|
76
|
-
if ENV[
|
77
|
-
task :
|
72
|
+
if ENV['RUN_CODE_RUN'] == 'true'
|
73
|
+
task default: [:test, :features]
|
78
74
|
else
|
79
|
-
task :
|
75
|
+
task default: :test
|
80
76
|
end
|
81
|
-
|
data/bin/jeweler
CHANGED
@@ -23,6 +23,7 @@ Feature: generated Gemfiel
|
|
23
23
|
And 'Gemfile' uses the gemcutter source
|
24
24
|
And 'Gemfile' has a development dependency on 'bundler'
|
25
25
|
And 'Gemfile' has a development dependency on the current version of jeweler
|
26
|
+
And 'Gemfile' has a development dependency on 'simplecov'
|
26
27
|
And 'Gemfile' has a development dependency on 'rcov'
|
27
28
|
And 'Gemfile' has a development dependency on 'rdoc'
|
28
29
|
And 'Gemfile' does not have a development dependency on 'yard'
|
@@ -13,7 +13,7 @@ Feature: generated test or spec
|
|
13
13
|
Given a working directory
|
14
14
|
And I have configured git sanely
|
15
15
|
When I generate a minitest project named 'the-perfect-gem' that is 'zomg, so good'
|
16
|
-
Then 'test/test_the-perfect-gem.rb' should define 'TestThePerfectGem' as a subclass of 'MiniTest::
|
16
|
+
Then 'test/test_the-perfect-gem.rb' should define 'TestThePerfectGem' as a subclass of 'MiniTest::Test'
|
17
17
|
|
18
18
|
Scenario: rspec
|
19
19
|
Given a working directory
|
@@ -51,4 +51,4 @@ Feature: generated test or spec
|
|
51
51
|
Given a working directory
|
52
52
|
And I have configured git sanely
|
53
53
|
When I generate a shindo project named 'the-perfect-gem' that is 'zomg, so good'
|
54
|
-
Then 'tests/the-perfect-gem_tests.rb' should have tests for 'ThePerfectGem'
|
54
|
+
Then 'tests/the-perfect-gem_tests.rb' should have tests for 'ThePerfectGem'
|
@@ -21,7 +21,7 @@ Given /^I use the jeweler command to generate the "([^"]+)" project in the worki
|
|
21
21
|
end
|
22
22
|
|
23
23
|
Given /^"([^"]+)" does not exist$/ do |file|
|
24
|
-
assert !
|
24
|
+
assert !File.exist?(File.join(@working_dir, file))
|
25
25
|
end
|
26
26
|
|
27
27
|
When /^I run "([^"]+)" in "([^"]+)"$/ do |command, directory|
|
@@ -33,7 +33,7 @@ When /^I run "([^"]+)" in "([^"]+)"$/ do |command, directory|
|
|
33
33
|
assert File.directory?(full_path), "#{full_path} is not a directory"
|
34
34
|
|
35
35
|
@stdout = `cd #{full_path} && #{command}`
|
36
|
-
@exited_cleanly =
|
36
|
+
@exited_cleanly = $CHILD_STATUS.exited?
|
37
37
|
end
|
38
38
|
|
39
39
|
Then /^the updated version, (.*), is displayed$/ do |version|
|
@@ -67,4 +67,3 @@ Given /^"VERSION" contains "([^\"]*)"$/ do |expected|
|
|
67
67
|
version = File.read(File.join(@working_dir, @name, 'VERSION')).chomp
|
68
68
|
assert_equal expected, version
|
69
69
|
end
|
70
|
-
|