acts_as_archival 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 175bbdb26230acbbbee4329bda6dd6bfc6eae3d5
4
+ data.tar.gz: d07f9da7b94fa39b6768cb369e20f7f84ddd4585
5
+ SHA512:
6
+ metadata.gz: 995e99fa5c849235e10b5b7588cf1fa62fcb97271833ca941462d832769fd32ffbefd02f3d0f9dbacdb6bd0bb3c0bfd65b2fd6ea08425d937cd7e42aa82ecc27
7
+ data.tar.gz: 00f416f9999d273e490d56aad4309f3b639518a4868c904fb79d7f3a747b0c6b70df4c108646e8b91205ffc14d7f77d594d069c6bb912b4c0ee04cf92bd2f81c
data/.gitignore CHANGED
@@ -4,7 +4,7 @@
4
4
  bin
5
5
  vendor/bundle
6
6
  *.gem
7
- Gemfile.lock
7
+ *emfile.lock
8
8
  pkg/*
9
9
  .DS_Store
10
10
  *.sqlite3
data/Appraisals ADDED
@@ -0,0 +1,11 @@
1
+ appraise "rails-3" do
2
+ gem "rails", ">= 3.0.0", "< 4.0"
3
+ end
4
+
5
+ appraise "rails-4" do
6
+ gem "rails", "~> 4.0.0"
7
+ end
8
+
9
+ appraise "rails-4.1" do
10
+ gem "rails", "~> 4.1.0"
11
+ end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changes!
2
2
 
3
+ ## 0.6.1
4
+ * Fix deprecation warnings on Rails 4.1
5
+ * Test suite now runs against multiple versions of Rails
6
+ * Fully automated test suite setup
7
+
3
8
  ## 0.6.0
4
9
  * **BREAKING CHANGE** (possibly): Some refactoring to modern gem module idioms instead of old school plugins
5
10
  * Officially support PostgreSQL
data/README.md CHANGED
@@ -120,14 +120,12 @@ to conditionally add the functionality to older Rails installations.
120
120
 
121
121
  ## Testing
122
122
 
123
- Because this plugin makes use of transactions we're testing it (mostly) on sqlite. Running the tests should be as easy as:
123
+ Running the tests should be as easy as:
124
124
 
125
125
  ``` bash
126
- bundle # if this fails you might need to install/configure some databases
127
- test/script/db_setup # makes the databases with the correct permissions (for mySQL)
128
- createuser -D -A -P archival_tester # makes user for PostgreSQL; answer the password prompt with "perspicacious"
129
- createdb -O archival_tester aaa_test # makes db for PostgreSQL and sets owner to our test user
130
- rake
126
+ script/setup # bundles, makes databases with permissions
127
+ rake # run tests on latest Rails
128
+ appraisal rake # run tests on all versions of Rails
131
129
  ```
132
130
 
133
131
  ## Help Wanted
@@ -151,7 +149,7 @@ ActsAsParanoid and PermanentRecords were both inspirations for this:
151
149
  * Dave Woodward
152
150
  * Miles Sterrett
153
151
  * James Hill
154
- * Marten Claes
152
+ * Maarten Claes
155
153
 
156
154
  Thanks!
157
155
 
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
  "Dave Woodward",
15
15
  "Miles Sterrett",
16
16
  "James Hill",
17
- "Marten Claes"]
17
+ "Maarten Claes"]
18
18
  gem.email = ["joel@expectedbehavior.com",
19
19
  "michael@expectedbehavior.com",
20
20
  "matt@expectedbehavior.com",
@@ -29,15 +29,16 @@ Gem::Specification.new do |gem|
29
29
 
30
30
  gem.add_dependency "activerecord"
31
31
 
32
+ gem.add_development_dependency "appraisal"
32
33
  gem.add_development_dependency "assertions-eb"
33
34
  gem.add_development_dependency "rake"
34
35
  gem.add_development_dependency "mysql2"
35
36
  gem.add_development_dependency "sqlite3"
36
37
  gem.add_development_dependency "pg"
37
- gem.add_development_dependency "highline"
38
38
  gem.add_development_dependency "rr"
39
39
  gem.add_development_dependency "database_cleaner"
40
40
 
41
+
41
42
  gem.description = <<-END
42
43
  *Atomic archiving/unarchiving for ActiveRecord-based apps*
43
44
 
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", ">= 3.0.0", "< 4.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.1.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.0.0"
6
+
7
+ gemspec :path => "../"
@@ -1,3 +1,3 @@
1
1
  module ActsAsArchival
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
@@ -23,7 +23,7 @@ module ExpectedBehavior
23
23
  scope :archived_from_archive_number, lambda { |head_archive_number| where(['archived_at IS NOT NULL AND archive_number = ?', head_archive_number]) }
24
24
 
25
25
  callbacks = ['archive','unarchive']
26
- define_callbacks *[callbacks, {:terminator => 'result == false'}].flatten
26
+ define_callbacks *[callbacks, {:terminator => lambda { |_, result| result == false }}].flatten
27
27
  callbacks.each do |callback|
28
28
  eval <<-end_callbacks
29
29
  def before_#{callback}(*args, &blk)
data/script/db_setup ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env ruby
2
+ require "bundler/setup"
3
+ require "yaml"
4
+
5
+ STDOUT.sync = true
6
+
7
+ DB_CONFIG = YAML.load(File.read(File.join(File.dirname(__FILE__), "..", "test", "database.yml")))
8
+
9
+ def execute_mysql(statement, password = nil)
10
+ password_option = if password.to_s.size > 0
11
+ "-p'#{password}'"
12
+ end
13
+ command = %Q{echo '#{statement}' | mysql -u root #{password_option}}
14
+ puts command
15
+ system(command)
16
+ end
17
+
18
+ def execute_postgres(statement)
19
+ command = %Q{echo "#{statement}" | psql postgres}
20
+ puts command
21
+ system(command)
22
+ end
23
+
24
+ def setup_mysql
25
+ mysql_root_password = nil
26
+ if !execute_mysql("SHOW DATABASES;", mysql_root_password)
27
+ loop do
28
+ print "MySQL root password to setup '#{DB_CONFIG["mysql"]["database"]}': "
29
+ mysql_root_password = gets.chomp
30
+ if execute_mysql("SHOW DATABASES;", mysql_root_password)
31
+ break
32
+ end
33
+ end
34
+ end
35
+
36
+ config = DB_CONFIG["mysql"]
37
+ execute_mysql("DROP DATABASE IF EXISTS #{config["database"]};", mysql_root_password)
38
+ execute_mysql("CREATE DATABASE #{config["database"]};", mysql_root_password)
39
+ execute_mysql(%Q{GRANT ALL ON `#{config["database"]}`.* TO `#{config["username"]}` IDENTIFIED BY "#{config["password"]}";}, mysql_root_password)
40
+ end
41
+
42
+ def setup_postgres
43
+ config = DB_CONFIG["pg"]
44
+ execute_postgres(%Q{DROP DATABASE IF EXISTS #{config["database"]};})
45
+ execute_postgres(%Q{DROP ROLE IF EXISTS #{config["username"]};})
46
+ execute_postgres(%Q{CREATE ROLE #{config["username"]} WITH PASSWORD '#{config["password"]}' LOGIN;})
47
+ execute_postgres(%Q{CREATE DATABASE #{config["database"]} WITH OWNER #{config["username"]};})
48
+ end
49
+
50
+ setup_mysql
51
+ setup_postgres
data/script/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+ set -e
3
+ cd "`dirname \"$0\"`/.."
4
+
5
+ bundle install
6
+ script/db_setup
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_archival
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
5
- prerelease:
4
+ version: 0.6.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Joel Meador
@@ -13,180 +12,152 @@ authors:
13
12
  - Dave Woodward
14
13
  - Miles Sterrett
15
14
  - James Hill
16
- - Marten Claes
15
+ - Maarten Claes
17
16
  autorequire:
18
17
  bindir: bin
19
18
  cert_chain: []
20
- date: 2014-04-14 00:00:00.000000000 Z
19
+ date: 2014-07-24 00:00:00.000000000 Z
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
22
  name: activerecord
24
23
  requirement: !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
- - - ! '>='
25
+ - - ">="
28
26
  - !ruby/object:Gem::Version
29
27
  version: '0'
30
28
  type: :runtime
31
29
  prerelease: false
32
30
  version_requirements: !ruby/object:Gem::Requirement
33
- none: false
34
31
  requirements:
35
- - - ! '>='
32
+ - - ">="
36
33
  - !ruby/object:Gem::Version
37
34
  version: '0'
38
35
  - !ruby/object:Gem::Dependency
39
- name: assertions-eb
36
+ name: appraisal
40
37
  requirement: !ruby/object:Gem::Requirement
41
- none: false
42
38
  requirements:
43
- - - ! '>='
39
+ - - ">="
44
40
  - !ruby/object:Gem::Version
45
41
  version: '0'
46
42
  type: :development
47
43
  prerelease: false
48
44
  version_requirements: !ruby/object:Gem::Requirement
49
- none: false
50
45
  requirements:
51
- - - ! '>='
46
+ - - ">="
52
47
  - !ruby/object:Gem::Version
53
48
  version: '0'
54
49
  - !ruby/object:Gem::Dependency
55
- name: rake
50
+ name: assertions-eb
56
51
  requirement: !ruby/object:Gem::Requirement
57
- none: false
58
52
  requirements:
59
- - - ! '>='
53
+ - - ">="
60
54
  - !ruby/object:Gem::Version
61
55
  version: '0'
62
56
  type: :development
63
57
  prerelease: false
64
58
  version_requirements: !ruby/object:Gem::Requirement
65
- none: false
66
59
  requirements:
67
- - - ! '>='
60
+ - - ">="
68
61
  - !ruby/object:Gem::Version
69
62
  version: '0'
70
63
  - !ruby/object:Gem::Dependency
71
- name: mysql2
64
+ name: rake
72
65
  requirement: !ruby/object:Gem::Requirement
73
- none: false
74
66
  requirements:
75
- - - ! '>='
67
+ - - ">="
76
68
  - !ruby/object:Gem::Version
77
69
  version: '0'
78
70
  type: :development
79
71
  prerelease: false
80
72
  version_requirements: !ruby/object:Gem::Requirement
81
- none: false
82
73
  requirements:
83
- - - ! '>='
74
+ - - ">="
84
75
  - !ruby/object:Gem::Version
85
76
  version: '0'
86
77
  - !ruby/object:Gem::Dependency
87
- name: sqlite3
78
+ name: mysql2
88
79
  requirement: !ruby/object:Gem::Requirement
89
- none: false
90
80
  requirements:
91
- - - ! '>='
81
+ - - ">="
92
82
  - !ruby/object:Gem::Version
93
83
  version: '0'
94
84
  type: :development
95
85
  prerelease: false
96
86
  version_requirements: !ruby/object:Gem::Requirement
97
- none: false
98
87
  requirements:
99
- - - ! '>='
88
+ - - ">="
100
89
  - !ruby/object:Gem::Version
101
90
  version: '0'
102
91
  - !ruby/object:Gem::Dependency
103
- name: pg
92
+ name: sqlite3
104
93
  requirement: !ruby/object:Gem::Requirement
105
- none: false
106
94
  requirements:
107
- - - ! '>='
95
+ - - ">="
108
96
  - !ruby/object:Gem::Version
109
97
  version: '0'
110
98
  type: :development
111
99
  prerelease: false
112
100
  version_requirements: !ruby/object:Gem::Requirement
113
- none: false
114
101
  requirements:
115
- - - ! '>='
102
+ - - ">="
116
103
  - !ruby/object:Gem::Version
117
104
  version: '0'
118
105
  - !ruby/object:Gem::Dependency
119
- name: highline
106
+ name: pg
120
107
  requirement: !ruby/object:Gem::Requirement
121
- none: false
122
108
  requirements:
123
- - - ! '>='
109
+ - - ">="
124
110
  - !ruby/object:Gem::Version
125
111
  version: '0'
126
112
  type: :development
127
113
  prerelease: false
128
114
  version_requirements: !ruby/object:Gem::Requirement
129
- none: false
130
115
  requirements:
131
- - - ! '>='
116
+ - - ">="
132
117
  - !ruby/object:Gem::Version
133
118
  version: '0'
134
119
  - !ruby/object:Gem::Dependency
135
120
  name: rr
136
121
  requirement: !ruby/object:Gem::Requirement
137
- none: false
138
122
  requirements:
139
- - - ! '>='
123
+ - - ">="
140
124
  - !ruby/object:Gem::Version
141
125
  version: '0'
142
126
  type: :development
143
127
  prerelease: false
144
128
  version_requirements: !ruby/object:Gem::Requirement
145
- none: false
146
129
  requirements:
147
- - - ! '>='
130
+ - - ">="
148
131
  - !ruby/object:Gem::Version
149
132
  version: '0'
150
133
  - !ruby/object:Gem::Dependency
151
134
  name: database_cleaner
152
135
  requirement: !ruby/object:Gem::Requirement
153
- none: false
154
136
  requirements:
155
- - - ! '>='
137
+ - - ">="
156
138
  - !ruby/object:Gem::Version
157
139
  version: '0'
158
140
  type: :development
159
141
  prerelease: false
160
142
  version_requirements: !ruby/object:Gem::Requirement
161
- none: false
162
143
  requirements:
163
- - - ! '>='
144
+ - - ">="
164
145
  - !ruby/object:Gem::Version
165
146
  version: '0'
166
- description: ! '*Atomic archiving/unarchiving for ActiveRecord-based apps*
167
-
147
+ description: |
148
+ *Atomic archiving/unarchiving for ActiveRecord-based apps*
168
149
 
169
150
  We had the problem that acts_as_paranoid and similar plugins/gems always work on
170
-
171
151
  a record by record basis and made it very difficult to restore records
172
-
173
152
  atomically (or archive them, for that matter).
174
153
 
175
-
176
154
  Because the archive and unarchive methods are in transactions, and every
177
-
178
155
  archival record involved gets the same archive number upon archiving, you can
179
-
180
156
  easily restore or remove an entire set of records without having to worry about
181
-
182
157
  partial deletion or restoration.
183
158
 
184
-
185
159
  Additionally, other plugins generally screw with how destroy/delete work. We
186
-
187
- don''t because we actually want to be able to destroy records.
188
-
189
- '
160
+ don't because we actually want to be able to destroy records.
190
161
  email:
191
162
  - joel@expectedbehavior.com
192
163
  - michael@expectedbehavior.com
@@ -198,14 +169,17 @@ executables: []
198
169
  extensions: []
199
170
  extra_rdoc_files: []
200
171
  files:
201
- - .gitignore
172
+ - ".gitignore"
173
+ - Appraisals
202
174
  - CHANGELOG.md
203
175
  - Gemfile
204
- - Gemfile.lock
205
176
  - LICENSE
206
177
  - README.md
207
178
  - Rakefile
208
179
  - acts_as_archival.gemspec
180
+ - gemfiles/rails_3.gemfile
181
+ - gemfiles/rails_4.1.gemfile
182
+ - gemfiles/rails_4.gemfile
209
183
  - init.rb
210
184
  - lib/acts_as_archival.rb
211
185
  - lib/acts_as_archival/version.rb
@@ -214,6 +188,8 @@ files:
214
188
  - lib/expected_behavior/association_operation/archive.rb
215
189
  - lib/expected_behavior/association_operation/base.rb
216
190
  - lib/expected_behavior/association_operation/unarchive.rb
191
+ - script/db_setup
192
+ - script/setup
217
193
  - test/ambiguous_table_test.rb
218
194
  - test/associations_test.rb
219
195
  - test/basic_test.rb
@@ -242,33 +218,31 @@ files:
242
218
  - test/responds_test.rb
243
219
  - test/schema.rb
244
220
  - test/scope_test.rb
245
- - test/script/db_setup
246
221
  - test/test_helper.rb
247
222
  - test/through_association_test.rb
248
223
  - test/transaction_test.rb
249
224
  homepage: http://github.com/expectedbehavior/acts_as_archival
250
225
  licenses: []
226
+ metadata: {}
251
227
  post_install_message:
252
228
  rdoc_options: []
253
229
  require_paths:
254
230
  - lib
255
231
  required_ruby_version: !ruby/object:Gem::Requirement
256
- none: false
257
232
  requirements:
258
- - - ! '>='
233
+ - - ">="
259
234
  - !ruby/object:Gem::Version
260
235
  version: '0'
261
236
  required_rubygems_version: !ruby/object:Gem::Requirement
262
- none: false
263
237
  requirements:
264
- - - ! '>='
238
+ - - ">="
265
239
  - !ruby/object:Gem::Version
266
240
  version: '0'
267
241
  requirements: []
268
242
  rubyforge_project:
269
- rubygems_version: 1.8.23
243
+ rubygems_version: 2.2.2
270
244
  signing_key:
271
- specification_version: 3
245
+ specification_version: 4
272
246
  summary: Atomic archiving/unarchiving for ActiveRecord-based apps
273
247
  test_files:
274
248
  - test/ambiguous_table_test.rb
@@ -299,7 +273,6 @@ test_files:
299
273
  - test/responds_test.rb
300
274
  - test/schema.rb
301
275
  - test/scope_test.rb
302
- - test/script/db_setup
303
276
  - test/test_helper.rb
304
277
  - test/through_association_test.rb
305
278
  - test/transaction_test.rb
data/test/script/db_setup DELETED
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require "bundler/setup"
3
- require "yaml"
4
- require 'highline/import'
5
-
6
- def read_database_config
7
- database_file = File.join(File.dirname(__FILE__), "/../", "database.yml")
8
- $DB_CONFIG = YAML.load(File.read(database_file))["mysql"]
9
- end
10
-
11
- def get_root_password
12
- $ROOT_PW = ask("Provide root mySQL password to setup '#{$DB_CONFIG["database"]}': ") { |q| q.echo = false}
13
- if !$ROOT_PW || $ROOT_PW.nil?
14
- puts "error reading password"
15
- exit 4
16
- end
17
- end
18
-
19
- def check_root_password
20
- password_check = "echo 'show databases;' | mysql -u root -p'#{$ROOT_PW}' > /dev/null"
21
- unless system password_check
22
- puts "incorrect password"
23
- exit 7
24
- end
25
- end
26
-
27
- def execute_mysql(message, statement, user = nil, password = nil)
28
- puts message
29
- `echo '#{statement}' | mysql -u #{user} -p'#{password}'`
30
- end
31
-
32
- def drop_existing(db, user, pass)
33
- drop_statement = "drop database if exists #{db};"
34
- execute_mysql("dropping #{db}", drop_statement, user, pass)
35
- end
36
-
37
- def create_db(db, user, pass)
38
- create_statement = "create database #{db};"
39
- execute_mysql("creating #{db}", create_statement, user, pass)
40
- end
41
-
42
- def grant_permission_on_db(db, user, pass)
43
- grant_statement = "grant all on `#{db}`.* to `#{$DB_CONFIG["username"]}`@`localhost` identified by \"#{$DB_CONFIG["password"]}\";"
44
- execute_mysql("granting on #{db}", grant_statement, user, pass)
45
- end
46
-
47
- read_database_config
48
- get_root_password
49
- check_root_password
50
-
51
- db = $DB_CONFIG["database"]
52
- user = "root"
53
- pass = $ROOT_PW
54
-
55
- drop_existing(db, user, pass)
56
- create_db(db, user, pass)
57
- grant_permission_on_db(db, user, pass)