cartage-rack 2.1 → 2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2ff5b79fccc786f315f9269e5b4029dc3712210
4
- data.tar.gz: a926ac738731f626e7aef89051432d0f2ddeea0f
3
+ metadata.gz: 2465d098dc1c5b15660734a754de4665cff292af
4
+ data.tar.gz: e48adff2eed98b3ce4c5ce3e0079535882bb7c02
5
5
  SHA512:
6
- metadata.gz: 195ad85dddd5128cced2f1104502d103d864c8a0d569ee5bfd2daf77d010a72294410db537febd1095c3d3fa5ab373227a6155854634bd9ca62de9e74769d7f7
7
- data.tar.gz: d6e8ba01329def7fe85668577434553b5749a7d79f7852eb4a95c8906cd57faaf1b6721ade8cebe2048ab6520b0ff9323fce290357fca1ccc4de20d7611165f7
6
+ metadata.gz: 3bce5c5f612e32ba55a271b64629632f89ba59a1c063d6a314af921698fb1dcad47d24ec2d9d965f3d4fc55016fe6cf916d583ba6396c749f79972fb32fb7f23
7
+ data.tar.gz: 487205fedd6cb0ad42a54a36c2c1fe0f6f17f9dcc73156ca1d9ad02923b613885ecb2c5194cf5b1b8a20a706aa5f3c698d523c6d7ac28131b052349e49badb7e
@@ -59,6 +59,7 @@ Here's the most direct way to get your work merged into the project:
59
59
  ### Contributors
60
60
 
61
61
  * Austin Ziegler created cartage-rack.
62
+ * Jesse Mignac added support for `$APP_ENV`.
62
63
 
63
64
  [Minitest]: https://github.com/seattlerb/minitest
64
65
  [quality commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
data/History.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 2.2 / 2018-03-23
2
+
3
+ * Add support for ENV['APP_ENV'] per Sinatra documentation recommendations.
4
+
1
5
  ### 2.1 / 2016-06-28
2
6
 
3
7
  * Fix default env issue where ENV['RAILS_ENV'] nor ENV['RACK_ENV'] is set
data/Rakefile CHANGED
@@ -54,16 +54,15 @@ module Hoe::Publish #:nodoc:
54
54
  end
55
55
  end
56
56
 
57
- namespace :test do
58
- if File.exist?('.simplecov-prelude.rb')
57
+ if File.exist?('.simplecov-prelude.rb')
58
+ namespace :test do
59
59
  task :coverage do
60
60
  spec.test_prelude = 'load ".simplecov-prelude.rb"'
61
-
62
61
  Rake::Task['test'].execute
63
62
  end
64
- end
65
63
 
66
- CLOBBER << 'coverage'
64
+ CLOBBER << 'coverage'
65
+ end
67
66
  end
68
67
 
69
68
  CLOBBER << 'tmp'
@@ -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 = '2.1' #:nodoc:
18
+ VERSION = '2.2' #:nodoc:
19
19
 
20
20
  class << self
21
21
  # When +true+, Cartage::Rack and Cartage::Rack::Simple will raise an
@@ -23,7 +23,7 @@ class Cartage
23
23
  # +release_hashref+). May be explicitly turned off.
24
24
  #
25
25
  # Defaults to +true+ except in development or test environments (based on
26
- # <tt>$RAILS_ENV</tt> and <tt>$RACK_ENV</tt>).
26
+ # <tt>$RAILS_ENV</tt>, <tt>$APP_ENV</tt> and <tt>$RACK_ENV</tt>).
27
27
  def require_metadata(value = (arg = false; nil)) # rubocop:disable Style/Semicolon
28
28
  @require_metadata = value unless arg == false
29
29
  @require_metadata || default_require_metadata
@@ -32,7 +32,7 @@ class Cartage
32
32
  private
33
33
 
34
34
  def default_require_metadata
35
- environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
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
@@ -53,7 +53,7 @@ class Cartage::Rack::Metadata
53
53
 
54
54
  def application_env
55
55
  @application_env ||= {
56
- 'env' => { 'name' => ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'UNKNOWN' }
56
+ 'env' => { 'name' => ENV['RAILS_ENV'] || ENV['APP_ENV'] || ENV['RACK_ENV'] || 'UNKNOWN' }
57
57
  }
58
58
  end
59
59
 
@@ -48,7 +48,9 @@ describe Cartage::Rack do
48
48
 
49
49
  context 'application environment' do
50
50
  it 'uses $RAILS_ENV first' do
51
- stub_env 'RAILS_ENV' => 'vne_sliar', 'RACK_ENV' => 'vne_kcar' do
51
+ stub_env 'RAILS_ENV' => 'vne_sliar',
52
+ 'APP_ENV' => 'vne_ppa',
53
+ 'RACK_ENV' => 'vne_kcar' do
52
54
  get '/'
53
55
 
54
56
  metadata['env'] = { 'name' => 'vne_sliar' }
@@ -59,8 +61,20 @@ describe Cartage::Rack do
59
61
  end
60
62
  end
61
63
 
62
- it 'uses $RACK_ENV second' do
63
- stub_env 'RAILS_ENV' => nil, 'RACK_ENV' => 'vne_kcar' do
64
+ it 'uses $APP_ENV second' do
65
+ stub_env 'RAILS_ENV' => nil, 'APP_ENV' => 'vne_ppa', 'RACK_ENV' => 'vne_kcar' do
66
+ get '/'
67
+
68
+ metadata['env'] = { 'name' => 'vne_ppa' }
69
+
70
+ assert last_response.ok?
71
+ assert_equal metadata.to_json, last_response.body
72
+ assert_equal 'application/json', last_response.header['Content-Type']
73
+ end
74
+ end
75
+
76
+ it 'uses $RACK_ENV third' do
77
+ stub_env 'RAILS_ENV' => nil, 'APP_ENV' => nil, 'RACK_ENV' => 'vne_kcar' do
64
78
  get '/'
65
79
 
66
80
  metadata['env'] = { 'name' => 'vne_kcar' }
@@ -71,8 +85,8 @@ describe Cartage::Rack do
71
85
  end
72
86
  end
73
87
 
74
- it 'falls through to UNKNOWN without either $RAILS_ENV or $RACK_ENV' do
75
- stub_env 'RAILS_ENV' => nil, 'RACK_ENV' => nil do
88
+ it 'falls through to UNKNOWN without either $RAILS_ENV, $APP_ENV or $RACK_ENV' do
89
+ stub_env 'RAILS_ENV' => nil, 'APP_ENV' => nil, 'RACK_ENV' => nil do
76
90
  get '/'
77
91
 
78
92
  metadata['env'] = { 'name' => 'UNKNOWN' }
@@ -57,7 +57,9 @@ describe Cartage::Rack::Simple do
57
57
 
58
58
  context 'application environment' do
59
59
  it 'uses $RAILS_ENV first' do
60
- stub_env 'RAILS_ENV' => 'vne_sliar', 'RACK_ENV' => 'vne_kcar' do
60
+ stub_env 'RAILS_ENV' => 'vne_sliar',
61
+ 'APP_ENV' => 'vne_ppa',
62
+ 'RACK_ENV' => 'vne_kcar' do
61
63
  get '/'
62
64
 
63
65
  assert last_response.ok?
@@ -66,8 +68,18 @@ describe Cartage::Rack::Simple do
66
68
  end
67
69
  end
68
70
 
69
- it 'uses $RACK_ENV second' do
70
- stub_env 'RAILS_ENV' => nil, 'RACK_ENV' => 'vne_kcar' do
71
+ it 'uses $APP_ENV second' do
72
+ stub_env 'RAILS_ENV' => nil, 'APP_ENV' => 'vne_ppa', 'RACK_ENV' => 'vne_kcar' do
73
+ get '/'
74
+
75
+ assert last_response.ok?
76
+ assert_equal 'vne_ppa: d0cb1ff (19851027104200)', last_response.body
77
+ assert_equal 'text/plain', last_response.header['Content-Type']
78
+ end
79
+ end
80
+
81
+ it 'uses $RACK_ENV third' do
82
+ stub_env 'RAILS_ENV' => nil, 'APP_ENV' => nil, 'RACK_ENV' => 'vne_kcar' do
71
83
  get '/'
72
84
 
73
85
  assert last_response.ok?
@@ -76,8 +88,8 @@ describe Cartage::Rack::Simple do
76
88
  end
77
89
  end
78
90
 
79
- it 'falls through to UNKNOWN without either $RAILS_ENV or $RACK_ENV' do
80
- stub_env 'RAILS_ENV' => nil, 'RACK_ENV' => nil do
91
+ it 'falls through to UNKNOWN without either $RAILS_ENV, $APP_ENV or $RACK_ENV' do
92
+ stub_env 'RAILS_ENV' => nil, 'APP_ENV' => nil, 'RACK_ENV' => nil do
81
93
  get '/'
82
94
 
83
95
  assert last_response.ok?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cartage-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.1'
4
+ version: '2.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Ziegler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-28 00:00:00.000000000 Z
11
+ date: 2018-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.9'
19
+ version: '5.11'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '5.9'
26
+ version: '5.11'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rdoc
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '4.0'
40
+ version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '4.2'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '4.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rack-test
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -254,14 +254,14 @@ dependencies:
254
254
  requirements:
255
255
  - - "~>"
256
256
  - !ruby/object:Gem::Version
257
- version: '3.15'
257
+ version: '3.16'
258
258
  type: :development
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
262
  - - "~>"
263
263
  - !ruby/object:Gem::Version
264
- version: '3.15'
264
+ version: '3.16'
265
265
  description: |-
266
266
  cartage-rack is a plug-in for {cartage}[https://github.com/KineticCafe/cartage]
267
267
  to provide a Rack application that reports on release metadata.
@@ -317,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
317
317
  version: '0'
318
318
  requirements: []
319
319
  rubyforge_project:
320
- rubygems_version: 2.6.4
320
+ rubygems_version: 2.6.14
321
321
  signing_key:
322
322
  specification_version: 4
323
323
  summary: cartage-rack is a plug-in for {cartage}[https://github.com/KineticCafe/cartage]