mongoid-sleeping_king_studios 0.7.6 → 0.7.7

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: 287eebf704b95b0ecc4b7d38feecd57d335f743c
4
- data.tar.gz: 92be00de6a85145ad88e07bb74b83e33a4b14f72
3
+ metadata.gz: 2778187b766f4fd07bf7f8ae56c723f27d2ec021
4
+ data.tar.gz: 8a1e1d93897f7b33437b59698a5130c9055c381a
5
5
  SHA512:
6
- metadata.gz: b389a9cead7baeb1462535a446a89d772b9bb438e48fdd8dc8e08e0a30722f671d1be7e453eddc6ad260cab6302918079b12611425addfcc6d59afe4fda918c5
7
- data.tar.gz: 8d093d8555253a54afae3a8924023ad422e1f5c2d44c303400a8c126988164f4e3380d30685139ce25add4d5c6eb13022829869d8061a6c57b9437c80a73a087
6
+ metadata.gz: 5004564b79d8842b2efb3eca985aa412438ee3d3d7a1b5506a5507ddb63dd58477a9a798c1fc1136ba91b0c627090e6ba2017c031efec0af17f95fa83b786429
7
+ data.tar.gz: cbb152f928cc5501fb97c327e0362517435cccf586644b750041967bebd2c7c64a21f063689fff300a2e1e8e029528df10c216dead5dbe884436723fd1471d73
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.7
4
+
5
+ ### New Features
6
+
7
+ * Added ::slugify_all! class-level helper to Sluggable concern, to ease adding
8
+ the concern to a model with existing documents.
9
+
3
10
  ## 0.7.6
4
11
 
5
12
  ### New Features
data/README.md CHANGED
@@ -172,6 +172,18 @@ short, url-friendly version.
172
172
  slugify :title
173
173
  end # class
174
174
 
175
+ #### Helpers
176
+
177
+ ##### ::slugify_all!
178
+
179
+ (Class Method) Loops through all documents in the collection. If the document's
180
+ slug is blank, or if it does not match the base attribute value, calculates the
181
+ value from the base attribute and assigns it atomically. Locked slugs (see the
182
+ :lockable option) are unaffected.
183
+
184
+ Use this method to generate slugs when adding this concern to a model with
185
+ existing documents.
186
+
175
187
  #### Options
176
188
 
177
189
  ##### Lockable
@@ -49,6 +49,7 @@ module Mongoid::SleepingKingStudios
49
49
 
50
50
  define_fields base, meta
51
51
  define_accessors base, meta
52
+ define_helpers base, meta
52
53
  define_validations base, meta
53
54
  end # module method apply
54
55
 
@@ -98,6 +99,32 @@ module Mongoid::SleepingKingStudios
98
99
  end # if
99
100
  end # module method define_fields
100
101
 
102
+ # @api private
103
+ #
104
+ # Creates the ::slugify_all! class-level helper method.
105
+ #
106
+ # @param [Class] base The base class into which the concern is mixed in.
107
+ # @param [Metadata] metadata The metadata for the relation.
108
+ #
109
+ # @since 0.7.7
110
+ def self.define_helpers base, metadata
111
+ # Define class-level helpers.
112
+ class_methods = Module.new
113
+
114
+ class_methods.send :define_method, :slugify_all! do
115
+ all.each do |obj|
116
+ value = metadata.value_to_slug(obj.send metadata.attribute)
117
+ if obj.slug.blank?
118
+ obj.set :slug => value
119
+ elsif obj.slug != value && !(metadata.lockable? && obj.slug_lock)
120
+ obj.set :slug => value
121
+ end # if
122
+ end # each
123
+ end # class method slugify_all!
124
+
125
+ base.extend class_methods
126
+ end # module method define_helpers
127
+
101
128
  # @api private
102
129
  #
103
130
  # Sets a validation on the slug field that validates the presence of the
@@ -166,6 +193,15 @@ module Mongoid::SleepingKingStudios
166
193
  concern = Mongoid::SleepingKingStudios::Sluggable
167
194
  concern.apply self, attribute, options
168
195
  end # class method slugify
196
+
197
+ # @!method slugify_all!
198
+ # Loops through all documents in the collection. If the document's slug
199
+ # is blank, or if it does not match the base attribute value,
200
+ # calculates the value from the base attribute and assigns it
201
+ # atomically. Locked slugs (see the :lockable option) are unaffected.
202
+ #
203
+ # Use this method to generate slugs when adding this concern to a model
204
+ # with existing documents.
169
205
  end # module
170
206
  end # module
171
207
  end # module
@@ -3,6 +3,6 @@
3
3
  module Mongoid
4
4
  module SleepingKingStudios
5
5
  # The current version of the gem.
6
- VERSION = '0.7.6'
6
+ VERSION = '0.7.7'
7
7
  end # module
8
8
  end # module
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-sleeping_king_studios
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob "Merlin" Smith
@@ -14,112 +14,112 @@ dependencies:
14
14
  name: mongoid
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.0.0.alpha.1
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
26
  version: 4.0.0.alpha.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sleeping_king_studios-ext
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.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
40
  version: '0.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.14'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.14'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-sleeping_king_studios
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: factory_girl
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '4.2'
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
82
  version: '4.2'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: database_cleaner
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 1.0.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
96
  version: 1.0.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: fuubar
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.2'
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
110
  version: '1.2'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: pry
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0.9'
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
124
  version: '0.9'
125
125
  description: |2
@@ -132,26 +132,26 @@ executables: []
132
132
  extensions: []
133
133
  extra_rdoc_files: []
134
134
  files:
135
- - lib/mongoid/sleeping_king_studios/concern/metadata.rb
135
+ - CHANGELOG.md
136
+ - LICENSE
137
+ - README.md
138
+ - lib/mongoid/sleeping_king_studios.rb
136
139
  - lib/mongoid/sleeping_king_studios/concern.rb
140
+ - lib/mongoid/sleeping_king_studios/concern/metadata.rb
137
141
  - lib/mongoid/sleeping_king_studios/error.rb
138
142
  - lib/mongoid/sleeping_king_studios/ext/mongoid/document.rb
139
- - lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb
143
+ - lib/mongoid/sleeping_king_studios/has_tree.rb
140
144
  - lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry.rb
145
+ - lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb
141
146
  - lib/mongoid/sleeping_king_studios/has_tree/children/metadata.rb
142
147
  - lib/mongoid/sleeping_king_studios/has_tree/errors.rb
143
148
  - lib/mongoid/sleeping_king_studios/has_tree/metadata.rb
144
149
  - lib/mongoid/sleeping_king_studios/has_tree/parent/metadata.rb
145
- - lib/mongoid/sleeping_king_studios/has_tree.rb
146
- - lib/mongoid/sleeping_king_studios/orderable/metadata.rb
147
150
  - lib/mongoid/sleeping_king_studios/orderable.rb
148
- - lib/mongoid/sleeping_king_studios/sluggable/metadata.rb
151
+ - lib/mongoid/sleeping_king_studios/orderable/metadata.rb
149
152
  - lib/mongoid/sleeping_king_studios/sluggable.rb
153
+ - lib/mongoid/sleeping_king_studios/sluggable/metadata.rb
150
154
  - lib/mongoid/sleeping_king_studios/version.rb
151
- - lib/mongoid/sleeping_king_studios.rb
152
- - LICENSE
153
- - CHANGELOG.md
154
- - README.md
155
155
  homepage: http://sleepingkingstudios.com
156
156
  licenses:
157
157
  - MIT
@@ -162,17 +162,17 @@ require_paths:
162
162
  - lib
163
163
  required_ruby_version: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - '>='
165
+ - - ">="
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  requirements:
170
- - - '>='
170
+ - - ">="
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  requirements: []
174
174
  rubyforge_project:
175
- rubygems_version: 2.0.6
175
+ rubygems_version: 2.2.1
176
176
  signing_key:
177
177
  specification_version: 4
178
178
  summary: A collection of Mongoid concerns and extensions.