semanticart-is_paranoid 0.9.0 → 0.9.3

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.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ is_paranoid.db
2
+ pkg
3
+ *.gem
4
+ doc/
data/CHANGELOG ADDED
@@ -0,0 +1,34 @@
1
+ This will only document major changes. Please see the commit log for minor changes.
2
+
3
+ -2009-09-15
4
+ * added support for has_many associations (i.e. @r2d2.components_with_destroyed) via Amiel Martin
5
+
6
+ -2009-06-13
7
+ * added support for is_paranoid conditions being maintained on preloaded associations
8
+ * destroy and restore now return self (to be more in keeping with other ActiveRecord methods) via Brent Dillingham
9
+
10
+ -2009-05-19
11
+ * added support for specifying relationships to restore via instance_model.restore(:include => [:parent_1, :child_1, :child_2]), etc.
12
+ * method_missing is no longer overridden on instances provided you declare your custom method_missing *before* specifying the model is_paranoid
13
+
14
+ -2009-05-12
15
+ * added support for parent_with_destroyed methods
16
+
17
+ -2009-04-27
18
+ * restoring models now cascades to child dependent => destroy models via Matt Todd
19
+
20
+ -2009-04-22
21
+ * destroying and restoring records no longer triggers saving/updating callbacks
22
+
23
+ -2009-03-28
24
+ * removing syntax for calculation require (all find and ActiveRecord calculations are done on-the-fly now via method_missing)
25
+ * adding ability to specify alternate fields and values for destroyed objects
26
+ * adding in support for _destroyed_only methods (with inspiration from David Krmpotic)
27
+ * adding init.rb via David Krmpotic
28
+ * adding jewler tasks via Scott Woods
29
+
30
+ -2009-03-24
31
+ * requiring specific syntax to include calculations
32
+
33
+ -2009-03-21
34
+ * initial release
data/MIT-LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2009 Jeffrey Chupp
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all 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,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.textile CHANGED
@@ -17,7 +17,7 @@ If you're working with Rails, in your environment.rb, add the following to your
17
17
  <pre>
18
18
  Rails::Initializer.run do |config|
19
19
  # ...
20
- config.gem "jchupp-is_paranoid", :lib => 'is_paranoid', :version => ">= 0.0.1"
20
+ config.gem "semanticart-is_paranoid", :lib => 'is_paranoid', :version => ">= 0.0.1"
21
21
  end
22
22
  </pre>
23
23
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 9
3
- :patch: 0
3
+ :patch: 3
4
4
  :major: 0
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'is_paranoid'
@@ -0,0 +1,56 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{is_paranoid}
8
+ s.version = "0.9.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jeffrey Chupp"]
12
+ s.date = %q{2009-09-15}
13
+ s.description = %q{}
14
+ s.email = %q{jeff@semanticart.com}
15
+ s.extra_rdoc_files = [
16
+ "README.textile"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "CHANGELOG",
21
+ "MIT-LICENSE",
22
+ "README.textile",
23
+ "Rakefile",
24
+ "VERSION.yml",
25
+ "init.rb",
26
+ "is_paranoid.gemspec",
27
+ "lib/is_paranoid.rb",
28
+ "spec/database.yml",
29
+ "spec/is_paranoid_spec.rb",
30
+ "spec/models.rb",
31
+ "spec/schema.rb",
32
+ "spec/spec.opts",
33
+ "spec/spec_helper.rb"
34
+ ]
35
+ s.homepage = %q{http://github.com/jchupp/is_paranoid/}
36
+ s.rdoc_options = ["--charset=UTF-8"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = %q{1.3.5}
39
+ s.summary = %q{ActiveRecord 2.3 compatible gem "allowing you to hide and restore records without actually deleting them." Yes, like acts_as_paranoid, only with less code and less complexity.}
40
+ s.test_files = [
41
+ "spec/is_paranoid_spec.rb",
42
+ "spec/models.rb",
43
+ "spec/schema.rb",
44
+ "spec/spec_helper.rb"
45
+ ]
46
+
47
+ if s.respond_to? :specification_version then
48
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
49
+ s.specification_version = 3
50
+
51
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
52
+ else
53
+ end
54
+ else
55
+ end
56
+ end
data/lib/is_paranoid.rb CHANGED
@@ -176,15 +176,30 @@ module IsParanoid
176
176
 
177
177
  self.class.send(
178
178
  :include,
179
- Module.new{ # Example:
180
- define_method name do |*args| # def android_with_destroyed
181
- parent_klass.first_with_destroyed( # Android.first_with_destroyed(
182
- :conditions => { # :conditions => {
183
- parent_klass.primary_key => # :id =>
184
- self.send(assoc.primary_key_name) # self.send(:android_id)
185
- } # }
186
- ) # )
187
- end # end
179
+ Module.new {
180
+ if assoc.macro.to_s =~ /^has/
181
+ parent_method = assoc.macro.to_s =~ /^has_one/ ? 'first_with_destroyed' : 'all_with_destroyed'
182
+ # Example:
183
+ define_method name do |*args| # def android_with_destroyed
184
+ parent_klass.send("#{parent_method}", # Android.all_with_destroyed(
185
+ :conditions => { # :conditions => {
186
+ assoc.primary_key_name => # :person_id =>
187
+ self.send(parent_klass.primary_key) # self.send(:id)
188
+ } # }
189
+ ) # )
190
+ end # end
191
+
192
+ else
193
+ # Example:
194
+ define_method name do |*args| # def android_with_destroyed
195
+ parent_klass.first_with_destroyed( # Android.first_with_destroyed(
196
+ :conditions => { # :conditions => {
197
+ parent_klass.primary_key => # :id =>
198
+ self.send(assoc.primary_key_name) # self.send(:android_id)
199
+ } # }
200
+ ) # )
201
+ end # end
202
+ end
188
203
  }
189
204
  )
190
205
  self.send(name, *args, &block)
data/spec/database.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  test:
2
2
  :adapter: sqlite3
3
- :dbfile: is_paranoid.db
3
+ :database: is_paranoid.db
@@ -203,6 +203,13 @@ describe IsParanoid do
203
203
  end
204
204
  end
205
205
 
206
+ it "should be able to access destroyed children" do
207
+ comps = @r2d2.components
208
+ comps.to_s # I have no idea why this makes it pass, but hey, here it is
209
+ @r2d2.components.first.destroy
210
+ @r2d2.components_with_destroyed.should == comps
211
+ end
212
+
206
213
  it "should return nil if no destroyed parent exists" do
207
214
  sticker = Sticker.new(:name => 'Rainbows')
208
215
  # because the default relationship works this way, i.e.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semanticart-is_paranoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Chupp
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-13 00:00:00 -07:00
12
+ date: 2009-09-15 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -22,9 +22,14 @@ extensions: []
22
22
  extra_rdoc_files:
23
23
  - README.textile
24
24
  files:
25
+ - .gitignore
26
+ - CHANGELOG
27
+ - MIT-LICENSE
25
28
  - README.textile
26
29
  - Rakefile
27
30
  - VERSION.yml
31
+ - init.rb
32
+ - is_paranoid.gemspec
28
33
  - lib/is_paranoid.rb
29
34
  - spec/database.yml
30
35
  - spec/is_paranoid_spec.rb
@@ -32,8 +37,9 @@ files:
32
37
  - spec/schema.rb
33
38
  - spec/spec.opts
34
39
  - spec/spec_helper.rb
35
- has_rdoc: true
40
+ has_rdoc: false
36
41
  homepage: http://github.com/jchupp/is_paranoid/
42
+ licenses:
37
43
  post_install_message:
38
44
  rdoc_options:
39
45
  - --charset=UTF-8
@@ -54,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
60
  requirements: []
55
61
 
56
62
  rubyforge_project:
57
- rubygems_version: 1.2.0
63
+ rubygems_version: 1.3.5
58
64
  signing_key:
59
65
  specification_version: 3
60
66
  summary: ActiveRecord 2.3 compatible gem "allowing you to hide and restore records without actually deleting them." Yes, like acts_as_paranoid, only with less code and less complexity.