has_history 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,20 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
require 'rails/generators'
|
3
|
+
require 'rails/generators/migration'
|
4
|
+
|
2
5
|
module HasHistory
|
3
6
|
class InstallGenerator < Rails::Generators::Base
|
4
|
-
desc "Copies a config initializer to config/initializers/has_history.rb"
|
7
|
+
desc "Copies a config initializer to config/initializers/has_history.rb and creates a migration file"
|
8
|
+
include Rails::Generators::Migration
|
9
|
+
source_root File.expand_path('../../templates', __FILE__)
|
5
10
|
|
6
|
-
|
11
|
+
def self.next_migration_number(path)
|
12
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
13
|
+
end
|
7
14
|
|
8
15
|
def copy_files
|
9
|
-
|
16
|
+
migration_template "create_history_entries.rb", "db/migrate/create_history_entries.rb"
|
17
|
+
template 'has_history.rb', 'config/initializers/has_history.rb'
|
10
18
|
end
|
11
19
|
end
|
12
20
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# ONLY FOR RUBY 1.9.x -*- encoding : utf-8 -*-
|
2
|
+
class CreateHistoryEntries < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
create_table :history_entries do |t|
|
5
|
+
t.integer :entity_id
|
6
|
+
t.string :entity_type
|
7
|
+
t.text :modifications
|
8
|
+
t.integer :modified_by_id
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
add_index :history_entries, [:entity_type, :entity_id], :unique => false
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
remove_index :history_entries, [:entity_type, :entity_id]
|
16
|
+
drop_table :history_entries
|
17
|
+
end
|
18
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'lib/has_history.rb'
|
2
|
-
|
3
1
|
# Array of attributes whose changes do not need to be saved to history
|
4
2
|
# Defaults to [:updated_at, :updater_id, :created_at, :creator_id, :updated_on, :created_on]
|
5
3
|
# HasHistory::History.ignore_attributes = [:updated_at, :updater_id, :created_at, :creator_id, :updated_on, :created_on]
|
data/lib/has_history/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_history
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- fastcatch
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-05-
|
18
|
+
date: 2012-05-30 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- Rakefile
|
37
37
|
- has_history.gemspec
|
38
38
|
- lib/generators/has_history/install_generator.rb
|
39
|
+
- lib/generators/templates/create_history_entries.rb
|
39
40
|
- lib/generators/templates/has_history.rb
|
40
41
|
- lib/has_history.rb
|
41
42
|
- lib/has_history/ar_extension.rb
|