cartage-rack 2.2 → 2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/History.md +58 -32
- data/Manifest.txt +1 -1
- data/README.rdoc +13 -8
- data/Rakefile +56 -53
- data/lib/cartage/rack/metadata.rb +27 -27
- data/lib/cartage/rack/simple.rb +10 -10
- data/lib/cartage/rack.rb +22 -22
- data/test/{minitest_config.rb → minitest_helper.rb} +8 -17
- data/test/test_cartage_rack.rb +88 -88
- data/test/test_cartage_rack_metadata.rb +64 -64
- data/test/test_cartage_rack_simple.rb +49 -49
- metadata +102 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c6357c37ee4d9d28e1f86c9c9b6faf08e1055cbc984728e5b36fdfee1ed6d5f6
|
4
|
+
data.tar.gz: e9a6fb9b02d54955114bddfe1dfa33c36232da0fe940f5ad10a884245ae55f08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74dc05db4625ba79f1cf4001f39381aef8d44ad3bcd62553372a501e1109c42ad7cda2ebafc925a0b1b45617f15486309cd44ffd2324160d307f7f28699ae7b7
|
7
|
+
data.tar.gz: e22dc98cd990f1b15b90fe9f68efb30b6bb082b0cc3ffded72ee124e0ea4b15bf0c9fe169963691d3512a9f121e6f61623d81c98d1fc8bae5dc3938757d230cd
|
data/History.md
CHANGED
@@ -1,55 +1,81 @@
|
|
1
|
-
|
1
|
+
# Change History
|
2
2
|
|
3
|
-
|
3
|
+
## 2.3 / 2022-12-16
|
4
4
|
|
5
|
-
|
5
|
+
This is primarily a (mostly-mechanical) modernization of the codebase,
|
6
|
+
bringing it up to Kinetic Commerce 2022 standards.
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
- Remove dead development files: `.autotest`, `.gemtest`, `.minitest.rb`,
|
9
|
+
`.rubocop.yml`, `.simplecov-prelude.rb`, `.travis.yml`
|
9
10
|
|
10
|
-
|
11
|
+
- Add new development files: `.github/workflows/ruby.yml`, `.rdoc_options`,
|
12
|
+
`.standard.yml`, `Appraisals`, `gemfiles/*.gemfile`
|
11
13
|
|
12
|
-
|
14
|
+
- Clean up configuration: `.gitignore`, `.hoerc`, `Rakefile`
|
13
15
|
|
14
|
-
|
15
|
-
Cartage::Rack that returns more information.
|
16
|
+
- Updated generated files: `Manifest.txt`, `cartage-rack.gemspec`
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
- Renamed `test/minitest_config.rb` to `test/minitest_helper.rb` to reflect
|
19
|
+
consistent naming.
|
19
20
|
|
20
|
-
|
21
|
-
Cartage::Rack::Simple() methods.
|
21
|
+
- Removed `context` alias for `describe`.
|
22
22
|
|
23
|
-
|
23
|
+
- Apply formatting from `standardrb` after dropping raw rubocop.
|
24
24
|
|
25
|
-
|
26
|
-
Conduct][kccoc].
|
25
|
+
- Sunset cartage-rack as of this version.
|
27
26
|
|
28
|
-
|
27
|
+
## 2.2 / 2018-03-23
|
29
28
|
|
30
|
-
|
29
|
+
- Add support for ENV['APP_ENV'] per Sinatra documentation recommendations.
|
31
30
|
|
32
|
-
|
33
|
-
presenting badly.
|
31
|
+
## 2.1 / 2016-06-28
|
34
32
|
|
35
|
-
|
36
|
-
|
33
|
+
- Fix default env issue where ENV['RAILS_ENV'] nor ENV['RACK_ENV'] is set
|
34
|
+
by adding default string.
|
37
35
|
|
38
|
-
|
39
|
-
timestamp
|
36
|
+
## 2.0 / 2016-05-31
|
40
37
|
|
41
|
-
|
42
|
-
the response. A timestamp will not be included if there is no
|
43
|
-
`release_hashref` file.
|
38
|
+
- Rewrote for compatibility with cartage 2.0.
|
44
39
|
|
45
|
-
|
40
|
+
- Renamed Cartage::Rack to Cartage::Rack::Simple and created a _new_
|
41
|
+
Cartage::Rack that returns more information.
|
46
42
|
|
47
|
-
|
43
|
+
- Extracted metadata gathering out of Cartage::Rack and into
|
44
|
+
Cartage::Rack::Metadata.
|
48
45
|
|
49
|
-
|
46
|
+
- Deprecated Cartage::Rack.mount in favour of Cartage::Rack() and
|
47
|
+
Cartage::Rack::Simple() methods.
|
50
48
|
|
51
|
-
|
49
|
+
- 1 governance change
|
52
50
|
|
53
|
-
|
51
|
+
- cartage-rack is now under the Kinetic Cafe Open Source [Code of
|
52
|
+
Conduct][kccoc].
|
53
|
+
|
54
|
+
## 1.1 / 2015-04-11
|
55
|
+
|
56
|
+
- 2 minor enhancements
|
57
|
+
|
58
|
+
- Implemented Cartage::Rack#inspect to prevent `rake routes` from
|
59
|
+
presenting badly.
|
60
|
+
|
61
|
+
- Preparing for a future Cartage change to the contents of the
|
62
|
+
`release_hashref` file. The future `release_hashref` will be two lines:
|
63
|
+
|
64
|
+
hashref
|
65
|
+
timestamp
|
66
|
+
|
67
|
+
If `release_hashref` has two lines, the timestamp will be included in
|
68
|
+
the response. A timestamp will not be included if there is no
|
69
|
+
`release_hashref` file.
|
70
|
+
|
71
|
+
- 1 development change
|
72
|
+
|
73
|
+
- Implemented tests for Cartage::Rack.
|
74
|
+
|
75
|
+
## 1.0 / 2015-03-20
|
76
|
+
|
77
|
+
- 1 major enhancement
|
78
|
+
|
79
|
+
- Birthday!
|
54
80
|
|
55
81
|
[kccoc]: https://github.com/KineticCafe/code-of-conduct
|
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
@@ -6,14 +6,19 @@ continuous integration :: {<img src="https://travis-ci.org/KineticCafe/cartage-r
|
|
6
6
|
|
7
7
|
== Description
|
8
8
|
|
9
|
-
cartage-rack
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
This release is the *last* version of cartage-rack. It will be replaced with
|
10
|
+
a different tool in the future, but this release will allow installation in
|
11
|
+
modern Ruby versions.
|
12
|
+
|
13
|
+
cartage-rack is a plug-in for
|
14
|
+
{cartage}[https://github.com/KineticCafe/cartage] to provide a Rack
|
15
|
+
application that reports on release metadata.
|
16
|
+
|
17
|
+
Cartage provides a repeatable means to create a package for a Rails
|
18
|
+
application that can be used in deployment with a configuration tool like
|
19
|
+
Ansible, Chef, Puppet, or Salt. The package is created with its dependencies
|
20
|
+
bundled in +vendor/bundle+, so it can be deployed in environments with strict
|
21
|
+
access control rules and without requiring development tool access.
|
17
22
|
|
18
23
|
== Synopsis
|
19
24
|
|
data/Rakefile
CHANGED
@@ -1,68 +1,71 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "rubygems"
|
4
|
+
require "hoe"
|
5
|
+
require "rake/clean"
|
6
6
|
|
7
7
|
Hoe.plugin :doofus
|
8
|
-
Hoe.plugin :email unless ENV['CI'] || ENV['TRAVIS']
|
9
8
|
Hoe.plugin :gemspec2
|
10
|
-
Hoe.plugin :
|
11
|
-
Hoe.plugin :minitest
|
9
|
+
Hoe.plugin :git2
|
12
10
|
Hoe.plugin :rubygems
|
13
|
-
Hoe.plugin :travis
|
14
11
|
|
15
|
-
|
16
|
-
developer(
|
12
|
+
Hoe.spec "cartage-rack" do
|
13
|
+
developer("Austin Ziegler", "aziegler@kineticcommerce.com")
|
14
|
+
developer("Kinetic Commerce", "dev@kineticcommerce.com")
|
17
15
|
|
18
|
-
self.history_file =
|
19
|
-
self.readme_file =
|
16
|
+
self.history_file = "History.md"
|
17
|
+
self.readme_file = "README.rdoc"
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
#
|
19
|
+
# This is a hack because of an issue with Hoe 3.26, but I'm not sure which
|
20
|
+
# hoe version introduced this issue or if it's a JRuby issue. This issue is
|
21
|
+
# demonstrable in lib/hoe.rb at line 676, which is (reformatted for space):
|
22
|
+
#
|
23
|
+
# ```ruby
|
24
|
+
# readme =
|
25
|
+
# input
|
26
|
+
# .lines
|
27
|
+
# .chunk { |l| l[/^(?:=+|#+)/] || "" } # # chunk is different somehow
|
28
|
+
# .map(&:last) # <-- HERE: "#" does not respond to #last
|
29
|
+
# .each_slice(2)
|
30
|
+
# .map { |k, v|
|
31
|
+
# kp = k.join
|
32
|
+
# kp = kp.strip.chomp(":").split.last.downcase if k.size == 1
|
33
|
+
# [kp, v.join.strip]
|
34
|
+
# }
|
35
|
+
# .to_h
|
36
|
+
# ```
|
37
|
+
#
|
38
|
+
# We don't *ship* with JRuby, but use it in CI only, so this is here at least
|
39
|
+
# temporarily.
|
40
|
+
if RUBY_PLATFORM.match?(/java/)
|
41
|
+
self.summary = self.description = "Description for testing"
|
42
|
+
self.homepage = "https://github.com/KineticCafe/app-identity/tree/main/ruby/"
|
43
|
+
end
|
26
44
|
|
27
|
-
|
28
|
-
extra_dev_deps << ['rdoc', '~> 4.2']
|
29
|
-
extra_dev_deps << ['rack-test', '~> 0.6']
|
30
|
-
extra_dev_deps << ['hoe-doofus', '~> 1.0']
|
31
|
-
extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
|
32
|
-
extra_dev_deps << ['hoe-git', '~> 1.5']
|
33
|
-
extra_dev_deps << ['hoe-travis', '~> 1.2']
|
34
|
-
extra_dev_deps << ['minitest', '~> 5.4']
|
35
|
-
extra_dev_deps << ['minitest-autotest', '~> 1.0']
|
36
|
-
extra_dev_deps << ['minitest-bisect', '~> 1.2']
|
37
|
-
extra_dev_deps << ['minitest-bonus-assertions', '~> 2.0']
|
38
|
-
extra_dev_deps << ['minitest-focus', '~> 1.1']
|
39
|
-
extra_dev_deps << ['minitest-hooks', '~> 1.4']
|
40
|
-
extra_dev_deps << ['minitest-moar', '~> 0.0']
|
41
|
-
extra_dev_deps << ['minitest-pretty_diff', '~> 0.1']
|
42
|
-
extra_dev_deps << ['timecop', '~> 0.8']
|
43
|
-
extra_dev_deps << ['simplecov', '~> 0.7']
|
44
|
-
end
|
45
|
+
license "MIT"
|
45
46
|
|
46
|
-
|
47
|
+
require_ruby_version ">= 2.7", "< 4"
|
47
48
|
|
48
|
-
|
49
|
-
alias __make_rdoc_cmd__cartage__ make_rdoc_cmd
|
49
|
+
spec_extras[:metadata] = ->(val) { val["rubygems_mfa_required"] = "true" }
|
50
50
|
|
51
|
-
|
52
|
-
spec.extra_rdoc_files.delete_if { |f| f == 'Manifest.txt' }
|
53
|
-
__make_rdoc_cmd__cartage__(*extra_args)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
if File.exist?('.simplecov-prelude.rb')
|
58
|
-
namespace :test do
|
59
|
-
task :coverage do
|
60
|
-
spec.test_prelude = 'load ".simplecov-prelude.rb"'
|
61
|
-
Rake::Task['test'].execute
|
62
|
-
end
|
51
|
+
# This gem *explicitly* does not have a hard link to cartage.
|
63
52
|
|
64
|
-
|
65
|
-
|
53
|
+
extra_dev_deps << ["appraisal", "~> 2.4"]
|
54
|
+
extra_dev_deps << ["hoe-doofus", "~> 1.0"]
|
55
|
+
extra_dev_deps << ["hoe-gemspec2", "~> 1.1"]
|
56
|
+
extra_dev_deps << ["hoe-git2", "~> 1.7"]
|
57
|
+
extra_dev_deps << ["hoe-rubygems", "~> 1.0"]
|
58
|
+
extra_dev_deps << ["minitest", "~> 5.16"]
|
59
|
+
extra_dev_deps << ["minitest-autotest", "~> 1.0"]
|
60
|
+
extra_dev_deps << ["minitest-bisect", "~> 1.2"]
|
61
|
+
extra_dev_deps << ["minitest-focus", "~> 1.1"]
|
62
|
+
extra_dev_deps << ["minitest-hooks", "~> 1.4"]
|
63
|
+
extra_dev_deps << ["minitest-moar", "~> 0.0"]
|
64
|
+
extra_dev_deps << ["minitest-pretty_diff", "~> 0.1"]
|
65
|
+
extra_dev_deps << ["rack-test", "~> 2.0"]
|
66
|
+
extra_dev_deps << ["rake", ">= 10.0", "< 14"]
|
67
|
+
extra_dev_deps << ["rdoc", "~> 6.4"]
|
68
|
+
extra_dev_deps << ["simplecov", "~> 0.7"]
|
69
|
+
extra_dev_deps << ["standard", "~> 1.0"]
|
70
|
+
extra_dev_deps << ["timecop", "~> 0.8"]
|
66
71
|
end
|
67
|
-
|
68
|
-
CLOBBER << 'tmp'
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "pathname"
|
4
|
+
require "json"
|
5
5
|
|
6
6
|
##
|
7
7
|
# A representation for Cartage metadata for use with Cartage::Rack and
|
8
8
|
# Cartage::Rack::Simple.
|
9
9
|
class Cartage::Rack::Metadata
|
10
|
-
METADATA_CLEANER = ->(_, v) {
|
11
|
-
v.delete_if(&METADATA_CLEANER) if v.
|
10
|
+
METADATA_CLEANER = ->(_, v) { # :nodoc:
|
11
|
+
v.delete_if(&METADATA_CLEANER) if v.is_a?(Hash)
|
12
12
|
v.nil? || (v.respond_to?(:empty?) && v.empty?)
|
13
13
|
}
|
14
14
|
private_constant :METADATA_CLEANER
|
@@ -31,7 +31,7 @@ class Cartage::Rack::Metadata
|
|
31
31
|
@filter = filter
|
32
32
|
@content = read_release_metadata_json || read_release_hashref
|
33
33
|
|
34
|
-
fail
|
34
|
+
fail "Cannot find release-metadata.json or release_hashref" if required && !@content
|
35
35
|
|
36
36
|
@source ||= :live
|
37
37
|
end
|
@@ -41,11 +41,11 @@ class Cartage::Rack::Metadata
|
|
41
41
|
# content data.
|
42
42
|
def resolve
|
43
43
|
content.merge(application_env).tap do |data|
|
44
|
-
@filter
|
44
|
+
@filter&.call(data)
|
45
45
|
end.delete_if(&METADATA_CLEANER)
|
46
46
|
end
|
47
47
|
|
48
|
-
def inspect
|
48
|
+
def inspect # :nodoc:
|
49
49
|
"#{@root_path.expand_path.basename} (#{@source})"
|
50
50
|
end
|
51
51
|
|
@@ -53,7 +53,7 @@ class Cartage::Rack::Metadata
|
|
53
53
|
|
54
54
|
def application_env
|
55
55
|
@application_env ||= {
|
56
|
-
|
56
|
+
"env" => {"name" => ENV["RAILS_ENV"] || ENV["APP_ENV"] || ENV["RACK_ENV"] || "UNKNOWN"}
|
57
57
|
}
|
58
58
|
end
|
59
59
|
|
@@ -61,24 +61,24 @@ class Cartage::Rack::Metadata
|
|
61
61
|
return @content if @content
|
62
62
|
|
63
63
|
{
|
64
|
-
|
64
|
+
"package" => {}
|
65
65
|
}.tap do |result|
|
66
|
-
package = result[
|
67
|
-
package[
|
68
|
-
package[
|
69
|
-
package[
|
66
|
+
package = result["package"]
|
67
|
+
package["name"] = @root_path.basename.to_s
|
68
|
+
package["hashref"] = release_hashref
|
69
|
+
package["timestamp"] = Time.now.utc.strftime("%Y%m%d%H%M%S")
|
70
70
|
|
71
71
|
if repo?
|
72
|
-
package[
|
73
|
-
|
74
|
-
|
72
|
+
package["repo"] = {
|
73
|
+
"type" => "git", # Hardcoded until we have other support
|
74
|
+
"url" => repo_url
|
75
75
|
}
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
80
|
def read_release_metadata_json
|
81
|
-
file = @root_path.join(
|
81
|
+
file = @root_path.join("release-metadata.json")
|
82
82
|
|
83
83
|
return unless file.exist?
|
84
84
|
|
@@ -87,7 +87,7 @@ class Cartage::Rack::Metadata
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def read_release_hashref
|
90
|
-
file = @root_path.join(
|
90
|
+
file = @root_path.join("release_hashref")
|
91
91
|
|
92
92
|
return unless file.exist?
|
93
93
|
|
@@ -96,10 +96,10 @@ class Cartage::Rack::Metadata
|
|
96
96
|
hashref, timestamp, = file.read.split($/)
|
97
97
|
|
98
98
|
{
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
99
|
+
"package" => {
|
100
|
+
"name" => @root_path.basename.to_s,
|
101
|
+
"hashref" => hashref,
|
102
|
+
"timestamp" => timestamp
|
103
103
|
}
|
104
104
|
}.delete_if(&METADATA_CLEANER)
|
105
105
|
end
|
@@ -107,22 +107,22 @@ class Cartage::Rack::Metadata
|
|
107
107
|
def repo_url
|
108
108
|
return unless repo?
|
109
109
|
unless defined?(@repo_url)
|
110
|
-
@repo_url =
|
111
|
-
match(/\n\s+Fetch URL: (?<fetch>[^\n]+)/)[:fetch]
|
110
|
+
@repo_url = `git remote show -n origin`
|
111
|
+
.match(/\n\s+Fetch URL: (?<fetch>[^\n]+)/)[:fetch]
|
112
112
|
end
|
113
113
|
@repo_url
|
114
114
|
end
|
115
115
|
|
116
116
|
def release_hashref
|
117
117
|
if repo?
|
118
|
-
"(git) #{
|
118
|
+
"(git) #{`git rev-parse --abbrev-ref HEAD`.chomp}"
|
119
119
|
else
|
120
|
-
|
120
|
+
"UNKNOWN - no .git directory"
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
124
|
def repo?
|
125
|
-
@is_repo = @root_path.join(
|
125
|
+
@is_repo = @root_path.join(".git").directory? unless defined?(@is_repo)
|
126
126
|
@is_repo
|
127
127
|
end
|
128
128
|
end
|
data/lib/cartage/rack/simple.rb
CHANGED
@@ -6,9 +6,9 @@ class Cartage::Rack
|
|
6
6
|
# Creates a new instance of the Cartage::Rack::Simple application to the
|
7
7
|
# specified +root_path+, or +Dir.pwd+. This method has been deprecated.
|
8
8
|
def mount(root_path = nil)
|
9
|
-
warn
|
10
|
-
Cartage::Rack.mount(path) is deprecated; use Cartage::Rack::Simple(path) instead.
|
11
|
-
|
9
|
+
warn <<~WARNING
|
10
|
+
Cartage::Rack.mount(path) is deprecated; use Cartage::Rack::Simple(path) instead.
|
11
|
+
WARNING
|
12
12
|
Simple(root_path)
|
13
13
|
end
|
14
14
|
|
@@ -36,21 +36,21 @@ Cartage::Rack.mount(path) is deprecated; use Cartage::Rack::Simple(path) instead
|
|
36
36
|
|
37
37
|
content = {}
|
38
38
|
|
39
|
-
content[:env] = dig(full_content,
|
40
|
-
content[:release_hashref] = dig(full_content,
|
41
|
-
content[:timestamp] = dig(full_content,
|
39
|
+
content[:env] = dig(full_content, "env", "name")
|
40
|
+
content[:release_hashref] = dig(full_content, "package", "hashref")
|
41
|
+
content[:timestamp] = dig(full_content, "package", "timestamp")
|
42
42
|
|
43
|
-
case env[
|
43
|
+
case env["PATH_INFO"]
|
44
44
|
when /\.json\z/
|
45
|
-
type =
|
45
|
+
type = "application/json"
|
46
46
|
body = content.to_json
|
47
47
|
else
|
48
|
-
type =
|
48
|
+
type = "text/plain"
|
49
49
|
body = "#{content[:env]}: #{content[:release_hashref]}"
|
50
50
|
body += " (#{content[:timestamp]})" if content[:timestamp]
|
51
51
|
end
|
52
52
|
|
53
|
-
[
|
53
|
+
[type, body]
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
data/lib/cartage/rack.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "pathname"
|
4
|
+
require "json"
|
5
5
|
|
6
6
|
# Cartage, a package builder.
|
7
7
|
class Cartage
|
@@ -15,7 +15,7 @@ class Cartage
|
|
15
15
|
# +application/json+ value, or as a +text/plain+ string if called with
|
16
16
|
# +.text+ or +.txt+.
|
17
17
|
class Rack
|
18
|
-
VERSION =
|
18
|
+
VERSION = "2.3" # :nodoc:
|
19
19
|
|
20
20
|
class << self
|
21
21
|
# When +true+, Cartage::Rack and Cartage::Rack::Simple will raise an
|
@@ -32,7 +32,7 @@ class Cartage
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def default_require_metadata
|
35
|
-
environment = ENV[
|
35
|
+
environment = ENV["RAILS_ENV"] || ENV["APP_ENV"] || ENV["RACK_ENV"] || "development"
|
36
36
|
environment !~ /\A(?:development|test)\z/i
|
37
37
|
end
|
38
38
|
end
|
@@ -41,12 +41,12 @@ class Cartage
|
|
41
41
|
@metadata = Cartage::Rack::Metadata.new(root_path, filter: filter)
|
42
42
|
end
|
43
43
|
|
44
|
-
def call(env)
|
44
|
+
def call(env) # :nodoc:
|
45
45
|
type, body = resolve_content(env)
|
46
|
-
[
|
46
|
+
["200", {"Content-Type" => type}, [body]]
|
47
47
|
end
|
48
48
|
|
49
|
-
def inspect
|
49
|
+
def inspect # :nodoc:
|
50
50
|
"#{self.class} for #{@metadata.inspect}"
|
51
51
|
end
|
52
52
|
|
@@ -55,32 +55,32 @@ class Cartage
|
|
55
55
|
def resolve_content(env)
|
56
56
|
content = @metadata.resolve
|
57
57
|
|
58
|
-
case env[
|
58
|
+
case env["PATH_INFO"]
|
59
59
|
when /\.te?xt\z/
|
60
|
-
type =
|
60
|
+
type = "text/plain"
|
61
61
|
body = [
|
62
|
-
"name: #{dig(content,
|
63
|
-
"environment: #{dig(content,
|
64
|
-
"hashref: #{dig(content,
|
62
|
+
"name: #{dig(content, "package", "name")}",
|
63
|
+
"environment: #{dig(content, "env", "name")}",
|
64
|
+
"hashref: #{dig(content, "package", "hashref")}"
|
65
65
|
]
|
66
66
|
|
67
|
-
value = dig(content,
|
67
|
+
value = dig(content, "package", "timestamp")
|
68
68
|
body << "timestamp: #{value}" if value
|
69
69
|
|
70
|
-
repo = dig(content,
|
71
|
-
body << "#{repo[
|
70
|
+
repo = dig(content, "package", "repo")
|
71
|
+
body << "#{repo["type"]}: #{repo["url"]}" if repo
|
72
72
|
body = body.join("\n")
|
73
73
|
else
|
74
|
-
type =
|
74
|
+
type = "application/json"
|
75
75
|
body = content.to_json
|
76
76
|
end
|
77
77
|
|
78
|
-
[
|
78
|
+
[type, body]
|
79
79
|
end
|
80
80
|
|
81
81
|
attr_reader :metadata
|
82
82
|
|
83
|
-
|
83
|
+
# :nocov:
|
84
84
|
def dig(hash, key, *rest)
|
85
85
|
if hash.respond_to?(:dig)
|
86
86
|
hash.dig(key, *rest)
|
@@ -89,7 +89,7 @@ class Cartage
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
DIGGER = ->(h, k, *r) {
|
92
|
+
DIGGER = ->(h, k, *r) { # :nodoc:
|
93
93
|
v = h[k]
|
94
94
|
if v.nil? || r.empty?
|
95
95
|
v
|
@@ -98,9 +98,9 @@ class Cartage
|
|
98
98
|
end
|
99
99
|
}
|
100
100
|
private_constant :DIGGER
|
101
|
-
|
101
|
+
# :nocov:
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
require_relative
|
106
|
-
require_relative
|
105
|
+
require_relative "rack/simple"
|
106
|
+
require_relative "rack/metadata"
|
@@ -1,18 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
gem
|
4
|
-
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require 'minitest/hooks/default'
|
11
|
-
require 'timecop'
|
3
|
+
gem "minitest"
|
4
|
+
|
5
|
+
require "minitest/autorun"
|
6
|
+
require "minitest/hooks/default"
|
7
|
+
require "minitest/moar"
|
8
|
+
require "rack/test"
|
9
|
+
require "timecop"
|
12
10
|
|
13
11
|
Timecop.safe_mode = true
|
14
12
|
|
15
|
-
require
|
13
|
+
require "cartage/rack"
|
16
14
|
|
17
15
|
module Minitest::CartageRackStubs
|
18
16
|
def stub_dir_pwd value, *block_args, &block
|
@@ -24,8 +22,6 @@ module Minitest::CartageRackStubs
|
|
24
22
|
env.fetch(key) { |k|
|
25
23
|
if options[:passthrough]
|
26
24
|
ENV.send(:"__minitest_stub__[]", k)
|
27
|
-
else
|
28
|
-
nil
|
29
25
|
end
|
30
26
|
}
|
31
27
|
}
|
@@ -75,8 +71,3 @@ module Minitest::CartageRackStubs
|
|
75
71
|
|
76
72
|
Minitest::Test.send(:include, self)
|
77
73
|
end
|
78
|
-
|
79
|
-
class << Minitest::Spec
|
80
|
-
alias context describe
|
81
|
-
private :context
|
82
|
-
end
|