client_version 0.1.0

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: 3f710b5c97a5ae74c49e10f631ad7b8e795b431f
4
+ data.tar.gz: 0e0b8055ef4cf009a941af19ed7a014bb7805d3d
5
+ SHA512:
6
+ metadata.gz: 420948abd388d037f483928cec8ae4e302628bc8fe10b8645e899357c0cf8c51e9b217c2cd623216484112398a3b580b0bc8b58768213efe00dd9adcab640640
7
+ data.tar.gz: 8aac58ea868a7152d4f77881324d0b425447697989d9d76eb9f3cf97fd07f94a617216d1299880c19859fe8d1dae8e0854ed58eec4651aac946d16765b3fa7d0
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Johannes Gorset
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # Client Version
2
+ [![Gem Version](https://img.shields.io/gem/v/client-version.svg?style=flat)](https://rubygems.org/gems/client-version)
3
+ [![Build Status](https://img.shields.io/travis/hyperoslo/client-version.svg?style=flat)](https://travis-ci.org/hyperoslo/client-version)
4
+ [![Code Climate](https://img.shields.io/codeclimate/github/hyperoslo/client-version.svg?style=flat)](https://codeclimate.com/github/hyperoslo/client-version)
5
+ [![Coverage Status](https://img.shields.io/coveralls/hyperoslo/client-version.svg?style=flat)](https://coveralls.io/r/hyperoslo/client-version)
6
+ [![Join the chat at https://gitter.im/hyperoslo/client-version](https://badges.gitter.im/hyperoslo/client-version.svg)](https://gitter.im/hyperoslo/client-version?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7
+
8
+ If you're building an API, it can be really helpful to be able to force your
9
+ clients to upgrade to the latest version. This is Rack middleware that simply
10
+ adds a `Client-Version` header to every response with the value of the
11
+ `CLIENT_VERSION` environment variable. Your clients can use it to determine
12
+ whether they should force the user to upgrade to the latest version.
13
+
14
+ ## Installation
15
+
16
+ You know the drill:
17
+
18
+ ```ruby
19
+ # Gemfile
20
+ gem 'client_version'
21
+ ```
22
+
23
+ ```bash
24
+ $ bundle install
25
+ ```
26
+
27
+ ## Configuration
28
+
29
+ If you're using Rails, you're all set; we've hooked into your middleware stack
30
+ for you. Otherwise just add `ClientVersion` to your middleware stack.
31
+
32
+ ## Hyper loves you
33
+
34
+ [Hyper] made this. We're a bunch of folks who love building things. You should
35
+ [tweet us] if you can't get it to work. In fact, you should tweet us anyway.
36
+ If you're using Facebook Messenger, we probably want to [hire you].
37
+
38
+ [Hyper]: https://github.com/hyperoslo
39
+ [tweet us]: http://twitter.com/hyperoslo
40
+ [hire you]: http://www.hyper.no/jobs/engineers
@@ -0,0 +1,17 @@
1
+ require 'client_version/version'
2
+ require 'client_version/railtie' if defined?(Rails)
3
+
4
+ # Rack middleware that adds adds a `Client-Version` header to every response
5
+ # with the value of the `CLIENT_VERSION` environment variable.
6
+ class ClientVersion
7
+ def initialize(app, client_version = ENV['CLIENT_VERSION'])
8
+ @app = app
9
+ @client_version = client_version
10
+ end
11
+
12
+ def call(env)
13
+ @app.call(env).tap do |_, headers, _|
14
+ headers['Client-Version'.freeze] = @client_version if @client_version
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ class ClientVersion
2
+ # Railtie to use the ClientVersion middleware.
3
+ class Railtie < Rails::Railtie
4
+ initializer 'client_version.use_middleware' do |app|
5
+ app.middleware.insert 0, ClientVersion
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ class ClientVersion
2
+ VERSION = '0.1.0'.freeze
3
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: client_version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Johannes Gorset
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.6.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.6.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.39'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.39'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '11.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '11.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Rack middleware for forcing clients to upgrade
126
+ email:
127
+ - johannes@hyper.no
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - LICENSE.txt
133
+ - README.md
134
+ - lib/client_version.rb
135
+ - lib/client_version/railtie.rb
136
+ - lib/client_version/version.rb
137
+ homepage: https://github.com/hyperoslo/client-version
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.5.1
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Rack middleware for forcing clients to upgrade
161
+ test_files: []