acts_as_archive 0.1.5 → 0.1.6

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/README.markdown CHANGED
@@ -5,23 +5,22 @@ Don't delete your records, move them to a different table.
5
5
 
6
6
  Like <code>acts\_as\_paranoid</code>, but doesn't mess with your SQL queries.
7
7
 
8
+ Compatibility
9
+ -------------
10
+
11
+ Tested with Ruby 1.8.6, 1.8.7, and 1.9.1.
12
+
8
13
  Install
9
14
  -------
10
15
 
11
- script/plugin:
12
-
13
16
  <pre>
14
- script/plugin install git://github.com/winton/acts_as_archive.git
17
+ sudo gem install acts_as_archive --source http://gemcutter.org
15
18
  </pre>
16
19
 
17
- rubygems:
20
+ **environment.rb**:
18
21
 
19
22
  <pre>
20
- # terminal
21
- sudo gem install winton-acts_as_archive
22
-
23
- # environment.rb
24
- config.gem "winton-acts_as_archive", :lib => "acts_as_archive", :source => "http://gems.github.com"
23
+ config.gem 'acts_as_archive'
25
24
  </pre>
26
25
 
27
26
  Update models
@@ -44,7 +43,7 @@ Terminal:
44
43
 
45
44
  <pre>
46
45
  cd your_rails_app
47
- acts_as_archive
46
+ acts_as_archive Article
48
47
  </pre>
49
48
 
50
49
  This command creates your archive tables (<code>archived_articles</code> as per the example).
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ spec = Gem::Specification.new do |s|
17
17
  s.platform = Gem::Platform::RUBY
18
18
  s.require_path = "lib"
19
19
  s.summary = "Don't delete your records, move them to a different table"
20
- s.version = "0.1.5"
20
+ s.version = "0.1.6"
21
21
  end
22
22
 
23
23
  desc "Package gem"
@@ -28,8 +28,8 @@ end
28
28
  desc "Install gem"
29
29
  task :install do
30
30
  Rake::Task['gem'].invoke
31
- `sudo gem uninstall #{GEM_NAME} -x`
32
- `sudo gem install pkg/#{GEM_NAME}*.gem`
31
+ `gem uninstall #{GEM_NAME} -x`
32
+ `gem install pkg/#{GEM_NAME}*.gem`
33
33
  `rm -Rf pkg`
34
34
  end
35
35
 
@@ -42,7 +42,8 @@ end
42
42
 
43
43
  desc "Run specs"
44
44
  Spec::Rake::SpecTask.new do |t|
45
- t.rcov = true
46
45
  t.spec_opts = ["--format", "specdoc", "--colour"]
47
46
  t.spec_files = FileList["spec/**/*_spec.rb"]
48
- end
47
+ end
48
+
49
+ task :default => :spec
data/bin/acts_as_archive CHANGED
@@ -1,6 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.push File.expand_path("#{File.dirname(__FILE__)}/../lib")
4
- require 'acts_as_archive'
5
-
6
- puts `script/runner "ActsAsArchive.update"`
3
+ puts `script/runner "ActsAsArchive.update #{ARGV.join ', '}"`
@@ -3,6 +3,18 @@ require File.dirname(__FILE__) + "/base/restore"
3
3
  require File.dirname(__FILE__) + "/base/table"
4
4
 
5
5
  module ActsAsArchive
6
+
7
+ def self.update(*models)
8
+ models.each do |klass|
9
+ if klass.respond_to?(:acts_as_archive?) && klass.acts_as_archive?
10
+ klass.create_archive_table
11
+ klass.migrate_from_acts_as_paranoid
12
+ klass.create_archive_indexes
13
+ puts 'Success!'
14
+ end
15
+ end
16
+ end
17
+
6
18
  module Base
7
19
  def self.included(base)
8
20
  base.extend ActMethods
@@ -19,9 +19,9 @@ module ActsAsArchive
19
19
  if table_exists? && !archive_table_exists?
20
20
  connection.execute(%{
21
21
  CREATE TABLE archived_#{table_name}
22
- #{"ENGINE=InnoDB" unless sqlite?}
22
+ ENGINE=InnoDB
23
23
  AS SELECT * from #{table_name}
24
- WHERE 1 = 0;
24
+ WHERE false;
25
25
  })
26
26
  columns = connection.columns("archived_#{table_name}").collect(&:name)
27
27
  unless columns.include?('deleted_at')
@@ -56,12 +56,6 @@ module ActsAsArchive
56
56
  end
57
57
  end
58
58
  end
59
-
60
- private
61
-
62
- def sqlite?
63
- ActiveRecord::Base.connection.class.to_s.downcase.include?('sqlite')
64
- end
65
59
  end
66
60
 
67
61
  module InstanceMethods
data/rails/init.rb CHANGED
@@ -2,15 +2,3 @@ require File.expand_path(File.dirname(__FILE__) + "/../lib/acts_as_archive")
2
2
 
3
3
  ActiveRecord::Base.send(:include, ActsAsArchive::Base)
4
4
  ActiveRecord::Migration.send(:include, ActsAsArchive::Migration)
5
-
6
- module ActsAsArchive
7
- def self.update
8
- Object.subclasses_of(ActiveRecord::Base).each do |klass|
9
- if klass.respond_to?(:acts_as_archive?) && klass.acts_as_archive?
10
- klass.create_archive_table
11
- klass.migrate_from_acts_as_paranoid
12
- klass.create_archive_indexes
13
- end
14
- end
15
- end
16
- end
@@ -32,23 +32,17 @@ describe ActsAsArchive::Base::Table do
32
32
  describe 'create_archive_indexes' do
33
33
 
34
34
  before(:all) do
35
- unless Article.send(:sqlite?)
36
- Article.create_archive_indexes
37
- end
35
+ Article.create_archive_indexes
38
36
  end
39
37
 
40
38
  it "should create archive indexes" do
41
- unless Article.send(:sqlite?)
42
- indexes.should == [ "id", "deleted_at" ]
43
- end
39
+ indexes.should == [ "id", "deleted_at" ]
44
40
  end
45
41
 
46
42
  it "should destroy archive indexes" do
47
- unless Article.send(:sqlite?)
48
- Article.class_eval { acts_as_archive }
49
- Article.create_archive_indexes
50
- indexes.should == []
51
- end
43
+ Article.class_eval { acts_as_archive }
44
+ Article.create_archive_indexes
45
+ indexes.should == []
52
46
  end
53
47
  end
54
48
 
@@ -1,10 +1,6 @@
1
1
  test:
2
- adapter: sqlite3
3
- database: ":memory:"
4
- # test:
5
- # adapter: mysql
6
- # database: acts_as_archive
7
- # username: root
8
- # password:
9
- # host: localhost
10
- # socket: /tmp/mysql.sock
2
+ adapter: mysql
3
+ database: acts_as_archive
4
+ username: root
5
+ password:
6
+ host: localhost
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winton Welsh
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-24 00:00:00 -08:00
12
+ date: 2010-02-03 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -22,7 +22,6 @@ extensions: []
22
22
  extra_rdoc_files:
23
23
  - README.markdown
24
24
  files:
25
- - acts_as_archive.gemspec
26
25
  - bin/acts_as_archive
27
26
  - init.rb
28
27
  - lib/acts_as_archive/base/destroy.rb
@@ -1,29 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{acts_as_archive}
5
- s.version = "0.1.5"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Winton Welsh"]
9
- s.date = %q{2009-11-24}
10
- s.default_executable = %q{acts_as_archive}
11
- s.email = %q{mail@wintoni.us}
12
- s.executables = ["acts_as_archive"]
13
- s.extra_rdoc_files = ["README.markdown"]
14
- s.files = ["acts_as_archive.gemspec", "bin", "bin/acts_as_archive", "init.rb", "lib", "lib/acts_as_archive", "lib/acts_as_archive/base", "lib/acts_as_archive/base/destroy.rb", "lib/acts_as_archive/base/restore.rb", "lib/acts_as_archive/base/table.rb", "lib/acts_as_archive/base.rb", "lib/acts_as_archive/migration.rb", "lib/acts_as_archive.rb", "MIT-LICENSE", "rails", "rails/init.rb", "Rakefile", "README.markdown", "spec", "spec/acts_as_archive", "spec/acts_as_archive/base", "spec/acts_as_archive/base/destroy_spec.rb", "spec/acts_as_archive/base/restore_spec.rb", "spec/acts_as_archive/base/table_spec.rb", "spec/acts_as_archive/base_spec.rb", "spec/acts_as_archive/migration_spec.rb", "spec/db", "spec/db/config", "spec/db/config/database.yml", "spec/db/log", "spec/db/migrate", "spec/db/migrate/001_add_to_articles.rb", "spec/db/migrate_2", "spec/db/migrate_2/001_add_to_articles.rb", "spec/db/models", "spec/db/models/article.rb", "spec/spec.opts", "spec/spec_helper.rb"]
15
- s.homepage = %q{http://github.com/winton/acts_as_archive}
16
- s.require_paths = ["lib"]
17
- s.rubygems_version = %q{1.3.5}
18
- s.summary = %q{Don't delete your records, move them to a different table}
19
-
20
- if s.respond_to? :specification_version then
21
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
22
- s.specification_version = 3
23
-
24
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
25
- else
26
- end
27
- else
28
- end
29
- end