web-connect 0.1.10 → 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/lib/netfira/web_connect.rb +4 -0
- data/lib/netfira/web_connect/configuration.rb +1 -1
- data/lib/netfira/web_connect/db_schema/20140514_support.rb +4 -2
- data/lib/netfira/web_connect/migration.rb +9 -2
- data/lib/netfira/web_connect/model/record/materialization.rb +5 -0
- data/lib/netfira/web_connect/model/record/serializer.rb +1 -1
- data/lib/netfira/web_connect/model/record/translation.rb +2 -0
- data/lib/netfira/web_connect/model/relation.rb +2 -0
- data/lib/netfira/web_connect/version.rb +1 -1
- metadata +6 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a9ed1943020c61d303c0e1e41d655dbf3becd2e
|
4
|
+
data.tar.gz: fd67c5f26c24a6d04e6df66fa5440286791e1b17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61adc8afbf05c6d19b0d52922179bbf52c26ec1f9df200bcfaaaa4cf963857d1ad6359db07a0200aa0cf55d513469ae753b49ac2038e531711dad9240e7651a7
|
7
|
+
data.tar.gz: c3d75c7a605e8ce13acd1deaace6c1a026191fa525481cb73e3ad8f07c34736fd521c488317c573f49a77cbd3f41a03097d10430acb4c87234e7078ec1477011
|
data/lib/netfira/web_connect.rb
CHANGED
@@ -2,7 +2,7 @@ module Netfira::WebConnect
|
|
2
2
|
class Configuration
|
3
3
|
|
4
4
|
attr_accessor :db_table_prefix, :file_store, :authenticator, :custom_fields,
|
5
|
-
:time_zone, :materialize_when_db_changed, :session_lifetime
|
5
|
+
:time_zone, :materialize_when_db_changed, :session_lifetime, :paranoia
|
6
6
|
|
7
7
|
attr_reader :logger, :db
|
8
8
|
|
@@ -4,7 +4,7 @@ class Support < Netfira::WebConnect::Migration
|
|
4
4
|
def change
|
5
5
|
|
6
6
|
create_table :_tables do |t|
|
7
|
-
t.string :name, limit: 50,
|
7
|
+
t.string :name, limit: 50, index: true
|
8
8
|
t.string :origin_key, limit: 20
|
9
9
|
t.boolean :file
|
10
10
|
t.boolean :writable
|
@@ -19,7 +19,7 @@ class Support < Netfira::WebConnect::Migration
|
|
19
19
|
Netfira::WebConnect::Models::Shop.create id: 0
|
20
20
|
|
21
21
|
create_table :_settings do |t|
|
22
|
-
t.references :shop
|
22
|
+
t.references :shop, index: true
|
23
23
|
t.string :key
|
24
24
|
t.binary :value, limit: 0x10000
|
25
25
|
t.string :content_type
|
@@ -31,6 +31,8 @@ class Support < Netfira::WebConnect::Migration
|
|
31
31
|
t.references :record
|
32
32
|
t.string :key
|
33
33
|
t.binary :value, limit: 0x10000
|
34
|
+
t.index [:shop_id, :table_id, :record_id], name: 'index_custom_fields'
|
35
|
+
t.index [:shop_id, :table_id, :record_id, :key], name: 'index_custom_fields_with_keys', unique: true
|
34
36
|
end
|
35
37
|
|
36
38
|
create_table :_sessions do |t|
|
@@ -22,13 +22,15 @@ module Netfira::WebConnect
|
|
22
22
|
create_table table_name, options do |t|
|
23
23
|
t.string options[:origin_key] || :"#{table_name.to_s.singularize}_id", index: true unless options[:writable]
|
24
24
|
yield t
|
25
|
-
t.references :shop
|
25
|
+
t.references :shop, index: true
|
26
26
|
if options[:sendable]
|
27
27
|
t.binary :guid, index: true
|
28
28
|
t.integer :delivery_status, default: 0, limit: 3, index: true
|
29
29
|
end
|
30
30
|
t.binary :digest, limit: 16
|
31
31
|
t.timestamps
|
32
|
+
t.datetime :deleted_at
|
33
|
+
t.index :deleted_at
|
32
34
|
end
|
33
35
|
if @l10n_buffer
|
34
36
|
create_l10n_table table_name do |t|
|
@@ -50,7 +52,7 @@ module Netfira::WebConnect
|
|
50
52
|
|
51
53
|
def create_file_table(table_name)
|
52
54
|
create_table table_name do |t|
|
53
|
-
t.references :shop
|
55
|
+
t.references :shop, index: true
|
54
56
|
t.string :file_name, index: true
|
55
57
|
t.string :remote_location
|
56
58
|
t.string :locale
|
@@ -59,6 +61,8 @@ module Netfira::WebConnect
|
|
59
61
|
t.binary :checksum, limit: 16
|
60
62
|
t.binary :digest, limit: 16
|
61
63
|
t.timestamps
|
64
|
+
t.datetime :deleted_at
|
65
|
+
t.index :deleted_at
|
62
66
|
end
|
63
67
|
add_table_def table_name, {}, true
|
64
68
|
end
|
@@ -67,6 +71,9 @@ module Netfira::WebConnect
|
|
67
71
|
first, second = [first, second].sort
|
68
72
|
create_table :"#{first}_to_#{second}" do |t|
|
69
73
|
t.references first.to_s.singularize, second.to_s.singularize, index: true
|
74
|
+
t.timestamps
|
75
|
+
t.datetime :deleted_at
|
76
|
+
t.index :deleted_at
|
70
77
|
end
|
71
78
|
end
|
72
79
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'paranoia'
|
2
|
+
|
1
3
|
module Netfira::WebConnect
|
2
4
|
class Model::Record
|
3
5
|
module Materialization
|
@@ -46,6 +48,9 @@ module Netfira::WebConnect
|
|
46
48
|
# Set up sendable behaviour
|
47
49
|
klass.include Model::Record::Sendable if klass.sendable?
|
48
50
|
|
51
|
+
# Set up paranoia (soft deletion)
|
52
|
+
klass.acts_as_paranoid if Netfira::WebConnect.paranoia?
|
53
|
+
|
49
54
|
# Set up file record behaviour
|
50
55
|
if klass.has_file?
|
51
56
|
klass.has_attached_file :attachment, Netfira::WebConnect.file_store
|
@@ -6,7 +6,7 @@ module Netfira::WebConnect
|
|
6
6
|
module Serializer
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
-
EXCLUDE_FROM_SERIALIZE = %w[id shop_id digest delivery_status created_at updated_at]
|
9
|
+
EXCLUDE_FROM_SERIALIZE = %w[id shop_id digest delivery_status created_at updated_at deleted_at]
|
10
10
|
|
11
11
|
included do
|
12
12
|
|
@@ -25,6 +25,8 @@ module Netfira::WebConnect
|
|
25
25
|
owner_class.has_many :translation_models,
|
26
26
|
class_name: klass.name,
|
27
27
|
inverse_of: :owner,
|
28
|
+
# TODO: cleanup on `really_destroy!`
|
29
|
+
dependent: Netfira::WebConnect.paranoia? ? nil : :delete_all,
|
28
30
|
autosave: true
|
29
31
|
|
30
32
|
# Add translations to the default scope, as they will almost
|
@@ -12,6 +12,7 @@ module Netfira::WebConnect
|
|
12
12
|
klass = Class.new(self)
|
13
13
|
Models.const_set "#{name_a}To#{name_b}", klass
|
14
14
|
klass.related_classes = [name_a, name_b].map{ |n| Models.const_get n.camelize.singularize }
|
15
|
+
klass.acts_as_paranoid if Netfira::WebConnect.paranoia?
|
15
16
|
end
|
16
17
|
|
17
18
|
def related_classes=(classes)
|
@@ -63,6 +64,7 @@ module Netfira::WebConnect
|
|
63
64
|
end
|
64
65
|
|
65
66
|
def records
|
67
|
+
self.class.current_scope = nil if Netfira::WebConnect.paranoia? # Fixes a bug triggered by paranoia
|
66
68
|
self.class.related_classes.map{ |klass| __send__ klass.single_name.to_sym }
|
67
69
|
end
|
68
70
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web-connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neil E. Pearson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -82,75 +82,19 @@ dependencies:
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '1.6'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
85
|
+
name: paranoia
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
91
|
-
type: :
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - "~>"
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: 3.0.0.beta2
|
98
|
-
- !ruby/object:Gem::Dependency
|
99
|
-
name: sqlite3
|
100
|
-
requirement: !ruby/object:Gem::Requirement
|
101
|
-
requirements:
|
102
|
-
- - "~>"
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
version: '1.3'
|
105
|
-
type: :development
|
106
|
-
prerelease: false
|
107
|
-
version_requirements: !ruby/object:Gem::Requirement
|
108
|
-
requirements:
|
109
|
-
- - "~>"
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: '1.3'
|
112
|
-
- !ruby/object:Gem::Dependency
|
113
|
-
name: rspec-its
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
115
|
-
requirements:
|
116
|
-
- - "~>"
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
version: '1.0'
|
119
|
-
type: :development
|
120
|
-
prerelease: false
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
122
|
-
requirements:
|
123
|
-
- - "~>"
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '1.0'
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: mime-types
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
requirements:
|
130
|
-
- - "~>"
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
version: '1.16'
|
133
|
-
type: :development
|
134
|
-
prerelease: false
|
135
|
-
version_requirements: !ruby/object:Gem::Requirement
|
136
|
-
requirements:
|
137
|
-
- - "~>"
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
version: '1.16'
|
140
|
-
- !ruby/object:Gem::Dependency
|
141
|
-
name: database_cleaner
|
142
|
-
requirement: !ruby/object:Gem::Requirement
|
143
|
-
requirements:
|
144
|
-
- - "~>"
|
145
|
-
- !ruby/object:Gem::Version
|
146
|
-
version: '1.3'
|
147
|
-
type: :development
|
90
|
+
version: '2.0'
|
91
|
+
type: :runtime
|
148
92
|
prerelease: false
|
149
93
|
version_requirements: !ruby/object:Gem::Requirement
|
150
94
|
requirements:
|
151
95
|
- - "~>"
|
152
96
|
- !ruby/object:Gem::Version
|
153
|
-
version: '
|
97
|
+
version: '2.0'
|
154
98
|
description: |
|
155
99
|
This is a Ruby version of Netfira's WebConnect server-side library
|
156
100
|
email:
|