Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Hashie >= 4.0 optional #33

Merged
merged 5 commits into from
Jan 24, 2023
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
4 changes: 2 additions & 2 deletions fittings.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "fittings"
s.version = "3.0.1"
s.version = "3.0.2"

s.authors = ["Edwin Cruz", "Colin Shield"]
s.date = %q{2011-09-06}
Expand All @@ -21,7 +21,7 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]

s.required_ruby_version = ">= 2.4.0"
s.add_dependency("hashie", ">= 4.0")
s.add_dependency("hashie")
s.add_development_dependency "rspec"
s.add_development_dependency "rake"
s.add_development_dependency "rdoc"
Expand Down
17 changes: 15 additions & 2 deletions lib/setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def self.available_settings
#=================================================================

def initialize
@available_settings ||= Hashie::Mash.quiet(:default).new
@available_settings ||= new_available_settings
end

def has_key?(key)
Expand Down Expand Up @@ -146,7 +146,7 @@ def loaded?

def load(params)
# reset settings hash
@available_settings = Hashie::Mash.quiet(:default).new
@available_settings = new_available_settings
@loaded = false

files = []
Expand Down Expand Up @@ -177,4 +177,17 @@ def load(params)
@loaded = true
@available_settings
end

private

def new_available_settings
# Spectre and other monoliths are tied to Hashie 3.x
# so once that isn't a problem and all apps can use Hashie >= 4.0
# then then Hashie::Mash.quiet can become the default.
if Hashie::Mash.respond_to?(:quiet)
Hashie::Mash.quiet(:default).new
else
Hashie::Mash.new
end
end
end