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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f150816f7a0d0a04624791bb0126192bd457baa
4
- data.tar.gz: 76bbeb5ff7e2e92919fd2a42479fdbfd12eb7667
3
+ metadata.gz: 8411833ee4800b3e7d701875b963b718af2c8351
4
+ data.tar.gz: f68ff074f4a685036f18e9a0536d431cee35ad1a
5
5
  SHA512:
6
- metadata.gz: 8809bf5a5ba5c9678db7a79b7ea9a00fa73f99366486f45745af56a7c524e34167c4061bb545219a68abde62ce2a93efedb793a3de2b673731ff4eb4fbb2d22d
7
- data.tar.gz: c327c96bd63e7f315b094072eab88e575d65a7985c15bf3cc6f6bf0446859aea859dac9edf4ca481ff2b14735d06e48e80773262a8b84dcae337e98e9bf13b8c
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
- ... TODO ...
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.6
1
+ 0.3.7
@@ -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
@@ -1,3 +1,5 @@
1
+ require 'volt/volt/environment'
2
+
1
3
  class Volt
2
4
  def self.root
3
5
  @root ||= File.expand_path(Dir.pwd)
@@ -14,4 +16,8 @@ class Volt
14
16
  def self.source_maps?
15
17
  !!ENV['MAPS']
16
18
  end
19
+
20
+ def self.env
21
+ @env ||= Volt::Environment.new
22
+ end
17
23
  end
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.6
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