key_mirror-ruby 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b9959b5dcb45f1c45ef38a8c20c9d4ccc71056857f57dc1fbe7d1101731b941
4
- data.tar.gz: 1147970bc00e6887a20f166a169b8370523a0bfcc28261f400ca060242b693c5
3
+ metadata.gz: 494e8bc5d2a7a5a89836b5e399c1aeed0fb2f11bae261f3044243db13fa6e10c
4
+ data.tar.gz: 794a035d8acfc2332b4ef0b5ec3ebcca3ecdcb9fe80fcbdf8a2cab27ba4d74ec
5
5
  SHA512:
6
- metadata.gz: f7bd2e1437f95d34e714c2c35737b8f0fb739ad166be1c397179cbe5623584c62b1ca8e5cef48e933acf2bde171ce5b9a460873f6cfc90687c65999b70c90b29
7
- data.tar.gz: c6d71885d3c495818de9b304c6f1a20b5dda6fd1b63dcb684843aca5e19f008646741863c358fe92fb501f417259e811f3f13d160995138590ad749b27d43c85
6
+ metadata.gz: dca4073244c2d0aac8947c6924f248cb75ceda153712ef7bb7803c0c353a06cb96a040d1f15935185fc32ada3e50ca49a05bd9595685f2e1caa72f12eb8b71dc
7
+ data.tar.gz: f36eeb50dbc4ddaadadf1a3ea5b80ade975023cef40627c6f6a970d972b87551a1f3effd86e2d35d7f7381741487c7160cb8dd02c4b1eee2b7c46c48cbace845
data/README.md CHANGED
@@ -26,6 +26,9 @@ require 'key_mirror'
26
26
 
27
27
  mirrored_key_hash = KeyMirror.({ hello: nil, 'world' => nil })
28
28
  # => { hello: 'hello', 'world' => 'world' }
29
+
30
+ mirrored_key_hash = KeyMirror.(%i[hello world])
31
+ # => { hello: 'hello', world: 'world' }
29
32
  ```
30
33
 
31
34
  ## Development
@@ -38,7 +41,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
38
41
 
39
42
  Bug reports and pull requests are welcome on GitHub at https://github.com/the-spectator/key_mirror-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/the-spectator/key_mirror-ruby/blob/master/CODE_OF_CONDUCT.md).
40
43
 
41
-
42
44
  ## License
43
45
 
44
46
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeyMirror
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/key_mirror.rb CHANGED
@@ -5,7 +5,7 @@ require "key_mirror/version"
5
5
  module KeyMirror
6
6
  class ArgumentError < StandardError
7
7
  def initialize
8
- super("argument must be a Hash")
8
+ super("argument must be a Hash or Array")
9
9
  end
10
10
  end
11
11
 
@@ -15,10 +15,11 @@ module KeyMirror
15
15
  end
16
16
  end
17
17
 
18
- def self.call(hash)
19
- raise KeyMirror::ArgumentError.new unless hash.is_a?(Hash)
18
+ def self.call(obj)
19
+ hash = {}
20
+ raise KeyMirror::ArgumentError.new unless obj.is_a?(Hash) || obj.is_a?(Array)
20
21
 
21
- hash.each do |key, _|
22
+ obj.each do |key, _|
22
23
  raise KeyMirror::KeyError unless key.is_a?(String) || key.is_a?(Symbol)
23
24
 
24
25
  hash[key] = key.to_s
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: key_mirror-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akshay Birajdar
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-22 00:00:00.000000000 Z
11
+ date: 2023-06-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: key_mirror ruby is a simple ruby helper which returns hash with values
14
14
  equal to stringified keys.
@@ -28,7 +28,7 @@ licenses:
28
28
  metadata:
29
29
  homepage_uri: https://github.com/the-spectator/keymirror-ruby
30
30
  source_code_uri: https://github.com/the-spectator/keymirror-ruby
31
- post_install_message:
31
+ post_install_message:
32
32
  rdoc_options: []
33
33
  require_paths:
34
34
  - lib
@@ -43,8 +43,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0'
45
45
  requirements: []
46
- rubygems_version: 3.1.4
47
- signing_key:
46
+ rubygems_version: 3.4.12
47
+ signing_key:
48
48
  specification_version: 4
49
49
  summary: Ruby implementation for JS keyMirror library
50
50
  test_files: []