Skip to content

Commit

Permalink
Fix formatting of assignment if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
pilaf committed Jan 5, 2024
1 parent b6ba0cd commit 54a0b5e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 42 deletions.
13 changes: 7 additions & 6 deletions fmrest.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "yard"
spec.add_development_dependency "yard-activesupport-concern"

ar_version = ENV["ACTIVE_RECORD_VERSION"] || "~> 7.0"
sqlite3_version = if (4.2..5.2).include?(ar_version.to_s.gsub(/[^\d.]/, "").to_f)
"~> 1.3.0"
else
"~> 1.4.0"
end
ar_version = ENV["ACTIVE_RECORD_VERSION"] || "~> 7.0"
sqlite3_version =
if (4.2..5.2).include?(ar_version.to_s.gsub(/[^\d.]/, "").to_f)
"~> 1.3.0"
else
"~> 1.4.0"
end

spec.add_development_dependency "activerecord", ar_version
spec.add_development_dependency "sqlite3", sqlite3_version
Expand Down
13 changes: 7 additions & 6 deletions lib/fmrest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ def config
end

def logger
@logger ||= if defined?(Rails)
Rails.logger
else
require "logger"
Logger.new($stdout)
end
@logger ||=
if defined?(Rails)
Rails.logger
else
require "logger"
Logger.new($stdout)
end
end

# Shortcut for `FmRest::V1.escape_find_operators`
Expand Down
11 changes: 6 additions & 5 deletions lib/fmrest/spyke/model/orm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,12 @@ def destroy(options = {})
# For whatever reason the Data API wants the script params as query
# string params for DELETE requests, making this more complicated
# than it should be
script_query_string = if options.has_key?(:script)
"?" + Faraday::Utils.build_query(FmRest::V1.convert_script_params(options[:script]))
else
""
end
script_query_string =
if options.has_key?(:script)
"?" + Faraday::Utils.build_query(FmRest::V1.convert_script_params(options[:script]))
else
""
end

self.attributes = delete(uri.to_s + script_query_string)
end
Expand Down
8 changes: 4 additions & 4 deletions lib/fmrest/v1/dates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def local_offset_for_datetime(dt, zone = nil)

# Do we have ActiveSupport's TimeZone?
time = if time.respond_to?(:in_time_zone)
time.in_time_zone(zone || ::Time.zone)
else
time.localtime
end
time.in_time_zone(zone || ::Time.zone)
else
time.localtime
end

Rational(time.utc_offset, 86400) # seconds in one day (24*60*60)
end
Expand Down
13 changes: 7 additions & 6 deletions lib/fmrest/v1/token_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ def token_store_key
# Strip the host part to just the hostname (i.e. no scheme or port)
host = @settings.host!
host = URI(host).hostname if host =~ /\Ahttps?:\/\//
identity_segment = if fmid_token = @settings.fmid_token
require "digest"
Digest::SHA256.hexdigest(fmid_token)
else
@settings.username!
end
identity_segment =
if fmid_token = @settings.fmid_token
require "digest"
Digest::SHA256.hexdigest(fmid_token)
else
@settings.username!
end
"#{host}:#{@settings.database!}:#{identity_segment}"
end
end
Expand Down
32 changes: 17 additions & 15 deletions spec/spyke/model/attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@
# TODO: Rewrite this spec to be less dependent on ActiveModel's internals
describe ".attribute_method_matchers" do
it "doesn't include a plain entry" do
matcher = if test_class.respond_to?(:attribute_method_patterns)
test_class.attribute_method_patterns.first
else
test_class.attribute_method_matchers.first
end
target = if matcher.respond_to?(:proxy_target)
# ActiveModel >= 7.1
matcher.proxy_target
elsif matcher.respond_to?(:target)
# ActiveModel >= 6, < 7.1
matcher.target
else
# ActiveModel <= 5
matcher.method_missing_target
end
matcher =
if test_class.respond_to?(:attribute_method_patterns)
test_class.attribute_method_patterns.first
else
test_class.attribute_method_matchers.first
end
target =
if matcher.respond_to?(:proxy_target)
# ActiveModel >= 7.1
matcher.proxy_target
elsif matcher.respond_to?(:target)
# ActiveModel >= 6, < 7.1
matcher.target
else
# ActiveModel <= 5
matcher.method_missing_target
end
expect(target).to_not eq("attribute")
end
end
Expand Down

0 comments on commit 54a0b5e

Please sign in to comment.