volt 0.9.4 → 0.9.5.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -1
  3. data/Gemfile +3 -1
  4. data/lib/volt/cli/asset_compile.rb +8 -9
  5. data/lib/volt/extra_core/object.rb +3 -1
  6. data/lib/volt/models/associations.rb +9 -6
  7. data/lib/volt/models/buffer.rb +3 -0
  8. data/lib/volt/models/field_helpers.rb +38 -21
  9. data/lib/volt/models/model.rb +1 -1
  10. data/lib/volt/models/permissions.rb +2 -2
  11. data/lib/volt/models/validations/validations.rb +5 -1
  12. data/lib/volt/models/validators/numericality_validator.rb +6 -2
  13. data/lib/volt/page/bindings/each_binding.rb +7 -0
  14. data/lib/volt/page/bindings/view_binding.rb +22 -20
  15. data/lib/volt/server/component_templates.rb +21 -7
  16. data/lib/volt/server/message_bus/message_encoder.rb +4 -0
  17. data/lib/volt/server/message_bus/peer_to_peer/peer_connection.rb +1 -1
  18. data/lib/volt/server/middleware/default_middleware_stack.rb +1 -5
  19. data/lib/volt/server/rack/asset_files.rb +59 -13
  20. data/lib/volt/server/rack/component_code.rb +1 -7
  21. data/lib/volt/server/rack/index_files.rb +12 -4
  22. data/lib/volt/server/rack/opal_files.rb +29 -7
  23. data/lib/volt/server/template_handlers/sprockets_component_handler.rb +163 -0
  24. data/lib/volt/server.rb +2 -3
  25. data/lib/volt/utils/generic_pool.rb +1 -1
  26. data/lib/volt/version.rb +1 -1
  27. data/lib/volt/volt/app.rb +1 -1
  28. data/lib/volt.rb +6 -1
  29. data/spec/apps/kitchen_sink/config/base/index.html +3 -7
  30. data/spec/integration/bindings_spec.rb +1 -0
  31. data/spec/models/associations_spec.rb +18 -0
  32. data/spec/models/buffer_spec.rb +12 -0
  33. data/spec/server/rack/asset_files_spec.rb +35 -25
  34. data/templates/project/config/base/index.html +2 -7
  35. data/volt.gemspec +5 -5
  36. metadata +13 -28
  37. data/lib/volt/server/component_handler.rb +0 -42
  38. data/lib/volt/server/template_handlers/handlers.rb +0 -0
@@ -1,42 +0,0 @@
1
- require 'stringio'
2
- require 'volt'
3
- require 'volt/server/rack/component_code'
4
-
5
- module Volt
6
- class ComponentHandler
7
- def initialize(component_paths)
8
- @component_paths = component_paths
9
- end
10
-
11
- def call(env)
12
- req = Rack::Request.new(env)
13
-
14
- path = req.path.strip
15
-
16
- request_source_map = (File.extname(path) == '.map')
17
-
18
- # TODO: Sanatize template path
19
- component_name = path.gsub(/^\/components\//, '').gsub(/[.](js|map)$/, '')
20
-
21
- javascript_code = compile_for_component(component_name, true, request_source_map)
22
-
23
- [200, { 'Content-Type' => 'application/javascript; charset=utf-8' }, StringIO.new(javascript_code)]
24
- end
25
-
26
- def compile_for_component(component_name, for_client, map = false)
27
- code = ComponentCode.new(component_name, @component_paths, for_client).code
28
-
29
- # Compile the code
30
- # javascript_code = Opal.compile(code)
31
- builder = Opal::Builder.new.build_str(code, 'app.rb')
32
-
33
- if map
34
- js_code = builder.source_map
35
- else
36
- js_code = builder.to_s + "\n//# sourceMappingURL=#{component_name}.map"
37
- end
38
-
39
- js_code
40
- end
41
- end
42
- end
File without changes