emmy-machine 0.2 → 0.4

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: f34511c1efaef1f267dbc64abc55b03e4b8f4721
4
- data.tar.gz: b3f74e3a47baa4fb505660d1252d472493a01517
3
+ metadata.gz: b3ad3e71202672a3562713e1c85ad47e4b7739e0
4
+ data.tar.gz: 9724037ad6dc9153cbaff317d6d70427fed2205a
5
5
  SHA512:
6
- metadata.gz: 4b517ae82b2ab6b6a90cba51e53e075bf0e12b5a7fd17885757864e86341a0079055a9c7f7cb1cfe48005cc6b2177ee6ee17ef39bfc8de88c7d4bde3e8ceabbd
7
- data.tar.gz: d23017e58ef02d5fe54ece007f7120ced0ba93ea54395d80be88cd85eb2532e69abf95d46d55b97c3ac80528749f7caff087fdd7099bd93110709bbc05460871
6
+ metadata.gz: 7738f684fdb57e1d6e66b1a3eaa75c94a680722c0fa21fbde8bb4f2f761de848c24613223b63d619deb77c0a82a6ff2c9015bfbc4b468d186501a6a63a1f8f9f
7
+ data.tar.gz: 216c025ed2df64ad558de270ea96fdfd6b93e774d51152e52e0bba659048cbb070efb96a54a3f4cb62a00f62104a1e323d9dfdd066e35aa802023fc0ee35c4af
data/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # EmmyMachine
2
2
 
3
- Don't use directly use emmy gem instead
3
+ This is a part of Emmy framework. A short description can be found in the root of this repository in README.md
data/emmy_machine.gemspec CHANGED
@@ -6,10 +6,10 @@ require 'emmy_machine/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "emmy-machine"
8
8
  spec.version = EmmyMachine::VERSION
9
- spec.authors = ["inre"]
9
+ spec.authors = ["Maksim V."]
10
10
  spec.email = ["inre.storm@gmail.com"]
11
- spec.summary = %q{EventMachine with fibers}
12
- #spec.description = %q{TODO: Write a longer description. Optional.}
11
+ spec.summary = %q{Cover EventMachine with fiber's sugar}
12
+ spec.description = spec.summary
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
15
15
 
@@ -18,10 +18,14 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "fibre", "~> 0.9"
21
+ spec.required_ruby_version = '>= 2.1.0'
22
+ spec.required_rubygems_version = '>= 2.3.0'
23
+
24
+ spec.add_dependency "fibre", "~> 1"
25
+ spec.add_dependency "event_object", "~> 1"
22
26
 
23
27
  spec.add_development_dependency "eventmachine", "~> 1.0"
24
- spec.add_development_dependency "bundler", "~> 1.6"
25
- spec.add_development_dependency "rspec", "~> 3.0"
26
- spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "bundler", "~> 1.12"
29
+ spec.add_development_dependency "rspec", "~> 3"
30
+ spec.add_development_dependency "rake", "~> 10"
27
31
  end
@@ -16,30 +16,38 @@ module EmmyMachine
16
16
  EventMachine.stop
17
17
  end
18
18
 
19
- def run_block &b
19
+ def run_once &b
20
20
  EventMachine.run do
21
- fiber_block do
21
+ async do
22
22
  yield
23
23
  stop
24
24
  end
25
25
  end
26
26
  end
27
27
 
28
- def fiber_block &b
29
- Fibre.pool.checkout &b
28
+ def init_pool(*a)
29
+ Fibre.init_pool(*a)
30
30
  end
31
31
 
32
- # Periodic timer
32
+ def pool
33
+ Fibre.pool
34
+ end
35
+
36
+ def async &b
37
+ pool.checkout &b
38
+ end
39
+
40
+ # Run the timer periodically
33
41
  def timer(interval=1, &b)
34
42
  EventMachine::PeriodicTimer.new(interval) do
35
- fiber_block &b
43
+ async &b
36
44
  end
37
45
  end
38
46
 
39
- # One run timer
47
+ # Run the timer once
40
48
  def timeout(interval=1, &b)
41
49
  EventMachine::Timer.new(interval) do
42
- fiber_block &b
50
+ async &b
43
51
  end
44
52
  end
45
53
 
@@ -3,8 +3,8 @@ module EmmyMachine
3
3
  using EventObject
4
4
  events :success, :error
5
5
 
6
- def sync
7
- Fiber.sync do |fiber|
6
+ def await
7
+ Fiber.await do |fiber|
8
8
  on :success do |response|
9
9
  fiber.resume response
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module EmmyMachine
2
- VERSION = "0.2"
2
+ VERSION = "0.4"
3
3
  end
@@ -3,21 +3,21 @@ require "spec_helper"
3
3
  describe EmmyMachine do
4
4
  using EventObject
5
5
 
6
- it "test run_block" do
6
+ it "calls run_once" do
7
7
  expect { |block|
8
- EmmyMachine.run_block &block
8
+ EmmyMachine.run_once &block
9
9
  }.to yield_control
10
10
  end
11
11
 
12
- it "test run_block with raise" do
12
+ it "calls run_once then an error will be raised" do
13
13
  expect {
14
- EmmyMachine.run_block do
14
+ EmmyMachine.run_once do
15
15
  raise "error"
16
16
  end
17
17
  }.to raise_error Fibre::FiberError
18
18
  end
19
19
 
20
- it "test connect" do
20
+ it "connects to the Github's index page" do
21
21
  expect { |block|
22
22
  EventMachine.run do
23
23
  http = EmmyMachine.connect("tcp://github.com:80")
@@ -37,7 +37,7 @@ describe EmmyMachine do
37
37
  }.to yield_control.at_least(1)
38
38
  end
39
39
 
40
- context "Reactor required" do
40
+ context "The reactor is required" do
41
41
  around do |example|
42
42
  EventMachine.run do
43
43
  example.run
@@ -45,12 +45,12 @@ describe EmmyMachine do
45
45
  end
46
46
  end
47
47
 
48
- it "test running?" do
48
+ it "is runned" do
49
49
  expect(EmmyMachine.running?).to be true
50
50
  end
51
51
  end
52
52
 
53
- context "Reactor and fiber required" do
53
+ context "The reactor and the fibers are required" do
54
54
  around do |example|
55
55
  EventMachine.run do
56
56
  Fibre.pool.checkout do
@@ -60,12 +60,12 @@ describe EmmyMachine do
60
60
  end
61
61
  end
62
62
 
63
- it "test deferred" do
63
+ it "is deferred" do
64
64
  defer = EmmyMachine::Deferred.new
65
65
  EmmyMachine.timer(0) do
66
66
  defer.success!('OK')
67
67
  end
68
- res = defer.sync
68
+ res = defer.await
69
69
 
70
70
  expect(res).to eq('OK')
71
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emmy-machine
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
- - inre
7
+ - Maksim V.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-09 00:00:00.000000000 Z
11
+ date: 2016-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fibre
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.9'
19
+ version: '1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.9'
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: event_object
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: eventmachine
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -44,43 +58,43 @@ dependencies:
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '1.6'
61
+ version: '1.12'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '1.6'
68
+ version: '1.12'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '3.0'
75
+ version: '3'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '3.0'
82
+ version: '3'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '10.0'
89
+ version: '10'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '10.0'
83
- description:
96
+ version: '10'
97
+ description: Cover EventMachine with fiber's sugar
84
98
  email:
85
99
  - inre.storm@gmail.com
86
100
  executables: []
@@ -112,18 +126,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
126
  requirements:
113
127
  - - ">="
114
128
  - !ruby/object:Gem::Version
115
- version: '0'
129
+ version: 2.1.0
116
130
  required_rubygems_version: !ruby/object:Gem::Requirement
117
131
  requirements:
118
132
  - - ">="
119
133
  - !ruby/object:Gem::Version
120
- version: '0'
134
+ version: 2.3.0
121
135
  requirements: []
122
136
  rubyforge_project:
123
- rubygems_version: 2.4.6
137
+ rubygems_version: 2.5.1
124
138
  signing_key:
125
139
  specification_version: 4
126
- summary: EventMachine with fibers
140
+ summary: Cover EventMachine with fiber's sugar
127
141
  test_files:
128
142
  - spec/emmy_machine_spec.rb
129
143
  - spec/spec_helper.rb