simple_hash 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 521d45ff55c32320ac029b38673e1512a97500ca
4
- data.tar.gz: 726f1571457a46a9965632f25a9ac27204db6afe
3
+ metadata.gz: 6d3f05f7f719e367a3be3bf4e6f3d043190a3033
4
+ data.tar.gz: 74af0790ea375fd1faee9aa779cbd7299ad45a89
5
5
  SHA512:
6
- metadata.gz: b1aa816b9a9da25d411b5b4e40b0635ef4818c20a30b84c41196227b7e51bea234fe67d9301d3dc014d8237980a2f32ca64215f184914941eb9a321652d3825a
7
- data.tar.gz: 728785f9443f1651de96f5dad793a23068674b5ceb85f7c31a49fb8c61ead6939a0fa055533d163b3962582e959e6304ad774d64378a09eabc4626813d7ec9ac
6
+ metadata.gz: a12e570ad9ef3368603c9c71d2f31c72d8f41764dc88263f074272b8f4eecf484dca41006579ada5e15c8ab1d3ce142213433574608540c6f6ba839a0ea5bc39
7
+ data.tar.gz: ca5e5f2226c19cc03ca345e8e936169b736bfbc9c5e410f45fd401d1c920041c13778277feaaf6122903d541489eb9464afc1f329ad3b91dd524ec8e1c18cdeb
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  language: ruby
3
3
  rvm:
4
- - "2.3"
4
+ - "2.3.0"
5
5
  - "2.2"
6
6
  - "2.1"
7
- - "rbx-2"
7
+ - "rbx-3.15"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_hash (0.0.1)
4
+ simple_hash (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  ## SimpleHash
2
+ [![Gem Version](https://badge.fury.io/rb/simple_hash.svg)](https://badge.fury.io/rb/simple_hash)
3
+ [![Build Status](https://travis-ci.org/karloku/simple_hash.svg?branch=master)](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
@@ -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
- variables.map do |variable|
27
- [variable.to_sym, list_block.binding.local_variable_get(variable)]
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 to Object, delegating to SimpleHash::h
30
+ # Adds #h method globally, delegating to SimpleHash::h
33
31
  def self.short_cut!
34
- Object.include(SimpleHash)
32
+ TOPLEVEL_BINDING.eval 'include SimpleHash'
35
33
  end
36
34
  end
37
35
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SimpleHash
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
@@ -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 = Date.today.to_s
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' # bc optional keyword args
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
 
@@ -4,7 +4,7 @@ describe SimpleHash do
4
4
  it 'builds hash' do
5
5
  a = 1
6
6
  b = 2
7
- expect(SimpleHash {[:a, :b]}).to eq(a: a, b: b)
7
+ expect(SimpleHash{[:a, :b]}).to eq(a: a, b: b)
8
8
  end
9
9
  end
10
10
 
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.1
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-03-30 00:00:00.000000000 Z
11
+ date: 2016-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls