spinebox 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,8 @@ module Spinebox
11
11
  def self.configuration(&block)
12
12
  @@configuration ||= OpenStruct.new(
13
13
  :assets => Sprockets::Environment.new,
14
- :views => Sprockets::Environment.new
14
+ :views => Sprockets::Environment.new,
15
+ :reload => true
15
16
  )
16
17
 
17
18
  block.call(@@configuration) if block
@@ -0,0 +1,26 @@
1
+ module Spinebox
2
+
3
+ # Rack middleware that reloads the sprockets environment on
4
+ # every request with a default delay of 5 seconds
5
+ class Reloader
6
+
7
+ def initialize(app, cooldown = 5)
8
+ @app, @cooldown = app, cooldown
9
+ @last = (Time.now - cooldown)
10
+ end
11
+
12
+ def call(env)
13
+ reload! if Time.now > @last + @cooldown
14
+ @app.call(env)
15
+ end
16
+
17
+ private
18
+ def reload!
19
+ Spinebox.config.assets.version = '0.1'
20
+ Spinebox.config.views.version = '0.1'
21
+
22
+ @last = Time.now
23
+ end
24
+
25
+ end
26
+ end
@@ -8,8 +8,18 @@ module Spinebox
8
8
  reset!
9
9
 
10
10
  # Draw the routes into a rack builder app
11
- def self.draw(&block)
12
- @@app = Rack::Builder.new(&block).to_app
11
+ def self.draw(&block)
12
+ @@app = Rack::Builder.app do
13
+
14
+ # Reload on every request?
15
+ if Spinebox.config.reload
16
+ use Spinebox::Reloader
17
+ use Rack::Reloader, 0
18
+ end
19
+
20
+ # Mapping from routes.rb
21
+ instance_eval(&block)
22
+ end
13
23
  end
14
24
 
15
25
  # The rack app
@@ -11,4 +11,7 @@ Spinebox.config do |config|
11
11
  # Concatenate assets or serve them seperately?
12
12
  config.concatenate = false
13
13
 
14
+ # Reload assets and views on every request?
15
+ config.reload = true
16
+
14
17
  end
@@ -1,3 +1,3 @@
1
1
  module Spinebox
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
data/lib/spinebox.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "sprockets"
2
2
  require "rack"
3
+ require "rack/reloader"
3
4
  require 'coffee_script'
4
5
  require 'eco'
5
6
  require 'sass'
@@ -11,6 +12,7 @@ require 'erb'
11
12
  require "spinebox/version"
12
13
  require "spinebox/base"
13
14
  require "spinebox/command"
15
+ require "spinebox/reloader"
14
16
  require "spinebox/config"
15
17
  require "spinebox/routes"
16
18
  require "spinebox/erb_context"
data/spec/routes_spec.rb CHANGED
@@ -8,7 +8,13 @@ describe Spinebox do
8
8
  end
9
9
 
10
10
  it "should load the routes from the default path" do
11
- Spinebox.app.should be_a Rack::URLMap
11
+ Spinebox.app.should be_a Spinebox::Reloader
12
+ end
13
+
14
+ it "should disable the reloading" do
15
+ Spinebox.config.reload = false
16
+ Spinebox.load_routes!
17
+ Spinebox::Routes.app.should be_a Rack::URLMap
12
18
  end
13
19
 
14
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spinebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-11 00:00:00.000000000 Z
12
+ date: 2012-05-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
16
- requirement: &70140945498360 !ruby/object:Gem::Requirement
16
+ requirement: &70204084591100 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.1.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70140945498360
24
+ version_requirements: *70204084591100
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rack
27
- requirement: &70140945497860 !ruby/object:Gem::Requirement
27
+ requirement: &70204084590580 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.4.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70140945497860
35
+ version_requirements: *70204084590580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: coffee-script
38
- requirement: &70140945497400 !ruby/object:Gem::Requirement
38
+ requirement: &70204084622360 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.2.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70140945497400
46
+ version_requirements: *70204084622360
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: eco
49
- requirement: &70140943507340 !ruby/object:Gem::Requirement
49
+ requirement: &70204084621900 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70140943507340
57
+ version_requirements: *70204084621900
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: sass
60
- requirement: &70140945531040 !ruby/object:Gem::Requirement
60
+ requirement: &70204084621440 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 3.1.15
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70140945531040
68
+ version_requirements: *70204084621440
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: colorize
71
- requirement: &70140945530580 !ruby/object:Gem::Requirement
71
+ requirement: &70204084620980 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.5.8
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70140945530580
79
+ version_requirements: *70204084620980
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: activesupport
82
- requirement: &70140945530120 !ruby/object:Gem::Requirement
82
+ requirement: &70204084620520 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 3.2.2
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70140945530120
90
+ version_requirements: *70204084620520
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: thin
93
- requirement: &70140945529660 !ruby/object:Gem::Requirement
93
+ requirement: &70204084620060 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: 1.3.1
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70140945529660
101
+ version_requirements: *70204084620060
102
102
  description: A ready to use spine.js rack skeleton builder with development server,
103
103
  routes, config and precompile support
104
104
  email:
@@ -121,6 +121,7 @@ files:
121
121
  - lib/spinebox/config.rb
122
122
  - lib/spinebox/erb_context.rb
123
123
  - lib/spinebox/generator.rb
124
+ - lib/spinebox/reloader.rb
124
125
  - lib/spinebox/routes.rb
125
126
  - lib/spinebox/templates/.DS_Store
126
127
  - lib/spinebox/templates/app/Gemfile