rack-revision 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 572e54825a1905f7d369a997922a7d6c3d9031f7
4
+ data.tar.gz: a5411935f6ae46862d16ddcee5efc3c0643325f7
5
+ SHA512:
6
+ metadata.gz: f771123d5a308206c920696f2c152d22cc40b99f7f13ea977a071edeb8d5dc0de42b160dd8b19a9b0f467fd643c579d5eb416b65a121221b804d10a86b1bd901
7
+ data.tar.gz: 5dbd53b2ecc0322bbe2cce1a62b2d6736f20a8b5a59bdba61480e2e7aab5f900e7fb2b07a01b3644c9b83264e1e8e0769ef08f4a96ace13a60e1b8ad4f351817
@@ -3,3 +3,4 @@ rvm:
3
3
  - 1.8.7
4
4
  - 1.9.2
5
5
  - 1.9.3
6
+ - 2.0.0
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
data/README.md CHANGED
@@ -3,22 +3,22 @@
3
3
  Rack::Revision is a quick drop-in component to enable code revision tracking.
4
4
  It adds `X-Revision` header with the code revision from capistrano's REVISION file.
5
5
 
6
+ [![Build Status](https://travis-ci.org/sosedoff/rack-revision.png?branch=master)](https://travis-ci.org/sosedoff/rack-revision)
7
+
6
8
  ## Installation
7
9
 
8
- From rubygems:
10
+ Add dependency to your Gemfile:
9
11
 
10
12
  ```
11
- gem install rack-revision
13
+ gem "rack-revision"
12
14
  ```
13
15
 
14
- Or install with bundler:
16
+ Install gem:
15
17
 
16
18
  ```
17
- gem 'rack-revision'
19
+ bundle install
18
20
  ```
19
21
 
20
- And run `bundle install`
21
-
22
22
  ## Usage
23
23
 
24
24
  Rack::Revision is implemented as a piece of Rack middleware and can be used with
@@ -26,17 +26,18 @@ any Rack-based application. If you have a `config.ru` rackup file you can
26
26
  drop the following snippet (for sinatra app):
27
27
 
28
28
  ```ruby
29
- require 'rack/revision'
29
+ require "rack/revision"
30
30
 
31
31
  # Basic example
32
32
  use Rack::Revision
33
33
 
34
34
  # With custom revision header
35
- use Rack::Revision, :header => 'X-CODE-VERSION'
35
+ use Rack::Revision, :header => "X-CODE-VERSION"
36
36
 
37
37
  # With custom filename and default value
38
- use Rack::Revision, :filename => '.version', :default => 'n/a'
38
+ use Rack::Revision, :filename => ".version", :default => "n/a"
39
39
 
40
+ # Execute application
40
41
  run Sinatra::Application
41
42
  ```
42
43
 
@@ -57,10 +58,21 @@ rake test
57
58
 
58
59
  ## License
59
60
 
60
- Copyright (c) 2012 Dan Sosedoff.
61
+ Copyright (c) 2012-2013 Dan Sosedoff.
61
62
 
62
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
63
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
64
+ this software and associated documentation files (the "Software"), to deal in
65
+ the Software without restriction, including without limitation the rights to
66
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
67
+ the Software, and to permit persons to whom the Software is furnished to do so,
68
+ subject to the following conditions:
63
69
 
64
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
70
+ The above copyright notice and this permission notice shall be included in all
71
+ copies or substantial portions of the Software.
65
72
 
66
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
73
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
75
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
76
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
77
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
78
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -6,20 +6,22 @@ module Rack
6
6
  @@revision = nil
7
7
 
8
8
  def initialize(app, options={})
9
- @options = {
10
- :header => options[:header].nil? ? 'X-Revision' : options[:header],
11
- :filename => options[:filename] || 'REVISION',
12
- :default => options[:default] || 'UNDEFINED',
13
- :rack_env => options[:rack_env].nil? ? 'rack.app_revision' : options[:rack_env]
14
- }
9
+ initialize_options(options)
15
10
 
16
11
  @app = app
17
12
  end
18
13
 
19
14
  def call(env)
20
- env[@options[:rack_env]] = revision if @options[:rack_env]
15
+ if @options[:rack_env]
16
+ env[@options[:rack_env]] = revision
17
+ end
18
+
21
19
  status, headers, body = @app.call(env)
22
- headers[@options[:header]] = revision if @options[:header]
20
+
21
+ if @options[:header]
22
+ headers[@options[:header]] = revision
23
+ end
24
+
23
25
  [status, headers, body]
24
26
  end
25
27
 
@@ -34,11 +36,24 @@ module Rack
34
36
  end
35
37
 
36
38
  def read_revision
37
- File.exists?(detected_filename) ? File.read(detected_filename).strip : @options[:default]
39
+ if File.exists?(detected_filename)
40
+ File.read(detected_filename).strip
41
+ else
42
+ @options[:default]
43
+ end
38
44
  end
39
45
 
40
46
  def detected_filename
41
47
  @file ||= (@options[:filename] =~ /\A\// ? @options[:filename] : File.join(Dir.pwd, @options[:filename]))
42
48
  end
49
+
50
+ def initialize_options(options)
51
+ @options = {
52
+ :header => options[:header].nil? ? "X-Revision" : options[:header],
53
+ :rack_env => options[:rack_env].nil? ? "rack.app_revision" : options[:rack_env],
54
+ :filename => options[:filename] || "REVISION",
55
+ :default => options[:default] || "UNDEFINED"
56
+ }
57
+ end
43
58
  end
44
59
  end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Revision
3
- VERSION = '1.0.1'
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,38 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-revision
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dan Sosedoff
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-17 00:00:00.000000000Z
11
+ date: 2013-08-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rack
16
- requirement: &2157761320 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *2157761320
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: rack-test
27
- requirement: &2157759940 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - '>='
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *2157759940
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  description: Adds an extra X-REVISION header with source code revision string (git,
37
42
  svn, etc)
38
43
  email:
@@ -52,28 +57,26 @@ files:
52
57
  - test/test_revision.rb
53
58
  homepage: http://github.com/sosedoff/rack-revision
54
59
  licenses: []
60
+ metadata: {}
55
61
  post_install_message:
56
62
  rdoc_options: []
57
63
  require_paths:
58
64
  - lib
59
65
  required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
66
  requirements:
62
- - - ! '>='
67
+ - - '>='
63
68
  - !ruby/object:Gem::Version
64
69
  version: '0'
65
70
  required_rubygems_version: !ruby/object:Gem::Requirement
66
- none: false
67
71
  requirements:
68
- - - ! '>='
72
+ - - '>='
69
73
  - !ruby/object:Gem::Version
70
74
  version: '0'
71
75
  requirements: []
72
76
  rubyforge_project:
73
- rubygems_version: 1.8.15
77
+ rubygems_version: 2.0.5
74
78
  signing_key:
75
- specification_version: 3
79
+ specification_version: 4
76
80
  summary: Code ravision rack middleware
77
81
  test_files:
78
82
  - test/test_revision.rb
79
- has_rdoc: