volt 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +20 -2
- data/VERSION +1 -1
- data/lib/volt/router/routes.rb +2 -2
- data/lib/volt/volt/environment.rb +27 -0
- data/lib/volt.rb +6 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8411833ee4800b3e7d701875b963b718af2c8351
|
4
|
+
data.tar.gz: f68ff074f4a685036f18e9a0536d431cee35ad1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c20f7c8102cf7b8b5f7fb35996cc9bf15400bc2d027324ab263357f7b46b2e5ae8843445b503fc22e37521e6b8ec195eba226fa4bed9e81a4b3e55968bc7103e
|
7
|
+
data.tar.gz: 3795c0247a76819a5ba58b444cf922db34c9234ae0816ebdf7c6d7ff7cfd535b03b0c5235277e52b20c47a491932667ca6137523135fde6195cec330f3bfdcb7
|
data/Readme.md
CHANGED
@@ -187,7 +187,7 @@ Simply use:
|
|
187
187
|
|
188
188
|
### With
|
189
189
|
|
190
|
-
|
190
|
+
... TODO: ...
|
191
191
|
|
192
192
|
## Bindings
|
193
193
|
|
@@ -327,7 +327,25 @@ Because all models provided by Volt are wrapped in a ReactiveValue, you can regi
|
|
327
327
|
|
328
328
|
# Controllers
|
329
329
|
|
330
|
-
|
330
|
+
A controller can be any class in Volt, however it is common to have that class inherit from ModelController. A model controller lets you specify a model that the controller works off of. This is a common pattern in Volt. To assign the current model, simply set @model to one of the provided models in the initializer.
|
331
|
+
|
332
|
+
class TodosController < ModelController
|
333
|
+
def initialize
|
334
|
+
@model = page
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
Now any methods not defined on the TodosController will fall through to the @model. All views in views/{controller_name} will have this controller as the target for any ruby run in their bindings. This means that calls on self (implicit or with self.) will have the model as their target (after calling through the controller). This lets you add methods to the controller to control how the model is handled.
|
339
|
+
|
340
|
+
Controllers in the app/home component do not need to be namespaced, all other components should namespace controllers like so:
|
341
|
+
|
342
|
+
module Auth
|
343
|
+
class LoginController < ModelController
|
344
|
+
# ...
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
Here "auth" would be the component name.
|
331
349
|
|
332
350
|
# Components
|
333
351
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.7
|
data/lib/volt/router/routes.rb
CHANGED
@@ -20,7 +20,7 @@ class Routes
|
|
20
20
|
def get(path, options={})
|
21
21
|
if path.index('{') && path.index('}')
|
22
22
|
# The path contains bindings.
|
23
|
-
path = build_path_matcher(path)
|
23
|
+
path = build_path_matcher(path, options)
|
24
24
|
else
|
25
25
|
add_path_matcher([path]) if Volt.server?
|
26
26
|
end
|
@@ -32,7 +32,7 @@ class Routes
|
|
32
32
|
# bindings in the path. Those are then used to create a proc
|
33
33
|
# that will return the path with the current params in it.
|
34
34
|
# If it matches it will be used.
|
35
|
-
def build_path_matcher(path)
|
35
|
+
def build_path_matcher(path, options)
|
36
36
|
sections = path.split(/(\{[^\}]+\})/)
|
37
37
|
sections = sections.reject {|v| v == '' }
|
38
38
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Volt
|
2
|
+
class Environment
|
3
|
+
def initialize
|
4
|
+
@env = ENV['VOLT_ENV'] || 'development'
|
5
|
+
end
|
6
|
+
|
7
|
+
def ==(val)
|
8
|
+
@env == val
|
9
|
+
end
|
10
|
+
|
11
|
+
def production?
|
12
|
+
self.==('production')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test?
|
16
|
+
self.==('test')
|
17
|
+
end
|
18
|
+
|
19
|
+
def development?
|
20
|
+
self.==('development')
|
21
|
+
end
|
22
|
+
|
23
|
+
def inspect
|
24
|
+
@env.inspect
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/volt.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stout
|
@@ -339,6 +339,7 @@ files:
|
|
339
339
|
- lib/volt/templates/targets/dom_target.rb
|
340
340
|
- lib/volt/templates/template_binding.rb
|
341
341
|
- lib/volt/templates/template_renderer.rb
|
342
|
+
- lib/volt/volt/environment.rb
|
342
343
|
- spec/app/bootstrap/assets/js/bootstrap.js
|
343
344
|
- spec/app/main/assets/js/test1.js
|
344
345
|
- spec/app/main/config/dependencies.rb
|