disco-railties 0.5.0.rc3 → 0.5.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/disco/server/projection_servers.rb +1 -2
- data/lib/generators/disco/app/app_generator.rb +2 -1
- data/lib/generators/disco/app/templates/app/controllers/event_source_controller.rb +15 -6
- data/lib/generators/disco/app/templates/config/initializers/event_source_server.rb +2 -0
- data/lib/generators/disco/command/USAGE +1 -1
- data/lib/generators/disco/command/command_generator.rb +1 -1
- data/lib/generators/disco/projection/projection_generator.rb +2 -2
- data/lib/generators/disco/scaffold/USAGE +3 -3
- data/lib/generators/disco/scaffold/scaffold_generator.rb +3 -4
- data/lib/generators/disco/scaffold/templates/_eventstream.js.erb +4 -10
- data/lib/rails-disco/version.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 363cbe23952c7e14f9fe448bd13d7cad3fbe9a0f
|
4
|
+
data.tar.gz: 81451efafd0ef2b0d6cb0d2bae3b2dd611550101
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a40e0e8afb54f6c4292e95ba17d812c327535f838bd96c506ae53e6df910a0d12cd2bbe019c1aa3a5da2dd597e433a25330b486079f96e94a916c932872886db
|
7
|
+
data.tar.gz: f80339d1425e6c52d8870e2ef8fd128daff32326e799c92ef3b5903d548b3d758723759d042a99c47c5cf014b192beef417f1c29a75c1aef506a874aa7fb1615
|
@@ -9,11 +9,10 @@ require 'active_record'
|
|
9
9
|
|
10
10
|
WORKER_COUNT = [ENV['WORKER_COUNT'].to_i, 1].max
|
11
11
|
WORKER_NUMBER = ENV['WORKER_NUMBER'].to_i
|
12
|
-
LOGGER = ActiveEvent::Support::MultiLogger.new "Projection Server#{WORKER_COUNT > 1 ? " Nr. #{WORKER_NUMBER}" :
|
12
|
+
LOGGER = ActiveEvent::Support::MultiLogger.new "Projection Server#{WORKER_COUNT > 1 ? " Nr. #{WORKER_NUMBER}" : ''}"
|
13
13
|
|
14
14
|
ActiveEvent::Autoload.app_path = ROOT_DIR
|
15
15
|
ActiveProjection::Autoload.app_path = ROOT_DIR
|
16
|
-
ActiveProjection::Autoload.worker_config = {path: ROOT_DIR, count: WORKER_COUNT, number: WORKER_NUMBER}
|
17
16
|
|
18
17
|
watchable_dirs = ActiveEvent::Autoload.watchable_dirs.merge ActiveProjection::Autoload.watchable_dirs
|
19
18
|
RELOADER = ActiveSupport::FileUpdateChecker.new([], watchable_dirs) do
|
@@ -37,6 +37,7 @@ gem 'puma'\n" unless behavior == :revoke
|
|
37
37
|
inside 'config/initializers' do
|
38
38
|
template 'create_domain.rb'
|
39
39
|
copy_file 'build_validations_registry.rb'
|
40
|
+
copy_file 'event_source_server.rb'
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -70,7 +71,7 @@ gem 'puma'\n" unless behavior == :revoke
|
|
70
71
|
|
71
72
|
def add_event_source_route
|
72
73
|
return if behavior == :revoke
|
73
|
-
route "get '
|
74
|
+
route "get 'event_source/:projection/:event' => 'event_source#projected'"
|
74
75
|
end
|
75
76
|
|
76
77
|
def enable_rake_tasks
|
@@ -1,16 +1,25 @@
|
|
1
1
|
class EventSourceController < ApplicationController
|
2
2
|
include ActionController::Live
|
3
|
-
include ActiveEvent::EventSourceServer
|
4
3
|
|
5
|
-
def
|
6
|
-
event_connection.start
|
4
|
+
def projected
|
7
5
|
response.headers['Content-Type'] = 'text/event-stream'
|
8
6
|
sse = ActiveEvent::SSE.new(response.stream)
|
9
|
-
|
10
|
-
sse.write(
|
7
|
+
ActiveEvent::EventSourceServer.after_event_projection event_id, projection do
|
8
|
+
sse.write(nil, event: 'projected')
|
11
9
|
end
|
12
10
|
rescue IOError
|
11
|
+
# ignored
|
13
12
|
ensure
|
14
13
|
sse.close
|
15
14
|
end
|
16
|
-
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def event_id
|
19
|
+
params[:event].to_i
|
20
|
+
end
|
21
|
+
|
22
|
+
def projection
|
23
|
+
params[:projection]
|
24
|
+
end
|
25
|
+
end
|
@@ -2,7 +2,7 @@ Description:
|
|
2
2
|
Generates a Command, an Event and adds it to the CommandProcessor or creates one.
|
3
3
|
|
4
4
|
Example:
|
5
|
-
rails generate disco:command CreateThing
|
5
|
+
rails generate disco:command CreateThing attr1 attr2 --event=CreatedThing --processor=Thing
|
6
6
|
|
7
7
|
This will create:
|
8
8
|
app/commands/create_thing_command.rb
|
@@ -6,7 +6,7 @@ module Disco
|
|
6
6
|
module Generators
|
7
7
|
class CommandGenerator < Rails::Generators::NamedBase
|
8
8
|
source_root File.expand_path('../templates', __FILE__)
|
9
|
-
argument :attributes, type: :array, default: [], banner: 'attribute attribute'
|
9
|
+
argument :attributes, type: :array, default: [], banner: '[attribute] [attribute]'
|
10
10
|
class_option :unique_id, type: :boolean, default: false, desc: 'Create a unique id when processing the command'
|
11
11
|
class_option :skip_model, type: :boolean, default: false, desc: 'Skip active model from the command'
|
12
12
|
class_option :model_name, type: :string, desc: 'Name of the active model behind the command'
|
@@ -8,11 +8,11 @@ module Disco
|
|
8
8
|
include UseDomainOption
|
9
9
|
|
10
10
|
def create_projection_file
|
11
|
-
template use_domain('projection.rb'), use_domain_class_file_path('projections', "#{
|
11
|
+
template use_domain('projection.rb'), use_domain_class_file_path('projections', "#{file_name}_projection.rb")
|
12
12
|
end
|
13
13
|
|
14
14
|
def create_test_files
|
15
|
-
template use_domain('projection_test.rb'), File.join('test/projections', use_domain_class_path, "#{
|
15
|
+
template use_domain('projection_test.rb'), File.join('test/projections', use_domain_class_path, "#{file_name}_projection_test.rb")
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -3,10 +3,10 @@ Description:
|
|
3
3
|
commands, events and command_processor.
|
4
4
|
|
5
5
|
Example:
|
6
|
-
disco generate scaffold Thing
|
6
|
+
disco generate scaffold Thing title:string
|
7
7
|
|
8
8
|
This will create:
|
9
|
-
app/controllers/things_controller
|
9
|
+
app/controllers/things_controller.rb
|
10
10
|
app/commands/create_thing_command.rb
|
11
11
|
app/commands/update_thing_command.rb
|
12
12
|
app/commands/delete_thing_command.rb
|
@@ -14,7 +14,7 @@ Example:
|
|
14
14
|
app/events/created_thing_event.rb
|
15
15
|
app/events/updated_thing_event.rb
|
16
16
|
app/events/deleted_thing_event.rb
|
17
|
-
app/projections/
|
17
|
+
app/projections/thing_projection.rb
|
18
18
|
db/migrate/create_things.rb
|
19
19
|
app/models/thing.rb
|
20
20
|
app/helpers/things_helper.rb
|
@@ -64,20 +64,19 @@ module Disco
|
|
64
64
|
|
65
65
|
def add_event_stream_to_views
|
66
66
|
return if behavior == :revoke
|
67
|
-
include_text =
|
67
|
+
include_text = "<%= javascript_tag render partial: 'application/eventstream/eventstream', formats: [:js], locals: {event_id: @event_id, projection: '#{class_name}Projection'} %>\n"
|
68
68
|
prepend_to_file File.join('app/views', class_path, plural_file_name, 'index.html.erb'), include_text
|
69
69
|
prepend_to_file File.join('app/views', class_path, plural_file_name, 'show.html.erb'), include_text
|
70
70
|
end
|
71
71
|
|
72
72
|
def add_to_projections(action)
|
73
73
|
return if behavior == :revoke
|
74
|
-
content = "
|
75
|
-
|
74
|
+
content = "\n
|
76
75
|
def #{projection_name_for_action(action)}(event)
|
77
76
|
#{projection_body_for_action(action)}
|
78
77
|
end"
|
79
78
|
indent(content) if namespaced?
|
80
|
-
inject_into_file File.join('app/projections', class_path, "#{
|
79
|
+
inject_into_file File.join('app/projections', class_path, "#{file_name}_projection.rb"), content, after: /(\s)*include(\s)*ActiveProjection::ProjectionType/
|
81
80
|
end
|
82
81
|
|
83
82
|
def command_name_for_action(action)
|
@@ -1,16 +1,10 @@
|
|
1
1
|
<% if event_id.present? %>
|
2
2
|
$(document).ready(function () {
|
3
3
|
setTimeout(function () {
|
4
|
-
var source = new EventSource('/
|
5
|
-
source.addEventListener('
|
6
|
-
|
7
|
-
if (<%= event_id %> == event.id){
|
8
|
-
window.location.reload();
|
9
|
-
}else if (<%= event_id %> < event.id){
|
10
|
-
source.removeEventListener('refresh');
|
11
|
-
source.close();
|
12
|
-
}
|
4
|
+
var source = new EventSource('/event_source/<%= projection %>/<%= event_id %>');
|
5
|
+
source.addEventListener('projected', function (e) {
|
6
|
+
window.location.reload();
|
13
7
|
});
|
14
8
|
}, 1);
|
15
9
|
});
|
16
|
-
<% end %>
|
10
|
+
<% end %>
|
data/lib/rails-disco/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: disco-railties
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.0.
|
4
|
+
version: 0.5.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HicknHack Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_event
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.5.0.
|
19
|
+
version: 0.5.0.rc4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.5.0.
|
26
|
+
version: 0.5.0.rc4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: active_domain
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.5.0.
|
33
|
+
version: 0.5.0.rc4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.5.0.
|
40
|
+
version: 0.5.0.rc4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: active_projection
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.5.0.
|
47
|
+
version: 0.5.0.rc4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.5.0.
|
54
|
+
version: 0.5.0.rc4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- lib/generators/disco/app/templates/config/disco.yml
|
93
93
|
- lib/generators/disco/app/templates/config/initializers/build_validations_registry.rb
|
94
94
|
- lib/generators/disco/app/templates/config/initializers/create_domain.rb
|
95
|
+
- lib/generators/disco/app/templates/config/initializers/event_source_server.rb
|
95
96
|
- lib/generators/disco/app/templates/db/seeds.rb
|
96
97
|
- lib/generators/disco/app/USAGE
|
97
98
|
- lib/generators/disco/command/command_generator.rb
|