rails_live 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 80cece85418243f9babcb5c0be860643d0d0b86e9aec537b3f8d35ddc44391c3
4
- data.tar.gz: 0fda7ac95f1a6ff4d61e05eb4eeaaf9fad8370899add9c630e3b37a64b71a5b2
3
+ metadata.gz: c93eec0ad8ef37f218e2bc2c7b14bce47764f65ca547ddc5c6e304b90b797d15
4
+ data.tar.gz: 785789ed97c191b4a8dd7b39b664bb4f5003102ff278634c2ee8d4b88fa64000
5
5
  SHA512:
6
- metadata.gz: a2f6dd3b7831d32a784bd040583494cc6149a1d9b83f77cefee24689075fe7feef00414b12f2e8f0ab4b29487a26b4b991d46cff876a02efd4859c382418df28
7
- data.tar.gz: 6684f12b692e9c4d384813e42f2873033722e2a2f6e2c5c2512b3ca3044547d275c6e8f3912242903f4d57e130135aa8c8377ec736a7ee173ef4916bcffcf4ff
6
+ metadata.gz: dbc8e57cf75af475a091185f8a512876b7065bfa61804c5405b5660587b47ac7871ea1eaba5682855a318d05a764ad1538abc5b26997dab80f1b087d210bb482
7
+ data.tar.gz: 39e6b9858192ea1e105a0e94ce7c9de872d83c880f4f949c33533359f5f31e808f6691bac3daa77915aa7ca5f906540817de357311f5a7e770ec188f96cbce15
@@ -1,5 +1,10 @@
1
1
  module RailsLive
2
2
  class ApplicationController < ActionController::Base
3
3
  protect_from_forgery with: :exception
4
+
5
+ if RailsLive.http_basic_authentication_enabled
6
+ http_basic_authenticate_with name: RailsLive.http_basic_authentication_user_name,
7
+ password: RailsLive.http_basic_authentication_password
8
+ end
4
9
  end
5
10
  end
data/config/routes.rb CHANGED
@@ -2,3 +2,9 @@ RailsLive::Engine.routes.draw do
2
2
  root to: 'stream#index'
3
3
  mount ActionCable.server, at: '/cable'
4
4
  end
5
+
6
+ if RailsLive.automatic_routes_mount
7
+ Rails.application.routes.draw do
8
+ mount_rails_live_routes
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate configuration file.
3
+
4
+ Example:
5
+ rails generate rails_db initializer
6
+
7
+ This will create:
8
+ config/rails_db.rb
@@ -0,0 +1,6 @@
1
+ class RailsDbGenerator < Rails::Generators::NamedBase
2
+ source_root File.expand_path('../templates', __FILE__)
3
+ def copy_initializer
4
+ template 'rails_db.rb', 'config/initializers/rails_db.rb'
5
+ end
6
+ end
@@ -0,0 +1,27 @@
1
+ if Object.const_defined?('RailsLive')
2
+ RailsLive.setup do |config|
3
+ # # enabled or not
4
+ # config.enabled = Rails.env.development?
5
+
6
+ # # automatic engine routes mounting
7
+ # config.automatic_routes_mount = true
8
+
9
+ # # Enable http basic authentication
10
+ # config.http_basic_authentication_enabled = false
11
+
12
+ # # Enable http basic authentication
13
+ # config.http_basic_authentication_user_name = 'rails_db'
14
+
15
+ # # Enable http basic authentication
16
+ # config.http_basic_authentication_password = 'passw0))rd'
17
+ end
18
+ end
19
+
20
+ unless defined?(RailsLive)
21
+ module RailsLive
22
+ def RailsLive.notify(*options)
23
+ # do nothing
24
+ # gem is not added, so just keep work
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+ def mount_rails_live_routes(options = {})
4
+ mount RailsLive::Engine => '/rails/live', :as => options[:as] || 'rails_live'
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsLive
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/rails_live.rb CHANGED
@@ -1,8 +1,28 @@
1
- require "rails_live/engine"
2
-
3
1
  module RailsLive
4
2
 
3
+ # is enabled?
4
+ mattr_accessor :enabled
5
+ @@enabled = true
6
+
7
+ # automatic engine routes mouting
8
+ mattr_accessor :automatic_routes_mount
9
+ @@automatic_routes_mount = true
10
+
11
+ # Enable http basic authentication
12
+ mattr_accessor :http_basic_authentication_enabled
13
+ @@http_basic_authentication_enabled = false
14
+
15
+ # Enable http basic authentication
16
+ mattr_accessor :http_basic_authentication_user_name
17
+ @@http_basic_authentication_user_name = 'rails_live'
18
+
19
+ # Enable http basic authentication
20
+ mattr_accessor :http_basic_authentication_password
21
+ @@http_basic_authentication_password = 'passw0))rd'
22
+
5
23
  def RailsLive.notify(message:, tags: [], user: {}, category: nil, datetime: Time.now)
24
+ return unless enabled
25
+
6
26
  ActionCable.server.broadcast 'updates_channel',
7
27
  message: message,
8
28
  tags: tags,
@@ -11,4 +31,18 @@ module RailsLive
11
31
  datetime: datetime.strftime('%H:%M:%S')
12
32
  end
13
33
 
34
+ def self.setup
35
+ yield(self)
36
+ end
37
+
38
+ def self.use_default_configuration!
39
+ self.enabled = true
40
+ self.http_basic_authentication_enabled = false
41
+ self.automatic_routes_mount = true
42
+ end
43
+
14
44
  end
45
+
46
+ require "rails_live/engine"
47
+ require "rails/routes"
48
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_live
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
@@ -182,6 +182,10 @@ files:
182
182
  - app/views/rails_live/shared/_header.html.erb
183
183
  - app/views/rails_live/stream/index.html.erb
184
184
  - config/routes.rb
185
+ - lib/generators/USAGE
186
+ - lib/generators/rails_live_generator.rb
187
+ - lib/generators/templates/rails_live.rb
188
+ - lib/rails/routes.rb
185
189
  - lib/rails_live.rb
186
190
  - lib/rails_live/engine.rb
187
191
  - lib/rails_live/railtie.rb