Skip to content

Commit 1a366ca

Browse files
authored
Merge pull request #373 from interagent/bf/rm-pliny-env
remove deprecated code to handle PLINY_ENV
2 parents e80d635 + bd2d8ab commit 1a366ca

File tree

3 files changed

+7
-104
lines changed

3 files changed

+7
-104
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [Unreleased]
7+
8+
### Removed
9+
10+
- Remove deprecated `PLINY_ENV` environment variable support in favor of `APP_ENV` to align with Sinatra conventions (https://github.com/interagent/pliny/pull/373)
11+
612
## [1.2.0] - 2025-02-10
713
### Added
814
- Add support for Ruby 3.3 and 3.4 ([#366](https://github.com/interagent/pliny/pull/3366))

lib/pliny/config_helpers.rb

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,13 @@ def array(method = nil)
5050
end
5151

5252
def rack_env
53-
if env == "development" || env == "test"
53+
if app_env == "development" || app_env == "test"
5454
"development"
5555
else
5656
"deployment"
5757
end
5858
end
5959

60-
# DEPRECATED: pliny_env is deprecated in favour of app_env.
61-
# See more at https://github.com/interagent/pliny/issues/277
62-
#
63-
# This method is kept temporary in case it is used somewhere in the app.
64-
def pliny_env
65-
warn "Config.pliny_env is deprecated and will be removed, " \
66-
"use Config.app_env instead."
67-
env
68-
end
69-
7060
private
7161

7262
def cast(value, method)
@@ -80,20 +70,6 @@ def create(name, value)
8070
instance_eval "def #{name}?; !!@#{name} end", __FILE__, __LINE__
8171
end
8272
end
83-
84-
# This method helps with transition from PLINY_ENV to APP_ENV.
85-
def env
86-
legacy_env || app_env
87-
end
88-
89-
# PLINY_ENV is deprecated, but it might be still used by someone.
90-
def legacy_env
91-
if ENV.key?("PLINY_ENV")
92-
warn "PLINY_ENV is deprecated in favour of APP_ENV, " \
93-
"update .env file or application configuration."
94-
ENV["PLINY_ENV"]
95-
end
96-
end
9773
end
9874

9975
# DEPRECATED: ConfigHelpers was a slightly more primitive version

spec/config_helpers_spec.rb

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -49,84 +49,5 @@
4949

5050
assert_equal "deployment", config.rack_env
5151
end
52-
53-
context "when legacy PLINY_ENV is still defined" do
54-
before do
55-
ENV["ORIGINAL_PLINY_ENV"] = ENV["PLINY_ENV"]
56-
ENV["PLINY_ENV"] = "staging"
57-
end
58-
59-
after do
60-
ENV["PLINY_ENV"] = ENV.delete("ORIGINAL_PLINY_ENV")
61-
end
62-
63-
it "uses PLINY_ENV value instead of APP_ENV" do
64-
config = Class.new do
65-
extend Pliny::CastingConfigHelpers
66-
override :app_env, "development", string
67-
end
68-
69-
assert_equal "deployment", config.rack_env
70-
end
71-
72-
it "displays deprecation warning" do
73-
config = Class.new do
74-
extend Pliny::CastingConfigHelpers
75-
override :app_env, "development", string
76-
end
77-
78-
io = StringIO.new
79-
$stderr = io
80-
config.rack_env
81-
$stderr = STDERR
82-
83-
assert_includes io.string, "PLINY_ENV is deprecated"
84-
end
85-
end
86-
end
87-
88-
describe "#pliny_env" do
89-
it "displays deprecation warning if pliny_env is used" do
90-
config = Class.new do
91-
extend Pliny::CastingConfigHelpers
92-
override :app_env, "development", string
93-
end
94-
95-
io = StringIO.new
96-
$stderr = io
97-
config.pliny_env
98-
$stderr = STDERR
99-
100-
assert_includes io.string, "Config.pliny_env is deprecated"
101-
end
102-
103-
it "returns app_env value" do
104-
config = Class.new do
105-
extend Pliny::CastingConfigHelpers
106-
override :app_env, "foo", string
107-
end
108-
109-
assert_equal "foo", config.pliny_env
110-
end
111-
112-
context "when legacy PLINY_ENV is still defined" do
113-
before do
114-
ENV["ORIGINAL_PLINY_ENV"] = ENV["PLINY_ENV"]
115-
ENV["PLINY_ENV"] = "staging"
116-
end
117-
118-
after do
119-
ENV["PLINY_ENV"] = ENV.delete("ORIGINAL_PLINY_ENV")
120-
end
121-
122-
it "returns PLINY_ENV value" do
123-
config = Class.new do
124-
extend Pliny::CastingConfigHelpers
125-
override :app_env, "development", string
126-
end
127-
128-
assert_equal "staging", config.pliny_env
129-
end
130-
end
13152
end
13253
end

0 commit comments

Comments
 (0)