company_scope 0.2.1 → 0.2.2
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/lib/company_scope/railtie.rb +13 -12
- data/lib/company_scope/version.rb +1 -1
- data/lib/company_scope.rb +1 -0
- data/lib/generators/company_scope/install_generator.rb +26 -0
- data/lib/generators/company_scope/templates/company_scope.rb.erb +3 -0
- data/log/test.log +40 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4828ee3b27fc705144a5ea007d19da75cf2532e9
|
4
|
+
data.tar.gz: 19bfe7b31a86d5b17e57345be24c170ce2b2af23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07afdd531247d5a265d8782f342b75448012529656306b0f173d8d35aa0beb8ef0d39b5afc552f28e2f94eaacbbc340611786003e04f0e627aa35872e63b6ab8
|
7
|
+
data.tar.gz: c7209d0567261ffb7b07232d8b78e153f6bd12ac946c64ef137bc4490e3cf1ff4c22431015e54348e8027c6b61d01afc4818ecbf1acef9d9870800fa92f9a248
|
@@ -7,22 +7,23 @@ module CompanyScope
|
|
7
7
|
initializer :after_initialize do |app|
|
8
8
|
#
|
9
9
|
CompanyScope.configure do |config|
|
10
|
+
config.enabled = app.config.company_scope[:configured] || false
|
10
11
|
config.company_model = app.config.company_scope[:company_model] || :company
|
11
12
|
config.company_name_matcher = app.config.company_scope[:company_name_matcher] || :subdomain_matcher
|
12
13
|
end
|
13
14
|
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
company_scope_configured = CompanyScope.config.enabled
|
16
|
+
# - this is set in the template initializer - if not by default it is disabled!
|
17
|
+
if company_scope_configured
|
18
|
+
company_config = CompanyScope.config.company_model
|
19
|
+
company_name_matcher = CompanyScope.config.company_name_matcher
|
20
|
+
# - add MultiCompany Rack middleware to detect the company_name from the subdomain
|
21
|
+
app.config.middleware.insert_before Rack::Runtime, Custom::MultiCompany, company_config, company_name_matcher
|
22
|
+
# - the base module injects the default scope into company dependant models
|
23
|
+
ActiveRecord::Base.send(:include, CompanyScope::Base)
|
24
|
+
# - the company_entity module injects class methods for acting as the company!
|
25
|
+
ActiveRecord::Base.send(:include, CompanyScope::Guardian)
|
26
|
+
end
|
26
27
|
#
|
27
28
|
if defined?(ActionController::Base)
|
28
29
|
# - the control module has some error handling for the application controller
|
data/lib/company_scope.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
module CompanyScope
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
desc "CompanyScope installs the relevant database migrations"
|
5
|
+
source_root File.expand_path("../templates", __FILE__)
|
6
|
+
|
7
|
+
class_option :company_class_name, :type => :string, :default => 'company', :desc => "Name of Company Model"
|
8
|
+
class_option :user_class_name, :type => :string, :default => 'user', :desc => "Name of User Model"
|
9
|
+
class_option :enable_uuid, :type => boolean, :default => false, :desc => "Enable UUID if the extension is used"
|
10
|
+
|
11
|
+
def self.source_root
|
12
|
+
File.expand_path("../templates", __FILE__)
|
13
|
+
end
|
14
|
+
|
15
|
+
def modify_application_rb
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_migrations
|
19
|
+
Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath|
|
20
|
+
name = File.basename(filepath)
|
21
|
+
template "migrations/#{name}", "db/migrate/#{name}"
|
22
|
+
sleep 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/log/test.log
CHANGED
@@ -358,3 +358,43 @@ Processing by DummyApplicationController#index as HTML
|
|
358
358
|
Completed 200 OK in 0ms (Views: 0.1ms)
|
359
359
|
Processing by DummyApplicationController#index as HTML
|
360
360
|
Completed 500 Internal Server Error in 0ms
|
361
|
+
Processing by DummyApplicationController#index as HTML
|
362
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
363
|
+
Processing by DummyApplicationController#index as HTML
|
364
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
365
|
+
Processing by DummyApplicationController#index as HTML
|
366
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
367
|
+
Processing by DummyApplicationController#index as HTML
|
368
|
+
Completed 500 Internal Server Error in 0ms
|
369
|
+
Processing by DummyApplicationController#index as HTML
|
370
|
+
Completed 200 OK in 1ms (Views: 1.0ms)
|
371
|
+
Processing by DummyApplicationController#index as HTML
|
372
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
373
|
+
Processing by DummyApplicationController#index as HTML
|
374
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
375
|
+
Processing by DummyApplicationController#index as HTML
|
376
|
+
Completed 500 Internal Server Error in 0ms
|
377
|
+
Processing by DummyApplicationController#index as HTML
|
378
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
379
|
+
Processing by DummyApplicationController#index as HTML
|
380
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
381
|
+
Processing by DummyApplicationController#index as HTML
|
382
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
383
|
+
Processing by DummyApplicationController#index as HTML
|
384
|
+
Completed 500 Internal Server Error in 0ms
|
385
|
+
Processing by DummyApplicationController#index as HTML
|
386
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
387
|
+
Processing by DummyApplicationController#index as HTML
|
388
|
+
Completed 200 OK in 1ms (Views: 0.3ms)
|
389
|
+
Processing by DummyApplicationController#index as HTML
|
390
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
391
|
+
Processing by DummyApplicationController#index as HTML
|
392
|
+
Completed 500 Internal Server Error in 0ms
|
393
|
+
Processing by DummyApplicationController#index as HTML
|
394
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
395
|
+
Processing by DummyApplicationController#index as HTML
|
396
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
397
|
+
Processing by DummyApplicationController#index as HTML
|
398
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
399
|
+
Processing by DummyApplicationController#index as HTML
|
400
|
+
Completed 500 Internal Server Error in 0ms
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: company_scope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Forkin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -206,6 +206,8 @@ files:
|
|
206
206
|
- lib/company_scope/railtie.rb
|
207
207
|
- lib/company_scope/version.rb
|
208
208
|
- lib/custom/multi_company.rb
|
209
|
+
- lib/generators/company_scope/install_generator.rb
|
210
|
+
- lib/generators/company_scope/templates/company_scope.rb.erb
|
209
211
|
- lib/subdomain_matcher.rb
|
210
212
|
- log/test.log
|
211
213
|
homepage: http://github.com/netflakes/company_scope
|