has_draft 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ has_draft (1.0.1)
5
+ activerecord (>= 3.0.0)
6
+ activesupport (>= 3.0.0)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ activemodel (3.0.6)
12
+ activesupport (= 3.0.6)
13
+ builder (~> 2.1.2)
14
+ i18n (~> 0.5.0)
15
+ activerecord (3.0.6)
16
+ activemodel (= 3.0.6)
17
+ activesupport (= 3.0.6)
18
+ arel (~> 2.0.2)
19
+ tzinfo (~> 0.3.23)
20
+ activesupport (3.0.6)
21
+ arel (2.0.9)
22
+ builder (2.1.2)
23
+ diff-lcs (1.1.2)
24
+ factory_girl (1.3.3)
25
+ faker (0.9.5)
26
+ i18n (~> 0.4)
27
+ i18n (0.5.0)
28
+ rspec (2.5.0)
29
+ rspec-core (~> 2.5.0)
30
+ rspec-expectations (~> 2.5.0)
31
+ rspec-mocks (~> 2.5.0)
32
+ rspec-core (2.5.1)
33
+ rspec-expectations (2.5.0)
34
+ diff-lcs (~> 1.1.2)
35
+ rspec-mocks (2.5.0)
36
+ sqlite3 (1.3.3)
37
+ sqlite3-ruby (1.3.3)
38
+ sqlite3 (>= 1.3.3)
39
+ tzinfo (0.3.26)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ activerecord (>= 3.0.0)
46
+ activesupport (>= 3.0.0)
47
+ factory_girl (~> 1.3.1)
48
+ faker (~> 0.9.1)
49
+ has_draft!
50
+ rspec (~> 2.0)
51
+ sqlite3-ruby (~> 1.3.1)
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 [name of plugin creator]
1
+ Copyright (c) 2010 Ben Hughes
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,3 +1,3 @@
1
1
  module HasDraft
2
- VERSION = "1.0.1"
3
- end
2
+ VERSION = "1.0.2"
3
+ end
data/lib/has_draft.rb CHANGED
@@ -20,8 +20,8 @@ module HasDraft
20
20
  :foreign_key => draft_foreign_key,
21
21
  :dependent => :destroy
22
22
 
23
- named_scope :with_draft, :include => [:draft], :conditions => "#{draft_table_name}.id IS NOT NULL"
24
- named_scope :without_draft, :include => [:draft], :conditions => "#{draft_table_name}.id IS NULL"
23
+ scope :with_draft, includes(:draft).where("#{draft_table_name}.id IS NOT NULL")
24
+ scope :without_draft, includes(:draft).where("#{draft_table_name}.id IS NULL")
25
25
  end
26
26
 
27
27
  # Dynamically Create Model::Draft Class
@@ -62,16 +62,16 @@ module HasDraft
62
62
  end
63
63
 
64
64
  def instantiate_draft
65
- self.draft = self.build_draft
65
+ self.build_draft
66
66
 
67
67
  copy_attributes_to_draft
68
68
  before_instantiate_draft
69
69
 
70
- self.draft
70
+ self.draft.tap(&:save)
71
71
  end
72
72
 
73
73
  def instantiate_draft!
74
- returning instantiate_draft do |draft|
74
+ instantiate_draft do |draft|
75
75
  draft.save unless self.new_record?
76
76
  end
77
77
  end
data/spec/db/test.sqlite3 CHANGED
Binary file
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,6 @@ require "rubygems"
2
2
  require "rspec"
3
3
  require "factory_girl"
4
4
  require "faker"
5
- require "rails"
6
5
  require "active_record"
7
6
  require "active_support"
8
7
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_draft
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ben Hughes
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-15 00:00:00 +08:00
18
+ date: 2011-04-15 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -50,6 +50,69 @@ dependencies:
50
50
  version: 3.0.0
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: rspec
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 2
64
+ - 0
65
+ version: "2.0"
66
+ type: :development
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: factory_girl
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ hash: 25
77
+ segments:
78
+ - 1
79
+ - 3
80
+ - 1
81
+ version: 1.3.1
82
+ type: :development
83
+ version_requirements: *id004
84
+ - !ruby/object:Gem::Dependency
85
+ name: faker
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ~>
91
+ - !ruby/object:Gem::Version
92
+ hash: 57
93
+ segments:
94
+ - 0
95
+ - 9
96
+ - 1
97
+ version: 0.9.1
98
+ type: :development
99
+ version_requirements: *id005
100
+ - !ruby/object:Gem::Dependency
101
+ name: sqlite3-ruby
102
+ prerelease: false
103
+ requirement: &id006 !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ~>
107
+ - !ruby/object:Gem::Version
108
+ hash: 25
109
+ segments:
110
+ - 1
111
+ - 3
112
+ - 1
113
+ version: 1.3.1
114
+ type: :development
115
+ version_requirements: *id006
53
116
  description: Allows for your ActiveRecord models to have drafts which are stored in a separate duplicate table.
54
117
  email: ben@railsgarden.com
55
118
  executables: []
@@ -68,7 +131,8 @@ files:
68
131
  - spec/factories/article.rb
69
132
  - spec/has_draft_spec.rb
70
133
  - spec/spec_helper.rb
71
- - CHANGELOG.rdoc
134
+ - Gemfile
135
+ - Gemfile.lock
72
136
  - LICENSE
73
137
  - Rakefile
74
138
  - README.rdoc
data/CHANGELOG.rdoc DELETED
@@ -1,10 +0,0 @@
1
- == [2010-10-15] 1.0.1 Minor fix to homepage URL
2
-
3
- == [2010-10-15] 1.0.0 Major Updates
4
-
5
- * Finally updated to be a Gem
6
- * Internal refactoring
7
- * Converted tests to RSpec
8
- * Added support for Rails 3.0
9
-
10
- == 0.1.0 Initial Version