multi_key_hash 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
  SHA1:
3
- metadata.gz: f409aff203d1cb86eeff4b85a1a3e5ab6767d7e4
4
- data.tar.gz: 3d39adf2113f383c2b4b23f9c86ca4915b3bdba8
3
+ metadata.gz: b2f03ecdb16e6595d62966217390c6d2f6d7ee4c
4
+ data.tar.gz: a5543922eb48c0b323ca82834ba23ca8a1776d5d
5
5
  SHA512:
6
- metadata.gz: 51adba605fff6cb264f86b2015ad02f45a2616c70eba209bbe49ca570a0be1c924047b37fa2bf50c7916c3996fd15c857b099a5a3db434c8902d962d8d3c8cec
7
- data.tar.gz: c6f5498239b4a510c475e06092e4e25519cdb6735dd7be79071a5790807d21387d4277753b4f9a5b255c7fb7fa021bd802f7c101747d7a9d1c599e5f3401eaef
6
+ metadata.gz: 8e76ca955eca25d20c087807129fcbe5eb8a6860acec64e710258ea7b47c2ef62224822f4faff92996d5c0351035caf11396d1619504ed009608c5bf6ee923e2
7
+ data.tar.gz: 85ba4f52bb8c932e951976ea5635cdf595133e236429ccb5c93ee6515493b40480b206c3f85c3765b4a54cdc8c2ee97052bb9417f9622a41b5d39f25d6ceee20
data/.editorconfig ADDED
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = false
data/.gitignore CHANGED
@@ -6,8 +6,10 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
12
13
  .rspec
14
+
13
15
  *.gem
data/.travis.yml CHANGED
@@ -2,4 +2,8 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.4.2
5
+ notifications:
6
+ email: false
5
7
  before_install: gem install bundler -v 1.16.0
8
+ script:
9
+ - bundle exec rspec
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # MultiKeyHash
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/multi_key_hash`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ > Hash with multiple keys for same value, symbol/string-indifferent key access.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ [![build-url][build-url-svg]][build-url]
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,18 +22,72 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ #### Creating new multiple keys hash and accessing it's keys
26
26
 
27
- ## Development
27
+ ```ruby
28
+ require 'multi_key_hash'
29
+
30
+ multi_hash = MultiKeyHash.new({%w[one two three] => 'number', %i[a b c] => 'letter', 'single' => 'value'})
31
+
32
+ multi_hash['one'] # number
33
+ multi_hash[:a] # letter
34
+ multi_hash['single'] # value
35
+ ```
36
+
37
+ #### Modifying values inside hash
38
+
39
+ ```ruby
40
+ multi_hash = MultiKeyHash.new({%w[one two three] => 'number', %i[a b c] => 'letter', 'single' => 'value'})
41
+
42
+ multi_hash['one'] = 'first_number' # first_number
43
+ multi_hash['two'] # number
44
+
45
+ multi_hash[:a] = 'first_letter' # first_letter
46
+ multi_hash[:b] # letter
47
+ ```
48
+
49
+ #### Adding new keys to hash
28
50
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
51
+ ```ruby
52
+ multi_hash = MultiKeyHash.new({%w[one two three] => 'number', %i[a b c] => 'letter', 'single' => 'value'})
53
+
54
+ multi_hash[:language] = 'english' # single key
55
+ multi_hash[[:ruby, :js, :php]] = 'programming_language' # multiple keys
56
+ ```
30
57
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
58
+ #### Deleting keys from hash
32
59
 
33
- ## Contributing
60
+ ```ruby
61
+ multi_hash = MultiKeyHash.new({%w[one two three] => 'number', %i[a b c] => 'letter', 'single' => 'value'})
62
+
63
+ multi_hash.delete(:a)
64
+ multi_hash[:b] #letter
34
65
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/multi_key_hash.
66
+ multi_hash.delete('one')
67
+ multi_hash['two'] #number
68
+ ```
69
+
70
+ #### Converting to regular hash
71
+
72
+ ```ruby
73
+ multi_hash = MultiKeyHash.new({%w[one two three] => 'number', %i[a b c] => 'letter', 'single' => 'value'})
74
+
75
+ multi_hash.to_h
76
+
77
+ # {
78
+ # 'one' => 'number',
79
+ # 'two' => 'number',
80
+ # 'three' => 'number',
81
+ # :a => 'letter',
82
+ # :b => 'letter',
83
+ # :c => 'letter',
84
+ # 'single' => 'value'
85
+ # }
86
+ ```
36
87
 
37
88
  ## License
38
89
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
90
+ [MIT License](https://opensource.org/licenses/MIT).
91
+
92
+ [build-url]: https://travis-ci.org/SamirHodzic/multi_key_hash
93
+ [build-url-svg]: https://travis-ci.org/SamirHodzic/multi_key_hash.svg?branch=master
@@ -1,3 +1,3 @@
1
1
  class MultiKeyHash
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['SamirHodzic']
10
10
  spec.email = ['samir.sgd@gmail.com']
11
11
 
12
- spec.summary = 'something'
13
- spec.description = 'somethingaa'
14
- spec.homepage = 'http://something.com'
12
+ spec.summary = 'MultiKeyHash gem for ruby'
13
+ spec.description = 'Multiple key hashes for ruby'
14
+ spec.homepage = 'https://github.com/SamirHodzic/multi_key_hash'
15
15
  spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files`.split($/)
@@ -81,7 +81,7 @@ RSpec.describe MultiKeyHash do
81
81
  regular_hash = multi_hash.to_h
82
82
 
83
83
  expect(regular_hash).to eq ({
84
- 'one' => 'number',
84
+ 'one' => 'number',
85
85
  'two' => 'number',
86
86
  'three' => 'number',
87
87
  :a => 'letter',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_key_hash
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
  - SamirHodzic
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- description: somethingaa
55
+ description: Multiple key hashes for ruby
56
56
  email:
57
57
  - samir.sgd@gmail.com
58
58
  executables:
@@ -61,6 +61,7 @@ executables:
61
61
  extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
+ - ".editorconfig"
64
65
  - ".gitignore"
65
66
  - ".rspec"
66
67
  - ".travis.yml"
@@ -75,7 +76,7 @@ files:
75
76
  - multi_key_hash.gemspec
76
77
  - spec/multi_key_hash_spec.rb
77
78
  - spec/spec_helper.rb
78
- homepage: http://something.com
79
+ homepage: https://github.com/SamirHodzic/multi_key_hash
79
80
  licenses:
80
81
  - MIT
81
82
  metadata: {}
@@ -98,7 +99,7 @@ rubyforge_project:
98
99
  rubygems_version: 2.6.13
99
100
  signing_key:
100
101
  specification_version: 4
101
- summary: something
102
+ summary: MultiKeyHash gem for ruby
102
103
  test_files:
103
104
  - spec/multi_key_hash_spec.rb
104
105
  - spec/spec_helper.rb