hashd 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c05f197d0a32b1399321a407b9b7b4537d6577e5
4
+ data.tar.gz: 0bb016c2a536ed413c919260c6c48a681b083498
5
+ SHA512:
6
+ metadata.gz: bbbb938551750eafef61ef7641028077c9ccfdb8b00f0b0fe61deda6a0e1b28b44160721e4f27f17f062a689b27f521871b13f4a1f937379026310f06ed95751
7
+ data.tar.gz: 2e0d3a77097f005142488f95c55d4cf7ee6b4d81a4aa8d1ae57572c0bf509b6dd35dcca33c3a24093fceb4b02924e9a11dc828e0c6961e45d6df09a69419b697
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .bundle
2
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rerun'
7
+ gem 'rb-fsevent'
8
+ gem 'terminal-notifier'
9
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Fugroup
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Hashd
2
+
3
+ Makes your hashes have dot syntax. Mutates the original hash.
4
+
5
+ ### Installation
6
+ ```ruby
7
+ gem install hashd
8
+ ```
9
+
10
+ ### Usage
11
+ ```ruby
12
+ h = {:world => 'flat'}
13
+
14
+ # Init using the to_dot method
15
+ h.to_dot
16
+ t.world => 'flat'
17
+
18
+ # Assignment works as well
19
+ t.horizon = 'alsoflat'
20
+ t.horizon => 'flat'
21
+ ```
22
+ Note: Don't use hash method names as hash keys.
23
+
24
+ This library is actively maintained by [Fugroup Ltd.](http://www.fugroup.net) We are the creators of [CrowdfundHQ.](https://crowdfundhq.com)
25
+
26
+ Thanks!
27
+
28
+ `@authors: Vidar`
data/config/boot.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/setup'
2
+ Bundler.require(:default, :development)
3
+
4
+ MODE = ENV['RACK_ENV'] || 'development'
5
+
6
+ require './lib/hashd.rb'
data/hashd.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'hashd'
3
+ s.version = '0.0.1'
4
+ s.date = '2017-07-14'
5
+ s.summary = "Hash dot syntax"
6
+ s.description = "Give any hash dot syntax. Supports nested properties, mutates original hash."
7
+ s.authors = ["Fugroup Limited"]
8
+ s.email = 'mail@fugroup.net'
9
+
10
+ s.homepage = 'https://github.com/fugroup/hashd'
11
+ s.license = 'MIT'
12
+
13
+ s.add_development_dependency 'futest', '>= 0'
14
+
15
+ s.require_paths = ['lib']
16
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ end
data/lib/hashd/hash.rb ADDED
@@ -0,0 +1,26 @@
1
+ class Hash
2
+
3
+ attr_accessor :dot
4
+
5
+ def to_dot
6
+ dotify(self); self
7
+ end
8
+
9
+ def method_missing(name, *args, &block)
10
+ return super(name, *args, &block) unless dot
11
+
12
+ if name[-1] == '='
13
+ self[name[0..-2].to_sym] = args[0]
14
+ else
15
+ self[name] || self[name.to_s]
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ # Set up each hash for dot syntax
22
+ def dotify(h)
23
+ h.dot = true; h.keys.each{|key| dotify(h[key]) if h[key].is_a?(::Hash)}
24
+ end
25
+
26
+ end
data/lib/hashd.rb ADDED
@@ -0,0 +1 @@
1
+ require_relative 'hashd/hash.rb'
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hashd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Fugroup Limited
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: futest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Give any hash dot syntax. Supports nested properties, mutates original
28
+ hash.
29
+ email: mail@fugroup.net
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - LICENSE
37
+ - README.md
38
+ - config/boot.rb
39
+ - hashd.gemspec
40
+ - lib/hashd.rb
41
+ - lib/hashd/hash.rb
42
+ homepage: https://github.com/fugroup/hashd
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 2.6.12
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Hash dot syntax
66
+ test_files: []