hashtastic 0.1.2 → 0.2.0

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
- SHA1:
3
- metadata.gz: '01864df0c3346d10e0c2211144b3449e3441ce43'
4
- data.tar.gz: c70c35043de5f4f764bccdf68641db1c54a03719
2
+ SHA256:
3
+ metadata.gz: 8a1e5b44ccfb59de465e29f03e25cb8d4f828b5b09074c0c8b96cbc826b51921
4
+ data.tar.gz: a9ccc452b9c6a67861224062c82d48ecc54c8acda26a1285d0696728cac0a886
5
5
  SHA512:
6
- metadata.gz: fd6185e35b4e7b9c893792730fd73b6bdddb612bce09081fc7e140817924f43ebe49d5dca120f96844ea9013e94b2ecc009e603530c854295c2250632ae96004
7
- data.tar.gz: eb6ec649a1b621ffd99be7613401ef81302d38481aa10563a8ff869c0390ecb6aeddb0f4a4f88b518f4520157e50e75ca9dd2e27f2f94af8e3306b84908ad684
6
+ metadata.gz: 0a0b7f8193c6e48fd2eeee598815ee8aa1c7416f101b3095e1536a96df0014b731e4ddc5a4b93c9f692d5387e59b63d026893bac62b1baff08ad4d990c921349
7
+ data.tar.gz: 8504b343d3a157f2d0e66c70393a1a243bf2a128db23485c942f238521ef6290f8e6c543b2c6496ae7309f0f2fa9c6f88767ee139470e30d976e0c5ff3af7c59
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+
8
+ ## [0.2.0] - 2019-07-17
9
+ ### Added:
10
+ - DictionaryHasher function
11
+
7
12
  ## [0.1.2] - 2018-08-01
8
13
  ### Fixed:
9
14
  - Yank gem
data/README.md CHANGED
@@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'hashtastic'
12
+ gem 'hashtastic', '~> 0.1.2'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -5,6 +5,8 @@ require 'active_support/all'
5
5
  require 'hashtastic/list_hasher'
6
6
  require 'hashtastic/dictionary_values_hasher'
7
7
  require 'hashtastic/ethereum_sha3'
8
+ require 'hashtastic/dictionary_hasher'
9
+ require 'hashtastic/digester'
8
10
 
9
11
  module Hashtastic
10
12
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hashtastic
4
+ class DictionaryHasher
5
+ class << self
6
+ def call(dictionary, filter = [])
7
+ encoded_message = Digester.call(dictionary, filter)
8
+
9
+ hasher = Digest::SHA3.new(256)
10
+
11
+ hasher.update(encoded_message)
12
+
13
+ hasher.hexdigest
14
+ end
15
+
16
+ private
17
+
18
+ def extractor(dictionary, filter)
19
+ dictionary.with_indifferent_access.slice(*filter)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hashtastic
4
+ class Digester
5
+ class << self
6
+ def call(dictionary, filter = [])
7
+ dictionary = filter.empty? ? dictionary : extractor(dictionary, filter)
8
+
9
+ URI.encode_www_form(dictionary.to_a.sort)
10
+ end
11
+
12
+ private
13
+
14
+ def extractor(dictionary, filter)
15
+ dictionary.with_indifferent_access.slice(*filter)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hashtastic
4
- VERSION = '0.1.2'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashtastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lucidity
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-02 00:00:00.000000000 Z
11
+ date: 2019-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -128,7 +128,9 @@ files:
128
128
  - bin/setup
129
129
  - hashtastic.gemspec
130
130
  - lib/hashtastic.rb
131
+ - lib/hashtastic/dictionary_hasher.rb
131
132
  - lib/hashtastic/dictionary_values_hasher.rb
133
+ - lib/hashtastic/digester.rb
132
134
  - lib/hashtastic/ethereum_sha3.rb
133
135
  - lib/hashtastic/list_hasher.rb
134
136
  - lib/hashtastic/version.rb
@@ -151,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
153
  - !ruby/object:Gem::Version
152
154
  version: '0'
153
155
  requirements: []
154
- rubyforge_project:
155
- rubygems_version: 2.6.8
156
+ rubygems_version: 3.0.3
156
157
  signing_key:
157
158
  specification_version: 4
158
159
  summary: Utility hash functions.