site_framework 4.2.0 → 4.3.0

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: 736273988a8fa45f51be7a43b9672a70a25d9ddd
4
- data.tar.gz: f27a518bc045aa5573a1591e553348446d0c28c9
3
+ metadata.gz: 837e5016c615d68c84e770a07dbda43a710064d0
4
+ data.tar.gz: 332d2d238b919e11075f25aa138d69ffd7f39926
5
5
  SHA512:
6
- metadata.gz: 0e25ded29d90b07a38ff43525c558ecc3462d78e813c4d844430c1d463407a2fbc86e9cb455928f5a2b05facfb582779676e37e53ec3d98e4f9134405fd5c665
7
- data.tar.gz: 04926aad616c3aa0b70daf50381267bc9d3f1f2d586e34fb455d51377843d099c97dc32bd019984ef46896fcbd575460a0cac6a91804f6c5d718a9699460ff46
6
+ metadata.gz: 8973d21a898910927bfc74f1683faccff9d83e926579205d1eca8585196b4afe52a230f2191ee8881f3e9d88e072a8d0bf3d0134fb808957b3727950174b8d81
7
+ data.tar.gz: 0a726fd7956bb053df96c438e911c893af119086506aabf091c7ac24b58ca8ade1ddf94eff6c4accd23b25cba3cf762baf444ab81062fd3dc7cb431d2aa9b196
data/README.md CHANGED
@@ -33,7 +33,7 @@ make them domain aware (ActiveRecord Only). e.g in your migration:
33
33
 
34
34
  ```ruby
35
35
  # Make posts table domain aware
36
- domain_aware(:posts)
36
+ site_aware(:posts)
37
37
  ```
38
38
 
39
39
  If you're using **Mongoid** just add a reference to **SiteFramework::Domain** in your model.
@@ -73,7 +73,7 @@ Note: You can provide default domains for **SiteFramework** via an
73
73
  initializer like this:
74
74
 
75
75
  ```ruby
76
- SiteFramework.setup do |config|
76
+ SiteFramework::Engine.setup do |config|
77
77
 
78
78
  config.default_domains = ['localhost', 'example.com']
79
79
 
@@ -102,7 +102,7 @@ In case of default site these methods will return `nil`
102
102
  ### Model Concern
103
103
  **SiteFramework** provides an **ActiveSupport** concern which transparently
104
104
  makes your models aware of the current **Site** and **Domain**. By includeing
105
- `SiteFramework::DomainAware` into your model, default scope of your model will
105
+ `SiteFramework::SiteAware` into your model, default scope of your model will
106
106
  change to return only records which belongs to current **Site**.
107
107
 
108
108
  This way you can use external gems with your multi-site application easily.
@@ -4,7 +4,7 @@ module SiteFramework
4
4
  # belongs to another **Domain**
5
5
  class Domain < (defined?(ActiveRecord) ? ActiveRecord::Base : Object)
6
6
 
7
- PATTERN = /\A[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?\z/ix
7
+ PATTERN = /\A[a-z0-9]*(\.?[a-z0-9]+)\.[a-z]{2,5}(:[0-9]{1,5})?(\/.)?$/ix
8
8
 
9
9
  if defined? Mongoid
10
10
  include Mongoid::Document
@@ -31,7 +31,9 @@ module SiteFramework
31
31
  validates_associated :site
32
32
  end
33
33
 
34
- validates(:name, presence: true, format: { with: PATTERN })
34
+ validates :name, presence: true, if: :valid_domain_name?
35
+
36
+
35
37
  validates_uniqueness_of :name
36
38
 
37
39
  before_save :normalize_name
@@ -39,5 +41,15 @@ module SiteFramework
39
41
  def normalize_name
40
42
  self.name = name.downcase
41
43
  end
44
+
45
+ def valid_domain_name?
46
+ if read_attribute :alias
47
+ false unless name =~ PATTERN
48
+ # TODO: Check the owner of domain
49
+ else
50
+ true
51
+ end
52
+ end
53
+
42
54
  end
43
55
  end
@@ -1,9 +1,17 @@
1
1
  class CreateSiteFrameworkDomains < ActiveRecord::Migration
2
2
  def change
3
- create_table :site_framework_domains do |t|
3
+ args = {}
4
+ args[:id] = :uuid if SiteFramework::Engine.use_uuid
5
+
6
+ create_table :site_framework_domains, **args do |t|
4
7
  t.string :name
5
- t.integer :site_id
6
- t.integer :parent_id, default: nil
8
+ if SiteFramework::Engine.use_uuid
9
+ t.uuid :site_id
10
+ t.uuid :parent_id, default: nil
11
+ else
12
+ t.integer :site_id
13
+ t.integer :parent_id, default: nil
14
+ end
7
15
  t.boolean :alias, default: false
8
16
 
9
17
  t.timestamps
@@ -1,6 +1,9 @@
1
1
  class CreateSiteFrameworkSites < ActiveRecord::Migration
2
2
  def change
3
- create_table :site_framework_sites do |t|
3
+ args = {}
4
+ args[:id] = :uuid if SiteFramework::Engine.use_uuid
5
+
6
+ create_table :site_framework_sites, **args do |t|
4
7
  t.string :title
5
8
  t.string :description
6
9
 
@@ -5,7 +5,11 @@ class ActiveRecord::Migration
5
5
 
6
6
  def site_aware(table_name)
7
7
  change_table table_name do |t|
8
- t.integer :site_id
8
+ if SiteFramework::Engine.use_uuid
9
+ t.uuid :site_id
10
+ else
11
+ t.integer :site_id
12
+ end
9
13
  end
10
14
 
11
15
  add_index table_name, :site_id
@@ -9,13 +9,20 @@ module SiteFramework
9
9
  g.test_framework :rspec
10
10
  end
11
11
 
12
- @@default_domains = ['localhost']
13
- mattr_accessor :default_domains
12
+
13
+ mattr_accessor :default_domains do
14
+ ['localhost']
15
+ end
14
16
 
15
17
  # This option allows developers to specify the prefix of path
16
18
  # which they wanted to prepend to view_paths array
17
- mattr_accessor :view_path_prefix
18
- @@view_path_prefix = "app/views"
19
+ mattr_accessor :view_path_prefix do
20
+ 'app/views'
21
+ end
22
+
23
+ mattr_accessor :use_uuid do
24
+ false
25
+ end
19
26
 
20
27
  def self.setup
21
28
  yield self
@@ -1,3 +1,3 @@
1
1
  module SiteFramework
2
- VERSION = '4.2.0'
2
+ VERSION = '4.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sameer Rahmani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-04 00:00:00.000000000 Z
11
+ date: 2016-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties