Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ursm committed Jul 12, 2024
1 parent 6fa3546 commit 9ea966d
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 16 deletions.
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ PATH
remote: .
specs:
fetch-api (0.5.0)
forwardable
json
mini_mime
net-http
Expand Down Expand Up @@ -34,7 +33,6 @@ GEM
ffi (1.17.0)
ffi (1.17.0-x86_64-linux-gnu)
fileutils (1.7.2)
forwardable (1.3.3)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
json (2.7.2)
Expand Down
1 change: 0 additions & 1 deletion Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

check 'lib'

library 'forwardable'
library 'json'
library 'mini_mime'
library 'net-http'
Expand Down
1 change: 0 additions & 1 deletion fetch-api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{\Aexe/}) { File.basename(_1) }
spec.require_paths = ['lib']

spec.add_dependency 'forwardable'
spec.add_dependency 'json'
spec.add_dependency 'mini_mime'
spec.add_dependency 'net-http'
Expand Down
2 changes: 0 additions & 2 deletions lib/fetch/form_data.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
require_relative 'multi_map'

require 'forwardable'

module Fetch
class FormData < MultiMap
def self.build(enumerable)
Expand Down
10 changes: 4 additions & 6 deletions lib/fetch/headers.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
require 'forwardable'

module Fetch
class Headers
include Enumerable

extend Forwardable

def_delegators :entries, :each

def initialize(init = [])
@data = {}

Expand Down Expand Up @@ -47,5 +41,9 @@ def set(key, value)
def values
@data.values.map { _1.join(', ') }
end

def each(&block)
block ? entries.each(&block) : entries.each
end
end
end
4 changes: 2 additions & 2 deletions lib/fetch/multi_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def values
@entries.map(&:last)
end

def each(...)
@entries.each(...)
def each(&)
@entries.each(&)
end

private
Expand Down
2 changes: 0 additions & 2 deletions sig/fetch/headers.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module Fetch
class Headers
include Enumerable[[String, String]]

extend Forwardable

def initialize: (_Each[[_ToS, _ToS]]) -> void
def append: (_ToS, _ToS) -> void
def delete: (_ToS) -> void
Expand Down

0 comments on commit 9ea966d

Please sign in to comment.