amirka-async-fu 1.2.1 → 1.4.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.
Files changed (4) hide show
  1. data/VERSION.yml +2 -2
  2. data/lib/async_fu.rb +0 -6
  3. data/test/test-1.rb +34 -31
  4. metadata +1 -1
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
- :minor: 2
4
- :patch: 1
3
+ :minor: 4
4
+ :patch: 0
@@ -1,6 +1,5 @@
1
1
  require 'fastthread'
2
2
  class AsyncFu
3
-
4
3
  def initialize(obj = nil)
5
4
  @class = obj || self
6
5
  at_exit{
@@ -10,13 +9,9 @@ class AsyncFu
10
9
  }
11
10
  end
12
11
  def method_missing(name, *args, &block)
13
- if @class.respond_to?(name)
14
12
  Thread.new{
15
13
  @class.send name, *args, &block
16
14
  }
17
- else
18
- @class.send name, *args, &block
19
- end
20
15
  end
21
16
  def exit
22
17
  @exit = true
@@ -24,5 +19,4 @@ class AsyncFu
24
19
  def self.method_added(method)
25
20
  private method
26
21
  end
27
-
28
22
  end
@@ -1,36 +1,39 @@
1
1
  require 'rubygems'
2
2
  require 'lib/async_fu.rb'
3
+ #require 'async_fu'
3
4
 
4
- class YourClass1
5
- def hello
6
- p 'start'
7
- p 'list ' + Thread.list.join( ' ')
8
- p 'main ' + Thread.main.to_s
9
- p 'this ' + Thread.current.to_s
10
- p 'end'
11
- end
5
+ class Some < AsyncFu
6
+ def grep(query, path)
7
+ begin
8
+ p 'lets play'
9
+ list = `grep -rne '#{query}' #{path}`
10
+ File.new( '/tmp/grep.log', 'w' ).write list
11
+ ensure
12
+ p 'errors'
13
+ end
14
+ p 'we done'
15
+ end
16
+ def tick
17
+ loop{
18
+ sleep 1
19
+ p 'tick'
20
+ }
21
+ end
22
+ def tack
23
+ loop{
24
+ sleep 2
25
+ p 'tack'
26
+ }
27
+ end
12
28
  end
13
29
 
14
- af = AsyncFu.new(YourClass1.new)
15
- #af.hello
16
-
17
- class YourClass2 < AsyncFu
18
- def hello
19
- p 'start'
20
- p 'list ' + Thread.list.join( ' ')
21
- p 'main ' + Thread.main.to_s
22
- p 'this ' + Thread.current.to_s
23
- p 'end'
24
- end
25
- def block(&block)
26
- block.call
27
- end
28
- end
29
-
30
- ai = YourClass2.new
31
- ai.hello
32
- p ai.methods
33
- ai.block{
34
- p 'hello iam block'
35
- }
36
- ai.exit
30
+ test = Some.new
31
+ #test.exit
32
+ p '1'
33
+ test.tick
34
+ p '2'
35
+ test.grep( 'thread.rb', '/usr/local/lib/ruby' )
36
+ p '3'
37
+ test.tack
38
+ p '4'
39
+ p test.methods
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amirka-async-fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amir Mamedov