simple_hash 0.0.1 → 0.0.2
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 +4 -4
- data/.travis.yml +2 -2
- data/Gemfile.lock +1 -1
- data/README.md +10 -0
- data/lib/simple_hash.rb +5 -7
- data/lib/simple_hash/version.rb +1 -1
- data/simple_hash.gemspec +3 -3
- data/spec/simple_hash/simple_hash_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d3f05f7f719e367a3be3bf4e6f3d043190a3033
|
4
|
+
data.tar.gz: 74af0790ea375fd1faee9aa779cbd7299ad45a89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a12e570ad9ef3368603c9c71d2f31c72d8f41764dc88263f074272b8f4eecf484dca41006579ada5e15c8ab1d3ce142213433574608540c6f6ba839a0ea5bc39
|
7
|
+
data.tar.gz: ca5e5f2226c19cc03ca345e8e936169b736bfbc9c5e410f45fd401d1c920041c13778277feaaf6122903d541489eb9464afc1f329ad3b91dd524ec8e1c18cdeb
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
## SimpleHash
|
2
|
+
[](https://badge.fury.io/rb/simple_hash)
|
3
|
+
[](https://travis-ci.org/karloku/simple_hash)
|
2
4
|
|
3
5
|
Brings ES6 object initializer sugar to Ruby.
|
4
6
|
|
@@ -30,6 +32,14 @@ Then you can build like this:
|
|
30
32
|
h{[:year, :month, :day, :hour, :minute, :second]}
|
31
33
|
```
|
32
34
|
|
35
|
+
## Support ruby version
|
36
|
+
|
37
|
+
+ MRI ~> 2.1
|
38
|
+
+ rubinius ~> 3.15
|
39
|
+
|
40
|
+
This gem uses Binding#local_variable_get, makes MRI < 2.1 and rubinius < 3.15 lack of support.
|
41
|
+
Using eval may solve the problem, but evaling an user passed string may cause problems.
|
42
|
+
|
33
43
|
## Installation
|
34
44
|
|
35
45
|
Install the gem
|
data/lib/simple_hash.rb
CHANGED
@@ -22,16 +22,14 @@ module SimpleHash
|
|
22
22
|
# @return [Hash] hash with passed-in keys, e.g. {key1: 'key1_value', key2: 'key2_value', ...}
|
23
23
|
def h(&list_block)
|
24
24
|
variables = yield.map(&:to_s)
|
25
|
-
Hash[
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
]
|
25
|
+
Hash.[](variables.map do |variable|
|
26
|
+
[variable.to_sym, list_block.binding.local_variable_get(variable)]
|
27
|
+
end)
|
30
28
|
end
|
31
29
|
|
32
|
-
# Adds #h method
|
30
|
+
# Adds #h method globally, delegating to SimpleHash::h
|
33
31
|
def self.short_cut!
|
34
|
-
|
32
|
+
TOPLEVEL_BINDING.eval 'include SimpleHash'
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
data/lib/simple_hash/version.rb
CHANGED
data/simple_hash.gemspec
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
3
|
|
4
4
|
require 'simple_hash/version'
|
5
|
+
require 'time'
|
5
6
|
|
6
7
|
Gem::Specification.new do |gem|
|
7
8
|
gem.name = 'simple_hash'
|
8
9
|
gem.version = SimpleHash::VERSION
|
9
|
-
gem.date =
|
10
|
+
gem.date = Time.parse(`git log -1 --format=%cd`).utc
|
10
11
|
gem.summary = 'Ruby short cut for making hash'
|
11
12
|
gem.description = 'Ruby short cut for making hash'
|
12
13
|
gem.homepage = 'https://github.com/karloku/simple_hash'
|
13
14
|
gem.authors = ['Karloku Sang']
|
14
15
|
gem.email = ['karloku@gmail.com']
|
15
16
|
gem.license = 'MIT'
|
16
|
-
gem.required_ruby_version = '>= 2.1.0'
|
17
|
+
gem.required_ruby_version = '>= 2.1.0'
|
17
18
|
|
18
19
|
gem.require_paths = ['lib']
|
19
|
-
gem.files = Dir['{lib}/**/*', 'MIT-LICENSE', 'README.md']
|
20
20
|
gem.files = `git ls-files`.split("\n")
|
21
21
|
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
22
22
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karloku Sang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|