rack-git-revision 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad3468f15420f291b85f31f48b797ab55021f027
4
+ data.tar.gz: 2590b33cd168646196aa31f15637b9e25f153ad8
5
+ SHA512:
6
+ metadata.gz: cf85d7c03da7f42e20dd2727c935d22655edc0a937488f148a3245b0314faf72ee965221742c276e2dfdd7c132ad4f8e68b94851d8ce9533f20a405dd34c5152
7
+ data.tar.gz: c614f0a9621d29f6a81a3c1df7ecc229756563b0228dc8bec05c16053c485e08730d1c753344596f44ccafed261125edb7902a623f61cb7085792e9345f2627a
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rack-git-revision.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 kotohata
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Rack::Git::Revision
2
+
3
+ Rack::GitRevision is a git revision http interface for rack applications.
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ # Gemfile
9
+ gem 'rack-dev-revision'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ ```
15
+ # config.ru
16
+ use Rack::DevRevision
17
+ ```
18
+
19
+ ```
20
+ $ curl localhost:3000/dev/revision
21
+ => 7424ba3207725cd1321f06949330b5f531f9af72
22
+ ```
23
+
24
+ ## Customize Url
25
+
26
+ ### Change Url path
27
+ ```
28
+ use Rack::GitRevision, path: '/git_revision'
29
+ ```
30
+
31
+ ### Change how to get revision
32
+
33
+ ```
34
+ use Rack::GitRevision, { revision: lambda { File.read('./REVISION').strip } }
35
+ ```
36
+
37
+
38
+ ### Options
39
+
40
+ #### Defaults
41
+ ```
42
+ options = {
43
+ path: '/dev/revision',
44
+ revision: lambda { `git log -1 --pretty="format:%H"` },
45
+ body: lambda { |revision| revision },
46
+ status: lambda { |revision| revision ? 200 : 404 },
47
+ headers: lambda { |revision| { 'Content-Type' => 'text/plain' }
48
+ }
49
+
50
+ ```
51
+
52
+
53
+ ## Contributing
54
+
55
+ 1. Fork it ( https://github.com/attracie/rack-git-revision/fork )
56
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
57
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
58
+ 4. Push to the branch (`git push origin my-new-feature`)
59
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,28 @@
1
+ module Rack
2
+ class GitRevision
3
+ VERSION = '1.0.0'
4
+
5
+ def initialize(app, options = {})
6
+ @app = app
7
+ @options = {
8
+ path: '/dev/revision',
9
+ revision: lambda { `git log -1 --pretty="format:%H"` },
10
+ body: lambda { |revision| revision },
11
+ status: lambda { |revision| revision ? 200 : 404 },
12
+ headers: lambda { |revision| { 'Content-Type' => 'text/plain' } },
13
+ }.merge(options)
14
+ end
15
+
16
+ def call(env)
17
+ if env['PATH_INFO'] == @options[:path]
18
+ revision = @options[:revision].call rescue nil
19
+ body = [@options[:body].call(revision) || 'not found']
20
+ status = @options[:status].call(revision)
21
+ headers = @options[:headers].call(revision)
22
+ [status, headers, body]
23
+ else
24
+ @app.call(env)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../lib/rack/git_revision', __FILE__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "rack-git-revision"
5
+ spec.version = Rack::GitRevision::VERSION
6
+ spec.authors = ["kotohata"]
7
+ spec.email = ["kotohata@attracie.com"]
8
+ spec.summary = %q{rack middleware which returns git revision}
9
+ spec.description = %q{rack middleware which returns git revision}
10
+ spec.homepage = "http://github.com/attracie/rack-git-revision"
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files -z`.split("\x0")
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_development_dependency 'rake', '~> 10.0'
18
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-git-revision
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - kotohata
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '10.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '10.0'
27
+ description: rack middleware which returns git revision
28
+ email:
29
+ - kotohata@attracie.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - lib/rack/git_revision.rb
40
+ - rack-git-revision.gemspec
41
+ homepage: http://github.com/attracie/rack-git-revision
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.2.2
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: rack middleware which returns git revision
65
+ test_files: []