context_manager 0.0.0 → 1.0.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 +4 -4
- data/lib/context_manager.rb +2 -21
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 218b8bb99a2ee8ad8d4fb1ae717500e616ce786925076a7b247b9eb6ebf97e6a
|
|
4
|
+
data.tar.gz: ad418f6035243b0027f047b3a9d047420c64c4fbbc563b02eef24cbf458230ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb7e9b8b02d03e24556dc1633eca40f20b3a059fb7dc7f8353c314d9599bff6a46c8775f182f86328da4832e9aff5c2564008999a3439f4749ebbc2c5ae45911
|
|
7
|
+
data.tar.gz: 96ba1db6680455ebb3f8d0244233b3e93cc074c7a580532c8fab307a2c9d252e85dcfd2e008fd0ca5d150cce178313a18ccfea97c4c744283fb62ce7fbcc4e96
|
data/lib/context_manager.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
def
|
|
1
|
+
def finish(&block)
|
|
2
2
|
Proc.new do |obj|
|
|
3
3
|
block.call(obj)
|
|
4
4
|
end
|
|
@@ -12,23 +12,4 @@ def with(*args)
|
|
|
12
12
|
ensure
|
|
13
13
|
arg[1].call(yield_obj)
|
|
14
14
|
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# # sample context manager
|
|
18
|
-
# def ctxmgr(filename)
|
|
19
|
-
# p "opening file.."
|
|
20
|
-
# f = File.open(filename)
|
|
21
|
-
# close_file = after do |file|
|
|
22
|
-
# p "closing a file.. #{file}"
|
|
23
|
-
# file.close
|
|
24
|
-
# end
|
|
25
|
-
|
|
26
|
-
# [f, close_file]
|
|
27
|
-
# end
|
|
28
|
-
|
|
29
|
-
# # usage
|
|
30
|
-
# with ctxmgr('filename.txt') do |e|
|
|
31
|
-
# p "file: #{e.read}"
|
|
32
|
-
# # p 'trying to read file, uh oh an exception occured'
|
|
33
|
-
# # raise 'akash'
|
|
34
|
-
# end
|
|
15
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: context_manager
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Akash Gupta
|
|
@@ -10,7 +10,8 @@ bindir: bin
|
|
|
10
10
|
cert_chain: []
|
|
11
11
|
date: 2020-06-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description: Python like context manger in Ruby
|
|
13
|
+
description: Python like context manger in Ruby. Context managers allow you to allocate
|
|
14
|
+
and release resources precisely when you want to.
|
|
14
15
|
email: akashsjhs@gmail.com
|
|
15
16
|
executables: []
|
|
16
17
|
extensions: []
|
|
@@ -20,7 +21,8 @@ files:
|
|
|
20
21
|
homepage: https://rubygems.org/gems/context_manager
|
|
21
22
|
licenses:
|
|
22
23
|
- MIT
|
|
23
|
-
metadata:
|
|
24
|
+
metadata:
|
|
25
|
+
source_code_uri: https://github.com/Akshg/context_manager
|
|
24
26
|
post_install_message:
|
|
25
27
|
rdoc_options: []
|
|
26
28
|
require_paths:
|