erb_with_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: 7c6eec7f30a1e82e762393c50ff25604382c8a54
4
- data.tar.gz: bf20035f0226afcb5f49ecb14766b50d571df95e
3
+ metadata.gz: 7eb4632ed4d105d0b15c6f00bf12a9dfb11d9f66
4
+ data.tar.gz: 3f9c83447be6335117d17d971ccc151544461b70
5
5
  SHA512:
6
- metadata.gz: 6258f6a11019a9972cb08154f79a7b8c28d6b8c52f5d7277f173e1c18b2af8f1f72a953006c1ae67af862fb343107978e14723f703d935ef6148832062d70e44
7
- data.tar.gz: c339ff68fb3296208ae8c116e7afeb2a19c778f8f73bbec0ca7fe7dd70cb067a7d94e8055920badec8a3c757e10adb11c9059c1097c0248bebd5b949ffe422f8
6
+ metadata.gz: 35cdf681968d43696851495fccc3dd5c0f5fe5a7c67755511961a32a749469818764d7e48858a83a95b936f332e35a4f89b6b67660204360ad1934e491e1387f
7
+ data.tar.gz: 1a77dda70664f88ca26c93198e8a5f1b78e30c9dd3035c02a0fcc27bc48915b950c09a38cb9b4d2287bc5185d7005805c519dd7ff5e3daf4a1f4475751a26ec6
data/lib/erb_with_hash.rb CHANGED
@@ -14,9 +14,25 @@ module ERBWithHash
14
14
  end
15
15
 
16
16
  def result_with_hash(hash)
17
- b = HashAsBinding.new(hash).instance_eval {Kernel.binding}
17
+ b = create_binding_from_hash(hash)
18
18
  result(b)
19
19
  end
20
+
21
+ private
22
+
23
+ def create_binding_from_hash(__hash__)
24
+ if binding.respond_to? :local_variable_set
25
+ __hash__.each_with_object(create_empty_binding) do |(k, v), b|
26
+ b.local_variable_set(k, v)
27
+ end
28
+ else
29
+ HashAsBinding.new(__hash__).instance_eval { Kernel.binding }
30
+ end
31
+ end
32
+
33
+ def create_empty_binding
34
+ BasicObject.new.instance_eval { Kernel.binding }
35
+ end
20
36
  end
21
37
 
22
38
  require 'erb'
@@ -1,3 +1,3 @@
1
1
  module ERBWithHash
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erb_with_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
  - Masatoshi Seki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-07 00:00:00.000000000 Z
11
+ date: 2014-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: Arrow Hash in ERB#result
@@ -44,7 +44,7 @@ executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
- - .gitignore
47
+ - ".gitignore"
48
48
  - Gemfile
49
49
  - LICENSE.txt
50
50
  - README.md
@@ -62,17 +62,17 @@ require_paths:
62
62
  - lib
63
63
  required_ruby_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - '>='
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  requirements:
70
- - - '>='
70
+ - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
74
  rubyforge_project:
75
- rubygems_version: 2.0.0
75
+ rubygems_version: 2.2.2
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: Arrow Hash in ERB#result