emmy-engine 0.1.4 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/emmy +8 -0
- data/emmy-engine.gemspec +16 -9
- data/lib/emmy/runner.rb +143 -0
- data/lib/emmy/version.rb +1 -1
- data/lib/emmy.rb +5 -1
- metadata +34 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb59578321a7548dfbfb97f3aec79be5fa4748d4
|
4
|
+
data.tar.gz: 6956f77fa81364267887394db94e96a81315178c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a561103f57d1797a6e91e7deb4cf255ed99ab771ff55797cca9353393fb8afbdceba608c9f33eedfc0452c9656a7fd6d9c32e48f4479b0d72315e6928d05f5a
|
7
|
+
data.tar.gz: c56a4fddb13fe885d462d22a98ee702940b6b3e8cfe521eed86b6795da420af967119e6d2f573aee808473a0007c9c90cf2bba2aaaea01b4fe00ef15a43b014c
|
data/README.md
CHANGED
data/bin/emmy
ADDED
data/emmy-engine.gemspec
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
4
5
|
require 'emmy/version'
|
6
|
+
version = File.read(File.expand_path('../../EMMY_VERSION', __FILE__)).strip
|
7
|
+
if version != Emmy::VERSION
|
8
|
+
puts "Different version numbers"
|
9
|
+
exit
|
10
|
+
end
|
5
11
|
|
6
12
|
Gem::Specification.new do |spec|
|
7
13
|
spec.name = "emmy-engine"
|
@@ -9,20 +15,21 @@ Gem::Specification.new do |spec|
|
|
9
15
|
spec.authors = ["inre"]
|
10
16
|
spec.email = ["inre.storm@gmail.com"]
|
11
17
|
|
12
|
-
spec.summary = %q{Emmy
|
18
|
+
spec.summary = %q{Emmy Engine}
|
13
19
|
#spec.description = %q{TODO: Write a longer description or delete this line.}
|
14
20
|
#spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
15
21
|
|
16
22
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir = "
|
18
|
-
spec.executables =
|
23
|
+
spec.bindir = "bin"
|
24
|
+
spec.executables = "emmy"
|
19
25
|
spec.require_paths = ["lib"]
|
20
26
|
|
21
|
-
spec.add_dependency "emmy-machine",
|
22
|
-
spec.add_dependency "emmy-http",
|
23
|
-
spec.add_dependency "emmy-http-client", "
|
27
|
+
spec.add_dependency "emmy-machine", "~> 0.1"
|
28
|
+
spec.add_dependency "emmy-http", "~> 0.2"
|
29
|
+
spec.add_dependency "emmy-http-client", "~> 0.1"
|
24
30
|
|
25
|
-
spec.add_development_dependency "
|
26
|
-
spec.add_development_dependency "
|
27
|
-
spec.add_development_dependency "
|
31
|
+
spec.add_development_dependency "eventmachine", "~> 1.0"
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3"
|
28
35
|
end
|
data/lib/emmy/runner.rb
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
module Emmy
|
2
|
+
class Runner
|
3
|
+
include Singleton
|
4
|
+
using EventObject
|
5
|
+
events :parse
|
6
|
+
|
7
|
+
RUBY = Gem.ruby
|
8
|
+
BIN_EMMY = "bin/emmy"
|
9
|
+
|
10
|
+
attr_accessor :argv
|
11
|
+
attr_accessor :env
|
12
|
+
attr_accessor :config
|
13
|
+
attr_accessor :action
|
14
|
+
attr_accessor :option_parser
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@argv = ARGV
|
18
|
+
@env = ENV
|
19
|
+
@config = EmmyHttp::Configuration.new
|
20
|
+
@action = :start_server
|
21
|
+
|
22
|
+
on :parse do
|
23
|
+
parse_environment!
|
24
|
+
end
|
25
|
+
on :parse do
|
26
|
+
option_parser.parse!(argv)
|
27
|
+
end
|
28
|
+
on :parse do
|
29
|
+
defaults!
|
30
|
+
end
|
31
|
+
on :parse do
|
32
|
+
update_rack_environment!
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def execute_bin_emmy
|
37
|
+
return false unless File.file?(BIN_EMMY)
|
38
|
+
exec RUBY, BIN_EMMY, *argv
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
def parse_environment!
|
43
|
+
config.environment = env['EMMY_ENV'] || env['RACK_ENV'] || 'development'
|
44
|
+
end
|
45
|
+
|
46
|
+
def update_rack_environment!
|
47
|
+
ENV['RACK_ENV'] = config.environment
|
48
|
+
end
|
49
|
+
|
50
|
+
def option_parser
|
51
|
+
@option_parser ||= OptionParser.new do |opts|
|
52
|
+
opts.banner = "Usage: emmy [options]"
|
53
|
+
opts.separator "Options:"
|
54
|
+
# configure
|
55
|
+
opts.on("-e", "--environment ENV", "Specifies the execution environment",
|
56
|
+
"Default: #{config.environment}") { |env| config.environment = env }
|
57
|
+
opts.on("-p", "--port PORT", "Runs Emmy on the specified port",
|
58
|
+
"Default: #{config.url.port}") { |port| config.url.port = port }
|
59
|
+
opts.on("-a", "--address HOST", "Binds Emmy to the specified host",
|
60
|
+
"Default: #{config.url.host}") { |address| config.url.host = address }
|
61
|
+
opts.on("-b", "--backend [name]", "Backend name",
|
62
|
+
"Default: backend") { |name| config.backend = name }
|
63
|
+
opts.on("-d", "--daemonize", "Runs server in the background") { config.daemonize = true }
|
64
|
+
opts.on("-s", "--silence", "Logging disabled") { config.logging = false }
|
65
|
+
# actions
|
66
|
+
opts.on("-i", "--info", "Shows server configuration") { @action = :show_configuration }
|
67
|
+
opts.on("-c", "--console", "Start a console") { @action = :start_console }
|
68
|
+
opts.on("-h", "--help", "Display this help message") { @action = :display_help }
|
69
|
+
opts.on("-v", "--version", "Display Emmy version.") { @action = :display_version }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def defaults!
|
74
|
+
if Process.uid == 0
|
75
|
+
config.user = "worker"
|
76
|
+
config.group = "worker"
|
77
|
+
end
|
78
|
+
|
79
|
+
config.pid ||= "tmp/pids/#{config.backend}.pid"
|
80
|
+
end
|
81
|
+
|
82
|
+
def run_action
|
83
|
+
# Run parsers
|
84
|
+
parse!
|
85
|
+
# start action
|
86
|
+
send(action)
|
87
|
+
self
|
88
|
+
end
|
89
|
+
|
90
|
+
def start_server
|
91
|
+
load backend_file
|
92
|
+
end
|
93
|
+
|
94
|
+
def start_console
|
95
|
+
if defined?(binding.pry)
|
96
|
+
TOPLEVEL_BINDING.pry
|
97
|
+
else
|
98
|
+
require 'irb'
|
99
|
+
require 'irb/completion'
|
100
|
+
IRB.start
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def show_configuration
|
105
|
+
puts "Server configuration:"
|
106
|
+
config.attributes.each do |name, value|
|
107
|
+
value = "off" if value.nil?
|
108
|
+
puts " #{name}: #{value}"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def display_help
|
113
|
+
puts option_parser
|
114
|
+
end
|
115
|
+
|
116
|
+
def display_version
|
117
|
+
puts Emmy::VERSION
|
118
|
+
end
|
119
|
+
|
120
|
+
def error(message)
|
121
|
+
puts message
|
122
|
+
exit
|
123
|
+
end
|
124
|
+
|
125
|
+
private
|
126
|
+
|
127
|
+
def backend_file
|
128
|
+
thin = (config.backend == 'backend') ? EmmyExtends::Thin::EMMY_BACKEND : nil rescue nil
|
129
|
+
backends = [
|
130
|
+
"#{Dir.getwd}/#{config.backend}.rb",
|
131
|
+
"#{Dir.getwd}/config/#{config.backend}.rb",
|
132
|
+
thin
|
133
|
+
].compact
|
134
|
+
|
135
|
+
backends.each do |file|
|
136
|
+
return file if File.readable_real?(file)
|
137
|
+
end
|
138
|
+
error "Can't find backend in #{backends.inspect} places."
|
139
|
+
end
|
140
|
+
|
141
|
+
#<<<
|
142
|
+
end
|
143
|
+
end
|
data/lib/emmy/version.rb
CHANGED
data/lib/emmy.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'singleton'
|
1
2
|
require 'emmy_machine'
|
2
3
|
require 'emmy_http'
|
3
4
|
require 'emmy_http/client'
|
@@ -7,5 +8,8 @@ module Emmy
|
|
7
8
|
include EventObject
|
8
9
|
include Fibre::Synchrony
|
9
10
|
|
10
|
-
autoload :Http,
|
11
|
+
autoload :Http, 'emmy/http'
|
12
|
+
autoload :Runner, 'emmy/runner'
|
11
13
|
end
|
14
|
+
|
15
|
+
require 'emmy/version'
|
metadata
CHANGED
@@ -1,57 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emmy-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- inre
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: emmy-machine
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1
|
19
|
+
version: '0.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.1
|
26
|
+
version: '0.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: emmy-http
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.2
|
33
|
+
version: '0.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.2
|
40
|
+
version: '0.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: emmy-http-client
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1
|
47
|
+
version: '0.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: eventmachine
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: '1.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,7 +111,8 @@ dependencies:
|
|
97
111
|
description:
|
98
112
|
email:
|
99
113
|
- inre.storm@gmail.com
|
100
|
-
executables:
|
114
|
+
executables:
|
115
|
+
- emmy
|
101
116
|
extensions: []
|
102
117
|
extra_rdoc_files: []
|
103
118
|
files:
|
@@ -106,9 +121,11 @@ files:
|
|
106
121
|
- Gemfile
|
107
122
|
- README.md
|
108
123
|
- Rakefile
|
124
|
+
- bin/emmy
|
109
125
|
- emmy-engine.gemspec
|
110
126
|
- lib/emmy.rb
|
111
127
|
- lib/emmy/http.rb
|
128
|
+
- lib/emmy/runner.rb
|
112
129
|
- lib/emmy/version.rb
|
113
130
|
homepage:
|
114
131
|
licenses: []
|
@@ -132,5 +149,5 @@ rubyforge_project:
|
|
132
149
|
rubygems_version: 2.4.6
|
133
150
|
signing_key:
|
134
151
|
specification_version: 4
|
135
|
-
summary: Emmy
|
152
|
+
summary: Emmy Engine
|
136
153
|
test_files: []
|