logux_rails 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Appraisals +4 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +3 -0
- data/README.md +7 -2
- data/app/helpers/logux_helper.rb +1 -2
- data/config/routes.rb +1 -1
- data/lib/logux/{actions.rb → action.rb} +1 -1
- data/lib/logux/model/proxy.rb +1 -1
- data/lib/logux/model/updates_deprecator.rb +12 -8
- data/lib/logux/version.rb +1 -1
- data/lib/logux_rails.rb +22 -1
- data/lib/tasks/logux_tasks.rake +10 -37
- data/logux_rails.gemspec +3 -6
- metadata +14 -77
- data/app/controllers/logux_controller.rb +0 -41
- data/lib/logux.rb +0 -107
- data/lib/logux/action_caller.rb +0 -42
- data/lib/logux/action_controller.rb +0 -6
- data/lib/logux/add.rb +0 -37
- data/lib/logux/auth.rb +0 -6
- data/lib/logux/base_controller.rb +0 -37
- data/lib/logux/channel_controller.rb +0 -24
- data/lib/logux/class_finder.rb +0 -61
- data/lib/logux/client.rb +0 -21
- data/lib/logux/error_renderer.rb +0 -40
- data/lib/logux/meta.rb +0 -36
- data/lib/logux/node.rb +0 -37
- data/lib/logux/policy.rb +0 -14
- data/lib/logux/policy_caller.rb +0 -34
- data/lib/logux/process.rb +0 -9
- data/lib/logux/process/action.rb +0 -60
- data/lib/logux/process/auth.rb +0 -27
- data/lib/logux/process/batch.rb +0 -59
- data/lib/logux/response.rb +0 -18
- data/lib/logux/stream.rb +0 -25
- data/lib/logux/test.rb +0 -35
- data/lib/logux/test/helpers.rb +0 -75
- data/lib/logux/test/matchers.rb +0 -10
- data/lib/logux/test/matchers/base.rb +0 -25
- data/lib/logux/test/matchers/response_chunks.rb +0 -48
- data/lib/logux/test/matchers/send_to_logux.rb +0 -51
- data/lib/logux/test/store.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97f35ecf2895e15f1ca45d1ec4d4aec86108d8ffdb48e7ff112d06b5593a4477
|
4
|
+
data.tar.gz: '0568b3e3bad4592b33b0f5ecfd24ccbe4fb980ff8e037b30cc4bf0e2f12d9549'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf3aa01217dbf9d6175b7ad846d0c4da52df51b9a63f555ec0655c05e5016a5dea5a1c8126625533fce36a8eb45f4df4690f69fe3e2cf4928df6ac91fde2a52f
|
7
|
+
data.tar.gz: b105c769a9c97b363da83f6deba35ba7cd026a5b0eb70a780e1936c9c51d6c64465de295c9d32aab977e80d0373b7755e2eece5503610c4d579c92a3f7459b5d
|
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Change Log
|
2
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
3
|
+
|
4
|
+
## 0.2
|
5
|
+
* Core Logux facilities are moved to `logux-rack` gem.
|
6
|
+
* `Logux::Actions` is soft-deprecated. Please use `Logux::Action` from now on.
|
7
|
+
* `Logux::Model::UpdatesDeprecator` is now coupled with `Logux::ActionCaller` via Logux configuration.
|
8
|
+
|
9
|
+
## 0.1.1
|
10
|
+
* Rails 6.0 support.
|
11
|
+
|
12
|
+
## 0.1
|
13
|
+
* Initial release.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -30,17 +30,22 @@ Logux.configuration do |config|
|
|
30
30
|
end
|
31
31
|
```
|
32
32
|
|
33
|
-
Mount
|
33
|
+
Mount `Logux::Rack` in your application routing configuration:
|
34
34
|
|
35
35
|
```ruby
|
36
|
+
# config/routes.rb
|
37
|
+
Rails.application.routes.draw do
|
36
38
|
mount Logux::Engine => '/'
|
39
|
+
end
|
37
40
|
```
|
38
41
|
|
39
42
|
After this, POST requests to `/logux` will be processed by `LoguxController`. You can redefine it or inherit from, if it necessary, for example, for implementing custom authorization flow.
|
40
43
|
|
41
44
|
Logux Rails will try to find Action for the specific message from Logux Server. For example, for `project/rename` action, you should define `Action::Project` class, inherited from `Logux::Action` base class, and implement `rename` method.
|
42
45
|
|
43
|
-
|
46
|
+
### Rake commands
|
47
|
+
|
48
|
+
Use `rails logux:actions` command to get the list of available action types, or `rails logux:channels` for channels. The default search path is set to `app/logux/actions` and `app/logux/channels` for actions and channels correspondingly, assuming `app` directory is the root of your Rails application. Both command support custom search paths: `rails logux:actions[lib/logux/actions]`.
|
44
49
|
|
45
50
|
## Development with Docker
|
46
51
|
|
data/app/helpers/logux_helper.rb
CHANGED
data/config/routes.rb
CHANGED
data/lib/logux/model/proxy.rb
CHANGED
@@ -5,17 +5,15 @@ module Logux
|
|
5
5
|
class UpdatesDeprecator
|
6
6
|
EVENT = 'logux.insecure_update'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
new(args).watch(&block)
|
11
|
-
end
|
8
|
+
def self.call(options = {}, &block)
|
9
|
+
new(options).call(&block)
|
12
10
|
end
|
13
11
|
|
14
|
-
def initialize(
|
15
|
-
@
|
12
|
+
def initialize(options)
|
13
|
+
@options = options
|
16
14
|
end
|
17
15
|
|
18
|
-
def
|
16
|
+
def call(&block)
|
19
17
|
callback = lambda(&method(:handle_insecure_update))
|
20
18
|
ActiveSupport::Notifications.subscribed(callback, EVENT, &block)
|
21
19
|
end
|
@@ -42,13 +40,19 @@ module Logux
|
|
42
40
|
Logux tracked #{pluralized_attributes} (#{insecure_attributes.join(', ')}) should be updated using model.logux.update(...)
|
43
41
|
TEXT
|
44
42
|
|
45
|
-
case
|
43
|
+
case level
|
46
44
|
when :warn
|
47
45
|
ActiveSupport::Deprecation.warn(message)
|
48
46
|
when :error
|
49
47
|
raise InsecureUpdateError, message
|
50
48
|
end
|
51
49
|
end
|
50
|
+
|
51
|
+
DEFAULT_LEVEL = :warn
|
52
|
+
|
53
|
+
def level
|
54
|
+
@options[:level] || DEFAULT_LEVEL
|
55
|
+
end
|
52
56
|
end
|
53
57
|
end
|
54
58
|
end
|
data/lib/logux/version.rb
CHANGED
data/lib/logux_rails.rb
CHANGED
@@ -1,3 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'action_controller'
|
4
|
+
require 'active_support'
|
5
|
+
require 'logux/rack'
|
6
|
+
require 'rails/engine'
|
7
|
+
require 'logux/engine'
|
8
|
+
|
9
|
+
module Logux
|
10
|
+
autoload :Model, 'logux/model'
|
11
|
+
|
12
|
+
configurable %i[
|
13
|
+
action_watcher
|
14
|
+
action_watcher_options
|
15
|
+
]
|
16
|
+
|
17
|
+
configuration_defaults do |config|
|
18
|
+
config.action_watcher = Logux::Model::UpdatesDeprecator
|
19
|
+
config.action_watcher_options = { level: :error }
|
20
|
+
config.logger = Rails.logger if defined?(Rails.logger)
|
21
|
+
config.logger ||= ActiveSupport::Logger.new(STDOUT)
|
22
|
+
config.on_error = proc {}
|
23
|
+
end
|
24
|
+
end
|
data/lib/tasks/logux_tasks.rake
CHANGED
@@ -1,46 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
namespace :logux do
|
5
|
-
desc 'Lists all Logux action types'
|
6
|
-
task actions: :environment do
|
7
|
-
Dir[Rails.root.join('app', 'logux', 'actions', '**', '*.rb')].each do |file|
|
8
|
-
require file
|
9
|
-
end
|
3
|
+
require 'logux/rake_tasks'
|
10
4
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
output << [
|
15
|
-
"#{klass.name.gsub(/^Actions::/, '').underscore}/#{action}",
|
16
|
-
"#{klass.name}##{action}"
|
17
|
-
]
|
18
|
-
end
|
19
|
-
end
|
5
|
+
module Logux
|
6
|
+
class RakeTasks
|
7
|
+
protected
|
20
8
|
|
21
|
-
|
22
|
-
|
23
|
-
puts "#{action.rjust(first_column_length, ' ')} #{klass_name}"
|
9
|
+
def default_actions_path
|
10
|
+
::Rails.root.join('app', 'logux', 'actions')
|
24
11
|
end
|
25
|
-
end
|
26
|
-
|
27
|
-
desc 'Lists all Logux channels'
|
28
|
-
task channels: :environment do
|
29
|
-
path = Rails.root.join('app', 'logux', 'channels', '**', '*.rb')
|
30
|
-
Dir[path].each { |file| require file }
|
31
12
|
|
32
|
-
|
33
|
-
|
34
|
-
output << [
|
35
|
-
klass_name.gsub(/^Channels::/, '').underscore,
|
36
|
-
klass_name
|
37
|
-
]
|
38
|
-
end
|
39
|
-
|
40
|
-
first_column_length = output.map(&:first).max_by(&:length).length
|
41
|
-
output.each do |channel, klass_name|
|
42
|
-
puts "#{channel.rjust(first_column_length, ' ')} #{klass_name}"
|
13
|
+
def default_channels_path
|
14
|
+
::Rails.root.join('app', 'logux', 'channels')
|
43
15
|
end
|
44
16
|
end
|
45
17
|
end
|
46
|
-
|
18
|
+
|
19
|
+
Logux::RakeTasks.new
|
data/logux_rails.gemspec
CHANGED
@@ -22,14 +22,11 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.add_dependency '
|
26
|
-
spec.add_dependency '
|
27
|
-
spec.add_dependency 'nanoid'
|
28
|
-
spec.add_dependency 'rails', '>= 5.0'
|
29
|
-
spec.add_dependency 'rest-client'
|
25
|
+
spec.add_dependency 'logux-rack', '>= 0.1.0'
|
26
|
+
spec.add_dependency 'rails', '>= 5.0', '< 6.1'
|
30
27
|
spec.add_development_dependency 'appraisal', '~> 2.2'
|
31
28
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
32
|
-
spec.add_development_dependency 'combustion', '~> 1.
|
29
|
+
spec.add_development_dependency 'combustion', '~> 1.1.0'
|
33
30
|
spec.add_development_dependency 'coveralls'
|
34
31
|
spec.add_development_dependency 'factory_bot'
|
35
32
|
spec.add_development_dependency 'pg'
|
metadata
CHANGED
@@ -1,57 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logux_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WildDima
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: logux-rack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.1.0
|
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:
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: configurations
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: nanoid
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
26
|
+
version: 0.1.0
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
name: rails
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +31,9 @@ dependencies:
|
|
59
31
|
- - ">="
|
60
32
|
- !ruby/object:Gem::Version
|
61
33
|
version: '5.0'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '6.1'
|
62
37
|
type: :runtime
|
63
38
|
prerelease: false
|
64
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -66,20 +41,9 @@ dependencies:
|
|
66
41
|
- - ">="
|
67
42
|
- !ruby/object:Gem::Version
|
68
43
|
version: '5.0'
|
69
|
-
-
|
70
|
-
name: rest-client
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
44
|
+
- - "<"
|
81
45
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
46
|
+
version: '6.1'
|
83
47
|
- !ruby/object:Gem::Dependency
|
84
48
|
name: appraisal
|
85
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +78,14 @@ dependencies:
|
|
114
78
|
requirements:
|
115
79
|
- - "~>"
|
116
80
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.
|
81
|
+
version: 1.1.0
|
118
82
|
type: :development
|
119
83
|
prerelease: false
|
120
84
|
version_requirements: !ruby/object:Gem::Requirement
|
121
85
|
requirements:
|
122
86
|
- - "~>"
|
123
87
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.
|
88
|
+
version: 1.1.0
|
125
89
|
- !ruby/object:Gem::Dependency
|
126
90
|
name: coveralls
|
127
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -318,11 +282,11 @@ files:
|
|
318
282
|
- ".rubocop_todo.yml"
|
319
283
|
- ".travis.yml"
|
320
284
|
- Appraisals
|
285
|
+
- CHANGELOG.md
|
321
286
|
- Gemfile
|
322
287
|
- LICENSE.txt
|
323
288
|
- README.md
|
324
289
|
- Rakefile
|
325
|
-
- app/controllers/logux_controller.rb
|
326
290
|
- app/helpers/logux_helper.rb
|
327
291
|
- app/logux/actions.rb
|
328
292
|
- app/logux/policies.rb
|
@@ -333,40 +297,13 @@ files:
|
|
333
297
|
- lib/generators/logux/model/USAGE
|
334
298
|
- lib/generators/logux/model/model_generator.rb
|
335
299
|
- lib/generators/logux/model/templates/migration.rb.erb
|
336
|
-
- lib/logux.rb
|
337
|
-
- lib/logux/action_caller.rb
|
338
|
-
- lib/logux/action_controller.rb
|
339
|
-
- lib/logux/actions.rb
|
340
|
-
- lib/logux/add.rb
|
341
|
-
- lib/logux/auth.rb
|
342
|
-
- lib/logux/base_controller.rb
|
343
|
-
- lib/logux/channel_controller.rb
|
344
|
-
- lib/logux/class_finder.rb
|
345
|
-
- lib/logux/client.rb
|
300
|
+
- lib/logux/action.rb
|
346
301
|
- lib/logux/engine.rb
|
347
|
-
- lib/logux/error_renderer.rb
|
348
|
-
- lib/logux/meta.rb
|
349
302
|
- lib/logux/model.rb
|
350
303
|
- lib/logux/model/dsl.rb
|
351
304
|
- lib/logux/model/proxy.rb
|
352
305
|
- lib/logux/model/updater.rb
|
353
306
|
- lib/logux/model/updates_deprecator.rb
|
354
|
-
- lib/logux/node.rb
|
355
|
-
- lib/logux/policy.rb
|
356
|
-
- lib/logux/policy_caller.rb
|
357
|
-
- lib/logux/process.rb
|
358
|
-
- lib/logux/process/action.rb
|
359
|
-
- lib/logux/process/auth.rb
|
360
|
-
- lib/logux/process/batch.rb
|
361
|
-
- lib/logux/response.rb
|
362
|
-
- lib/logux/stream.rb
|
363
|
-
- lib/logux/test.rb
|
364
|
-
- lib/logux/test/helpers.rb
|
365
|
-
- lib/logux/test/matchers.rb
|
366
|
-
- lib/logux/test/matchers/base.rb
|
367
|
-
- lib/logux/test/matchers/response_chunks.rb
|
368
|
-
- lib/logux/test/matchers/send_to_logux.rb
|
369
|
-
- lib/logux/test/store.rb
|
370
307
|
- lib/logux/version.rb
|
371
308
|
- lib/logux_rails.rb
|
372
309
|
- lib/tasks/logux_tasks.rake
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class LoguxController < ActionController::Base
|
4
|
-
include ActionController::Live
|
5
|
-
|
6
|
-
def create
|
7
|
-
logux_stream.write('[')
|
8
|
-
Logux.verify_request_meta_data(meta_params)
|
9
|
-
Logux.process_batch(stream: logux_stream, batch: command_params)
|
10
|
-
rescue => ex
|
11
|
-
handle_processing_errors(ex)
|
12
|
-
ensure
|
13
|
-
logux_stream.write(']')
|
14
|
-
logux_stream.close
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def unsafe_params
|
20
|
-
params.to_unsafe_h
|
21
|
-
end
|
22
|
-
|
23
|
-
def command_params
|
24
|
-
unsafe_params.dig('commands')
|
25
|
-
end
|
26
|
-
|
27
|
-
def meta_params
|
28
|
-
unsafe_params&.slice(:version, :password)
|
29
|
-
end
|
30
|
-
|
31
|
-
def logux_stream
|
32
|
-
@logux_stream ||= Logux::Stream.new(response.stream)
|
33
|
-
end
|
34
|
-
|
35
|
-
def handle_processing_errors(exception)
|
36
|
-
Logux.configuration.on_error.call(exception)
|
37
|
-
Logux.logger.error("#{exception}\n#{exception.backtrace.join("\n")}")
|
38
|
-
ensure
|
39
|
-
logux_stream.write(Logux::ErrorRenderer.new(exception).message)
|
40
|
-
end
|
41
|
-
end
|