volt 0.9.0.pre5 → 0.9.0.pre6

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: c6b166ab0b3c9e33c493d7c65d65d3c5db8f9cdb
4
- data.tar.gz: 406513b0bc558b964c2207cf6b9ee4f66796d65e
3
+ metadata.gz: 4d7f725c0927c9b59afe03d26fb21eabd1dedb70
4
+ data.tar.gz: 5db3976c7d9fa0c0f4d39143fbdc55f605ef1d4d
5
5
  SHA512:
6
- metadata.gz: 0350b5ca4ba46fc30c183be534f5e0ba4b0a4ba1af4cfedf4599a354d91a2f72865aaba9d639fe821001740874c9cc6b73d2dff095a673d3b128d22ca3bcd75c
7
- data.tar.gz: 6ba8bd6674ea7057d27ab6259b203c8397c023b43c39eaf0d66573e36c44d56c1dc606e357a1d921016b3271101b78d7696d417896c697f3a2ed354c74e38446
6
+ metadata.gz: 19f53d2bf32447609e05e3ec6bc7f111b746da01e6def14e94bc94a56a0f1940b328342d15d82e9378227855d99c02369b0bf31e356616a2ee149b8fd489b080
7
+ data.tar.gz: e7a5b0e5e96857977531d42c3805e9547ebff7af8cc3248aab7d39374e2fb880d124ceaf83493bd3cf61ca3db8d17198c2b8e0e66cada5cf59b9c08412fed9b3
data/CHANGELOG.md CHANGED
@@ -23,6 +23,9 @@
23
23
  - ```the_page``` is a shortcut to the page collection inside of specs. (Unfortunately, ```page``` is used by capybara, so for now we're using ```the_page```, we'll find a better solution in the future.)
24
24
  - Add filtering to logging on password, and option to configure filtered args. Also, improve the way errors are displayed.
25
25
  - You can now call raw in a content binding to render the raw html on the page. Use carefully, this can open you up to xss attacks. We reccomend never showing html from the user directly.
26
+ - before/after actions added to ModelController (HttpController support coming soon).
27
+ - in the disabled attribute, you can now bind to a boolean or string.
28
+ - added a .fetch_each method that fetches all items, then yields each one.
26
29
 
27
30
  ### Changed
28
31
  - template bindings have been renamed to view. ```{{ view "path/for/view" }}``` instead of ```{{ template "path/for/view" }}```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0.pre5
1
+ 0.9.0.pre6
@@ -75,7 +75,7 @@ class Generate < Thor
75
75
  method_option :name, type: :string, banner: 'The name of the task.'
76
76
  method_option :component, type: :string, default: 'main', banner: 'The component the task should be created in.', required: false
77
77
  def task(name, component = 'main')
78
- name = name.underscore.singularize
78
+ name = name.underscore.gsub(/_tasks$/, '').singularize + '_tasks'
79
79
  output_file = Dir.pwd + "/app/#{component}/tasks/#{name}.rb"
80
80
  spec_file = Dir.pwd + "/spec/app/#{component}/tasks/#{name}_spec.rb"
81
81
  template('task/task.rb.tt', output_file, task_name: name.camelize.singularize)
@@ -87,9 +87,9 @@ module Volt
87
87
  # here by storing by action and having an all category as well.
88
88
  def filter_actions_by_only_exclude(callbacks, action)
89
89
  callbacks.select do |callback, options|
90
- if options
90
+ if options && (only = options[:only])
91
91
  # If there is an only, make sure the action is in the list.
92
- options[:only].include?(action.to_sym)
92
+ [only].flatten.include?(action.to_sym)
93
93
  else
94
94
  # If no only, include it
95
95
  true
@@ -41,7 +41,7 @@ module Volt
41
41
  end
42
42
 
43
43
  proxy_with_root_dep :[], :size, :first, :last, :state_for#, :limit, :find_one, :find
44
- proxy_to_persistor :find, :where, :skip, :sort, :limit, :then, :fetch, :fetch_first
44
+ proxy_to_persistor :find, :where, :skip, :sort, :limit, :then, :fetch, :fetch_first, :fetch_each
45
45
 
46
46
  def initialize(array = [], options = {})
47
47
  @options = options
@@ -197,12 +197,12 @@ module Volt
197
197
  end
198
198
  end
199
199
 
200
- def buffer
200
+ def buffer(attrs={})
201
201
  model_path = options[:path] + [:[]]
202
202
  model_klass = Volt::Model.class_at_path(model_path)
203
203
 
204
204
  new_options = options.merge(path: model_path, save_to: self, buffer: true).reject { |k, _| k.to_sym == :persistor }
205
- model = model_klass.new({}, new_options)
205
+ model = model_klass.new(attrs, new_options)
206
206
 
207
207
  model
208
208
  end
@@ -16,6 +16,7 @@ require 'volt/models/permissions'
16
16
  require 'volt/models/associations'
17
17
  require 'volt/reactive/class_eventable'
18
18
  require 'volt/utils/event_counter'
19
+ require 'volt/reactive/reactive_accessors'
19
20
  require 'thread'
20
21
 
21
22
  module Volt
@@ -43,6 +44,7 @@ module Volt
43
44
  include ListenerTracker
44
45
  include Permissions
45
46
  include Associations
47
+ include ReactiveAccessors
46
48
 
47
49
  attr_reader :attributes, :parent, :path, :persistor, :options
48
50
 
@@ -257,14 +259,19 @@ module Volt
257
259
  else
258
260
  # If we're expanding, or the get is for a collection, in which
259
261
  # case we always expand.
260
- if expand || attr_name.plural?
262
+ plural_attr = attr_name.plural?
263
+ if expand || plural_attr
261
264
  new_value = read_new_model(attr_name)
262
265
 
263
266
  # A value was generated, store it
264
267
  if new_value
265
268
  # Assign directly. Since this is the first time
266
269
  # we're loading, we can just assign.
267
- set(attr_name, new_value)
270
+ #
271
+ # Don't track changes if we're setting a collection
272
+ Volt.run_in_mode_if(plural_attr, :no_change_tracking) do
273
+ set(attr_name, new_value)
274
+ end
268
275
  end
269
276
 
270
277
  return new_value
@@ -104,7 +104,6 @@ module Volt
104
104
 
105
105
  # Called the first time data is requested from this collection
106
106
  def load_data
107
- # puts "LOAD DATA: #{@model.path.inspect}: #{@model.options[:query].inspect}"
108
107
  Computation.run_without_tracking do
109
108
  loaded_state = @model.loaded_state
110
109
 
@@ -218,6 +217,15 @@ module Volt
218
217
  promise
219
218
  end
220
219
 
220
+ # A combination of .fetch and .each. Returns the fetch promise
221
+ def fetch_each
222
+ fetch do |items|
223
+ items.each do |item|
224
+ yield(item)
225
+ end
226
+ end
227
+ end
228
+
221
229
  # Alias then for now
222
230
  # TODO: Deprecate
223
231
  alias_method :then, :fetch
@@ -97,6 +97,15 @@ module Volt
97
97
  if val != element.value
98
98
  element.value = val
99
99
  end
100
+ when 'disabled'
101
+ # Disabled is handled specially, you can either return a boolean:
102
+ # (true being disabled, false not disabled), or you can optionally
103
+ # include the "disabled" string. (or any string)
104
+ if val != false && val.present?
105
+ element.attr('disabled', 'disabled')
106
+ else
107
+ element.remove_attr('disabled')
108
+ end
100
109
  else
101
110
  element[@attribute_name] = val
102
111
  end
@@ -33,8 +33,14 @@ module Volt
33
33
  values = current_values(value)
34
34
  @value = values
35
35
 
36
- @added_listener.remove if @added_listener
37
- @removed_listener.remove if @removed_listener
36
+ if @added_listener
37
+ @added_listener.remove
38
+ @added_listener = nil
39
+ end
40
+ if @removed_listener
41
+ @removed_listener.remove
42
+ @removed_listener = nil
43
+ end
38
44
 
39
45
  if @value.respond_to?(:on)
40
46
  @added_listener = @value.on('added') { |position| item_added(position) }
@@ -132,6 +138,8 @@ module Volt
132
138
  # Clear value
133
139
  @value = []
134
140
 
141
+ @getter = nil
142
+
135
143
  if @added_listener
136
144
  @added_listener.remove
137
145
  @added_listener = nil
@@ -18,6 +18,7 @@ module Volt
18
18
  end
19
19
 
20
20
  def remove
21
+ raise "Listener has already been removed" if @removed
21
22
  @removed = true
22
23
 
23
24
  @events.each do |event|
@@ -35,7 +35,11 @@ module Volt
35
35
  # Takes a string and splits on bindings, returns the string split on bindings
36
36
  # and the number of bindings.
37
37
  def binding_parts_and_count(value)
38
- parts = value.split(/(\{\{[^\}]+\}\})/).reject(&:blank?)
38
+ if value.is_a?(String)
39
+ parts = value.split(/(\{\{[^\}]+\}\})/).reject(&:blank?)
40
+ else
41
+ parts = ['']
42
+ end
39
43
  binding_count = parts.count { |p| p[0] == '{' && p[1] == '{' && p[-2] == '}' && p[-1] == '}' }
40
44
 
41
45
  [parts, binding_count]
data/lib/volt/server.rb CHANGED
@@ -9,6 +9,7 @@ end
9
9
 
10
10
  require 'rack'
11
11
  require 'sass'
12
+ require 'volt/utils/tilt_patch'
12
13
  if RUBY_PLATFORM != 'java'
13
14
  require 'rack/sockjs'
14
15
  require 'eventmachine'
@@ -0,0 +1,8 @@
1
+ # A patch to fix https://github.com/opal/opal/issues/801 until it is fixed in (0.8)
2
+ if RUBY_PLATFORM == 'opal'
3
+ class Boolean
4
+ def hash
5
+ self ? 'Boolean:true' : 'Boolean:false'
6
+ end
7
+ end
8
+ end
@@ -33,7 +33,7 @@ module Volt
33
33
 
34
34
  if last
35
35
  # return, creating if needed
36
- return(section[arg] ||= create_new_item(*args, &block))
36
+ return (section[arg] ||= create_new_item(*args, &block))
37
37
  else
38
38
  next_section = section[arg]
39
39
  next_section ||= (section[arg] = {})
@@ -27,6 +27,18 @@ module Volt
27
27
  end
28
28
  end
29
29
 
30
+ def run_in_mode_if(conditional, mode_name)
31
+ if conditional
32
+ # Yes, run in the mode
33
+ Volt.run_in_mode(mode_name) do
34
+ yield
35
+ end
36
+ else
37
+ # Just run normally
38
+ yield
39
+ end
40
+ end
41
+
30
42
  # Check to see if we are in the specified mode
31
43
  def in_mode?(mode_name)
32
44
  return defined?(Thread) && Thread.current[mode_name]
@@ -0,0 +1,9 @@
1
+ class Tilt::Template
2
+ # Tilt outputs the following error:
3
+ # WARN: tilt autoloading 'sass' in a non thread-safe way; explicit require 'sass' suggested.
4
+ # I can't get rid of this no matter what I do. (If someone smarter wants to take a shot at
5
+ # it, please do.) For now for my sanity, I'm just silencing its warnings.
6
+ def warn(*args)
7
+ # Kernel.warn(*args)
8
+ end
9
+ end
data/lib/volt.rb CHANGED
@@ -4,6 +4,7 @@ require 'volt/reactive/computation'
4
4
  require 'volt/reactive/dependency'
5
5
  require 'volt/utils/modes'
6
6
  require 'volt/utils/volt_user_error'
7
+ require 'volt/utils/boolean_patch'
7
8
 
8
9
  require 'volt/config'
9
10
  unless RUBY_PLATFORM == 'opal'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0.pre5
4
+ version: 0.9.0.pre6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Stout
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-15 00:00:00.000000000 Z
11
+ date: 2015-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -614,6 +614,7 @@ files:
614
614
  - lib/volt/store/mongo.rb
615
615
  - lib/volt/tasks/dispatcher.rb
616
616
  - lib/volt/tasks/task_handler.rb
617
+ - lib/volt/utils/boolean_patch.rb
617
618
  - lib/volt/utils/ejson.rb
618
619
  - lib/volt/utils/event_counter.rb
619
620
  - lib/volt/utils/generic_counting_pool.rb
@@ -623,6 +624,7 @@ files:
623
624
  - lib/volt/utils/logging/task_logger.rb
624
625
  - lib/volt/utils/modes.rb
625
626
  - lib/volt/utils/promise_patch.rb
627
+ - lib/volt/utils/tilt_patch.rb
626
628
  - lib/volt/utils/timers.rb
627
629
  - lib/volt/utils/volt_user_error.rb
628
630
  - lib/volt/volt/environment.rb