waitress-core 0.1.0 → 0.2.0

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: 53fac76668e1321e024fed8489d1e3bcf80075e2
4
- data.tar.gz: 8cc2c10b4661f3c42a5432eda9504691d1d47bf0
3
+ metadata.gz: f552a919bea93da988c0e9d2da78f1f7f3ba950b
4
+ data.tar.gz: 1c68dce7fcd814fd1a2a2ee4ceca5b6a8bf08676
5
5
  SHA512:
6
- metadata.gz: efb9647f241a506830c1a69f18869e2fcc7b67d8dc092ce0b14512445773fb2e8118a9c3c2ad8809e892f48f176588e32e8e510ef6e9aaaa30c73ec44ca2bb08
7
- data.tar.gz: fc393bf48cdebecbadc08d8a1dc3ec998443c3ebeb00242065a0bb5c0e03b65f45f670f92c389c8370cfc17d6f1e3f1922fb99d5c3dd2f27286a7c070ff233b0
6
+ metadata.gz: 8b2bccd565fbda334321875aa11e1d59f45b995c69f4d061af4c348ced0db5479625cb019b5bf0ccf24e61af5de58b7b7ece144ba74da04f136cedc4fc8c347e
7
+ data.tar.gz: eab73cf5eff46c885eff8f9c6eb69e6872887958a99c1ef0fb7bf9a5cf42f7b60644d552702c577ab098bb2d1dd98e9ccad9f9b8c445b4bc6fd5433487124d63
@@ -27,17 +27,25 @@ VALUE WRB_Parse(VALUE self, VALUE string, VALUE buffer) {
27
27
 
28
28
  int i = 0;
29
29
  char pc = NULL;
30
+ int line_cur = 1;
31
+ int line = 1;
32
+
30
33
  while (i < slen) {
31
34
  char c = sptr[i];
35
+ if (c == '\n') line_cur += 1;
36
+
32
37
  int open_e = i + tarlen;
33
38
  char *open_s = substr(sptr, i, tarlen);
34
39
 
35
40
  if (mat(open_s, tar) && pc != '\\') {
41
+ line = line_cur;
36
42
  int j = open_e;
37
43
  int search = 1;
38
44
  int q1 = 0; int q2 = 0;
39
45
  while (j < slen && search) {
40
46
  char cc = sptr[j];
47
+ if (cc == '\n') line_cur += 1;
48
+
41
49
  int close_e = j + endlen;
42
50
  char *close_s = substr(sptr, j, endlen);
43
51
 
@@ -48,7 +56,7 @@ VALUE WRB_Parse(VALUE self, VALUE string, VALUE buffer) {
48
56
  i = close_e - 1;
49
57
  search = 0;
50
58
  char *rb_ev = substr(sptr, open_e, j - open_e);
51
- rb_eval_string(rb_ev);
59
+ rb_yield_values(2, rb_str_new2(rb_ev), INT2NUM(line));
52
60
  }
53
61
  }
54
62
 
data/lib/waitress/chef.rb CHANGED
@@ -66,8 +66,11 @@ module Waitress
66
66
  # +target+:: The target file, given in absolute path form.
67
67
  def self.include_absfile target
68
68
  ext = File.extname target
69
+ bind = Waitress::EvalBindings.new
69
70
  if ext == ".wrb"
70
- Waitress::WRBParser.parse! File.read(target), $RESPONSE.body_io
71
+ Waitress::WRBParser.parse!(File.read(target), $RESPONSE.body_io) do |txt, lino|
72
+ eval(txt, bind.context, target, lino) # For some reason, rb_f_eval is not exposed to ruby.h
73
+ end
71
74
  elsif ext == ".rb"
72
75
  require target
73
76
  else
@@ -79,7 +82,7 @@ module Waitress
79
82
  # to automatically include an index file if it exists under the
80
83
  # requested directory, automatically add the .wrb or .html file extension
81
84
  # for paths without the extension, etc. A hash containing the result (ok / notfound)
82
- # and the new filepath will be given.
85
+ # and the new filepath will be given.
83
86
  def self.find_file abspath
84
87
  ret = {}
85
88
  if File.exist?(abspath)
@@ -0,0 +1,9 @@
1
+ module Waitress
2
+ class EvalBindings
3
+
4
+ def context
5
+ binding()
6
+ end
7
+
8
+ end
9
+ end
@@ -56,7 +56,7 @@ module Waitress
56
56
 
57
57
  # Killall running processes
58
58
  def killall
59
- @running_processes.each { |x| x.kill }
59
+ @running_processes.each { |x| x.kill rescue nil }
60
60
  end
61
61
 
62
62
  # Join the server, blocking the current thread in order to keep the server alive.
@@ -1,3 +1,3 @@
1
1
  module Waitress
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/waitress.rb CHANGED
@@ -14,6 +14,7 @@ require 'waitress/handlers/dirhandler'
14
14
  require 'waitress/handlers/handler404'
15
15
  require 'waitress/handlers/libhandler'
16
16
  require 'waitress/chef'
17
+ require 'waitress/evalbind'
17
18
 
18
19
  require 'waitress_http11'
19
20
 
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waitress-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaci Brunning
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-30 00:00:00.000000000 Z
11
+ date: 2015-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -148,6 +148,7 @@ files:
148
148
  - lib/waitress.rb
149
149
  - lib/waitress/chef.rb
150
150
  - lib/waitress/configure.rb
151
+ - lib/waitress/evalbind.rb
151
152
  - lib/waitress/handlers/dirhandler.rb
152
153
  - lib/waitress/handlers/handler.rb
153
154
  - lib/waitress/handlers/handler404.rb