company_scope 0.2.1 → 0.2.2

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
  SHA1:
3
- metadata.gz: 67f97ee18ea2db521a006698af04ac418b25f655
4
- data.tar.gz: 7aadddea2aba3eb1f1401489b8641875f804bcab
3
+ metadata.gz: 4828ee3b27fc705144a5ea007d19da75cf2532e9
4
+ data.tar.gz: 19bfe7b31a86d5b17e57345be24c170ce2b2af23
5
5
  SHA512:
6
- metadata.gz: efef00d3736d4fda3be69119dd086f4610c023c5f421ed0fc532cc7f675e7047405d8e6f3e333ec285959f897c6fda35515772d5ce70ea8a910cbe75408d8411
7
- data.tar.gz: 95167ad9bd1ae66d7beb473eb44e8daa91eab2c4ec3985ff8c451d639c29b506e13e9f2d08c14a58a59b0819d512b630e3574dc88f9783bb2c0f5a23c8a21a65
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
- company_config = CompanyScope.config.company_model
15
- company_name_matcher = CompanyScope.config.company_name_matcher
16
- #
17
- # - add MultiCompany Rack middleware to detect the company_name from the subdomain
18
- #app.config.middleware.insert_after Rack::Sendfile, Custom::MultiCompany, company_config, company_name_matcher
19
- app.config.middleware.insert_before Rack::Runtime, Custom::MultiCompany, company_config, company_name_matcher
20
- # - the base module injects the default scope into company dependant models
21
- #
22
- ActiveRecord::Base.send(:include, CompanyScope::Base)
23
- #
24
- # - the company_entity module injects class methods for acting as the company!
25
- ActiveRecord::Base.send(:include, CompanyScope::Guardian)
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
@@ -1,3 +1,3 @@
1
1
  module CompanyScope
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/lib/company_scope.rb CHANGED
@@ -12,6 +12,7 @@ require File.dirname(__FILE__) + '/company_scope/railtie' if defined? ::Rails::R
12
12
  #
13
13
  module CompanyScope
14
14
  class Config
15
+ attr_accessor :enabled
15
16
  attr_accessor :company_model
16
17
  attr_accessor :company_name_matcher
17
18
  end
@@ -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
@@ -0,0 +1,3 @@
1
+ CompanyScope.setup do |config|
2
+
3
+ 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.1
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-03-24 00:00:00.000000000 Z
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