Skip to content

Commit

Permalink
remove duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpeterson committed Nov 21, 2024
1 parent ab2eccb commit cdf8a18
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 29 deletions.
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ PATH
pundit
rails
turbo-rails
web-console

GEM
remote: https://rubygems.org/
Expand Down
1 change: 1 addition & 0 deletions cafe_car.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
spec.add_dependency "kaminari"
spec.add_dependency "pundit"
spec.add_dependency "chronic"
spec.add_dependency "web-console"
end
18 changes: 6 additions & 12 deletions lib/cafe_car/param_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,21 @@ def merge(_key, a, b)

def value(v)
case v
when '""', "''"
''
when 'nil', ''
nil
when /[{}\[\]]/
JSON.parse(v)
when /,/
value v.split(',')
when Array then v.map { value(_1) }
when '""', "''" then ''
when 'nil', '' then nil
when /[{}\[\]]/ then JSON.parse(v)
when /,/ then value(v.split(','))
when /^(.*?)\.\.(\.?)(.*)$/
Range.new(*[$1, $3].map(&:presence).map { value(_1) }, $2.present?)
when /^\$(\w+)\.(\w+)$/
$1.constantize.arel_table[$2]
when Array
v.map { value(_1) }
when Hash
v.reject {|k, *| k.include?('.') }
.transform_values { value(_1) }
.merge(parse(v))
.tap {|h| h.merge!(h.delete('')) if h.key?('') }
else
v
else v
end
end
end
14 changes: 0 additions & 14 deletions test/dummy/app/views/active_storage/blobs/_blob.html.erb

This file was deleted.

This file was deleted.

0 comments on commit cdf8a18

Please sign in to comment.