GFunk911-mharris_ext 1.4.1 → 1.4.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.
- data/VERSION.yml +1 -1
- data/lib/mharris_ext/accessor.rb +13 -0
- data/lib/mharris_ext/benchmark.rb +13 -2
- data/lib/mharris_ext/time.rb +5 -0
- metadata +3 -1
data/VERSION.yml
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
class Object
|
2
|
+
def attr_accessor_nn_one(sym)
|
3
|
+
define_method(sym) do
|
4
|
+
res = instance_variable_get("@#{sym}")
|
5
|
+
raise "method #{sym} cannot return nil value" unless res
|
6
|
+
res
|
7
|
+
end
|
8
|
+
attr_writer(sym)
|
9
|
+
end
|
10
|
+
def attr_accessor_nn(*args)
|
11
|
+
args.flatten.each { |x| attr_accessor_nn_one(x) }
|
12
|
+
end
|
13
|
+
end
|
@@ -1,6 +1,17 @@
|
|
1
1
|
def tm(msg="Thing")
|
2
2
|
t = Time.now
|
3
|
-
yield
|
3
|
+
res = yield
|
4
4
|
seconds = Time.now - t
|
5
5
|
puts "#{msg} took #{seconds} seconds"
|
6
|
-
|
6
|
+
res
|
7
|
+
end
|
8
|
+
|
9
|
+
def print_memory_usage!
|
10
|
+
Thread.new do
|
11
|
+
loop do
|
12
|
+
mem = `ps -l #{Process.pid}`.to_a[1].split[8]
|
13
|
+
puts "Memory: #{mem} #{Time.now}"
|
14
|
+
sleep(10)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: GFunk911-mharris_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Harris
|
@@ -44,6 +44,7 @@ extra_rdoc_files:
|
|
44
44
|
files:
|
45
45
|
- VERSION.yml
|
46
46
|
- lib/mharris_ext
|
47
|
+
- lib/mharris_ext/accessor.rb
|
47
48
|
- lib/mharris_ext/benchmark.rb
|
48
49
|
- lib/mharris_ext/cmd.rb
|
49
50
|
- lib/mharris_ext/enumerable.rb
|
@@ -52,6 +53,7 @@ files:
|
|
52
53
|
- lib/mharris_ext/gems.rb
|
53
54
|
- lib/mharris_ext/methods.rb
|
54
55
|
- lib/mharris_ext/regexp.rb
|
56
|
+
- lib/mharris_ext/time.rb
|
55
57
|
- lib/mharris_ext.rb
|
56
58
|
- test/mharris_ext_test.rb
|
57
59
|
- test/test_helper.rb
|