git_versioner 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -0
- data/LICENSE +20 -0
- data/README.md +27 -0
- data/Rakefile +23 -0
- data/lib/git_versioner.rb +30 -0
- data/lib/git_versioner/railtie.rb +16 -0
- data/lib/git_versioner/version.rb +3 -0
- data/lib/git_versioner/view_helpers.rb +7 -0
- metadata +53 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 Brian Boughton
|
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.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# GitVersioner
|
2
|
+
|
3
|
+
Use Git tags to versionize your rails application.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
```ruby
|
7
|
+
gem "git_versioner"
|
8
|
+
```
|
9
|
+
|
10
|
+
## Getting Started
|
11
|
+
Once the gem is added to your rails application you don't have to do anything else.
|
12
|
+
By default the version will be memorized when the Rails application is initialized
|
13
|
+
in production and will be retrieved each request when in development.
|
14
|
+
|
15
|
+
Change the memorization technique `config/initializers/version.rb`
|
16
|
+
```ruby
|
17
|
+
YourAppName::VERSION.memorize do
|
18
|
+
true
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
A view helper is provided for your convince.
|
23
|
+
```erb
|
24
|
+
<footer>
|
25
|
+
<p><%= version %></p>
|
26
|
+
</footer>
|
27
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require 'rake'
|
4
|
+
require 'rdoc/task'
|
5
|
+
|
6
|
+
require 'rake/testtask'
|
7
|
+
|
8
|
+
Rake::TestTask.new(:test) do |t|
|
9
|
+
t.libs << 'lib'
|
10
|
+
t.libs << 'test'
|
11
|
+
t.pattern = 'test/**/*_test.rb'
|
12
|
+
t.verbose = false
|
13
|
+
end
|
14
|
+
|
15
|
+
task :default => :test
|
16
|
+
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'GitVersioner'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README.rdoc')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'git_versioner/railtie' if defined?(Rails)
|
2
|
+
|
3
|
+
module GitVersioner
|
4
|
+
class << self
|
5
|
+
|
6
|
+
attr_writer :memorize
|
7
|
+
def memorize
|
8
|
+
@memorize = yield if block_given?
|
9
|
+
@memorize
|
10
|
+
end
|
11
|
+
|
12
|
+
def memorize?
|
13
|
+
memorize == true
|
14
|
+
end
|
15
|
+
|
16
|
+
def version
|
17
|
+
if memorize?
|
18
|
+
@version ||= calculate_version
|
19
|
+
else
|
20
|
+
calculate_version
|
21
|
+
end
|
22
|
+
end
|
23
|
+
alias :to_s :version
|
24
|
+
|
25
|
+
private
|
26
|
+
def calculate_version
|
27
|
+
`git describe --always`.strip
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'git_versioner/view_helpers'
|
2
|
+
|
3
|
+
module GitVersioner
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
initializer "git_versioner.versionize" do
|
6
|
+
Rails.application.class.parent::VERSION = GitVersioner
|
7
|
+
Rails.application.class.parent::VERSION.memorize do
|
8
|
+
Rails.env == 'production'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
initializer "git_versioner.view_helpers" do
|
13
|
+
ActionView::Base.send :include, ViewHelpers
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git_versioner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brian Boughton
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-27 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email:
|
16
|
+
- brian@brianboughton.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/git_versioner/railtie.rb
|
22
|
+
- lib/git_versioner/version.rb
|
23
|
+
- lib/git_versioner/view_helpers.rb
|
24
|
+
- lib/git_versioner.rb
|
25
|
+
- LICENSE
|
26
|
+
- Rakefile
|
27
|
+
- Gemfile
|
28
|
+
- README.md
|
29
|
+
homepage: ''
|
30
|
+
licenses: []
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 1.8.24
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: Control application version through Git
|
53
|
+
test_files: []
|