save_queue 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/.gitignore +13 -4
  2. data/.travis.yml +4 -1
  3. data/CONTRIBUTING.md +120 -0
  4. data/HISTORY.md +11 -0
  5. data/LICENSE +13 -4
  6. data/README.md +282 -55
  7. data/Rakefile +10 -3
  8. data/lib/save_queue/exceptions.rb +13 -0
  9. data/lib/save_queue/object.rb +41 -18
  10. data/lib/save_queue/object_queue.rb +87 -0
  11. data/lib/save_queue/plugins/notification/object.rb +35 -0
  12. data/lib/save_queue/plugins/notification/queue.rb +25 -0
  13. data/lib/save_queue/plugins/notification.rb +15 -0
  14. data/lib/save_queue/plugins/validation/exceptions.rb +12 -0
  15. data/lib/save_queue/plugins/validation/queue.rb +16 -17
  16. data/lib/save_queue/plugins/validation.rb +4 -17
  17. data/lib/save_queue/ruby1.9/observer.rb +204 -0
  18. data/lib/save_queue/uniq_queue.rb +38 -0
  19. data/lib/save_queue/version.rb +1 -1
  20. data/lib/save_queue.rb +1 -0
  21. data/save_queue.gemspec +4 -3
  22. data/spec/notification/notification_spec.rb +45 -0
  23. data/spec/notification/object_spec.rb +54 -0
  24. data/spec/notification/queue_spec.rb +28 -0
  25. data/spec/object_queue_spec.rb +155 -0
  26. data/spec/object_spec.rb +208 -0
  27. data/spec/save_queue_spec.rb +75 -0
  28. data/spec/support/object_helpers.rb +10 -0
  29. data/spec/support/queue_helpers.rb +26 -0
  30. data/spec/uniq_queue_spec.rb +132 -0
  31. data/spec/validation/queue_spec.rb +139 -0
  32. data/spec/validation/validation_spec.rb +42 -0
  33. metadata +35 -20
  34. data/lib/save_queue/plugins/validation/object.rb +0 -25
  35. data/lib/save_queue/queue.rb +0 -45
  36. data/spec/save_queue_usage_spec.rb +0 -311
  37. data/spec/support/mock_helpers.rb +0 -17
  38. data/spec/validation_spec.rb +0 -126
data/.gitignore CHANGED
@@ -2,12 +2,21 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
- .idea/
5
+ .idea/*
6
6
  doc/
7
- log/*.log
8
- /tmp/
9
- tmp/
7
+ log/*
8
+ tmp/*
10
9
  db/*.sqlite3
11
10
  /coverage
12
11
  /coverage.data
13
12
  /.yardoc
13
+ .rvmrc
14
+
15
+ ## generic files to ignore
16
+ *~
17
+ *.lock
18
+ *.DS_Store
19
+ *.swp
20
+ *.out
21
+ *.swo
22
+ *.md.html
data/.travis.yml CHANGED
@@ -2,6 +2,9 @@ rvm:
2
2
  - 1.8.7
3
3
  - 1.9.2
4
4
  - 1.9.3
5
- - jruby
5
+ #- jruby-19mode # Not working on travis
6
+ - jruby-18mode
7
+ - rbx-19mode
8
+ - rbx-18mode
6
9
  - ruby-head
7
10
  - ree
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,120 @@
1
+ Contributing to Save Queue
2
+ ==========================
3
+ Save Queue is an open source project. Anyone can use the code, but more importantly, anyone can contribute. This is a
4
+ group effort and we value your input. Please consider making a contribution to help improve the Save Queue. This
5
+ guide covers:
6
+
7
+ * How to file a ticket when you discover a bug
8
+ * How to contribute fixes and improvements to the core
9
+ * Information on how to improve the documentation
10
+
11
+ ### Notification via Ticket
12
+
13
+ You can also search existing bug reports/issues and file a new one if you do not find an issue relevant to your
14
+ proposed change. See Filing an Issue for more details.
15
+
16
+ The important thing is that you communicate your intention in advance of doing a lot of work. Simple bug fixes and
17
+ non-controversial changes do not require this approach but you can save some time by suggesting an improvement and
18
+ having it rejected before you write a bunch of the code.
19
+
20
+ ## Filing an Issue
21
+
22
+ If you would like to file a bug report, please create an issue in our Github Issues Tracker. You should do a basic
23
+ search of the issues database before creating a new issue to ensure that you are not creating a duplicate issue.
24
+
25
+ ### Providing a Patch
26
+
27
+ If you are filing and issue and supplying a patch at the same time, please file a Pull Request instead. The pull
28
+ request will also create an issue at the same time but its superior to just creating an issue because the code and
29
+ issue can be linked.
30
+
31
+ If the ticket already exists, however, and you want to supply a patch after the fact,
32
+ you can simply reference the issue number in your commit message. For example, if your commit fixed issue #123 you
33
+ could use the following commit message:
34
+
35
+ Fixed a problem with Facebook authentication.
36
+
37
+ [Fixes #123]
38
+ Github will automatically detect this commit message when you push it and link the issue. Please see the detailed
39
+ Github Issues blog post for more details.
40
+
41
+ ### Feature Requests
42
+
43
+ We’re interested in hearing your ideas for new features. A feature request is any idea you have to improve the software experience that
44
+ is not strictly related to a bug or error of omission.
45
+
46
+ Feature requests that are accompanied by source code are always welcome. In this case you should read the next
47
+ section on Creating a Pull Request.
48
+
49
+ ## Creating a Pull Request
50
+
51
+ If you are going to contribute code to the Save Queue project, the best mechanism for doing this is to create a pull
52
+ request in Github. If you’re unfamiliar with the general concept of pull requests you may want to read more on pull
53
+ requests in Github.
54
+
55
+ If your code is associated with an existing issue then you can provide a patch instead of creating a pull request.
56
+
57
+ ### Creating a Fork
58
+
59
+ The official Save Queue source code is maintained in Github under the AlexParamonov/save_queue
60
+
61
+ You simply need to “fork” the project and then start hacking.
62
+
63
+ See the Github guide on creating forks for more details.
64
+
65
+ ### Topic Branches
66
+
67
+ Git branches are “cheap.” Creating branches in Git is incredibly easy and its an ideal way to isolate a specific set
68
+ of changes. You may be fixing several things at one time but by keeping your changes isolated it will help us to
69
+ find and apply only the changes we’re interested in. You should create a clean branch based on the latest
70
+ save_queue/master when doing this. It is important you follow these steps exactly,
71
+ it will prevent you from accidentally including unrelated changes from your local repository into the branch.
72
+
73
+ For example, if we were submitting a patch to fix an issue with the CSS in the flash error message you could create
74
+ a branch as follows:
75
+
76
+ $ git remote add upstream git://github.com/AlexParamonov/save_queue.git
77
+ $ git fetch upstream
78
+ $ git checkout -b fix-css-for-error-flash --track upstream/master
79
+
80
+ The fetch command will grab all of the latest commits from the Save Queue master branch. Don’t worry,
81
+ it doesn’t alter your working repository in a harmful way. The track part of the command will tell git that this
82
+ branch should track with the remote version of the upstream master. This is another way of saying that the branch
83
+ should be based on a clean copy of the latest official source code (without any of your unrelated local changes.)
84
+
85
+ You can then do work locally on this topic branch and push it up to your Github fork when you are done. So in our
86
+ previous example we do something like:
87
+
88
+ $ git push origin fix-css-for-error-flash
89
+
90
+ Of course if you want the fix for yourself to use in your own local code you should probably merge it down to your
91
+ own personal master branch that you’re using for development
92
+
93
+ $ git checkout master
94
+ $ git merge fix-css-for-error-flash
95
+
96
+ You should probably also clean up after yourself a little. The branch has been pushed to Github and you’ve merged it
97
+ locally so you don’t really need a local copy of the branch laying around.
98
+
99
+ $ git branch -D fix-css-for-error-flash
100
+
101
+ ### Including a Test
102
+
103
+ Ideally your pull request will also include a test that verifies a bug (or the absence of the new feature) before
104
+ your fix and also verifies proper functionality when you are finished. Please read the Testing Guide for more
105
+ information on writing and running your tests.
106
+
107
+ Pull requests with tests are given top priority. Failure to include a test will likely delay acceptance of your patch.
108
+
109
+ ### Creating the Pull Request
110
+
111
+ Once your code is ready to go and you have pushed your topic branch to Github then you are ready to create the pull
112
+ request and notify the Save Queue team that your contribution is ready. You do this by browsing your project in
113
+ Github and changing to the topic branch you just pushed. Once you are on the topic branch simply create a pull
114
+ request by pressing the “Pull Request” button.
115
+
116
+ The Github guide on pull requests describes this in more detail with screenshots if you’re still confused on this
117
+ part.
118
+
119
+ ## Contributing to the Documentation
120
+ Improvements to the documentation is encouraged.
data/HISTORY.md CHANGED
@@ -1,3 +1,14 @@
1
+ 0.3.x
2
+ =====
3
+ + Notification plugin
4
+ + add save! method
5
+ + refactor Validation plugin
6
+ + bugfixing
7
+
8
+ 0.2.x
9
+ =====
10
+ Implemented main functionality, add Validation plugin
11
+
1
12
  0.0.1
2
13
  =====
3
14
  Initial release. Add README, LICENSE, .gitignore, etc
data/LICENSE CHANGED
@@ -1,7 +1,16 @@
1
- Copyright (c) 2011 Alexander N Paramonov
1
+ Copyright (c) 2011-2012 Alexander N Paramonov
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
4
+ documentation files (the "Software"), to deal in the Software without restriction,
5
+ including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
6
+ and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
7
+ subject to the following conditions:
4
8
 
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ Software.
6
11
 
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
15
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,123 +1,347 @@
1
1
  Save Queue
2
2
  ==========
3
- Save Queue allows to push related objects to an object's queue for delayed save, that will triggered on object#save. In this case object wil store all related information on its save.
3
+ Save Queue allows to push objects to other object's queue for a delayed save.
4
+ Queue save will be triggered by object#save.
5
+
6
+
7
+ Contents
8
+ ---------
9
+ 1. Installation
10
+ 1. Contributing
11
+ 1. Usage
12
+ * Getting started
13
+ * Tracking changes
14
+ * Error handling
15
+ 1. Plugins
16
+ * Validation
17
+ * Notification
18
+ 1. Creating your own Queues / TODO
19
+ 1. FAQ
20
+ 1. Requirements
21
+ 1. Compatibility
22
+ 1. Copyright
4
23
 
5
24
  Installation
6
25
  ------------
7
26
  gem install save_queue
8
27
 
28
+ Contributing
29
+ -------------
30
+ __Please help to improve this project!__
31
+
32
+ See [contributing guide](http://github.com/AlexParamonov/save_queue/blob/master/CONTRIBUTING.md) for best practices
33
+
9
34
  Usage
10
35
  -----
11
36
 
12
- How to start:
37
+ ### Getting started
13
38
 
14
39
  1. include SaveQueue:
15
40
 
16
41
  require 'save_queue'
42
+
17
43
  class Artice
18
44
  include SaveQueue
19
45
  end
20
46
 
21
47
  2. call \#mark_as_changed method when object gets dirty:
22
48
 
49
+ require 'save_queue'
50
+
23
51
  class Artice
52
+ include SaveQueue
53
+
24
54
  def change_attribute attr, value
55
+ @attributes ||= {}
25
56
  @attributes[attr] = value
26
57
  mark_as_changed # call this and object will be marked for save
27
58
  end
28
59
  end
29
60
 
30
- 3. point save method to your save logic or dont care if you use #save already:
31
-
32
- class Artice
33
- # @return [boolean]
34
- def save
35
- write
36
- end
37
- end
38
-
39
- 4. If you want to use validation, include SaveQueue::Plugins::Validation and implement #valid? method. You may got failed objects by save_queue.objects_with_errors
40
-
41
- class Artice
42
- include SaveQueue::Plugins::Validation
43
-
44
- # @return [boolean]
45
- def valid?
46
- true
47
- end
48
- end
49
-
50
- 5. add SaveQueue to some other classes:
61
+ 3. add SaveQueue to some other classes (or implement #save and #has_unsaved_changes? in it):
51
62
 
52
63
  require 'save_queue'
64
+
53
65
  class Tag
54
66
  include SaveQueue
67
+
68
+ @attributes ||= {}
69
+ @attributes[attr] = value
70
+ mark_as_changed # call this and object will be marked for save
55
71
  end
56
72
 
73
+ 4. Add some functionality:
74
+
57
75
  class Artice
58
- def tags= tag_objects
76
+ def tags=(tag_objects)
59
77
  @tags = tag_objects
60
- saved_queue.add_all tag_objects
78
+ save_queue.add_all tag_objects
61
79
  end
62
80
 
63
- def add_tag tag
81
+ def add_tag(tag)
64
82
  @tags ||= []
65
83
  @tags << tag
66
- saved_queue.add tag
84
+ save_queue.add tag # you may use also #<<, #push methods
67
85
  end
68
86
  end
69
87
 
70
- 6. Use it:
88
+ 6. Voila!
71
89
 
72
90
  article = Article.new
73
- tag_objects = [Tag.new, Tag.new, Tag.new]
74
- article.tags = tag_object
75
- article.add_tag Tag.new
91
+
92
+ tag_objects = []
93
+ 3.times do
94
+ tag = Tag.new
95
+ tag.change_attribute :title, "new tag"
96
+ tag.should_receive(:save).once
97
+ tag_objects << tag
98
+ end
99
+
100
+ article.tags = tag_objects
101
+
102
+ tag = Tag.new
103
+ tag.change_attribute :title, "single tag"
104
+ tag.should_receive(:save).once
105
+
106
+ article.add_tag tag
76
107
 
77
108
  # that will save article and all tags in this article if article
78
109
  # and tags are valid, and if article.save and all tag.save returns true
79
- article.save
110
+ # You may also use #save! method, that will trigger save_queue.save! and
111
+ # raise SaveQueue::FailedSaveError on fail
112
+ article.save.should be_true
80
113
 
81
- 7. Handle errors
114
+ # You may call save on queue explicitly:
115
+ #
116
+ # article.save_queue.save
117
+ # article.save
82
118
 
83
- 7.1. You did not include SaveQueue::Plugins::Validation:
119
+ 7. Read README for more details :)
84
120
 
85
- begin
86
- article.save
87
- rescue SaveQueue::FailedSaveError => save_error
88
121
 
89
- # @params [Hash] info
90
- # @option info [Array<Object>] :saved
91
- # @option info [Object] :failed
92
- # @option info [Array<Object>] :pending
93
- save_error.context
94
- end
122
+ ### Tracking changes
123
+ By default SaveQueue provide changes tracking functional.
124
+ In order to use it, call #mark_as_changed method in your mutator methods like this:
95
125
 
96
- 7.2. You've included SaveQueue::Plugins::Validation:
126
+ require "save_queue"
127
+ class Artice
128
+ include SaveQueue
97
129
 
98
- # Note nothing was actually saved. You dont need to do a cleanup
99
- unless article.save then
100
- failed_objects = article.saved_query.objects_with_errors
101
- end
130
+ def change_attribute attr, value
131
+ @attributes[attr] = value
132
+ mark_as_changed # call this and object will be marked for save
133
+ end
134
+ end
102
135
 
136
+ If you want to mark object as saved, you may use #mark_as_saved method. SaveQueue will automatically call #mark_as_saved
137
+ after saving an object.
138
+ This marks are used when SaveQueue calls #save. Object will be saved only, if it #has_unsaved_changes? returns true.
139
+ There are some docs from spec tests:
103
140
 
141
+ #has_unsaved_changes?
142
+ should return true for changed object
143
+ should return false for unchanged object
144
+ should return false for new object
104
145
 
105
146
  If you have custom logic for marking objects dirty then you may want to override
106
- \#has_unsaved_changes? method in you class like this:
147
+ \#has_unsaved_changes? method, methods #mark_as_saved and #mark_as_changed in you class like this:
107
148
 
108
149
  def has_unsaved_changes?
109
- dirty? # dirty is you custom method to determine has object unsaved_changes or not
150
+ dirty? # dirty is your custom method to determine has object unsaved_changes or not
151
+ end
152
+
153
+ def mark_as_saved
154
+ # your custom methods
155
+ end
156
+
157
+ def mark_as_changed
158
+ # your custom methods
159
+ end
160
+
161
+
162
+ ### Error handling
163
+
164
+ SaveQueue assumes, that #save method returns true/false and #save! raise an Exception if save failed:
165
+
166
+ unless article.save
167
+ # You may use article.save_queue.errors.any? or article.save_queue.errors.empty? also
168
+
169
+ # returns a [Hash] that contains information about saving proccess:
170
+ # @option [Array<Object>] :processed
171
+ # @option [Array<Object>] :saved
172
+ # @option [Object] :failed
173
+ # @option [Array<Object>] :pending
174
+ article.save_queue.errors[:save]
175
+ end
176
+
177
+
178
+ begin
179
+ article.save!
180
+ rescue SaveQueue::FailedSaveError => error
181
+
182
+ # returns a [Hash] that contains information about saving proccess:
183
+ # @option [Array<Object>] :processed
184
+ # @option [Array<Object>] :saved
185
+ # @option [Object] :failed
186
+ # @option [Array<Object>] :pending
187
+ error.context
188
+
189
+ article.save_queue.errors[:save] # also set
110
190
  end
111
191
 
112
- method \#mark_as_saved becomes useless in this case and you should mark objects by your self.
113
192
 
114
193
 
115
- Note: Today Save Queue use only #save method to perform save actions on an objects, but later this should be changed to custom option.
194
+ Plugins
195
+ -------
196
+ I am trying to extract any "extra" functionality into separate plugins, that you may want to include.
197
+
198
+ ### Validation
199
+
200
+ If you want to use validation, include SaveQueue::Plugins::Validation and implement #valid? method.
201
+ You may got failed objects from save_queue.errors\[:validation] array.
202
+ \save_queue.errors are empty if no errors occurs
203
+
204
+ require 'save_queue'
205
+ require 'save_queue/plugins/validation'
206
+
207
+ class Artice
208
+ include SaveQueue
209
+ include SaveQueue::Plugins::Validation
210
+
211
+ # @return [boolean]
212
+ def valid?
213
+ true
214
+ end
215
+
216
+ # ...
217
+ end
218
+
219
+ There are specs for them:
220
+
221
+ ValidQueue
222
+ invalid objects
223
+ save
224
+ should not be saved
225
+ should set errors
226
+ save!
227
+ should raise SaveQueue::FailedValidationError exception
228
+ should set errors
229
+ valid objects
230
+ save
231
+ should be saved
232
+ should not set errors
233
+ save!
234
+ should not raise an exception
235
+ should not set errors
236
+
237
+ Also you got more error hangling options:
238
+
239
+ # Note: queue was not saved. You dont need to do a cleanup
240
+ unless article.save then
241
+ failed_objects = article.errors[:validation]
242
+ end
243
+
244
+ begin
245
+ article.save!
246
+ rescue SaveQueue::FailedValidationError => error
247
+ # [Array<Object>]
248
+ error.failed_objects
249
+
250
+ article.save_queue.errors[:validation] # also set
251
+ end
252
+
253
+ You may catch both save and validation errors by
254
+
255
+ begin
256
+ article.save!
257
+ rescue SaveQueue::Error
258
+ # do something
259
+ end
260
+
261
+ if you want not to save an object if save_queue is invalid then add this check to your save method (or any other method that you use, ex: valid?):
262
+
263
+ def save
264
+ return false unless save_queue.valid?
265
+ #..
266
+ end
267
+
268
+ or you may add it to your validation.
269
+ Note, that #valid? and #validate return true/false and #validate! raises SaveQueue::FailedValidationError exception
270
+
271
+ ### Notification
272
+
273
+ If you want to use notification, include SaveQueue::Plugins::Notification.
274
+ You'll get object notified by #queue_changed_event method, which by default call #mark_as_changed method if queue was successfuly changed.
275
+ You may override this method in your object if you want to.
276
+
277
+ class Artice
278
+ include SaveQueue
279
+ include SaveQueue::Plugins::Notification
280
+ end
281
+
282
+ article = Article.new
283
+ article.mark_as_saved
284
+ article.save_queue << tag
285
+ article.should have_unsaved changes
286
+
287
+ class Artice
288
+ def queue_changed_event(result, object)
289
+ super
290
+ puts "queue was changed!"
291
+ end
292
+ end
293
+
294
+ article = Article.new
295
+ article.mark_as_saved
296
+ article.save_queue << tag # "queue was changed!"
297
+ article.should have_unsaved changes
298
+
299
+
300
+ Creating your own Queues
301
+ -------------------------
302
+
303
+ / TODO
304
+
305
+ FAQ
306
+ ---
307
+
308
+ __Q: I use #write method to store object, how can i use SaveQueue?__
309
+
310
+ A: You may implement save method like this:
311
+
312
+ class Artice
313
+ # @return [boolean]
314
+ def save
315
+ write
316
+ end
317
+ end
318
+
319
+ Note that SaveQueue assumes, that #save method returns true/false and #save! raise an Exception if save failed
320
+
321
+ __Q: Where i can get more information?__
322
+
323
+ A: See test specs for more details.
324
+
325
+ __How?__
326
+
327
+ clone git project by
328
+
329
+ git clone git://github.com/AlexParamonov/save_queue.git
330
+
331
+ cd into it and run bundle
332
+
333
+ cd save_queue
334
+ bundle
335
+
336
+ and run rake
337
+
338
+ rake
339
+
116
340
 
117
341
  Requirements
118
342
  ------------
119
343
 
120
- * ActiveSupport
344
+ * hooks
121
345
  * rspec2 for testing
122
346
 
123
347
  Compatibility
@@ -127,7 +351,9 @@ tested with Ruby
127
351
  * 1.8.7
128
352
  * 1.9.2
129
353
  * 1.9.3
130
- * jruby
354
+ * jruby-18mode
355
+ * rbx-19mode
356
+ * rbx-18mode
131
357
  * ruby-head
132
358
  * ree
133
359
 
@@ -135,4 +361,5 @@ see [build history](http://travis-ci.org/#!/AlexParamonov/save_queue/builds)
135
361
 
136
362
  Copyright
137
363
  ---------
138
- Copyright © 2011 Alexander N Paramonov. See LICENSE for details.
364
+ Copyright © 2011-2012 Alexander N Paramonov.
365
+ Released under the MIT License. See the LICENSE file for further details.
data/Rakefile CHANGED
@@ -1,5 +1,12 @@
1
+ # encoding: utf-8
2
+ # GEMS
1
3
  require "bundler/gem_tasks"
2
- require 'rspec'
4
+
5
+ # SPECS
6
+ require 'rspec/core'
3
7
  require 'rspec/core/rake_task'
4
- RSpec::Core::RakeTask.new(:spec)
5
- task :default => [:spec]
8
+ RSpec::Core::RakeTask.new(:spec) do |spec|
9
+ spec.pattern = FileList['spec/**/*_spec.rb']
10
+ end
11
+ #Rake::Task["spec"].execute
12
+ task :default => :spec
@@ -0,0 +1,13 @@
1
+ module SaveQueue
2
+ class Error < RuntimeError; end
3
+ class FailedSaveError < Error
4
+ attr_reader :context
5
+ def initialize(context_hash)
6
+ @context = context_hash
7
+ end
8
+
9
+ def to_s # Some default way to display errors
10
+ "#{super}: " + @context.to_s
11
+ end
12
+ end
13
+ end