gollum-lib 4.0.3-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile +3 -0
- data/HISTORY.md +11 -0
- data/LICENSE +21 -0
- data/README.md +286 -0
- data/Rakefile +187 -0
- data/docs/sanitization.md +33 -0
- data/gemspec.rb +100 -0
- data/gollum-lib.gemspec +4 -0
- data/gollum-lib_java.gemspec +4 -0
- data/lib/gollum-lib.rb +64 -0
- data/lib/gollum-lib/blob_entry.rb +95 -0
- data/lib/gollum-lib/committer.rb +243 -0
- data/lib/gollum-lib/file.rb +158 -0
- data/lib/gollum-lib/file_view.rb +155 -0
- data/lib/gollum-lib/filter.rb +78 -0
- data/lib/gollum-lib/filter/code.rb +145 -0
- data/lib/gollum-lib/filter/macro.rb +57 -0
- data/lib/gollum-lib/filter/metadata.rb +29 -0
- data/lib/gollum-lib/filter/plain_text.rb +16 -0
- data/lib/gollum-lib/filter/remote_code.rb +63 -0
- data/lib/gollum-lib/filter/render.rb +20 -0
- data/lib/gollum-lib/filter/sanitize.rb +18 -0
- data/lib/gollum-lib/filter/tags.rb +320 -0
- data/lib/gollum-lib/filter/toc.rb +109 -0
- data/lib/gollum-lib/filter/wsd.rb +54 -0
- data/lib/gollum-lib/git_access.rb +247 -0
- data/lib/gollum-lib/gitcode.rb +48 -0
- data/lib/gollum-lib/helpers.rb +13 -0
- data/lib/gollum-lib/hook.rb +35 -0
- data/lib/gollum-lib/macro.rb +43 -0
- data/lib/gollum-lib/macro/all_pages.rb +11 -0
- data/lib/gollum-lib/markup.rb +197 -0
- data/lib/gollum-lib/markups.rb +20 -0
- data/lib/gollum-lib/page.rb +491 -0
- data/lib/gollum-lib/pagination.rb +62 -0
- data/lib/gollum-lib/sanitization.rb +176 -0
- data/lib/gollum-lib/version.rb +5 -0
- data/lib/gollum-lib/wiki.rb +925 -0
- data/licenses/licenses.txt +6 -0
- metadata +410 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTBlOGQ3ZDA1OTc3ZDRhNDQxYWEyZWFmMDQxN2Q3ODUzNTlmZjkzNw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NmQzNTQ4YTg4YTI1NGZkNTI0NGQyY2FmN2FjMWRhNWE3N2U2MzI0YQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZjI0YjMxZDQ4NjQ2ZmVmODY0YjNiNmFiMWExZWI4ZDNkZGI5MjBhOTQyNGI2
|
10
|
+
ODlmNGYwYjYxNzNkZjJiNDNkMDIwZTdjNWZhNzQxNTRmZWRiYjJlYWZlNTEw
|
11
|
+
OTM2ZjEyZWY4YmQwN2Y2MjU0MjNjZTg3ZmU2MDJhZjljYTJiOTA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZTc4MTZkNDM3OGE4YmY5YzI3NzYxZDRkMWM1MTFiMTgzZTk4M2RlZGFkOGQz
|
14
|
+
NjdhNTNkN2ViYTJhMjllOWRkNzg4ZGVjMjYyY2IxMzc3NWMyNTlkMWIwMjEz
|
15
|
+
YzJlYzJhNDhhZDMxMjA3Njc2MzM5YmI4NTNmMTQ0ZmM0MWQ4YWE=
|
data/Gemfile
ADDED
data/HISTORY.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# v4.0.2 /2015-0119
|
2
|
+
|
3
|
+
* Bugfixes
|
4
|
+
|
5
|
+
# v4.0.1 /2014-12-04
|
6
|
+
|
7
|
+
* Security fix for [remote code execution issue](https://github.com/gollum/gollum/issues/913). Please update!
|
8
|
+
|
9
|
+
# v0.0.1 / 2013-03-19
|
10
|
+
|
11
|
+
* First release, extrated from https://github.com/gollum/gollum
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) Tom Preston-Werner, Rick Olson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,286 @@
|
|
1
|
+
gollum lib -- A wiki built on top of Git
|
2
|
+
========================================
|
3
|
+
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/gollum-lib.svg)](http://badge.fury.io/rb/gollum-lib)
|
5
|
+
[![Build Status](https://travis-ci.org/gollum/gollum-lib.svg?branch=master)](https://travis-ci.org/gollum/gollum-lib)
|
6
|
+
[![Dependency Status](https://gemnasium.com/gollum/gollum-lib.svg)](https://gemnasium.com/gollum/gollum-lib)
|
7
|
+
|
8
|
+
## DESCRIPTION
|
9
|
+
|
10
|
+
[Gollum](https://github.com/gollum/gollum) is a simple wiki system built on
|
11
|
+
top of Git that powers GitHub Wikis.
|
12
|
+
|
13
|
+
Gollum-lib is the Ruby API that allows you to retrieve raw or formatted wiki
|
14
|
+
content from a Git repository, write new content to the repository, and collect
|
15
|
+
various meta data about the wiki as a whole.
|
16
|
+
|
17
|
+
Gollum-lib follows the rules of [Semantic Versioning](http://semver.org/) and uses
|
18
|
+
[TomDoc](http://tomdoc.org/) for inline documentation.
|
19
|
+
|
20
|
+
## SYSTEM REQUIREMENTS
|
21
|
+
|
22
|
+
- Python 2.5+ (2.7.3 recommended)
|
23
|
+
- Ruby 1.9.3+ (1.9.3 recommended)
|
24
|
+
- Unix like operating system (OS X, Ubuntu, Debian, and more)
|
25
|
+
- Will not work on Windows (because of [grit](https://github.com/github/grit))
|
26
|
+
|
27
|
+
## INSTALLATION
|
28
|
+
|
29
|
+
The best way to install Gollum-lib is with RubyGems:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
$ [sudo] gem install gollum-lib
|
33
|
+
```
|
34
|
+
|
35
|
+
If you're installing from source, you can use [Bundler][bundler] to pick up all the
|
36
|
+
gems:
|
37
|
+
|
38
|
+
```bash
|
39
|
+
$ bundle install
|
40
|
+
```
|
41
|
+
|
42
|
+
In order to use the various formats that Gollum supports, you will need to
|
43
|
+
separately install the necessary dependencies for each format. You only need
|
44
|
+
to install the dependencies for the formats that you plan to use.
|
45
|
+
|
46
|
+
* [AsciiDoc](http://www.methods.co.nz/asciidoc/) -- `gem install asciidoctor`
|
47
|
+
* [Creole](http://wikicreole.org/) -- `gem install creole`
|
48
|
+
* [Markdown](http://daringfireball.net/projects/markdown/) -- `gem install redcarpet`
|
49
|
+
* [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) -- `gem install github-markdown`
|
50
|
+
* [Org](http://orgmode.org/) -- `gem install org-ruby`
|
51
|
+
* [Pod](http://search.cpan.org/dist/perl/pod/perlpod.pod) -- `Pod::Simple::HTML` comes with Perl >= 5.10. Lower versions should install Pod::Simple from CPAN.
|
52
|
+
* [RDoc](http://rdoc.sourceforge.net/)
|
53
|
+
* [ReStructuredText](http://docutils.sourceforge.net/rst.html) -- `easy_install docutils`
|
54
|
+
* [Textile](http://www.textism.com/tools/textile/) -- `gem install RedCloth`
|
55
|
+
* [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth`
|
56
|
+
|
57
|
+
[bundler]: http://gembundler.com/
|
58
|
+
|
59
|
+
## SYNTAX
|
60
|
+
|
61
|
+
Gollum supports a variety of formats and extensions (Markdown, MediaWiki, Textile, …).
|
62
|
+
On top of these formats Gollum lets you insert headers, footers, links, image, math and more.
|
63
|
+
|
64
|
+
Check out the [Gollum Wiki](https://github.com/gollum/gollum/wiki) for all of Gollum's formats and syntactic options.
|
65
|
+
|
66
|
+
## API DOCUMENTATION
|
67
|
+
|
68
|
+
Initialize the `Gollum::Repo` object:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
# Require rubygems if necessary
|
72
|
+
require 'rubygems'
|
73
|
+
|
74
|
+
# Require the Gollum library
|
75
|
+
require 'gollum-lib'
|
76
|
+
|
77
|
+
# Create a new Gollum::Wiki object by initializing it with the path to the
|
78
|
+
# Git repository.
|
79
|
+
wiki = Gollum::Wiki.new("my-gollum-repo.git")
|
80
|
+
# => <Gollum::Wiki>
|
81
|
+
```
|
82
|
+
|
83
|
+
By default, internal wiki links are all absolute from the root. To specify a different
|
84
|
+
base path, you can specify the `:base_path` option:
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
|
88
|
+
```
|
89
|
+
|
90
|
+
Note that `base_path` just modifies the links.
|
91
|
+
|
92
|
+
Get the latest version of the given human or canonical page name:
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
page = wiki.page('page-name')
|
96
|
+
# => <Gollum::Page>
|
97
|
+
|
98
|
+
page.raw_data
|
99
|
+
# => "# My wiki page"
|
100
|
+
|
101
|
+
page.formatted_data
|
102
|
+
# => "<h1>My wiki page</h1>"
|
103
|
+
|
104
|
+
page.format
|
105
|
+
# => :markdown
|
106
|
+
|
107
|
+
vsn = page.version
|
108
|
+
# => <Gollum::Git::Commit>
|
109
|
+
|
110
|
+
vsn.id
|
111
|
+
# => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
|
112
|
+
```
|
113
|
+
|
114
|
+
Get the footer (if any) for a given page:
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
page.footer
|
118
|
+
# => <Gollum::Page>
|
119
|
+
```
|
120
|
+
|
121
|
+
Get the header (if any) for a given page:
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
page.header
|
125
|
+
# => <Gollum::Page>
|
126
|
+
```
|
127
|
+
|
128
|
+
Get a list of versions for a given page:
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
vsns = wiki.page('page-name').versions
|
132
|
+
# => [<Gollum::Git::Commit, <Gollum::Git::Commit, <Gollum::Git::Commit>]
|
133
|
+
|
134
|
+
vsns.first.id
|
135
|
+
# => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
|
136
|
+
|
137
|
+
vsns.first.authored_date
|
138
|
+
# => Sun Mar 28 19:11:21 -0700 2010
|
139
|
+
```
|
140
|
+
|
141
|
+
Get a specific version of a given canonical page file:
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
wiki.page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
|
145
|
+
```
|
146
|
+
|
147
|
+
Get the latest version of a given static file:
|
148
|
+
|
149
|
+
```ruby
|
150
|
+
file = wiki.file('asset.js')
|
151
|
+
# => <Gollum::File>
|
152
|
+
|
153
|
+
file.raw_data
|
154
|
+
# => "alert('hello');"
|
155
|
+
|
156
|
+
file.version
|
157
|
+
# => <Gollum::Git::Commit>
|
158
|
+
```
|
159
|
+
|
160
|
+
Get a specific version of a given static file:
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
wiki.file('asset.js', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
|
164
|
+
```
|
165
|
+
|
166
|
+
Get an in-memory Page preview (useful for generating previews for web
|
167
|
+
interfaces):
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
preview = wiki.preview_page("My Page", "# Contents", :markdown)
|
171
|
+
preview.formatted_data
|
172
|
+
# => "<h1>Contents</h1>"
|
173
|
+
```
|
174
|
+
|
175
|
+
Methods that write to the repository require a Hash of commit data that takes
|
176
|
+
the following form:
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
commit = { :message => 'commit message',
|
180
|
+
:name => 'Tom Preston-Werner',
|
181
|
+
:email => 'tom@github.com' }
|
182
|
+
```
|
183
|
+
|
184
|
+
Write a new version of a page (the file will be created if it does not already
|
185
|
+
exist) and commit the change. The file will be written at the repo root.
|
186
|
+
|
187
|
+
```ruby
|
188
|
+
wiki.write_page('Page Name', :markdown, 'Page contents', commit)
|
189
|
+
```
|
190
|
+
|
191
|
+
Update an existing page. If the format is different than the page's current
|
192
|
+
format, the file name will be changed to reflect the new format.
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
page = wiki.page('Page Name')
|
196
|
+
wiki.update_page(page, page.name, page.format, 'Page contents', commit)
|
197
|
+
```
|
198
|
+
|
199
|
+
To delete a page and commit the change:
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
wiki.delete_page(page, commit)
|
203
|
+
```
|
204
|
+
|
205
|
+
Register or unregister a hook to be called after a page commit:
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
Gollum::Hook.register(:post_commit, :hook_id) do |committer, sha1|
|
209
|
+
# Your code here
|
210
|
+
end
|
211
|
+
|
212
|
+
Gollum::Hook.unregister(:post_commit, :hook_id)
|
213
|
+
```
|
214
|
+
|
215
|
+
## WINDOWS FILENAME VALIDATION
|
216
|
+
|
217
|
+
Note that filenames on windows must not contain any of the following characters `\ / : * ? " < > |`. See [this support article](http://support.microsoft.com/kb/177506) for details.
|
218
|
+
|
219
|
+
## CONTRIBUTE
|
220
|
+
|
221
|
+
If you'd like to hack on Gollum-lib, start by forking the repo on GitHub:
|
222
|
+
|
223
|
+
http://github.com/gollum/gollum-lib
|
224
|
+
|
225
|
+
To get all of the dependencies, install the gem first. The best way to get
|
226
|
+
your changes merged back into core is as follows:
|
227
|
+
|
228
|
+
1. Clone down your fork
|
229
|
+
1. Create a thoughtfully named topic branch to contain your change
|
230
|
+
1. Hack away
|
231
|
+
1. Add tests and make sure everything still passes by running `rake`
|
232
|
+
1. If you are adding new functionality, document it in the README
|
233
|
+
1. Do not change the version number, I will do that on my end
|
234
|
+
1. If necessary, rebase your commits into logical chunks, without errors
|
235
|
+
1. Push the branch up to GitHub
|
236
|
+
1. Send a pull request to the gollum/gollum-lib project.
|
237
|
+
|
238
|
+
## RELEASING
|
239
|
+
|
240
|
+
Gollum-lib uses [Semantic Versioning](http://semver.org/). Having `x.y.z` :
|
241
|
+
|
242
|
+
For z releases:
|
243
|
+
|
244
|
+
```bash
|
245
|
+
$ rake bump
|
246
|
+
$ rake release
|
247
|
+
```
|
248
|
+
|
249
|
+
For x.y releases:
|
250
|
+
|
251
|
+
```bash
|
252
|
+
$ rake gemspec
|
253
|
+
$ rake release
|
254
|
+
```
|
255
|
+
|
256
|
+
## BUILDING THE GEM FROM MASTER
|
257
|
+
|
258
|
+
```bash
|
259
|
+
$ gem uninstall -aIx gollum-lib
|
260
|
+
$ git clone https://github.com/gollum/gollum-lib.git
|
261
|
+
$ cd gollum-lib
|
262
|
+
gollum-lib$ rake build
|
263
|
+
gollum-lib$ rake install
|
264
|
+
```
|
265
|
+
|
266
|
+
## RUN THE TESTS
|
267
|
+
|
268
|
+
```bash
|
269
|
+
$ bundle install
|
270
|
+
$ bundle exec rake test
|
271
|
+
```
|
272
|
+
|
273
|
+
## WORK WITH TEST REPOS
|
274
|
+
|
275
|
+
An example of how to add a test file to the bare repository `lotr.git`.
|
276
|
+
|
277
|
+
```bash
|
278
|
+
$ mkdir tmp; cd tmp
|
279
|
+
$ git clone ../lotr.git/ .
|
280
|
+
Cloning into '.'...
|
281
|
+
done.
|
282
|
+
$ git log
|
283
|
+
$ echo "test" > test.md
|
284
|
+
$ git add . ; git commit -am "Add test"
|
285
|
+
$ git push ../lotr.git/ master
|
286
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
#############################################################################
|
6
|
+
#
|
7
|
+
# Helper functions
|
8
|
+
#
|
9
|
+
#############################################################################
|
10
|
+
|
11
|
+
def name
|
12
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
13
|
+
end
|
14
|
+
|
15
|
+
def version
|
16
|
+
line = File.read("lib/gollum-lib/version.rb")[/^\s*VERSION\s*=\s*.*/]
|
17
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
18
|
+
end
|
19
|
+
|
20
|
+
# assumes x.y.z all digit version
|
21
|
+
def next_version
|
22
|
+
# x.y.z
|
23
|
+
v = version.split '.'
|
24
|
+
# bump z
|
25
|
+
v[-1] = v[-1].to_i + 1
|
26
|
+
v.join '.'
|
27
|
+
end
|
28
|
+
|
29
|
+
def bump_version
|
30
|
+
old_file = File.read("lib/gollum-lib/version.rb")
|
31
|
+
old_version_line = old_file[/^\s*VERSION\s*=\s*.*/]
|
32
|
+
new_version = next_version
|
33
|
+
# replace first match of old version with new version
|
34
|
+
old_file.sub!(old_version_line, " VERSION = '#{new_version}'")
|
35
|
+
|
36
|
+
File.write("lib/gollum-lib/version.rb", old_file)
|
37
|
+
|
38
|
+
new_version
|
39
|
+
end
|
40
|
+
|
41
|
+
def date
|
42
|
+
Date.today.to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
def rubyforge_project
|
46
|
+
name
|
47
|
+
end
|
48
|
+
|
49
|
+
def gemspec_file
|
50
|
+
"gemspec.rb"
|
51
|
+
end
|
52
|
+
|
53
|
+
def gemspecs
|
54
|
+
["#{name}.gemspec", "#{name}_java.gemspec"]
|
55
|
+
end
|
56
|
+
|
57
|
+
def gem_files
|
58
|
+
["#{name}-#{version}.gem", "#{name}-#{version}-java.gem"]
|
59
|
+
end
|
60
|
+
|
61
|
+
def replace_header(head, header_name)
|
62
|
+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
63
|
+
end
|
64
|
+
|
65
|
+
#############################################################################
|
66
|
+
#
|
67
|
+
# Standard tasks
|
68
|
+
#
|
69
|
+
#############################################################################
|
70
|
+
|
71
|
+
task :default => :test
|
72
|
+
|
73
|
+
require 'rake/testtask'
|
74
|
+
Rake::TestTask.new(:test) do |test|
|
75
|
+
test.libs << 'lib' << 'test' << '.'
|
76
|
+
test.pattern = 'test/**/test_*.rb'
|
77
|
+
test.verbose = true
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "Generate RCov test coverage and open in your browser"
|
81
|
+
task :coverage do
|
82
|
+
require 'rcov'
|
83
|
+
sh "rm -fr coverage"
|
84
|
+
sh "rcov test/test_*.rb"
|
85
|
+
sh "open coverage/index.html"
|
86
|
+
end
|
87
|
+
|
88
|
+
desc "Open an irb session preloaded with this library"
|
89
|
+
task :console do
|
90
|
+
sh "irb -rubygems -r ./lib/#{name}.rb"
|
91
|
+
end
|
92
|
+
|
93
|
+
#############################################################################
|
94
|
+
#
|
95
|
+
# Custom tasks (add your own tasks here)
|
96
|
+
#
|
97
|
+
#############################################################################
|
98
|
+
|
99
|
+
desc "Update version number and gemspec"
|
100
|
+
task :bump do
|
101
|
+
puts "Updated version to #{bump_version}"
|
102
|
+
# Execute does not invoke dependencies.
|
103
|
+
# Manually invoke gemspec then validate.
|
104
|
+
Rake::Task[:gemspec].execute
|
105
|
+
Rake::Task[:validate].execute
|
106
|
+
end
|
107
|
+
|
108
|
+
desc "Build and install"
|
109
|
+
task :install => :build do
|
110
|
+
sh "gem install --local --no-ri --no-rdoc pkg/#{name}-#{version}.gem"
|
111
|
+
end
|
112
|
+
|
113
|
+
#############################################################################
|
114
|
+
#
|
115
|
+
# Packaging tasks
|
116
|
+
#
|
117
|
+
#############################################################################
|
118
|
+
|
119
|
+
desc 'Create a release build'
|
120
|
+
task :release => :build do
|
121
|
+
unless `git branch` =~ /^\* master$/
|
122
|
+
puts "You must be on the master branch to release!"
|
123
|
+
exit!
|
124
|
+
end
|
125
|
+
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
126
|
+
sh "git pull --rebase origin master"
|
127
|
+
sh "git tag v#{version}"
|
128
|
+
sh "git push origin master"
|
129
|
+
sh "git push origin v#{version}"
|
130
|
+
sh "gem push pkg/#{name}-#{version}.gem"
|
131
|
+
sh "gem push pkg/#{name}-#{version}-java.gem"
|
132
|
+
end
|
133
|
+
|
134
|
+
desc 'Publish to rubygems. Same as release'
|
135
|
+
task :publish => :release
|
136
|
+
|
137
|
+
desc 'Build gem'
|
138
|
+
task :build => :gemspec do
|
139
|
+
sh "mkdir -p pkg"
|
140
|
+
gemspecs.each do |gemspec|
|
141
|
+
sh "gem build #{gemspec}"
|
142
|
+
end
|
143
|
+
gem_files.each do |gem_file|
|
144
|
+
sh "mv #{gem_file} pkg"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
desc 'Update gemspec'
|
149
|
+
task :gemspec => :validate do
|
150
|
+
# read spec file and split out manifest section
|
151
|
+
spec = File.read(gemspec_file)
|
152
|
+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
153
|
+
|
154
|
+
# replace name version and date
|
155
|
+
replace_header(head, :name)
|
156
|
+
replace_header(head, :date)
|
157
|
+
#comment this out if your rubyforge_project has a different name
|
158
|
+
replace_header(head, :rubyforge_project)
|
159
|
+
|
160
|
+
# determine file list from git ls-files
|
161
|
+
files = `git ls-files`.
|
162
|
+
split("\n").
|
163
|
+
sort.
|
164
|
+
reject { |file| file =~ /^\./ }.
|
165
|
+
reject { |file| file =~ /^(rdoc|pkg|test|Home\.md|\.gitattributes|Guardfile)/ }.
|
166
|
+
map { |file| " #{file}" }.
|
167
|
+
join("\n")
|
168
|
+
|
169
|
+
# piece file back together and write
|
170
|
+
manifest = " s.files = %w[\n#{files}\n ]\n"
|
171
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
172
|
+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
173
|
+
puts "Updated #{gemspec_file}"
|
174
|
+
end
|
175
|
+
|
176
|
+
desc 'Validate lib files and version file'
|
177
|
+
task :validate do
|
178
|
+
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
|
179
|
+
unless libfiles.empty?
|
180
|
+
puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
|
181
|
+
exit!
|
182
|
+
end
|
183
|
+
unless Dir['VERSION*'].empty?
|
184
|
+
puts "A `VERSION` file at root level violates Gem best practices."
|
185
|
+
exit!
|
186
|
+
end
|
187
|
+
end
|