rails_git_version 0.0.1
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.
- data/MIT-LICENSE +20 -0
- data/README.md +66 -0
- data/Rakefile +9 -0
- data/app/controllers/rails_git_version/application_controller.rb +4 -0
- data/app/controllers/rails_git_version/description_controller.rb +11 -0
- data/app/helpers/rails_git_version/application_helper.rb +9 -0
- data/app/views/layouts/rails_git_version/application.html.erb +24 -0
- data/app/views/rails_git_version/description/index.html.erb +3 -0
- data/config/routes.rb +4 -0
- data/lib/rails_git_version.rb +31 -0
- data/lib/rails_git_version/config.rb +20 -0
- data/lib/rails_git_version/engine.rb +11 -0
- data/lib/rails_git_version/version.rb +3 -0
- data/lib/tasks/rails_git_version_tasks.rake +4 -0
- metadata +177 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
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,66 @@
|
|
1
|
+
# Rails Git Version 
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
If you are using Git to manage your Rails apps' source code this gem
|
6
|
+
will make it possible to find a description of what is deployed from
|
7
|
+
within your browser.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
To add this functionality to your Rails 3 app add it to your Gemfile.
|
12
|
+
|
13
|
+
``` ruby
|
14
|
+
gem 'rails_git_version' '~> 0.1'
|
15
|
+
```
|
16
|
+
|
17
|
+
Bundle install the new gem, and decide where you want to access your
|
18
|
+
description of what's currently live.
|
19
|
+
|
20
|
+
If you want to use `http://example.com/_deployed` as I do you need to
|
21
|
+
add set this up in your routes.rb file like so.
|
22
|
+
|
23
|
+
``` ruby
|
24
|
+
Rails.application.routes.draw do
|
25
|
+
mount RailsGitVersion::Engine => '/_deployed'
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
## Configuration
|
30
|
+
|
31
|
+
By default, RailGitVersion will assume your git repository is in the
|
32
|
+
same directory as `Rails.root`. If this is not the case you can tell
|
33
|
+
RailsGitVersion where to look for a `.git` directory by adding the
|
34
|
+
following line to your config/application.rb file.
|
35
|
+
|
36
|
+
``` ruby
|
37
|
+
module Dummy
|
38
|
+
class Application < Rails::Application
|
39
|
+
config.encoding = 'utf-8'
|
40
|
+
config.filter_parameters += [:password]
|
41
|
+
config.assets.enabled = true
|
42
|
+
config.assets.version = '1.0'
|
43
|
+
|
44
|
+
# And all of your other configuration...
|
45
|
+
|
46
|
+
# Add this line with a path to the directory containing the .git
|
47
|
+
# directory.
|
48
|
+
config.rails_git_version.root = File.expand_path('..', __FILE__)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
## Troubleshooting
|
54
|
+
|
55
|
+
When you start your Rails application, RailsGitVersion will attempt to
|
56
|
+
find the SHA of the most recent commit using [Grit][]. If the repository
|
57
|
+
can be accessed, and the commit found it will be logged to your
|
58
|
+
Rails.logger.
|
59
|
+
|
60
|
+
If for some reason Grit can't find your .git directory a quiet message
|
61
|
+
will be printed to explain something has gone wrong.
|
62
|
+
|
63
|
+
Try running `Grit::Repo.new(path)` within `rails console` replacing path
|
64
|
+
with the full path logged after something went wrong.
|
65
|
+
|
66
|
+
[Grit]: https://github.com/mojombo/grit
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>RailsGitVersion</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
font: 14px 'helvetica', sans-serif; color: #444;
|
8
|
+
padding: 0;
|
9
|
+
margin: 0;
|
10
|
+
}
|
11
|
+
p.deployed {
|
12
|
+
margin: 0;
|
13
|
+
padding: 10px;
|
14
|
+
}
|
15
|
+
span.rest { color: #999; }
|
16
|
+
</style>
|
17
|
+
<%= csrf_meta_tags %>
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
|
21
|
+
<%= yield %>
|
22
|
+
|
23
|
+
</body>
|
24
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'grit'
|
2
|
+
require 'rails_git_version/config'
|
3
|
+
require 'rails_git_version/engine'
|
4
|
+
|
5
|
+
module RailsGitVersion
|
6
|
+
extend self
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_reader :repo
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup
|
13
|
+
config.root ||= Rails.root
|
14
|
+
|
15
|
+
@repo = Grit::Repo.new(config.root.to_s)
|
16
|
+
log_success
|
17
|
+
rescue Grit::InvalidGitRepositoryError
|
18
|
+
@repo = nil
|
19
|
+
log_failure
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def log_success
|
25
|
+
Rails.logger.info "RailsGitVersion: Found version #{@repo.commits.first.id_abbrev}."
|
26
|
+
end
|
27
|
+
|
28
|
+
def log_failure
|
29
|
+
Rails.logger.warn "RailsGitVersion: Failed to access git repo in #{config.root}."
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'active_support/configurable'
|
2
|
+
|
3
|
+
module RailsGitVersion
|
4
|
+
class Configuration
|
5
|
+
include ActiveSupport::Configurable
|
6
|
+
config_accessor :root
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.configure
|
10
|
+
yield @config ||= RailsGitVersion::Configuration.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.config
|
14
|
+
@config
|
15
|
+
end
|
16
|
+
|
17
|
+
configure do |config|
|
18
|
+
# config.root = Rails.root
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_git_version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- James Conroy-Finn
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.3
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.3
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: grit
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '2.5'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.5'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: pry
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.9'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.9'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: simplecov
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.6'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0.6'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec-rails
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '2.9'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '2.9'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: aruba
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0.4'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.4'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: cucumber-rails
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.3'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '1.3'
|
126
|
+
description: Find your git version within your running Rails application
|
127
|
+
email:
|
128
|
+
- james@logi.cl
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- app/controllers/rails_git_version/application_controller.rb
|
134
|
+
- app/controllers/rails_git_version/description_controller.rb
|
135
|
+
- app/helpers/rails_git_version/application_helper.rb
|
136
|
+
- app/views/layouts/rails_git_version/application.html.erb
|
137
|
+
- app/views/rails_git_version/description/index.html.erb
|
138
|
+
- config/routes.rb
|
139
|
+
- lib/rails_git_version/config.rb
|
140
|
+
- lib/rails_git_version/engine.rb
|
141
|
+
- lib/rails_git_version/version.rb
|
142
|
+
- lib/rails_git_version.rb
|
143
|
+
- lib/tasks/rails_git_version_tasks.rake
|
144
|
+
- MIT-LICENSE
|
145
|
+
- Rakefile
|
146
|
+
- README.md
|
147
|
+
homepage: http://jamesconroyfinn.com
|
148
|
+
licenses: []
|
149
|
+
post_install_message:
|
150
|
+
rdoc_options: []
|
151
|
+
require_paths:
|
152
|
+
- lib
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ! '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
segments:
|
160
|
+
- 0
|
161
|
+
hash: -336369872854003235
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
none: false
|
164
|
+
requirements:
|
165
|
+
- - ! '>='
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
segments:
|
169
|
+
- 0
|
170
|
+
hash: -336369872854003235
|
171
|
+
requirements: []
|
172
|
+
rubyforge_project:
|
173
|
+
rubygems_version: 1.8.23
|
174
|
+
signing_key:
|
175
|
+
specification_version: 3
|
176
|
+
summary: Find your git version within your running Rails application
|
177
|
+
test_files: []
|