attribute-filters 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- [��z\�/�^��0��BT]6�Yc��/-�V�XA8��`�Cg U6��aP]U���G2�)���t�qL�`�6���-���iK���W�Ty4��ʺ.I;Z��g�z�Z���Cz��1wa��<8S�=��=��J]�ꇁW]3��a���W��\~��&�ݎA���Á[s��ODM]
2
- P�"��}\:aR���[�?^�%���}���yb죱<�Rڠ��F�\��ۇ
1
+ 7�Fq�%���b��(L�{"ÀM(@#V?%�������u�j^Q�1�<]��Z~.�<�jF\�{��� ���q[,`ω�9��q��8lɯ(P6 (���,2�>���j+z�� ��RCh/�p6{=n"�+0GAV6绔rUsO4O<�f�Z"�|�-�{{Hi��(��zD��ȑ�D��39!1�{C�\t�︰g����r#�Ld�;%��ݘ�W]4�p[���Uv1x5A��+����O�
data/.yardopts CHANGED
@@ -6,7 +6,7 @@
6
6
  -p docs/yard-tpl
7
7
  -t default
8
8
  -
9
- docs/USAGE
9
+ docs/USAGE.md
10
10
  docs/HISTORY
11
11
  ChangeLog
12
12
  docs/COPYING
data/ChangeLog CHANGED
@@ -1,3 +1,191 @@
1
+ commit 275690a75a7218aab8766a50d61b8be5eec20509
2
+ Author: Paweł Wilk <siefca@gnu.org>
3
+ Date: Tue Jul 10 11:32:08 2012 +0200
4
+
5
+ Bugfix release 1.1.3
6
+
7
+ commit 1087942cbf4e003e72524e4b877f98960e3c004e
8
+ Author: Paweł Wilk <siefca@gnu.org>
9
+ Date: Sun Jul 8 10:50:35 2012 +0200
10
+
11
+ Preparing for release 1.2.0
12
+
13
+ commit 7963c74a4ee7e59baecbccf83acdfc101a29257a
14
+ Author: Paweł Wilk <siefca@gnu.org>
15
+ Date: Sun Jul 8 10:40:13 2012 +0200
16
+
17
+ README links updated
18
+
19
+ commit 65ddb3ef269de01ca122c5949d2401990bc34e53
20
+ Author: Paweł Wilk <siefca@gnu.org>
21
+ Date: Sun Jul 8 10:13:01 2012 +0200
22
+
23
+ Removed the show DSL method from AttrQuery proxy class
24
+
25
+ commit 2216013e69c30bd3ab3e6c5ff9ecd4379f768239
26
+ Author: Paweł Wilk <siefca@gnu.org>
27
+ Date: Sun Jul 8 10:12:24 2012 +0200
28
+
29
+ Documentation updated, finished editing the USAGE
30
+
31
+ commit 40db8f483d43bd894bff7437e9582c82f6f6db6a
32
+ Author: Paweł Wilk <siefca@gnu.org>
33
+ Date: Sun Jul 8 10:11:34 2012 +0200
34
+
35
+ Added the Common module with common filtering methods
36
+
37
+ commit 067712ddfd5c7435e7066c1dca94b2b39c5edb09
38
+ Author: Paweł Wilk <siefca@gnu.org>
39
+ Date: Sat Jul 7 16:16:34 2012 +0200
40
+
41
+ Added checking of model methods that are needed for a proper operation
42
+
43
+ commit 813b22d395d3376db0e31a1e6de6ec8f43f04c04
44
+ Author: Paweł Wilk <siefca@gnu.org>
45
+ Date: Sat Jul 7 16:15:19 2012 +0200
46
+
47
+ Replaced changed_attributes calls by more generic calls to changes method in DSL's filtering methods
48
+
49
+ commit 246937196e11b7abbaeb2c7b35134c9a239716bb
50
+ Author: Paweł Wilk <siefca@gnu.org>
51
+ Date: Sat Jul 7 14:44:54 2012 +0200
52
+
53
+ Re-added from_attributes_that alias for instance method attribute_set
54
+
55
+ commit 355d637d1fa0e37b693b69da705d6844904613c5
56
+ Author: Paweł Wilk <siefca@gnu.org>
57
+ Date: Sat Jul 7 14:44:19 2012 +0200
58
+
59
+ Proxy class Query is now viral and tries to wrap the results in its own instances
60
+
61
+ commit d484f5bbac557cb46f5a686ba26620334ee89d05
62
+ Author: Paweł Wilk <siefca@gnu.org>
63
+ Date: Sat Jul 7 14:41:00 2012 +0200
64
+
65
+ Added from_attributes_that as the alias for attribute_set instance method, documentation updated
66
+
67
+ commit acae50c77864ebbec1946979d3d5f2753a16d4cd
68
+ Author: Paweł Wilk <siefca@gnu.org>
69
+ Date: Sat Jul 7 13:40:35 2012 +0200
70
+
71
+ USAGE updated
72
+
73
+ commit cb4374b295cca47ef8a3fdf1c796296ab423367c
74
+ Author: Paweł Wilk <siefca@gnu.org>
75
+ Date: Sat Jul 7 13:40:23 2012 +0200
76
+
77
+ Used original sort and sort_by implementation and intermediate array in enumerator (performance)
78
+
79
+ commit 2b6b316298da88970c655234aec22959eabc2e02
80
+ Author: Paweł Wilk <siefca@gnu.org>
81
+ Date: Sat Jul 7 01:30:20 2012 +0200
82
+
83
+ ChangeLog updated
84
+
85
+ commit 007a5384e65afec1c453080bebb7b813da99b00d
86
+ Author: Paweł Wilk <siefca@gnu.org>
87
+ Date: Sat Jul 7 01:29:56 2012 +0200
88
+
89
+ Added 'none' and 'one' presence selectors to AttributeSet::Query class
90
+
91
+ commit c5c6b5d9d8049dfd0d45b6607e2858de3b83544d
92
+ Author: Paweł Wilk <siefca@gnu.org>
93
+ Date: Sat Jul 7 01:26:38 2012 +0200
94
+
95
+ Added AttributeSetEnumerable and AttributeSetEnumerator
96
+
97
+ commit 069b357b8c75456c9c2fe27b3570fe3cd3077c4d
98
+ Author: Paweł Wilk <siefca@gnu.org>
99
+ Date: Sat Jul 7 01:25:07 2012 +0200
100
+
101
+ Virtual attributes support methods moved (documentation parsing purposes)
102
+
103
+ commit acbc2e8426371019ade72c7b33b330834b3b73d7
104
+ Author: Paweł Wilk <siefca@gnu.org>
105
+ Date: Sat Jul 7 01:23:00 2012 +0200
106
+
107
+ Serious bugfix in AttributeSet::Query proxy class (typo caused incorrect processing)
108
+
109
+ commit 1c13b364a3f26da726e85b19d1fda16786985c82
110
+ Author: Paweł Wilk <siefca@gnu.org>
111
+ Date: Sat Jul 7 01:21:38 2012 +0200
112
+
113
+ Documentation updated
114
+
115
+ commit 295da0da4b14f3b1a9399400139a15ecdfcf27d1
116
+ Author: Paweł Wilk <siefca@gnu.org>
117
+ Date: Fri Jul 6 13:43:12 2012 +0200
118
+
119
+ Added virtual attributes support in filters
120
+
121
+ commit aae677905aa9ae47eca7e708babcbc0c7f34c7c1
122
+ Author: Paweł Wilk <siefca@gnu.org>
123
+ Date: Fri Jul 6 02:49:49 2012 +0200
124
+
125
+ Documentation updated
126
+
127
+ commit 95619151c116585bb325b6f242c921dad1a33977
128
+ Author: Paweł Wilk <siefca@gnu.org>
129
+ Date: Thu Jul 5 16:02:27 2012 +0200
130
+
131
+ Renamed USAGE to USAGE.md
132
+
133
+ commit 1c0bb54762b5ccc60fb3c27c0c24fe19ac078020
134
+ Author: Paweł Wilk <siefca@gnu.org>
135
+ Date: Thu Jul 5 15:58:59 2012 +0200
136
+
137
+ Preparing for new release
138
+
139
+ commit 6b75c4de40301060b2b5b19824f00cc5acc0fa8e
140
+ Author: Paweł Wilk <siefca@gnu.org>
141
+ Date: Thu Jul 5 15:21:13 2012 +0200
142
+
143
+ Added DSL instance methods attribute_sets and attributes_to_sets
144
+
145
+ commit e545baad64e6820d93cdc7c89b2ece83f12d6329
146
+ Author: Paweł Wilk <siefca@gnu.org>
147
+ Date: Thu Jul 5 15:20:02 2012 +0200
148
+
149
+ Added missing respond_to? definitions to proxy classes
150
+
151
+ commit f856d0b6f669cafc3ec5a1d84030e99870b5fcee
152
+ Author: Paweł Wilk <siefca@gnu.org>
153
+ Date: Thu Jul 5 15:19:18 2012 +0200
154
+
155
+ Added DSL keyword for querying which attribute sets are associated with an attribute
156
+
157
+ commit 5611e8c098c21d38f0fa9bd21f338f51a658ae30
158
+ Author: Paweł Wilk <siefca@gnu.org>
159
+ Date: Thu Jul 5 15:16:18 2012 +0200
160
+
161
+ README updated
162
+
163
+ commit c68b3219ef0923d1184c0c5efb4240c1d53a89d5
164
+ Author: Paweł Wilk <siefca@gnu.org>
165
+ Date: Thu Jul 5 13:38:06 2012 +0200
166
+
167
+ Added the_attribute DSL method for instances and AttributeSet::AttrQuery proxy class
168
+
169
+ commit 964e46d2a77502192461c6f1e208dab73871caa9
170
+ Author: Paweł Wilk <siefca@gnu.org>
171
+ Date: Thu Jul 5 12:23:27 2012 +0200
172
+
173
+ Added filter_attribute DSL keyword for adding attribute names to specified sets (alternative syntax)
174
+
175
+ - Added @__attributes_to_sets_map for storing reverse mappings of attribute names to sets;
176
+ - Changed the way the internal data structures are accessed by adding private methods:
177
+ __attributes_to_sets_map and __attribute_sets
178
+ - Internal data structures are now duplicated when accessed from outside and the default value
179
+ for a set (when an element doesn't exist) is an empty set
180
+ - Updated RSpec examples,
181
+ - Added new DSL example to README.
182
+
183
+ commit e8c2c98b55152fff9b6515197f5315b0dfe702ea
184
+ Author: Paweł Wilk <siefca@gnu.org>
185
+ Date: Sun Jul 1 00:57:34 2012 +0200
186
+
187
+ Documentation fixed and updated
188
+
1
189
  commit 0235e6184da1ca9ef4264a772032c820d76fec19
2
190
  Author: Paweł Wilk <siefca@gnu.org>
3
191
  Date: Sun Jul 1 00:42:03 2012 +0200
data/Manifest.txt CHANGED
@@ -13,13 +13,15 @@ docs/HISTORY
13
13
  docs/LEGAL
14
14
  docs/LGPL-LICENSE
15
15
  docs/TODO
16
- docs/USAGE
16
+ docs/USAGE.md
17
17
  docs/rdoc.css
18
18
  docs/yard-tpl/default/fulldoc/html/css/common.css
19
19
  init.rb
20
20
  lib/attribute-filters.rb
21
21
  lib/attribute-filters/active_model_insert.rb
22
22
  lib/attribute-filters/attribute_set.rb
23
+ lib/attribute-filters/attribute_set_attrquery.rb
24
+ lib/attribute-filters/attribute_set_enum.rb
23
25
  lib/attribute-filters/attribute_set_query.rb
24
26
  lib/attribute-filters/common_filters.rb
25
27
  lib/attribute-filters/dsl_filters.rb
data/README.md CHANGED
@@ -1,9 +1,7 @@
1
1
  Attribute Filters for Rails
2
2
  ===========================
3
3
 
4
- **attribute-filters version `1.1`** (**`Sugar, ah honey honey`**)
5
-
6
- **THIS IS BETA!**
4
+ **attribute-filters version `1.2`** (**`Lavender Bunch`**)
7
5
 
8
6
  * https://rubygems.org/gems/attribute-filters
9
7
  * https://github.com/siefca/attribute-filters/tree
@@ -31,17 +29,17 @@ To refine that process you may write more generic methods
31
29
  for altering attributes. They should be designed to handle
32
30
  common operations and not tied to certain attributes.
33
31
 
34
- Enough words, let's see that approach in action.
32
+ Enough words, let's see that in action.
35
33
 
36
34
  ### Before ###
37
35
 
38
36
  ```ruby
39
37
  class User < ActiveRecord::Base
40
-
38
+
41
39
  before_validation :strip_and_downcase_username
42
40
  before_validation :strip_and_downcase_email
43
41
  before_validation :strip_and_capitalize_real_name
44
-
42
+
45
43
  def strip_and_downcase_username
46
44
  if username.present?
47
45
  self.username = self.username.strip.mb_chars.downcase.to_s
@@ -54,14 +52,13 @@ class User < ActiveRecord::Base
54
52
  self.email.downcase!
55
53
  end
56
54
  end
57
-
55
+
58
56
  def strip_and_capitalize_real_name
59
57
  if real_name.present?
60
58
  self.real_name = self.real_name.strip.mb_chars.split(' ').
61
59
  map { |n| n.capitalize }.join(' ')
62
60
  end
63
- end
64
-
61
+ end
65
62
  end
66
63
  ```
67
64
 
@@ -73,83 +70,97 @@ The filtering code is not reusable since it operates on specific attributes.
73
70
 
74
71
  ```ruby
75
72
  class User < ActiveRecord::Base
76
-
77
73
  attributes_that should_be_stripped: [ :username, :email, :real_name ]
78
74
  attributes_that should_be_downcased: [ :username, :email ]
79
75
  attributes_that should_be_capitalized: [ :real_name ]
80
-
76
+
81
77
  before_validation :strip_names
82
78
  before_validation :downcase_names
83
79
  before_validation :capitalize_names
84
-
80
+
85
81
  def downcase_names
86
82
  filter_attributes_that :should_be_downcased do |atr|
87
83
  atr.mb_chars.downcase.to_s
88
84
  end
89
85
  end
90
-
86
+
91
87
  def capitalize_names
92
88
  filter_attributes_that :should_be_capitalized do |atr|
93
89
  atr.mb_chars.split(' ').map { |n| n.capitalize }.join(' ')
94
90
  end
95
91
  end
96
-
92
+
97
93
  def strip_names
98
94
  for_attributes_that(:should_be_stripped) { |atr| atr.strip! }
99
95
  end
100
-
101
96
  end
102
97
  ```
103
98
 
104
- Attributes that need to be altered may be simply added to the attribute sets
99
+ or even shorter:
100
+
101
+ ```ruby
102
+ class User < ActiveRecord::Base
103
+ include ActiveModel::AttributeFilters::Common
104
+
105
+ attributes_that should_be_stripped: [ :username, :email, :real_name ]
106
+ attributes_that should_be_downcased: [ :username, :email ]
107
+ attributes_that should_be_fully_capitalized: [ :real_name ]
108
+
109
+ before_validation :strip_attributes
110
+ before_validation :downcase_attributes
111
+ before_validation :fully_capitalize_attributes
112
+ end
113
+ ```
114
+
115
+ Attributes that have to be altered may be simply added to the attribute sets
105
116
  that you define and then filtered with generic methods. You can use
106
117
  these methods in all your models if you wish.
107
118
 
108
119
  The last action can be performed by putting the filtering methods into
109
120
  some base class that models inherit form or (better) into your own
110
- handy module that is included in your models.
121
+ handy module that is included in your models. Alternatively you can
122
+ use predefined filters from `ActiveModel::AttributeFilters::Common` module.
111
123
 
112
- Usage
113
- -----
114
-
115
- You can use it to do attribute filtering as presented above but you can also
116
- try using ActiveModel::AttributeSet directly, which helps to express some logic.
117
- For example:
124
+ If you would rather like to group filters by attribute names then
125
+ the alternative syntax may be helpful:
118
126
 
119
127
  ```ruby
120
128
  class User < ActiveRecord::Base
121
-
122
- attributes_that_are required_to_trade: [ :username, :home_address, :bank_account ]
123
-
124
- def can_trade?
125
- are_attributes(:required_to_trade).all.present?
126
- end
127
-
129
+ the_attribute email: [ :should_be_stripped, :should_be_downcased ]
130
+ the_attribute username: [ :should_be_stripped, :should_be_downcased ]
131
+ the_attribute real_name: [ :should_be_stripped, :should_be_capitalized ]
128
132
  end
129
133
  ```
130
134
 
131
- * See [USAGE](http://rubydoc.info/gems/attribute-filters/file/docs/USAGE) for more examples and detailed information about the usage.
135
+ Usage
136
+ -----
137
+
138
+ You can use it to filter attributes (as presented above) but you can also
139
+ use it to express some logic
140
+ [on your own](http://http://rubydoc.info/gems/attribute-filters/file/docs/USAGE#Custom_applications).
141
+
142
+ * See [USAGE](http://rubydoc.info/gems/attribute-filters/file/docs/USAGE) for examples and detailed information about the usage.
132
143
  * See [whole documentation](http://rubydoc.info/gems/attribute-filters/) to browse all documents.
133
144
 
134
145
  How it works?
135
146
  -------------
136
147
 
137
- It creates a new Active Model module called ActiveModel::AttributeFilters. That module
138
- contains the needed DSL that goes into your models. It also creates ActiveModel::AttributeSet
148
+ It creates a new Active Model submodule called `AttributeFilters`. That module
149
+ contains the needed DSL that goes into your models. It also creates `ActiveModel::AttributeSet`
139
150
  class which is just a new kind of set, a structure for storing sets of attribute names.
140
151
 
141
152
  Then it forces Rails to include the AttributeFilters in any model that
142
153
  at any time will include ActiveModel::AttributeMethods. The last one is included
143
- quite often; e.g. ActiveRecord and other popular ORM-s use it. (I'm calling it
154
+ quite often; e.g. Active Record and other popular ORM-s use it. (I'm calling it
144
155
  "the accompanying module".)
145
156
 
146
157
  That's why you can make use of attribute filters without explicitly including
147
158
  the module, as long as your application relies on any popular ORM.
148
159
 
149
160
  However, if something would go wrong or your application is somehow unusual, you can always
150
- include the AttributeFilters module manually in any of your models:
161
+ include the `AttributeFilters` module manually in any of your models:
151
162
 
152
- ```
163
+ ```ruby
153
164
  class ExampleModel
154
165
  include ActiveModel::AttributeFilters
155
166
  end
@@ -178,7 +189,7 @@ Download
178
189
  Installation
179
190
  ------------
180
191
 
181
- ```
192
+ ```ruby
182
193
  gem install attribute-filters
183
194
  ```
184
195
 
@@ -195,6 +206,7 @@ Common rake tasks
195
206
 
196
207
  * `bundle exec rake bundler:gemfile` – regenerate the `Gemfile`
197
208
  * `bundle exec rake docs` – render the documentation (output in the subdirectory directory `doc`)
209
+ * `bundle exec rake gem:spec` – builds static gemspec file (`attribute-filters.gemspec`)
198
210
  * `bundle exec rake gem` – builds package (output in the subdirectory `pkg`)
199
211
  * `bundle exec rake test` – performs tests
200
212
  * `bundle exec rake Manifest.txt` – regenerates the `Manifest.txt` file
@@ -213,8 +225,8 @@ Copyright (c) 2012 by Paweł Wilk.
213
225
 
214
226
  attribute-filters is copyrighted software owned by Paweł Wilk (pw@gnu.org).
215
227
  You may redistribute and/or modify this software as long as you
216
- comply with either the terms of the LGPL (see {file:docs/LGPL-LICENSE}),
217
- or Ruby's license (see {file:docs/COPYING}).
228
+ comply with either the terms of the LGPL (see [LGPL-LICENSE](http://rubydoc.info/gems/attribute-filters/file/docs/LGPL-LICENSE)),
229
+ or Ruby's license (see [COPYING](http://rubydoc.info/gems/attribute-filters/file/docs/COPYING)).
218
230
 
219
231
  THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
220
232
  OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION,
@@ -2,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "attribute-filters"
5
- s.version = "1.1.2.20120701004000"
5
+ s.version = "1.1.3.20120705154806"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Pawe\u{142} Wilk"]
9
9
  s.cert_chain = ["/Users/siefca/.gem/gem-public_cert.pem"]
10
- s.date = "2012-06-30"
10
+ s.date = "2012-07-05"
11
11
  s.description = "Concise way of filtering model attributes in Rails."
12
12
  s.email = ["pw@gnu.org"]
13
13
  s.extra_rdoc_files = ["Manifest.txt"]
14
- s.files = [".rspec", ".yardopts", "ChangeLog", "Gemfile", "Gemfile.lock", "LGPL-LICENSE", "Manifest.txt", "README.md", "Rakefile", "attribute-filters.gemspec", "docs/COPYING", "docs/HISTORY", "docs/LEGAL", "docs/LGPL-LICENSE", "docs/TODO", "docs/USAGE", "docs/rdoc.css", "docs/yard-tpl/default/fulldoc/html/css/common.css", "init.rb", "lib/attribute-filters.rb", "lib/attribute-filters/active_model_insert.rb", "lib/attribute-filters/attribute_set.rb", "lib/attribute-filters/attribute_set_query.rb", "lib/attribute-filters/common_filters.rb", "lib/attribute-filters/dsl_filters.rb", "lib/attribute-filters/dsl_sets.rb", "lib/attribute-filters/helpers.rb", "lib/attribute-filters/railtie.rb", "lib/attribute-filters/version.rb", "spec/attribute-filters_spec.rb", "spec/spec_helper.rb", ".gemtest"]
14
+ s.files = [".rspec", ".yardopts", "ChangeLog", "Gemfile", "Gemfile.lock", "LGPL-LICENSE", "Manifest.txt", "README.md", "Rakefile", "attribute-filters.gemspec", "docs/COPYING", "docs/HISTORY", "docs/LEGAL", "docs/LGPL-LICENSE", "docs/TODO", "docs/USAGE", "docs/rdoc.css", "docs/yard-tpl/default/fulldoc/html/css/common.css", "init.rb", "lib/attribute-filters.rb", "lib/attribute-filters/active_model_insert.rb", "lib/attribute-filters/attribute_set.rb", "lib/attribute-filters/attribute_set_attrquery.rb", "lib/attribute-filters/attribute_set_query.rb", "lib/attribute-filters/common_filters.rb", "lib/attribute-filters/dsl_filters.rb", "lib/attribute-filters/dsl_sets.rb", "lib/attribute-filters/helpers.rb", "lib/attribute-filters/railtie.rb", "lib/attribute-filters/version.rb", "spec/attribute-filters_spec.rb", "spec/spec_helper.rb", ".gemtest"]
15
15
  s.homepage = "https://rubygems.org/gems/attribute-filters/"
16
16
  s.rdoc_options = ["--title", "Attribute::Filters Documentation", "--quiet"]
17
17
  s.require_paths = ["lib"]
data/docs/HISTORY CHANGED
@@ -1,3 +1,28 @@
1
+ === 1.1.3 / 2012-07-10
2
+
3
+ * major bugfixes
4
+
5
+ * In AttributeSet::Query proxy class: removed typo that caused incorrect processing
6
+
7
+ * minor bugfixes
8
+
9
+ * Added missing respond_to? definitions to proxy classes
10
+
11
+ * major enhancements
12
+
13
+ * Added enumerators (AttributeSetEnumerable and AttributeSetEnumerator)
14
+ * Added predefined filtering methods
15
+ * Added virtual attributes support in filters
16
+ * Written the usage instructions
17
+
18
+ * minor enhancements
19
+
20
+ * Removed the show DSL method from AttrQuery proxy class
21
+ * Added checking of model methods that are needed for a proper operation
22
+ * Proxy class Query is now viral and tries to wrap the results in its own instances
23
+ * Added 'none' and 'one' presence selectors to AttributeSet::Query class
24
+ * Added from_attributes_that as the alias for attribute_set instance method
25
+
1
26
  === 1.1.2 / 2012-06-30
2
27
 
3
28
  * major bugfixes