dzl 1.0.0.beta1 → 1.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
data/dzl.gemspec CHANGED
@@ -8,14 +8,14 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Kyle Brett", "Paul Bergeron"]
9
9
  s.email = ["kyle@vitrue.com", "pbergeron@vitrue.com"]
10
10
  s.homepage = "http://github.com/vitrue/dzl"
11
- s.summary = %q{Parameter validation and request routing DSL & framework}
12
- s.description = %q{Dzl zones live!}
11
+ s.summary = %q{Parameter validation and request routing DSL & web framework}
12
+ s.description = %q{Small, fast racktivesupport web framework with handy DSL and explicit parameter validation.}
13
13
 
14
14
  s.files = `git ls-files`.split("\n")
15
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
  s.require_paths = ["lib"]
18
18
 
19
- s.add_runtime_dependency 'rack'
20
- s.add_runtime_dependency 'activesupport'
19
+ s.add_runtime_dependency 'rack', '~> 1.4.1'
20
+ s.add_runtime_dependency 'activesupport', '~> 3.2.2'
21
21
  end
@@ -5,6 +5,7 @@ module Dzl::RackInterface
5
5
  PROFILE_REQUESTS = false
6
6
 
7
7
  def call(env)
8
+ __reloader.reload_if_updated if respond_to?(:__reloader)
8
9
  response = nil
9
10
  request = nil
10
11
  start_time = Time.now
@@ -0,0 +1,44 @@
1
+ class Dzl::Reloader
2
+ def initialize(app)
3
+ @app = app
4
+ @files = Dir["#{app.root}/lib/**/*.rb"]
5
+ @last_reload = Time.now
6
+ end
7
+
8
+ def reload_if_updated
9
+ reload! if updated?
10
+ end
11
+
12
+ def reload!
13
+ @app.__wipe
14
+
15
+ @files.each do |file|
16
+ begin
17
+ load(file) if $LOADED_FEATURES.include?(file)
18
+ rescue LoadError, SyntaxError, SystemStackError => e
19
+ @app.logger.error(e)
20
+ @app.logger.error(e.backtrace)
21
+ @app.logger.error "While loading file #{file}"
22
+ end
23
+ end
24
+
25
+ @last_reload = Time.now
26
+ end
27
+
28
+ private
29
+ def updated?
30
+ # If it hasn't been two seconds, don't reload.
31
+ updated_at > (@last_reload + 2.seconds)
32
+ end
33
+
34
+ def files_and_mtimes(rb_files)
35
+ rb_files.each_with_object({}) do |file, out|
36
+ out[file] = File.mtime(file)
37
+ end
38
+ end
39
+
40
+ def updated_at
41
+ @files.collect {|f| File.mtime(f)}.max
42
+ end
43
+ end
44
+
data/lib/dzl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dzl
2
- VERSION = "1.0.0.beta1"
2
+ VERSION = "1.0.0.beta2"
3
3
  end
data/lib/dzl.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'active_support'
1
2
  require 'active_support/core_ext'
2
3
  require 'dzl/version'
3
4
  require 'dzl/logger'
@@ -30,6 +31,12 @@ module Dzl
30
31
  )
31
32
  end
32
33
 
34
+ [:development?, :production?, :staging?, :test?].each do |m|
35
+ define_singleton_method(m) do
36
+ env == m.to_s[0..-2]
37
+ end
38
+ end
39
+
33
40
  base.extend(RackInterface)
34
41
 
35
42
  class << base
@@ -40,6 +47,10 @@ module Dzl
40
47
  @__router ||= Dzl::DSLSubjects::Router.new(self)
41
48
  end
42
49
 
50
+ def __wipe
51
+ @__router = nil
52
+ end
53
+
43
54
  def __logger
44
55
  @__logger ||= begin
45
56
  if self.orig_respond_to?(:logger) && self.logger.is_a?(ActiveSupport::BufferedLogger)
@@ -79,18 +90,15 @@ module Dzl
79
90
  endpoint_page.close
80
91
  end
81
92
  end
82
- end
83
- end
84
93
 
85
- [:development?, :production?, :staging?, :test?].each do |m|
86
- define_singleton_method(m) do
87
- env == m.to_s[0..-2]
94
+ if Dzl.development?
95
+ require 'dzl/reloader'
96
+ def __reloader
97
+ @__reloader ||= Dzl::Reloader.new(self)
98
+ end
99
+ end
88
100
  end
89
101
  end
90
-
91
- def self.development?
92
- true
93
- end
94
102
  end
95
103
 
96
104
  Diesel = Dzl
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dzl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta1
4
+ version: 1.0.0.beta2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,31 +10,32 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-16 00:00:00.000000000 Z
13
+ date: 2012-03-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
17
- requirement: &70345596630620 !ruby/object:Gem::Requirement
17
+ requirement: &70297835742860 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
- - - ! '>='
20
+ - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: '0'
22
+ version: 1.4.1
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70345596630620
25
+ version_requirements: *70297835742860
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activesupport
28
- requirement: &70345596630120 !ruby/object:Gem::Requirement
28
+ requirement: &70297835740780 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
- - - ! '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 3.2.2
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70345596630120
37
- description: Dzl zones live!
36
+ version_requirements: *70297835740780
37
+ description: Small, fast racktivesupport web framework with handy DSL and explicit
38
+ parameter validation.
38
39
  email:
39
40
  - kyle@vitrue.com
40
41
  - pbergeron@vitrue.com
@@ -83,6 +84,7 @@ files:
83
84
  - lib/dzl/examples/trey.rb
84
85
  - lib/dzl/logger.rb
85
86
  - lib/dzl/rack_interface.rb
87
+ - lib/dzl/reloader.rb
86
88
  - lib/dzl/request.rb
87
89
  - lib/dzl/response_context.rb
88
90
  - lib/dzl/response_context/request_helpers.rb
@@ -126,7 +128,7 @@ rubyforge_project:
126
128
  rubygems_version: 1.8.15
127
129
  signing_key:
128
130
  specification_version: 3
129
- summary: Parameter validation and request routing DSL & framework
131
+ summary: Parameter validation and request routing DSL & web framework
130
132
  test_files:
131
133
  - spec/dsl_subject_spec.rb
132
134
  - spec/endpoint_doc_spec.rb