emmy-extends 0.1.9 → 0.1.10

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: 68666d4e032eda76f5bb20fd82848655ed7b5a2b
4
- data.tar.gz: 8ffa2d98b0e91916b40c0d5a0c55ca1f98620fce
3
+ metadata.gz: 5b9ea4d3a1fcacff55960ab9a41e129980ad6e66
4
+ data.tar.gz: cf1aee06b24799a6cdb0a6bc4c57df017aa36073
5
5
  SHA512:
6
- metadata.gz: 9cba9ac93732d51ad587ea0a6f2e2030bd044e1c58eaf2b5b2484055822837eef696e65d0e4802af0153820460550ea020bd9ba48b37d893995bf57708435a87
7
- data.tar.gz: cf59f236c6ee0f263f125a754e3f9e22a379f7083e66e5565287f5952d270540ff1c6e97c93641d622e8c3c30388455bb2c528e9301c29ab129510b01d8f919a
6
+ metadata.gz: 8f741508afbc3ffccd6ff986e380cbbe15877280cd390401a9076e3cc06cf8bc7d1443d177ce7d7bbd648e7ce3ebad0dfd98214a9ed70f3fec33084113ebeb91
7
+ data.tar.gz: 57a31dfbfb877b48ed77d2e002e054b0683b4f8bcd89ab870f20f189c3eb77519f384c4a086c3e226850ee830af53adc9046cce17a4ccb4b76a98ddbaf2cf51d
data/README.md CHANGED
@@ -90,7 +90,10 @@ EmmyMachine.run do
90
90
  run Application
91
91
  end
92
92
 
93
- EmmyMachine.bind(*EmmyExtends::Thin.server("tcp://localhost:65535", app, options))
93
+ thin = EmmyExtends::Thin::Controller.new({
94
+ url: "tcp://localhost:65535"
95
+ }, app)
96
+ EmmyMachine.bind(*thin)
94
97
  end
95
98
  ```
96
99
 
data/bin/emmy-thin ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ require 'emmy'
3
+ require 'emmy_extends/thin'
4
+
5
+ runner = Emmy::Runner.instance
6
+
7
+ unless runner.execute_bin_emmy
8
+ runner.run_action
9
+ end
data/emmy-extends.gemspec CHANGED
@@ -14,14 +14,13 @@ Gem::Specification.new do |spec|
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.executables = ["emmy-thin"]
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "emmy-machine", "~> 0.1"
22
22
  spec.add_dependency "emmy-http", "~> 0.1"
23
23
 
24
-
25
24
  spec.add_development_dependency "eventmachine", "~> 1.0.3"
26
25
  spec.add_development_dependency "rspec", "~> 3"
27
26
  spec.add_development_dependency "bundler", "~> 1.7"
@@ -1,5 +1,3 @@
1
- require 'thin'
2
-
3
1
  module EmmyExtends
4
2
  class Thin::Backend < ::Thin::Backends::Base
5
3
  attr_accessor :url
@@ -1,23 +1,35 @@
1
- require 'uri'
2
-
3
1
  module EmmyExtends
4
2
  class Thin::Controller < ::Thin::Controllers::Controller
5
3
 
6
- attr_accessor :app, :url
4
+ attr_accessor :app
5
+ attr_accessor :config
6
+ attr_accessor :server
7
+ attr_accessor :backend
7
8
 
8
- def initialize(url, app, options={})
9
- @url = URI(url.to_s)
9
+ def initialize(config, app, opts={})
10
10
  @app = app
11
- super(options_with_defaults(options))
11
+ @config = config.is_a?(Hash) ? EmmyHttp::Configuration.new(config) : config
12
+ options = {
13
+ environment: config.environment,
14
+ address: config.url.host,
15
+ port: config.url.port,
16
+ pid: config.pid,
17
+ log: config.log || File.join(Dir.pwd, "log/#{config.backend}.log")
18
+ }
19
+ super(option_defaults.merge(options.merge(opts)))
20
+ setup
12
21
  end
13
22
 
14
23
  def start
24
+ end
25
+
26
+ def setup
15
27
  if @options[:socket]
16
- server = ::Thin::Server.new(@options[:socket], @options)
28
+ @server = ::Thin::Server.new(@options[:socket], @options)
17
29
  else
18
- server = ::Thin::Server.new(url.host, url.port, @options)
30
+ @server = ::Thin::Server.new(config.url.host, config.url.port, @options)
19
31
  end
20
- server.backend.url = url
32
+ server.backend.url = config.url
21
33
 
22
34
  # Set options
23
35
  server.pid_file = @options[:pid]
@@ -52,29 +64,33 @@ module EmmyExtends
52
64
  #server.on_restart { Thin::Command.run(:start, @options) }
53
65
 
54
66
  # just return thin-backend
55
- server.backend
67
+ @backend = server.backend
68
+ end
69
+
70
+ def to_a
71
+ @backend.to_a
56
72
  end
57
73
 
58
74
  private
59
75
 
60
- def options_with_defaults(opt)
61
- {
62
- backend: EmmyExtends::Thin::Backend,
63
- threaded: false,
64
- no_epoll: false,
65
- chdir: Dir.pwd,
66
- environment: 'development',
67
- address: '0.0.0.0',
68
- port: 3434,
69
- timeout: 30, #sec
70
- pid: "tmp/pids/server.pid",
71
- log: File.join(Dir.pwd, "log/server.log"),
72
- max_conns: 1024,
73
- max_persistent_conns: 100,
74
- require: [],
75
- wait: 30, #sec
76
- daemonize: false
77
- }.update(opt)
78
- end
76
+ def option_defaults
77
+ {
78
+ backend: EmmyExtends::Thin::Backend,
79
+ threaded: false,
80
+ no_epoll: false,
81
+ chdir: Dir.pwd,
82
+ #environment: 'development',
83
+ #address: '0.0.0.0',
84
+ #port: 3434,
85
+ timeout: 0, #sec
86
+ #pid: "tmp/pids/thin.pid",
87
+ #log: File.join(Dir.pwd, "log/server.log"),
88
+ max_conns: 1024,
89
+ max_persistent_conns: 100,
90
+ require: [],
91
+ wait: 30, #sec
92
+ #daemonize: false
93
+ }
94
+ end
79
95
  end
80
96
  end
@@ -0,0 +1,20 @@
1
+ config = Emmy::Runner.instance.config
2
+ config_ru = File.join(Dir.getwd, "config.ru")
3
+
4
+ unless File.readable_real?(config_ru)
5
+ puts "Missing #{config_ru} file."
6
+ exit
7
+ end
8
+
9
+ rackup_code = File.read(config_ru)
10
+ # can run bundler in rackup.ru
11
+ app = eval("Rack::Builder.new { use Fibre::Rack::FiberPool; ( #{rackup_code}\n )}.to_app", TOPLEVEL_BINDING, config_ru)
12
+
13
+ require 'thin'
14
+
15
+ Emmy.run do
16
+ puts "Thin web server"
17
+ puts "Application starting in #{config.environment}"
18
+ puts "Listening on #{config.url}"
19
+ Emmy.bind *EmmyExtends::Thin::Controller.new(config, app)
20
+ end
@@ -1,10 +1,11 @@
1
+ require 'thin'
2
+
1
3
  module EmmyExtends
2
4
  module Thin
3
- autoload :Connection, "emmy_extends/thin/connection"
4
- autoload :Backend, "emmy_extends/thin/backend"
5
- autoload :Controller, "emmy_extends/thin/controller"
6
- autoload :ClassMethods, "emmy_extends/thin/class_methods"
7
-
8
- extend ClassMethods
5
+ EMMY_BACKEND = File.expand_path('../thin/rackup.rb', __FILE__)
9
6
  end
10
7
  end
8
+
9
+ require "emmy_extends/thin/connection"
10
+ require "emmy_extends/thin/backend"
11
+ require "emmy_extends/thin/controller"
@@ -1,3 +1,3 @@
1
1
  module EmmyExtends
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emmy-extends
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - inre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-08 00:00:00.000000000 Z
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: emmy-machine
@@ -97,7 +97,8 @@ dependencies:
97
97
  description:
98
98
  email:
99
99
  - inre.storm@gmail.com
100
- executables: []
100
+ executables:
101
+ - emmy-thin
101
102
  extensions: []
102
103
  extra_rdoc_files: []
103
104
  files:
@@ -106,6 +107,7 @@ files:
106
107
  - LICENSE.txt
107
108
  - README.md
108
109
  - Rakefile
110
+ - bin/emmy-thin
109
111
  - emmy-extends.gemspec
110
112
  - lib/emmy_extends/activerecord/adapter.rb
111
113
  - lib/emmy_extends/activerecord/connection_handling.rb
@@ -127,9 +129,9 @@ files:
127
129
  - lib/emmy_extends/savon/operation.rb
128
130
  - lib/emmy_extends/thin.rb
129
131
  - lib/emmy_extends/thin/backend.rb
130
- - lib/emmy_extends/thin/class_methods.rb
131
132
  - lib/emmy_extends/thin/connection.rb
132
133
  - lib/emmy_extends/thin/controller.rb
134
+ - lib/emmy_extends/thin/rackup.rb
133
135
  - lib/emmy_extends/version.rb
134
136
  - spec/ConvertTemperature.asmx.xml
135
137
  - spec/em_http_request_spec.rb
@@ -1,11 +0,0 @@
1
- require "emmy_extends/core_ext"
2
-
3
- module EmmyExtends
4
- module Thin::ClassMethods
5
- using CoreExt
6
-
7
- def server(url, app, opt={})
8
- Thin::Controller.new(url, app, opt.to_options).start
9
- end
10
- end
11
- end