rack-git-version 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rack-git-version.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ module Rack
2
+ class GitVersion
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ require "rack-git-version/version"
2
+
3
+ module Rack
4
+ class GitVersion
5
+ def initialize app
6
+ @app = app
7
+ end
8
+
9
+ def git_version
10
+ @@git_version ||= `git describe --all`.strip
11
+ end
12
+
13
+ def call env
14
+ status, headers, response = @app.call env
15
+ headers["X-Git-Version"] ||= git_version
16
+ [status, headers, response]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "rack-git-version/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rack-git-version"
7
+ s.version = Rack::GitVersion::VERSION
8
+ s.authors = ["Mike Nicholaides"]
9
+ s.email = ["mike@ablegray.com"]
10
+ s.homepage = "https://github.com/nicholaides/rack-git-version"
11
+ s.summary = %q{Adds your git ref to the HTTP headers}
12
+ s.description = %q{Adds your git ref to the HTTP headers}
13
+
14
+ s.rubyforge_project = "rack-git-version"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ s.add_development_dependency "rspec"
23
+ s.add_development_dependency "rack-test"
24
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rack::GitVersion do
4
+ before do
5
+ @status = 200
6
+ @headers = { 'Content-Type' => 'text/plain', 'X-Another-Header' => 'Something' }
7
+ @body = 'Test App'
8
+ @version = "somebranch/SHA234234987"
9
+
10
+ @app = Rack::GitVersion.new(lambda{ [@status, @headers, [@body]] })
11
+ @app.stub :git_version => @version
12
+ end
13
+
14
+ def app
15
+ @app
16
+ end
17
+
18
+ let(:response){ get '/' }
19
+
20
+ it "should keep the same HTTP Code" do
21
+ response.status.should == @status
22
+ end
23
+
24
+ it "should keep the same body" do
25
+ response.body.should == @body
26
+ end
27
+
28
+ it "should add the git version to the headers" do
29
+ response.headers["X-Git-Version"].should == @version
30
+ end
31
+
32
+ it "should leave the other headers" do
33
+ @headers.each do |name, value|
34
+ response.headers[name].should == value
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,12 @@
1
+ require "rubygems"
2
+ require "rspec"
3
+ require "rack/test"
4
+
5
+ $LOAD_PATH.unshift File.dirname(File.dirname(__FILE__)) + '/lib'
6
+ $LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))
7
+
8
+ require "rack-git-version"
9
+
10
+ RSpec.configure do |config|
11
+ config.include Rack::Test::Methods
12
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-git-version
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Mike Nicholaides
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-08 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rack-test
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
49
+ description: Adds your git ref to the HTTP headers
50
+ email:
51
+ - mike@ablegray.com
52
+ executables: []
53
+
54
+ extensions: []
55
+
56
+ extra_rdoc_files: []
57
+
58
+ files:
59
+ - .gitignore
60
+ - .rspec
61
+ - Gemfile
62
+ - Rakefile
63
+ - lib/rack-git-version.rb
64
+ - lib/rack-git-version/version.rb
65
+ - rack-git-version.gemspec
66
+ - spec/git_version_spec.rb
67
+ - spec/spec_helper.rb
68
+ has_rdoc: true
69
+ homepage: https://github.com/nicholaides/rack-git-version
70
+ licenses: []
71
+
72
+ post_install_message:
73
+ rdoc_options: []
74
+
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ requirements: []
96
+
97
+ rubyforge_project: rack-git-version
98
+ rubygems_version: 1.5.2
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Adds your git ref to the HTTP headers
102
+ test_files:
103
+ - spec/git_version_spec.rb
104
+ - spec/spec_helper.rb