cartage-rack 1.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: 1fa674a4148825b651ef4b4877a11512f398fccf
4
+ data.tar.gz: 41fd855e575def1e21c4822ad926825bbfb29f84
5
+ SHA512:
6
+ metadata.gz: bd9c50ca6065c103d6df58d84541be5d9d342955e1ce14ed5e103bd31a78d6098a95e405f8c55b371eb31657dc9e9aac408723901a02f553aba9460f4f4af232
7
+ data.tar.gz: cdf0ee60b847b6c8450c7c87492474147691bcd880554a091ddf4ec287c33b721667f0b7f4ced8012f538ef985a05704c159b8f6375b7f892341b90f9b4f7587
data/.autotest ADDED
@@ -0,0 +1,27 @@
1
+ # -*- ruby -*-
2
+
3
+ require "autotest/restart"
4
+
5
+ Autotest.add_hook :initialize do |at|
6
+ # .minitest.rb ensures that the gem version of minitest is used.
7
+ at.testlib = ".minitest.rb"
8
+ # at.testlib = "minitest/unit"
9
+ #
10
+ # at.extra_files << "../some/external/dependency.rb"
11
+ #
12
+ # at.libs << ":../some/external"
13
+ #
14
+ # at.add_exception "vendor"
15
+ #
16
+ # at.add_mapping(/dependency.rb/) do |f, _|
17
+ # at.files_matching(/test_.*rb$/)
18
+ # end
19
+ #
20
+ # %w(TestA TestB).each do |klass|
21
+ # at.extra_class_map[klass] = "test/test_misc.rb"
22
+ # end
23
+ end
24
+
25
+ # Autotest.add_hook :run_command do |at|
26
+ # system "rake build"
27
+ # end
data/.gemtest ADDED
@@ -0,0 +1 @@
1
+
data/.minitest.rb ADDED
@@ -0,0 +1,2 @@
1
+ gem "minitest"
2
+ require "minitest/autorun"
data/Contributing.rdoc ADDED
@@ -0,0 +1,63 @@
1
+ == Contributing
2
+
3
+ We value any contribution to cartage-rack you can provide: a bug report, a
4
+ feature request, or code contributions.
5
+
6
+ cartage-rack has a few contribution guidelines:
7
+
8
+ * Changes *will* *not* be accepted without tests. The test suite is written
9
+ with {Minitest}[https://github.com/seattlerb/minitest].
10
+ * Match our coding style.
11
+ * Use a thoughtfully-named topic branch that contains your change. Rebase your
12
+ commits into logical chunks as necessary.
13
+ * Use {quality commit messages}[http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html].
14
+ * Do not change the version number; when your patch is accepted and a release
15
+ is made, the version will be updated at that point.
16
+ * Submit a GitHub pull request with your changes.
17
+
18
+ === Test Dependencies
19
+
20
+ cartage-rack uses Ryan Davis’s {Hoe}[https://github.com/seattlerb/hoe] to manage
21
+ the release process, and it adds a number of rake tasks. You will mostly be
22
+ interested in:
23
+
24
+ $ rake
25
+
26
+ which runs the tests the same way that:
27
+
28
+ $ rake test
29
+ $ rake travis
30
+
31
+ will do.
32
+
33
+ To assist with the installation of the development dependencies for cartage-rack,
34
+ I have provided the simplest possible Gemfile pointing to the (generated)
35
+ +cartage-rack.gemspec+ file. This will permit you to do:
36
+
37
+ $ bundle install
38
+
39
+ to get the development dependencies. If you aleady have +hoe+ installed, you
40
+ can accomplish the same thing with:
41
+
42
+ $ rake newb
43
+
44
+ This task will install any missing dependencies, run the tests/specs, and
45
+ generate the RDoc.
46
+
47
+ === Workflow
48
+
49
+ Here's the most direct way to get your work merged into the project:
50
+
51
+ * Fork the project.
52
+ * Clone down your fork (<tt>git clone git://github.com/KineticCafe/cartage-rack.git</tt>).
53
+ * Create a topic branch to contain your change (<tt>git checkout -b my\_awesome\_feature</tt>).
54
+ * Hack away, add tests. Not necessarily in that order.
55
+ * Make sure everything still passes by running +rake+.
56
+ * If necessary, rebase your commits into logical chunks, without errors.
57
+ * Push the branch up (<tt>git push origin my\_awesome\_feature</tt>).
58
+ * Create a pull request against KineticCafe/cartage-rack and describe
59
+ what your change does and the why you think it should be merged.
60
+
61
+ === Contributors
62
+
63
+ * Austin Ziegler created cartage-rack.
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # -*- ruby -*-
2
+
3
+ # NOTE: This file is not the canonical source of dependencies. Edit the
4
+ # Rakefile, instead.
5
+
6
+ source "https://rubygems.org/"
7
+ gemspec
8
+
9
+ # vim: syntax=ruby
data/History.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ === 1.0 / 2015-03-20
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
data/Licence.rdoc ADDED
@@ -0,0 +1,27 @@
1
+ == Licence
2
+
3
+ This software is available under an MIT-style licence.
4
+
5
+ * Copyright 2015 Kinetic Cafe
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
8
+ this software and associated documentation files (the "Software"), to deal in
9
+ the Software without restriction, including without limitation the rights to
10
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11
+ of the Software, and to permit persons to whom the Software is furnished to do
12
+ so, subject to the following conditions:
13
+
14
+ * The names of its contributors may not be used to endorse or promote
15
+ products derived from this software without specific prior written
16
+ permission.
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,11 @@
1
+ .autotest
2
+ .gemtest
3
+ .minitest.rb
4
+ Contributing.rdoc
5
+ Gemfile
6
+ History.rdoc
7
+ Licence.rdoc
8
+ Manifest.txt
9
+ README.rdoc
10
+ Rakefile
11
+ lib/cartage/rack.rb
data/README.rdoc ADDED
@@ -0,0 +1,68 @@
1
+ = cartage-rack by Kinetic Cafe
2
+
3
+ code :: https://github.com/KineticCafe/cartage-rack/
4
+ issues :: https://github.com/KineticCafe/cartage-rack/issues
5
+ continuous integration :: {<img src="https://travis-ci.org/KineticCafe/cartage-rack.png" />}[https://travis-ci.org/KineticCafe/cartage-rack]
6
+
7
+ == Description
8
+
9
+ cartage-rack is a plug-in for {cartage}[https://github.com/KineticCafe/cartage]
10
+ to provide a Rack application.
11
+
12
+ Cartage provides a repeatable means to create a package for a Rails application
13
+ that can be used in deployment with a configuration tool like Ansible, Chef,
14
+ Puppet, or Salt. The package is created with its dependencies bundled in
15
+ +vendor/bundle+, so it can be deployed in environments with strict access
16
+ control rules and without requiring development tool access.
17
+
18
+ == Synopsis
19
+
20
+ Cartage::Rack provides a Rack application generator to read and return the
21
+ +release_hashref+ from an endpoint to verify that the server was deployed. This
22
+ endpoint supports both JSON and plaintext output. To add this to a Rails
23
+ application, simply mount it in +config/routes.rb+:
24
+
25
+ require 'cartage/rack'
26
+
27
+ Rails.application.routes.draw do
28
+ get '/release' => Cartage::Rack.mount(Rails.root)
29
+ end
30
+
31
+ Or map it in a normal Rack application in +config.ru+:
32
+
33
+ require 'cartage/rack'
34
+ map('/release') do
35
+ run Cartage::Rack.mount(Dir.pwd)
36
+ end
37
+
38
+ It can then be queried easily:
39
+
40
+ % rails start
41
+ % curl localhost:3000/release
42
+ development: (git) main
43
+ % curl localhost:3000/release.json
44
+ { "env" : "development", "release_hashref" : "(git) main" }
45
+
46
+ == Install
47
+
48
+ Add cartage-rack to your Gemfile:
49
+
50
+ gem 'cartage-rack', '~> 1.0'
51
+
52
+ Or manually install:
53
+
54
+ % gem install cartage-rack
55
+
56
+ == cartage-rack Semantic Versioning
57
+
58
+ cartage-rack uses a {Semantic Versioning}[http://semver.org/] scheme with one
59
+ change:
60
+
61
+ * When PATCH is zero (+0+), it will be omitted from version references.
62
+
63
+ cartage-rack will generally track cartage for major versions to ensure plugin API
64
+ compatibility.
65
+
66
+ :include: Contributing.rdoc
67
+
68
+ :include: Licence.rdoc
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require 'pathname'
6
+
7
+ Hoe.plugin :doofus
8
+ Hoe.plugin :email unless ENV['CI'] or ENV['TRAVIS']
9
+ Hoe.plugin :gemspec2
10
+ Hoe.plugin :git
11
+ Hoe.plugin :minitest
12
+ Hoe.plugin :rubygems
13
+
14
+ spec = Hoe.spec 'cartage-rack' do
15
+ developer('Austin Ziegler', 'aziegler@kineticcafe.com')
16
+
17
+ self.history_file = 'History.rdoc'
18
+ self.readme_file = 'README.rdoc'
19
+ self.extra_rdoc_files = FileList['*.rdoc'].to_a
20
+
21
+ license 'MIT'
22
+
23
+ self.extra_dev_deps << ['rake', '~> 10.0']
24
+ self.extra_dev_deps << ['rack-test', '~> 0.6']
25
+ self.extra_dev_deps << ['hoe-doofus', '~> 1.0']
26
+ self.extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
27
+ self.extra_dev_deps << ['hoe-git', '~> 1.5']
28
+ self.extra_dev_deps << ['minitest', '~> 5.4']
29
+ self.extra_dev_deps << ['minitest-autotest', '~> 1.0']
30
+ self.extra_dev_deps << ['minitest-bisect', '~> 1.2']
31
+ self.extra_dev_deps << ['minitest-focus', '~> 1.1']
32
+ self.extra_dev_deps << ['minitest-moar', '~> 0.0']
33
+ self.extra_dev_deps << ['minitest-pretty_diff', '~> 0.1']
34
+ self.extra_dev_deps << ['simplecov', '~> 0.7']
35
+ end
36
+
37
+ namespace :test do
38
+ task :coverage do
39
+ prelude = <<-EOS
40
+ require 'simplecov'
41
+ SimpleCov.start('test_frameworks') { command_name 'Minitest' }
42
+ gem 'minitest'
43
+ EOS
44
+ spec.test_prelude = prelude.split($/).join('; ')
45
+ Rake::Task['test'].execute
46
+ end
47
+ end
48
+
49
+ # vim: syntax=ruby
@@ -0,0 +1,52 @@
1
+ require 'pathname'
2
+
3
+ # Cartage, a package builder.
4
+ class Cartage; end
5
+
6
+ # Cartage::Rack is a simple application that reads an application’s
7
+ # +release_hashref+ and returns it as a +text/plain+ string, or as
8
+ # +application/json+ if it is called with +.json+.
9
+ #
10
+ # If +release_hashref+ does not exist, Cartage::Rack will read the hash of the
11
+ # current HEAD.
12
+ class Cartage::Rack
13
+ VERSION = '1.0' #:nodoc:
14
+
15
+ # Creates a new version of the Cartage::Rack application to the specified
16
+ # +root_path+, or +Dir.pwd+.
17
+ def self.mount(root_path = Dir.pwd)
18
+ new(root_path)
19
+ end
20
+
21
+ # Sets the root path for Cartage::Rack.
22
+ def initialize(root_path)
23
+ @root_path = Pathname(root_path)
24
+ end
25
+
26
+ # The Rack application method.
27
+ def call(env)
28
+ file = @root_path.join('release_hashref')
29
+ release_hashref = if file.exist?
30
+ file.read
31
+ elsif @root_path.join('.git').directory?
32
+ "(git) #{%x(git rev-parse --abbrev-ref HEAD)}"
33
+ else
34
+ 'UNKNOWN - no release_hashref or source control directory'
35
+ end
36
+ application_env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'UNKNOWN'
37
+
38
+ case env['PATH_INFO']
39
+ when /\.json\z/
40
+ type = 'application/json'
41
+ body = {
42
+ env: application_env,
43
+ release_hashref: release_hashref
44
+ }.to_json
45
+ else
46
+ type = 'text/plain'
47
+ body = "#{application_env}: #{release_hashref}"
48
+ end
49
+
50
+ [ '200', { 'Content-Type' => type }, [ body ] ]
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,267 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cartage-rack
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Austin Ziegler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
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'
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'
69
+ - !ruby/object:Gem::Dependency
70
+ name: hoe-doofus
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: hoe-gemspec2
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: hoe-git
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.5'
111
+ - !ruby/object:Gem::Dependency
112
+ name: minitest-autotest
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: minitest-bisect
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.2'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.2'
139
+ - !ruby/object:Gem::Dependency
140
+ name: minitest-focus
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.1'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.1'
153
+ - !ruby/object:Gem::Dependency
154
+ name: minitest-moar
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: minitest-pretty_diff
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.1'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.1'
181
+ - !ruby/object:Gem::Dependency
182
+ name: simplecov
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '0.7'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '0.7'
195
+ - !ruby/object:Gem::Dependency
196
+ name: hoe
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '3.13'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '3.13'
209
+ description: |-
210
+ cartage-rack is a plug-in for {cartage}[https://github.com/KineticCafe/cartage]
211
+ to provide a Rack application.
212
+
213
+ Cartage provides a repeatable means to create a package for a Rails application
214
+ that can be used in deployment with a configuration tool like Ansible, Chef,
215
+ Puppet, or Salt. The package is created with its dependencies bundled in
216
+ +vendor/bundle+, so it can be deployed in environments with strict access
217
+ control rules and without requiring development tool access.
218
+ email:
219
+ - aziegler@kineticcafe.com
220
+ executables: []
221
+ extensions: []
222
+ extra_rdoc_files:
223
+ - Contributing.rdoc
224
+ - History.rdoc
225
+ - Licence.rdoc
226
+ - Manifest.txt
227
+ - README.rdoc
228
+ files:
229
+ - ".autotest"
230
+ - ".gemtest"
231
+ - ".minitest.rb"
232
+ - Contributing.rdoc
233
+ - Gemfile
234
+ - History.rdoc
235
+ - Licence.rdoc
236
+ - Manifest.txt
237
+ - README.rdoc
238
+ - Rakefile
239
+ - lib/cartage/rack.rb
240
+ homepage: https://github.com/KineticCafe/cartage-rack/
241
+ licenses:
242
+ - MIT
243
+ metadata: {}
244
+ post_install_message:
245
+ rdoc_options:
246
+ - "--main"
247
+ - README.rdoc
248
+ require_paths:
249
+ - lib
250
+ required_ruby_version: !ruby/object:Gem::Requirement
251
+ requirements:
252
+ - - ">="
253
+ - !ruby/object:Gem::Version
254
+ version: '0'
255
+ required_rubygems_version: !ruby/object:Gem::Requirement
256
+ requirements:
257
+ - - ">="
258
+ - !ruby/object:Gem::Version
259
+ version: '0'
260
+ requirements: []
261
+ rubyforge_project:
262
+ rubygems_version: 2.2.2
263
+ signing_key:
264
+ specification_version: 4
265
+ summary: cartage-rack is a plug-in for {cartage}[https://github.com/KineticCafe/cartage]
266
+ to provide a Rack application
267
+ test_files: []