Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.

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

## [Unreleased]

### Removed

- Remove deprecated `PLINY_ENV` environment variable support in favor of `APP_ENV` to align with Sinatra conventions (https://github.com/interagent/pliny/pull/373)

## [1.2.0] - 2025-02-10
### Added
- Add support for Ruby 3.3 and 3.4 ([#366](https://github.com/interagent/pliny/pull/3366))
Expand Down
26 changes: 1 addition & 25 deletions lib/pliny/config_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,13 @@ def array(method = nil)
end

def rack_env
if env == "development" || env == "test"
if app_env == "development" || app_env == "test"
"development"
else
"deployment"
end
end

# DEPRECATED: pliny_env is deprecated in favour of app_env.
# See more at https://github.com/interagent/pliny/issues/277
#
# This method is kept temporary in case it is used somewhere in the app.
def pliny_env
warn "Config.pliny_env is deprecated and will be removed, " \
"use Config.app_env instead."
env
end

private

def cast(value, method)
Expand All @@ -80,20 +70,6 @@ def create(name, value)
instance_eval "def #{name}?; !!@#{name} end", __FILE__, __LINE__
end
end

# This method helps with transition from PLINY_ENV to APP_ENV.
def env
legacy_env || app_env
end

# PLINY_ENV is deprecated, but it might be still used by someone.
def legacy_env
if ENV.key?("PLINY_ENV")
warn "PLINY_ENV is deprecated in favour of APP_ENV, " \
"update .env file or application configuration."
ENV["PLINY_ENV"]
end
end
end

# DEPRECATED: ConfigHelpers was a slightly more primitive version
Expand Down
79 changes: 0 additions & 79 deletions spec/config_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,84 +49,5 @@

assert_equal "deployment", config.rack_env
end

context "when legacy PLINY_ENV is still defined" do
before do
ENV["ORIGINAL_PLINY_ENV"] = ENV["PLINY_ENV"]
ENV["PLINY_ENV"] = "staging"
end

after do
ENV["PLINY_ENV"] = ENV.delete("ORIGINAL_PLINY_ENV")
end

it "uses PLINY_ENV value instead of APP_ENV" do
config = Class.new do
extend Pliny::CastingConfigHelpers
override :app_env, "development", string
end

assert_equal "deployment", config.rack_env
end

it "displays deprecation warning" do
config = Class.new do
extend Pliny::CastingConfigHelpers
override :app_env, "development", string
end

io = StringIO.new
$stderr = io
config.rack_env
$stderr = STDERR

assert_includes io.string, "PLINY_ENV is deprecated"
end
end
end

describe "#pliny_env" do
it "displays deprecation warning if pliny_env is used" do
config = Class.new do
extend Pliny::CastingConfigHelpers
override :app_env, "development", string
end

io = StringIO.new
$stderr = io
config.pliny_env
$stderr = STDERR

assert_includes io.string, "Config.pliny_env is deprecated"
end

it "returns app_env value" do
config = Class.new do
extend Pliny::CastingConfigHelpers
override :app_env, "foo", string
end

assert_equal "foo", config.pliny_env
end

context "when legacy PLINY_ENV is still defined" do
before do
ENV["ORIGINAL_PLINY_ENV"] = ENV["PLINY_ENV"]
ENV["PLINY_ENV"] = "staging"
end

after do
ENV["PLINY_ENV"] = ENV.delete("ORIGINAL_PLINY_ENV")
end

it "returns PLINY_ENV value" do
config = Class.new do
extend Pliny::CastingConfigHelpers
override :app_env, "development", string
end

assert_equal "staging", config.pliny_env
end
end
end
end