emmy 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2041fb4a9d568e8e20f44d949d9135f4676bdd00
4
+ data.tar.gz: 0d2d66054fa2e3c35bb810ccfed7c71f66d290ad
5
+ SHA512:
6
+ metadata.gz: 032fcbae35f052d0651da036400d68b7b1ea96ca500e1f50c26188fd0903c187709cb7965e545a206c46de7a8c3fe15f60e29bec09b195b6d880bad5cedf5f3a
7
+ data.tar.gz: c6f11dd40c7bf0b1895a1705d67fb91e4e7f6659d3a243366ec91ec74b4181ffe8ce7ae9ede913aa66db4255c4fe0653a49fa6c1956274b1af86e83959210f10
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in emmy.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 che
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Emmy
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'emmy'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install emmy
18
+
19
+ ## Modules
20
+
21
+ * emmy - required all emmy gems and have emmy bash command
22
+ * emmy-machine - systax sugar for EventMachine
23
+ * emmy-http - thin runner and cover for EmHttpRequest
24
+ * emmy-log - Logging system for emmy
25
+
26
+ ## Namespaces
27
+
28
+ * EmmyMachine
29
+ * EmmyHttp
30
+ * EmmyLog
31
+ * Emmy
32
+
33
+ ## Usage
34
+
35
+
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it ( https://github.com/chelovekov/emmy/fork )
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in emmy_machine.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Che
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # EmmyMachine
2
+
3
+ Don't use directly use emmy gem instead
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'emmy_machine/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "emmy-machine"
8
+ spec.version = EmmyMachine::VERSION
9
+ spec.authors = ["Che"]
10
+ spec.email = ["chelovekov@gmail.com"]
11
+ spec.summary = %q{Fibered methods for Emmy}
12
+ #spec.description = %q{TODO: Write a longer description. Optional.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "eventmachine", "~> 1.0.3"
22
+ spec.add_dependency "fibre", "~> 0.9.0"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rspec", "~> 3"
26
+ spec.add_development_dependency "rake"
27
+ end
@@ -0,0 +1,104 @@
1
+ module EmmyMachine
2
+ module ClassMethods
3
+ def run(&b)
4
+ EventMachine.reactor_running? ? b.call : EventMachine.run(&b)
5
+ end
6
+
7
+ def loop
8
+ EventMachine.run
9
+ end
10
+
11
+ def running?
12
+ EventMachine.reactor_running?
13
+ end
14
+
15
+ def stop
16
+ EventMachine.stop
17
+ end
18
+
19
+ def run_block &b
20
+ EventMachine.run_block do
21
+ fiber_block &b
22
+ end
23
+ end
24
+
25
+ def fiber_block &b
26
+ Fibre.pool.checkout &b
27
+ end
28
+
29
+ # Periodic timer
30
+ def timer(interval=1, &b)
31
+ EventMachine::PeriodicTimer.new(interval) do
32
+ fiber_block &b
33
+ end
34
+ end
35
+
36
+ #
37
+ # One run timer
38
+ #
39
+ # timeout 5 do
40
+ # puts "This message shows after 5 seconds"
41
+ # end
42
+ #
43
+ def timeout(interval=1, &b)
44
+ EventMachine::Timer.new(interval) do
45
+ fiber_block &b
46
+ end
47
+ end
48
+
49
+ #
50
+ # Connect to server
51
+ #
52
+ # emmy.connect("tcp://localhost:5555")
53
+ # emmy.connect("ipc://mypoint")
54
+ # emmy.connect("tcp://localhost:5555", handler, *args)
55
+ # emmy.connect(*emmy.http.get(url))
56
+ def connect(url, *a, &b)
57
+ url = URI(url.to_s)
58
+ b = a.last if b.nil? && a.size > 0 && a.last.is_a?(Proc)
59
+ handler = a.empty? ? Connection : a.first
60
+
61
+ case url.scheme
62
+ when "tcp" then
63
+ EventMachine.connect(url.host, url.port, handler, *a, &b)
64
+ when "ipc" then
65
+ EventMachine.connect_unix_domain(url[6..-1], handler, *a, &b)
66
+ else
67
+ raise ArgumentError, "unsupported url scheme"
68
+ end
69
+ end
70
+
71
+ #
72
+ # Start server
73
+ #
74
+ # emmy.bind("tcp://localhost:5555", ServerConnection)
75
+ # emmy.bind("ipc://mypoint", ServerConnection)
76
+ # emmy.bind(* emmy.server.thin("tcp://localhost:4780", app))
77
+ def bind(url, *a, &b)
78
+ url = URI(url.to_s)
79
+ b = a.last if b.nil? && a.size > 0 && a.last.is_a?(Proc)
80
+ handler = a.empty? ? Connection : a.first
81
+
82
+ case url.scheme
83
+ when "tcp" then
84
+ EventMachine.start_server(url.host, url.port, handler, *a, &b)
85
+ when "ipc" then
86
+ EventMachine.start_unix_domain_server(url[6..-1], handler, *a, &b)
87
+ else
88
+ raise ArgumentError, "unsupported url scheme"
89
+ end
90
+ end
91
+
92
+ def next_tick
93
+ fiber = Fiber.current
94
+ EventMachine.next_tick { fiber.resume }
95
+ Fiber.yield
96
+ end
97
+
98
+ def sleep(time)
99
+ fiber = Fiber.current
100
+ timeout(time) { fiber.resume }
101
+ Fiber.yield
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,18 @@
1
+ module EmmyMachine
2
+ module Connection
3
+ using EventObject
4
+
5
+ def self.included(base)
6
+ base.events :connect, :data, :close, :error
7
+ base.class_eval do
8
+ alias_method :connection_completed, :connect!
9
+ alias_method :receive_data, :data!
10
+ end
11
+ end
12
+
13
+ def unbind(reason=nil)
14
+ close!(reason)
15
+ error!(reason) if error?
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module EmmyMachine
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,10 @@
1
+ require "fibre"
2
+ require "eventmachine"
3
+
4
+ require "emmy_machine/version"
5
+ require "emmy_machine/connection"
6
+ require "emmy_machine/class_methods"
7
+
8
+ module EmmyMachine
9
+ extend ClassMethods
10
+ end
data/emmy.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'emmy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "emmy"
8
+ spec.version = Emmy::VERSION
9
+ spec.authors = ["che"]
10
+ spec.email = ["chelovekov@gmail.com"]
11
+ spec.summary = %q{Emmy - EventMachine-based framework}
12
+ #spec.description = %q{TODO: Write a longer description. Optional.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "event_object", "~> 0.9"
22
+ spec.add_dependency "emmy-machine", "~> 0.1"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rspec", "~> 3"
26
+ spec.add_development_dependency "rake"
27
+ end
@@ -0,0 +1,3 @@
1
+ module Emmy
2
+ VERSION = "0.1.1"
3
+ end
data/lib/emmy.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "emmy/version"
2
+ require "emmy_machine"
3
+
4
+ module Emmy
5
+ extend EmmyMachine::ClassMethods
6
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emmy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - che
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: event_object
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: emmy-machine
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - chelovekov@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - emmy-machine/.gitignore
96
+ - emmy-machine/Gemfile
97
+ - emmy-machine/LICENSE.txt
98
+ - emmy-machine/README.md
99
+ - emmy-machine/Rakefile
100
+ - emmy-machine/emmy_machine.gemspec
101
+ - emmy-machine/lib/emmy_machine.rb
102
+ - emmy-machine/lib/emmy_machine/class_methods.rb
103
+ - emmy-machine/lib/emmy_machine/connection.rb
104
+ - emmy-machine/lib/emmy_machine/version.rb
105
+ - emmy.gemspec
106
+ - lib/emmy.rb
107
+ - lib/emmy/version.rb
108
+ homepage: ''
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.4.1
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Emmy - EventMachine-based framework
132
+ test_files: []