push_type_core 0.6.0.beta.1 → 0.6.0.beta.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/app/fields/push_type/asset_field.rb +0 -4
- data/app/fields/push_type/matrix_field.rb +11 -16
- data/app/fields/push_type/relation_field.rb +2 -2
- data/app/fields/push_type/repeater_field.rb +21 -23
- data/app/fields/push_type/tag_list_field.rb +3 -0
- data/lib/push_type/field_type.rb +1 -1
- data/lib/push_type/primitives/object_type.rb +7 -0
- data/lib/push_type/version.rb +1 -1
- data/test/dummy/config/initializers/push_type.rb +1 -1
- data/test/dummy/config/secrets.yml +2 -2
- data/test/dummy/db/schema.rb +1 -1
- data/test/dummy/log/test.log +12060 -12009
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/0ANSDcZJu9gPyqtYPIW729qm1kriQ29Vn9LU8T2SGQU.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/_d65qW7wxRtKVSYpmfSenECz5QUWVI9pppUgV7TA1Rk.cache +0 -0
- data/test/dummy/tmp/generators/app/models/category.rb +7 -0
- data/test/dummy/tmp/generators/app/views/taxonomies/category.html.erb +3 -0
- data/test/fields/push_type/asset_field_test.rb +0 -1
- data/test/fields/push_type/repeater_field_test.rb +7 -4
- metadata +24 -24
- data/test/dummy/tmp/generators/config/initializers/push_type.rb +0 -55
- data/test/dummy/tmp/generators/config/routes.rb +0 -59
- /data/test/dummy/db/migrate/{20151015181653_create_push_type_users.push_type.rb → 20151102165837_create_push_type_users.push_type.rb} +0 -0
- /data/test/dummy/db/migrate/{20151015181654_create_push_type_nodes.push_type.rb → 20151102165838_create_push_type_nodes.push_type.rb} +0 -0
- /data/test/dummy/db/migrate/{20151015181655_create_push_type_node_hierarchies.push_type.rb → 20151102165839_create_push_type_node_hierarchies.push_type.rb} +0 -0
- /data/test/dummy/db/migrate/{20151015181656_create_push_type_assets.push_type.rb → 20151102165840_create_push_type_assets.push_type.rb} +0 -0
- /data/test/dummy/db/migrate/{20151015181657_create_push_type_taxonomies.push_type.rb → 20151102165841_create_push_type_taxonomies.push_type.rb} +0 -0
- /data/test/dummy/db/migrate/{20151015181658_create_push_type_taxonomy_hierarchies.push_type.rb → 20151102165842_create_push_type_taxonomy_hierarchies.push_type.rb} +0 -0
- /data/test/dummy/db/migrate/{20151015181659_add_field_store_default_values.push_type.rb → 20151102165843_add_field_store_default_values.push_type.rb} +0 -0
- /data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/{MSZIb53M-WSslpcsxtT_LlGognclDpLjB9YyJ1qLm3c.cache → aTa2i4fIuP1rB3Te3BmhxVW3c0wwyYQtTIQW710wrm0.cache} +0 -0
- /data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/{jE1v4kSAksoYAFuvE0Nbl5ZIcuyFYlWX8cb9YkFd5BY.cache → idBOP3HLwMKqIi2fmJ86l7s0AJCQq-p3JBAe01H630c.cache} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 695f0cf51a3d8408ce92094dfe92610f6e079546
|
4
|
+
data.tar.gz: 727b6d4d5c39f6c0b3196362a113823e0a416fa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 374753265c5c609f1602a81d7f0138e0c47a96ace93124ba45bfda9d7c02772b4a29bbf760c12e8158e39d36d1da5903330949a987f74ccd93e5c63b63f2a9ac
|
7
|
+
data.tar.gz: 994a863f1bdb86cf7189ddb78f89dc10df1714fc66a4be0938b9bda6a6a088e88c15ee9613a84d2434af8824a4ec7e06fc18e133733808b006c868f27b3c24c2
|
@@ -7,36 +7,31 @@ module PushType
|
|
7
7
|
def initialize(*args, &block)
|
8
8
|
super
|
9
9
|
structure_class.class_eval(&block) if block
|
10
|
-
validate_field_types!
|
11
10
|
end
|
12
11
|
|
13
12
|
def value
|
14
13
|
return if json_value.blank?
|
15
|
-
|
16
|
-
structure_class.new(field_store: h)
|
17
|
-
end
|
14
|
+
rows
|
18
15
|
end
|
19
16
|
|
20
17
|
def fields
|
21
18
|
@fields ||= structure_class.new.fields
|
22
19
|
end
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
def rows
|
22
|
+
Array(json_value).map do |h|
|
23
|
+
structure_class.new(field_store: h)
|
24
|
+
end
|
28
25
|
end
|
29
26
|
|
30
|
-
def
|
31
|
-
|
32
|
-
unless field_type_whitelist.include?(f.kind)
|
33
|
-
raise ArgumentError, "Invalid field type. `#{ kind }` cannot be used in #{ self.class.name }."
|
34
|
-
end
|
35
|
-
end
|
27
|
+
def structure
|
28
|
+
@structure ||= structure_class.new
|
36
29
|
end
|
37
30
|
|
38
|
-
|
39
|
-
|
31
|
+
private
|
32
|
+
|
33
|
+
def structure_class
|
34
|
+
@structure_class ||= PushType::Structure.clone
|
40
35
|
end
|
41
36
|
|
42
37
|
end
|
@@ -5,7 +5,7 @@ module PushType
|
|
5
5
|
|
6
6
|
def initialize(*args)
|
7
7
|
super
|
8
|
-
raise ArgumentError, "Relation field names must end with suffix `_id` or `
|
8
|
+
raise ArgumentError, "Relation field names must end with suffix `_id` or `_ids`." unless relation_name
|
9
9
|
end
|
10
10
|
|
11
11
|
def json_primitive
|
@@ -33,7 +33,7 @@ module PushType
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def relation_class
|
36
|
-
(@opts[:to] || relation_name.singularize).classify.constantize
|
36
|
+
(@opts[:to] || relation_name.singularize).to_s.classify.constantize
|
37
37
|
end
|
38
38
|
|
39
39
|
def relation_root
|
@@ -6,22 +6,31 @@ module PushType
|
|
6
6
|
|
7
7
|
def initialize(*args)
|
8
8
|
super
|
9
|
-
|
9
|
+
raise ArgumentError, "Invalid field type. `#{ @opts[:repeats] }` cannot be used in #{ self.class.name }." if [:tag_list].include?(@opts[:repeats])
|
10
|
+
_key, _opts = structure_json_key, @opts
|
11
|
+
structure_class.class_eval do
|
12
|
+
field _key, _opts[:repeats], _opts.except(:css_class, :repeats).merge(multiple: false)
|
13
|
+
define_method(:f) { fields[_key] }
|
14
|
+
end
|
10
15
|
end
|
11
16
|
|
12
17
|
def value
|
13
18
|
return if json_value.blank?
|
14
|
-
|
15
|
-
generate_field('_f' => j).value
|
16
|
-
end
|
19
|
+
rows.map(&:_f)
|
17
20
|
end
|
18
21
|
|
19
22
|
def template
|
20
23
|
'repeater'
|
21
24
|
end
|
22
25
|
|
23
|
-
def
|
24
|
-
|
26
|
+
def rows
|
27
|
+
Array(json_value).map do |j|
|
28
|
+
structure_class.new(field_store: { structure_json_key => j }.as_json)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def structure
|
33
|
+
@structure ||= structure_class.new
|
25
34
|
end
|
26
35
|
|
27
36
|
private
|
@@ -30,27 +39,16 @@ module PushType
|
|
30
39
|
super.except(:template, :form_helper)
|
31
40
|
end
|
32
41
|
|
33
|
-
def
|
34
|
-
|
42
|
+
def structure_class
|
43
|
+
@structure_class ||= PushType::Structure.clone
|
35
44
|
end
|
36
45
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
"#{ @opts[:repeats] }_field".camelize.constantize
|
46
|
+
def structure_json_key
|
47
|
+
case @opts[:repeats]
|
48
|
+
when :relation, :node, :taxonomy, :asset then :_f_id
|
49
|
+
else :_f
|
42
50
|
end
|
43
51
|
end
|
44
52
|
|
45
|
-
def validate_field_type!
|
46
|
-
unless field_type_whitelist.include?(@opts[:repeats])
|
47
|
-
raise ArgumentError, "Invalid field type. `#{ @opts[:repeats] }` cannot be used in #{ self.class.name }."
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def field_type_whitelist
|
52
|
-
[:number, :string, :text]
|
53
|
-
end
|
54
|
-
|
55
53
|
end
|
56
54
|
end
|
@@ -24,6 +24,9 @@ module PushType
|
|
24
24
|
on_class do |klass, field_name, field_class|
|
25
25
|
klass.class_eval do
|
26
26
|
|
27
|
+
# Break unless we are working on an ActiveRecord klass
|
28
|
+
break unless respond_to?(:scope)
|
29
|
+
|
27
30
|
# Dynamically define standard scope .with_all_`field_name`
|
28
31
|
# Returns ActiveRecord::Relation
|
29
32
|
#
|
data/lib/push_type/field_type.rb
CHANGED
@@ -28,7 +28,7 @@ module PushType
|
|
28
28
|
def initialize(name, model, opts = {})
|
29
29
|
@name = name
|
30
30
|
@model = model
|
31
|
-
@opts = [defaults, self.class.options, opts].compact.inject(&:
|
31
|
+
@opts = [defaults, self.class.options, opts].compact.inject(&:deep_merge)
|
32
32
|
end
|
33
33
|
|
34
34
|
def kind
|
data/lib/push_type/version.rb
CHANGED
@@ -50,6 +50,6 @@ PushType.setup do |config|
|
|
50
50
|
# secret_access_key: ENV['SECRET_ACCESS_KEY_ID']
|
51
51
|
# }
|
52
52
|
|
53
|
-
# config.dragonfly_secret = '
|
53
|
+
# config.dragonfly_secret = '95ec48e6fde12daa65a9093d7c6cd8a626019001f388ed0d407154d78ac44f30'
|
54
54
|
|
55
55
|
end
|
@@ -11,10 +11,10 @@
|
|
11
11
|
# if you're sharing your code publicly.
|
12
12
|
|
13
13
|
development:
|
14
|
-
secret_key_base:
|
14
|
+
secret_key_base: 992655c5cb254e30f6a08279cae78c7bb529da42b7f3f598f2ae57e3809c19e934351882962572232d8d2bc801734f7a269b042b04be4263d2b67f1a48406924
|
15
15
|
|
16
16
|
test:
|
17
|
-
secret_key_base:
|
17
|
+
secret_key_base: 1962b2ff958bc3e4bf7281cafde40cb1e34e1419dc68293ac323e874027d1600bb6538bb74ac7f34856ede2702dfe57f5d9eb6c96b00735606fd7b3ba5a9fa1d
|
18
18
|
|
19
19
|
# Do not keep production secrets in the repository,
|
20
20
|
# instead read values from the environment.
|
data/test/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20151102165843) do
|
15
15
|
|
16
16
|
# These are extensions that must be enabled in order to support this database
|
17
17
|
enable_extension "plpgsql"
|