custom_fields 2.4.0.rc1 → 2.4.0.rc2
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/LICENSE +18 -0
- data/README.md +104 -0
- data/lib/custom_fields/extensions/mongoid/document.rb +0 -1
- data/lib/custom_fields/extensions/mongoid/factory.rb +0 -1
- data/lib/custom_fields/extensions/mongoid/fields/localized.rb +12 -2
- data/lib/custom_fields/extensions/mongoid/relations/referenced/in.rb +0 -1
- data/lib/custom_fields/extensions/mongoid/relations/referenced/many.rb +0 -1
- data/lib/custom_fields/extensions/mongoid/validations/collection_size.rb +0 -1
- data/lib/custom_fields/extensions/origin/smash.rb +0 -1
- data/lib/custom_fields/source.rb +9 -2
- data/lib/custom_fields/types/has_many.rb +2 -2
- data/lib/custom_fields/types/many_to_many.rb +20 -9
- data/lib/custom_fields/types/money.rb +2 -2
- data/lib/custom_fields/types/select.rb +2 -2
- data/lib/custom_fields/version.rb +1 -2
- data/lib/custom_fields.rb +1 -1
- metadata +65 -51
- data/MIT-LICENSE +0 -20
- data/README.textile +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5356e1b094019ce1577efe0dd50bb50a53a036a6
|
4
|
+
data.tar.gz: 7a26e9aa7c23b01d5f37adacb25d13427f6c7328
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2100b8484500a39c00e31221c92e30a6a39a121bf75505b59cee72e3ea0b73d206f6ac8fefd7043a979da41461b13f381942975961c94a9b21c6623c8bd7a9fc
|
7
|
+
data.tar.gz: 5acbfac290dc314b4b9371b2ffeabe92f0366488b6e800a25faa82afacee5e8444bea3a70f502eeb5ccd5f33deb4b4e3f988d0a8313da24cad6c2411a7fa4294
|
data/LICENSE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright (c) 2013-2015, Didier Lafforgue
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
7
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
8
|
+
subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
15
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
16
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
[CustomFields]
|
2
|
+
==============
|
3
|
+
|
4
|
+
[![Travis CI Status][Travis CI Status]][Travis CI]
|
5
|
+
[![Gemnasium Status][Gemnasium Status]][Gemnasium]
|
6
|
+
|
7
|
+
Manage custom fields to a Mongoid document or a collection. This module is one of the core features we implemented in
|
8
|
+
our custom CMS, named LocomotiveCMS. Basically, its aim is to provide to editors a way to manage extra fields to a
|
9
|
+
Mongoid document through, for instance, a web UI.
|
10
|
+
|
11
|
+
The main goals:
|
12
|
+
|
13
|
+
* Offering a very secure way to add, edit and delete extra fields to a Mongoid document.
|
14
|
+
* Scoping the modifications added to a Mongoid document, so that other documents of the same class won't be updated.
|
15
|
+
|
16
|
+
Requirements
|
17
|
+
------------
|
18
|
+
|
19
|
+
* MongoDB 2.x
|
20
|
+
* Mongoid 4.x
|
21
|
+
* ActiveSupport 4.2.x
|
22
|
+
|
23
|
+
Examples
|
24
|
+
--------
|
25
|
+
|
26
|
+
### On a `has_many` relationship
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
class Company
|
30
|
+
include CustomFields::Source
|
31
|
+
|
32
|
+
has_many :employees
|
33
|
+
|
34
|
+
custom_fields_for :employees
|
35
|
+
end
|
36
|
+
|
37
|
+
class Employee
|
38
|
+
include CustomFields::Target
|
39
|
+
|
40
|
+
field :name, String
|
41
|
+
|
42
|
+
belongs_to :company, inverse_of: :employees
|
43
|
+
end
|
44
|
+
|
45
|
+
company = Company.new
|
46
|
+
company.employees_custom_fields.build label: 'His/her position', name: 'position', type: 'string', required: true
|
47
|
+
|
48
|
+
company.save
|
49
|
+
|
50
|
+
company.employees.build name: 'Michael Scott', position: 'Regional manager'
|
51
|
+
|
52
|
+
another_company = Company.new
|
53
|
+
employee = another_company.employees.build
|
54
|
+
employee.position # Returns a `not defined method` error
|
55
|
+
```
|
56
|
+
|
57
|
+
### On the class itself
|
58
|
+
|
59
|
+
**IN PROGRESS**
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
class Company
|
63
|
+
custom_fields_for_itself
|
64
|
+
end
|
65
|
+
|
66
|
+
company = Company.new
|
67
|
+
company.self_metadata_custom_fields.build label: 'Shipping Address', name: 'address', type: 'text'
|
68
|
+
|
69
|
+
company.save
|
70
|
+
|
71
|
+
company.self_metadata.address = '700 S Laflin, 60607 Chicago'
|
72
|
+
|
73
|
+
another_company = Company.new
|
74
|
+
other_company.self_metadata.address # Returns a `not defined method` error
|
75
|
+
```
|
76
|
+
|
77
|
+
Development
|
78
|
+
-----------
|
79
|
+
|
80
|
+
### Run specs
|
81
|
+
|
82
|
+
Run `rspec` or `rake`.
|
83
|
+
|
84
|
+
### Test Coverage
|
85
|
+
|
86
|
+
Run `COVERAGE=true rspec` or `COVERAGE=true rake`.
|
87
|
+
|
88
|
+
Contact
|
89
|
+
-------
|
90
|
+
|
91
|
+
Feel free to contact me at didier at nocoffee dot fr.
|
92
|
+
|
93
|
+
License
|
94
|
+
-------
|
95
|
+
|
96
|
+
Copyright (c) 2013-2015 NoCoffee, released under the [MIT License (MIT)], see [LICENSE].
|
97
|
+
|
98
|
+
[CustomFields]: https://github.com/locomotivecms/custom_fields "Custom fields extension for Mongoid."
|
99
|
+
[Gemnasium]: https://gemnasium.com/locomotivecms/custom_fields "CustomFields at Gemnasium"
|
100
|
+
[Gemnasium Status]: https://img.shields.io/gemnasium/locomotivecms/custom_fields.svg?style=flat "Gemnasium Status"
|
101
|
+
[LICENSE]: https://raw.githubusercontent.com/locomotivecms/custom_fields/master/LICENSE "License"
|
102
|
+
[MIT License (MIT)]: http://opensource.org/licenses/MIT "The MIT License (MIT)"
|
103
|
+
[Travis CI]: https://travis-ci.org/locomotivecms/custom_fields "CustomFields at Travis CI"
|
104
|
+
[Travis CI Status]: https://img.shields.io/travis/locomotivecms/custom_fields.svg?style=flat "Travis CI Status"
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
module Mongoid #:nodoc:
|
3
2
|
module Fields #:nodoc:
|
4
3
|
|
@@ -23,7 +22,18 @@ module Mongoid #:nodoc:
|
|
23
22
|
elsif object.has_key?(locale.to_s)
|
24
23
|
object[locale.to_s]
|
25
24
|
elsif I18n.fallbacks?
|
26
|
-
object
|
25
|
+
lookup_with_fallback(object)
|
26
|
+
else
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def lookup_with_fallback(object)
|
32
|
+
fallback_locales = I18n.fallbacks[locale].try(:map, &:to_s)
|
33
|
+
|
34
|
+
if fallback_locales
|
35
|
+
_locale = fallback_locales.find { |loc| !object[loc].nil? }
|
36
|
+
object[_locale]
|
27
37
|
else
|
28
38
|
nil
|
29
39
|
end
|
data/lib/custom_fields/source.rb
CHANGED
@@ -172,9 +172,16 @@ module CustomFields
|
|
172
172
|
operations['$set'].merge!({ 'custom_fields_recipe.version' => self.custom_fields_version(name) })
|
173
173
|
collection, selector = self.send(name).collection, self.send(name).criteria.selector
|
174
174
|
|
175
|
-
#
|
175
|
+
# http://docs.mongodb.org/manual/reference/method/db.collection.update/#update-parameter
|
176
|
+
# The <update> document must contain only update operator expressions.
|
177
|
+
%w(set unset rename).each do |operation_name|
|
178
|
+
_fields = operations.delete("$#{operation_name}")
|
176
179
|
|
177
|
-
|
180
|
+
next if _fields.empty?
|
181
|
+
|
182
|
+
_operation = { "$#{operation_name}" => _fields }
|
183
|
+
collection.find(selector).update _operation, multi: true
|
184
|
+
end
|
178
185
|
end
|
179
186
|
|
180
187
|
# If the localized attribute has been changed in at least one of the custom fields,
|
@@ -26,13 +26,13 @@ module CustomFields
|
|
26
26
|
# @param [ Hash ] rule It contains the name of the relation and if it is required or not
|
27
27
|
#
|
28
28
|
def apply_has_many_custom_field(klass, rule)
|
29
|
-
# puts "#{klass.inspect}.has_many #{rule['name'].inspect}, class_name: #{rule['class_name'].inspect}, inverse_of: #{rule['inverse_of']}" # DEBUG
|
29
|
+
# puts "#{klass.inspect}.has_many #{rule['name'].inspect}, class_name: #{rule['class_name'].inspect}, inverse_of: #{rule['inverse_of']}, order_by: #{rule['order_by'].inspect}" # DEBUG
|
30
30
|
position_name = "position_in_#{rule['inverse_of']}"
|
31
31
|
|
32
32
|
_order_by = rule['order_by'] || position_name.to_sym.asc
|
33
33
|
_inverse_of = rule['inverse_of'].blank? ? nil : rule['inverse_of'] # an empty String can cause weird behaviours
|
34
34
|
|
35
|
-
klass.has_many rule['name'], class_name: rule['class_name'], inverse_of: _inverse_of, order: _order_by do
|
35
|
+
klass.has_many rule['name'], class_name: rule['class_name'], inverse_of: _inverse_of, order: _order_by, validate: false do
|
36
36
|
|
37
37
|
def filtered(conditions = {}, order_by = nil)
|
38
38
|
list = conditions.empty? ? self.unscoped : self.where(conditions)
|
@@ -28,11 +28,7 @@ module CustomFields
|
|
28
28
|
def apply_many_to_many_custom_field(klass, rule)
|
29
29
|
# puts "#{klass.inspect}.many_to_many #{rule['name'].inspect}, class_name: #{rule['class_name'].inspect} / #{rule['order_by']}" # DEBUG
|
30
30
|
|
31
|
-
klass.has_and_belongs_to_many rule['name'], class_name: rule['class_name'], inverse_of: rule['inverse_of'], order: rule['order_by'] do
|
32
|
-
|
33
|
-
# def at_least_one_element?
|
34
|
-
# (base.send(metadata.key.to_sym).try(:size) || 0) > 0
|
35
|
-
# end
|
31
|
+
klass.has_and_belongs_to_many rule['name'], class_name: rule['class_name'], inverse_of: rule['inverse_of'], validate: false, order: rule['order_by'] do
|
36
32
|
|
37
33
|
def filtered(conditions = {}, order_by = nil)
|
38
34
|
list = conditions.empty? ? self : self.where(conditions)
|
@@ -40,15 +36,30 @@ module CustomFields
|
|
40
36
|
if order_by
|
41
37
|
list.order_by(order_by)
|
42
38
|
else
|
43
|
-
|
44
|
-
# Warning: it returns an array and not a criteria object meaning it breaks the chain
|
45
|
-
ids = base.send(relation_metadata.key.to_sym)
|
46
|
-
list.entries.sort { |a, b| ids.index(a.id) <=> ids.index(b.id) }
|
39
|
+
_naturally_ordered(list, order_by)
|
47
40
|
end
|
48
41
|
end
|
49
42
|
|
50
43
|
alias :ordered :filtered # backward compatibility + semantic purpose
|
51
44
|
|
45
|
+
def _naturally_ordered(criteria, order_by = nil)
|
46
|
+
# use the natural order given by the initial array (ex: project_ids).
|
47
|
+
# Warning: it returns an array and not a criteria object meaning it breaks the chain
|
48
|
+
ids = base.send(relation_metadata.key.to_sym)
|
49
|
+
criteria.entries.sort { |a, b| ids.index(a.id) <=> ids.index(b.id) }
|
50
|
+
end
|
51
|
+
|
52
|
+
def pluck_with_natural_order(*attributes)
|
53
|
+
criteria = self.only([:_id] + [*attributes])
|
54
|
+
_naturally_ordered(criteria).map do |entry|
|
55
|
+
if attributes.size == 1
|
56
|
+
entry.public_send(attributes.first.to_sym)
|
57
|
+
else
|
58
|
+
attributes.map { |name| entry.public_send(name.to_sym) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
52
63
|
end
|
53
64
|
|
54
65
|
if rule['required']
|
@@ -107,7 +107,7 @@ module CustomFields
|
|
107
107
|
protected
|
108
108
|
|
109
109
|
def _set_money_defaults(names)
|
110
|
-
::
|
110
|
+
::Monetize.assume_from_symbol = self.send(names[:allow_currency_from_symbol])
|
111
111
|
::Money.default_currency = self.send(names[:default_currency])
|
112
112
|
end
|
113
113
|
|
@@ -129,7 +129,7 @@ module CustomFields
|
|
129
129
|
def _set_money(_money, names)
|
130
130
|
return if _money.blank?
|
131
131
|
_set_money_defaults(names)
|
132
|
-
money = _money.kind_of?(Money) ? _money : ::
|
132
|
+
money = _money.kind_of?(Money) ? _money : ::Monetize.parse(_money)
|
133
133
|
self.write_attribute(names[:cents_field], money.cents)
|
134
134
|
self.write_attribute(names[:currency_field], money.currency.iso_code)
|
135
135
|
rescue
|
@@ -134,8 +134,8 @@ module CustomFields
|
|
134
134
|
#
|
135
135
|
def group_by_select_option(name, order_by = nil)
|
136
136
|
name_id = "#{name}_id"
|
137
|
-
groups = self.each.group_by{|x| x.send(name_id)}.map do |(k, v)|
|
138
|
-
{name_id => k,
|
137
|
+
groups = self.each.group_by { |x| x.send(name_id) }.map do |(k, v)|
|
138
|
+
{ name_id => k, 'group' => v }
|
139
139
|
end
|
140
140
|
|
141
141
|
_select_options(name).map do |option|
|
data/lib/custom_fields.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.0.
|
4
|
+
version: 2.4.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -16,128 +16,128 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.0.
|
19
|
+
version: 4.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.0.
|
26
|
+
version: 4.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: carrierwave-mongoid
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.7.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.7.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 4.2.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 4.2.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: monetize
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.1.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.1.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '10.4'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '10.4'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: pry
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.10.1
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.10.1
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 3.1.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 3.1.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec-its
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.0
|
117
|
+
version: 1.1.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.0
|
124
|
+
version: 1.1.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: mocha
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: 1.1.0
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: 1.1.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: simplecov
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
@@ -151,45 +151,58 @@ dependencies:
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.9.1
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: database_cleaner
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
159
|
+
version: 1.3.0
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "
|
164
|
+
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
166
|
+
version: 1.3.0
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: RedCloth
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 4.2.
|
173
|
+
version: 4.2.9
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 4.2.9
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: yard
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 0.8.7
|
174
188
|
type: :development
|
175
189
|
prerelease: false
|
176
190
|
version_requirements: !ruby/object:Gem::Requirement
|
177
191
|
requirements:
|
178
192
|
- - "~>"
|
179
193
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
181
|
-
description: Manage custom fields to a
|
182
|
-
is one of the core features we implemented in our custom
|
183
|
-
email:
|
184
|
-
- didier@nocoffee.fr
|
194
|
+
version: 0.8.7
|
195
|
+
description: Manage custom fields to a Mongoid document or a collection. This module
|
196
|
+
is one of the core features we implemented in our custom CMS, named LocomotiveCMS.
|
197
|
+
email: didier@nocoffee.fr
|
185
198
|
executables: []
|
186
199
|
extensions: []
|
187
200
|
extra_rdoc_files:
|
188
|
-
-
|
189
|
-
- README.
|
201
|
+
- LICENSE
|
202
|
+
- README.md
|
190
203
|
files:
|
191
|
-
-
|
192
|
-
- README.
|
204
|
+
- LICENSE
|
205
|
+
- README.md
|
193
206
|
- config/locales/de.yml
|
194
207
|
- config/locales/en.yml
|
195
208
|
- config/locales/fr.yml
|
@@ -230,8 +243,9 @@ files:
|
|
230
243
|
- lib/custom_fields/types/tags.rb
|
231
244
|
- lib/custom_fields/types/text.rb
|
232
245
|
- lib/custom_fields/version.rb
|
233
|
-
homepage:
|
234
|
-
licenses:
|
246
|
+
homepage: https://github.com/locomotivecms/custom_fields
|
247
|
+
licenses:
|
248
|
+
- MIT
|
235
249
|
metadata: {}
|
236
250
|
post_install_message:
|
237
251
|
rdoc_options: []
|
@@ -239,18 +253,18 @@ require_paths:
|
|
239
253
|
- lib
|
240
254
|
required_ruby_version: !ruby/object:Gem::Requirement
|
241
255
|
requirements:
|
242
|
-
- - "
|
256
|
+
- - "~>"
|
243
257
|
- !ruby/object:Gem::Version
|
244
|
-
version: '
|
258
|
+
version: '2.1'
|
245
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
246
260
|
requirements:
|
247
|
-
- - "
|
261
|
+
- - "~>"
|
248
262
|
- !ruby/object:Gem::Version
|
249
|
-
version:
|
263
|
+
version: '2.4'
|
250
264
|
requirements: []
|
251
|
-
rubyforge_project:
|
252
|
-
rubygems_version: 2.
|
265
|
+
rubyforge_project:
|
266
|
+
rubygems_version: 2.4.5
|
253
267
|
signing_key:
|
254
268
|
specification_version: 4
|
255
|
-
summary: Custom fields extension for Mongoid
|
269
|
+
summary: Custom fields extension for Mongoid.
|
256
270
|
test_files: []
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2013 [Didier Lafforgue]
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
"!https://secure.travis-ci.org/locomotivecms/custom_fields.png!":http://travis-ci.org/locomotivecms/custom_fields
|
2
|
-
|
3
|
-
h1. CustomFields
|
4
|
-
|
5
|
-
Manage custom fields to a mongoid document or a collection. This module is one of the core features we implemented in our custom cms, LocomotiveCMS.
|
6
|
-
Basically, its aim is to provide to editors a way to manage extra fields to a Mongoid document through, for instance, a web UI.
|
7
|
-
|
8
|
-
The main goals:
|
9
|
-
|
10
|
-
* offering a very secure way to add / edit / delete extra fields to a Mongoid document
|
11
|
-
* scoping the modifications added to a Mongoid document so that other documents of the same class won't be updated.
|
12
|
-
|
13
|
-
h2. Requirements
|
14
|
-
|
15
|
-
ActiveSupport 3.2.13, MongoDB 2.0 and Mongoid 3.1.3
|
16
|
-
|
17
|
-
h2. Examples
|
18
|
-
|
19
|
-
h3. On a has_many relationship
|
20
|
-
|
21
|
-
bc.. class Company
|
22
|
-
include CustomFields::Source
|
23
|
-
|
24
|
-
has_many :employees
|
25
|
-
|
26
|
-
custom_fields_for :employees
|
27
|
-
end
|
28
|
-
|
29
|
-
class Employee
|
30
|
-
include CustomFields::Target
|
31
|
-
|
32
|
-
field :name, String
|
33
|
-
|
34
|
-
belongs_to :company, :inverse_of => :employees
|
35
|
-
end
|
36
|
-
|
37
|
-
company = Company.new
|
38
|
-
company.employees_custom_fields.build :label => 'His/her position', :name => 'position', :type => 'string', :required => true
|
39
|
-
|
40
|
-
company.save
|
41
|
-
|
42
|
-
company.employees.build :name => 'Michael Scott', :position => 'Regional manager'
|
43
|
-
|
44
|
-
another_company = Company.new
|
45
|
-
employee = another_company.employees.build
|
46
|
-
employee.position # returns a "not defined method" error
|
47
|
-
|
48
|
-
h3. On the class itself
|
49
|
-
|
50
|
-
[IN PROGRESS]
|
51
|
-
|
52
|
-
bc.. class Company
|
53
|
-
custom_fields_for_itself
|
54
|
-
end
|
55
|
-
|
56
|
-
company = Company.new
|
57
|
-
company.self_metadata_custom_fields.build :label => 'Shipping Address', :name => 'address', :type => 'text'
|
58
|
-
|
59
|
-
company.save
|
60
|
-
|
61
|
-
company.self_metadata.address = '700 S Laflin, 60607 Chicago'
|
62
|
-
|
63
|
-
another_company = Company.new
|
64
|
-
other_company.self_metadata.address # returns a "not defined method" error
|
65
|
-
|
66
|
-
h2. Contact
|
67
|
-
|
68
|
-
Feel free to contact me at didier at nocoffee dot fr.
|
69
|
-
|
70
|
-
Copyright (c) 2013 NoCoffee, released under the MIT license
|