track_changes 0.5.0 → 0.5.1

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.
Files changed (40) hide show
  1. data/LICENSE +20 -20
  2. data/README.rdoc +87 -87
  3. data/TODO +4 -4
  4. data/VERSION.yml +5 -5
  5. data/lib/track_changes/audit_filter.rb +69 -69
  6. data/lib/track_changes/base.rb +9 -9
  7. data/lib/track_changes/class_methods.rb +74 -74
  8. data/lib/track_changes/configuration.rb +38 -38
  9. data/lib/track_changes/filter.rb +43 -43
  10. data/lib/track_changes/initializer.rb +18 -18
  11. data/lib/track_changes/instance_methods.rb +5 -5
  12. data/lib/track_changes/result.rb +36 -36
  13. data/lib/track_changes.rb +12 -12
  14. data/test/base_test.rb +20 -20
  15. data/test/class_methods_test.rb +29 -29
  16. data/test/filter_test.rb +73 -73
  17. data/test/functional/posts_controller_test.rb +16 -16
  18. data/test/rails_root/app/controllers/application_controller.rb +2 -2
  19. data/test/rails_root/app/controllers/posts_controller.rb +36 -36
  20. data/test/rails_root/app/models/audit.rb +4 -4
  21. data/test/rails_root/app/models/post.rb +3 -3
  22. data/test/rails_root/config/boot.rb +110 -110
  23. data/test/rails_root/config/database.yml +3 -3
  24. data/test/rails_root/config/environment.rb +7 -7
  25. data/test/rails_root/config/environments/test.rb +7 -7
  26. data/test/rails_root/config/initializers/new_rails_defaults.rb +7 -7
  27. data/test/rails_root/config/initializers/session_store.rb +4 -4
  28. data/test/rails_root/config/initializers/track_changes_setup.rb +8 -8
  29. data/test/rails_root/config/routes.rb +3 -3
  30. data/test/rails_root/db/migrate/20100115021125_create_audits.rb +16 -16
  31. data/test/rails_root/db/migrate/20100115021151_create_posts.rb +15 -15
  32. data/test/rails_root/log/test.log +377 -2494
  33. data/test/rails_root/script/console +3 -3
  34. data/test/rails_root/script/generate +3 -3
  35. data/test/result_test.rb +35 -35
  36. data/test/test_helper.rb +29 -29
  37. data/test/track_changes/audit_filter_test.rb +154 -154
  38. data/test/track_changes/configuration_test.rb +36 -36
  39. data/test/track_changes/initializer_test.rb +37 -37
  40. metadata +31 -19
@@ -1,110 +1,110 @@
1
- # Don't change this file!
2
- # Configure your app in config/environment.rb and config/environments/*.rb
3
-
4
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
-
6
- module Rails
7
- class << self
8
- def boot!
9
- unless booted?
10
- preinitialize
11
- pick_boot.run
12
- end
13
- end
14
-
15
- def booted?
16
- defined? Rails::Initializer
17
- end
18
-
19
- def pick_boot
20
- (vendor_rails? ? VendorBoot : GemBoot).new
21
- end
22
-
23
- def vendor_rails?
24
- File.exist?("#{RAILS_ROOT}/vendor/rails")
25
- end
26
-
27
- def preinitialize
28
- load(preinitializer_path) if File.exist?(preinitializer_path)
29
- end
30
-
31
- def preinitializer_path
32
- "#{RAILS_ROOT}/config/preinitializer.rb"
33
- end
34
- end
35
-
36
- class Boot
37
- def run
38
- load_initializer
39
- Rails::Initializer.run(:set_load_path)
40
- end
41
- end
42
-
43
- class VendorBoot < Boot
44
- def load_initializer
45
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
- Rails::Initializer.run(:install_gem_spec_stubs)
47
- Rails::GemDependency.add_frozen_gem_path
48
- end
49
- end
50
-
51
- class GemBoot < Boot
52
- def load_initializer
53
- self.class.load_rubygems
54
- load_rails_gem
55
- require 'initializer'
56
- end
57
-
58
- def load_rails_gem
59
- if version = self.class.gem_version
60
- gem 'rails', version
61
- else
62
- gem 'rails'
63
- end
64
- rescue Gem::LoadError => load_error
65
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
- exit 1
67
- end
68
-
69
- class << self
70
- def rubygems_version
71
- Gem::RubyGemsVersion rescue nil
72
- end
73
-
74
- def gem_version
75
- if defined? RAILS_GEM_VERSION
76
- RAILS_GEM_VERSION
77
- elsif ENV.include?('RAILS_GEM_VERSION')
78
- ENV['RAILS_GEM_VERSION']
79
- else
80
- parse_gem_version(read_environment_rb)
81
- end
82
- end
83
-
84
- def load_rubygems
85
- min_version = '1.3.2'
86
- require 'rubygems'
87
- unless rubygems_version >= min_version
88
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
- exit 1
90
- end
91
-
92
- rescue LoadError
93
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
- exit 1
95
- end
96
-
97
- def parse_gem_version(text)
98
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
- end
100
-
101
- private
102
- def read_environment_rb
103
- File.read("#{RAILS_ROOT}/config/environment.rb")
104
- end
105
- end
106
- end
107
- end
108
-
109
- # All that for this:
110
- Rails.boot!
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
3
+
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
+
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
14
+
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
26
+
27
+ def preinitialize
28
+ load(preinitializer_path) if File.exist?(preinitializer_path)
29
+ end
30
+
31
+ def preinitializer_path
32
+ "#{RAILS_ROOT}/config/preinitializer.rb"
33
+ end
34
+ end
35
+
36
+ class Boot
37
+ def run
38
+ load_initializer
39
+ Rails::Initializer.run(:set_load_path)
40
+ end
41
+ end
42
+
43
+ class VendorBoot < Boot
44
+ def load_initializer
45
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
+ Rails::Initializer.run(:install_gem_spec_stubs)
47
+ Rails::GemDependency.add_frozen_gem_path
48
+ end
49
+ end
50
+
51
+ class GemBoot < Boot
52
+ def load_initializer
53
+ self.class.load_rubygems
54
+ load_rails_gem
55
+ require 'initializer'
56
+ end
57
+
58
+ def load_rails_gem
59
+ if version = self.class.gem_version
60
+ gem 'rails', version
61
+ else
62
+ gem 'rails'
63
+ end
64
+ rescue Gem::LoadError => load_error
65
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
+ exit 1
67
+ end
68
+
69
+ class << self
70
+ def rubygems_version
71
+ Gem::RubyGemsVersion rescue nil
72
+ end
73
+
74
+ def gem_version
75
+ if defined? RAILS_GEM_VERSION
76
+ RAILS_GEM_VERSION
77
+ elsif ENV.include?('RAILS_GEM_VERSION')
78
+ ENV['RAILS_GEM_VERSION']
79
+ else
80
+ parse_gem_version(read_environment_rb)
81
+ end
82
+ end
83
+
84
+ def load_rubygems
85
+ min_version = '1.3.2'
86
+ require 'rubygems'
87
+ unless rubygems_version >= min_version
88
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
+ exit 1
90
+ end
91
+
92
+ rescue LoadError
93
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
+ exit 1
95
+ end
96
+
97
+ def parse_gem_version(text)
98
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
+ end
100
+
101
+ private
102
+ def read_environment_rb
103
+ File.read("#{RAILS_ROOT}/config/environment.rb")
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ # All that for this:
110
+ Rails.boot!
@@ -1,3 +1,3 @@
1
- test:
2
- :adapter: sqlite3
3
- :database: ":memory:"
1
+ test:
2
+ :adapter: sqlite3
3
+ :database: ":memory:"
@@ -1,7 +1,7 @@
1
- RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
2
-
3
- require File.join(File.dirname(__FILE__), 'boot')
4
-
5
- Rails::Initializer.run do |config|
6
- config.time_zone = 'UTC'
7
- end
1
+ RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
2
+
3
+ require File.join(File.dirname(__FILE__), 'boot')
4
+
5
+ Rails::Initializer.run do |config|
6
+ config.time_zone = 'UTC'
7
+ end
@@ -1,7 +1,7 @@
1
- config.cache_classes = true
2
- config.whiny_nils = true
3
- config.action_controller.consider_all_requests_local = true
4
- config.action_controller.perform_caching = false
5
- config.action_view.cache_template_loading = true
6
- config.action_controller.allow_forgery_protection = false
7
- config.action_mailer.delivery_method = :test
1
+ config.cache_classes = true
2
+ config.whiny_nils = true
3
+ config.action_controller.consider_all_requests_local = true
4
+ config.action_controller.perform_caching = false
5
+ config.action_view.cache_template_loading = true
6
+ config.action_controller.allow_forgery_protection = false
7
+ config.action_mailer.delivery_method = :test
@@ -1,7 +1,7 @@
1
- if defined?(ActiveRecord)
2
- ActiveRecord::Base.include_root_in_json = true
3
- ActiveRecord::Base.store_full_sti_class = true
4
- end
5
- ActionController::Routing.generate_best_match = false
6
- ActiveSupport.use_standard_json_time_format = true
7
- ActiveSupport.escape_html_entities_in_json = false
1
+ if defined?(ActiveRecord)
2
+ ActiveRecord::Base.include_root_in_json = true
3
+ ActiveRecord::Base.store_full_sti_class = true
4
+ end
5
+ ActionController::Routing.generate_best_match = false
6
+ ActiveSupport.use_standard_json_time_format = true
7
+ ActiveSupport.escape_html_entities_in_json = false
@@ -1,4 +1,4 @@
1
- ActionController::Base.session = {
2
- :key => '_rails_root_session',
3
- :secret => '54bf4d986f9e5cf80f28c31e03278d3689cb30e84aceb32893bfa617ad7a0fe0bfc4e7012f6b6e1bb9787f2c02cdff1fef4bc928f3ad060d5d6687dd2f813a54'
4
- }
1
+ ActionController::Base.session = {
2
+ :key => '_rails_root_session',
3
+ :secret => '54bf4d986f9e5cf80f28c31e03278d3689cb30e84aceb32893bfa617ad7a0fe0bfc4e7012f6b6e1bb9787f2c02cdff1fef4bc928f3ad060d5d6687dd2f813a54'
4
+ }
@@ -1,8 +1,8 @@
1
- require 'track_changes'
2
-
3
- TrackChanges::Initializer.instance do |config|
4
- config.audit_association = :audits
5
- config.current_user = :current_user
6
- config.ignore_nil = true
7
- end
8
-
1
+ require 'track_changes'
2
+
3
+ TrackChanges::Initializer.instance do |config|
4
+ config.audit_association = :audits
5
+ config.current_user = :current_user
6
+ config.ignore_nil = true
7
+ end
8
+
@@ -1,3 +1,3 @@
1
- ActionController::Routing::Routes.draw do |map|
2
- map.resources :posts
3
- end
1
+ ActionController::Routing::Routes.draw do |map|
2
+ map.resources :posts
3
+ end
@@ -1,16 +1,16 @@
1
- class CreateAudits < ActiveRecord::Migration
2
- def self.up
3
- create_table :audits do |t|
4
- t.string :audited_type
5
- t.integer :audited_id
6
- t.string :user
7
- t.text :change_set
8
-
9
- t.timestamps
10
- end
11
- end
12
-
13
- def self.down
14
- drop_table :audits
15
- end
16
- end
1
+ class CreateAudits < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :audits do |t|
4
+ t.string :audited_type
5
+ t.integer :audited_id
6
+ t.string :user
7
+ t.text :change_set
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ drop_table :audits
15
+ end
16
+ end
@@ -1,15 +1,15 @@
1
- class CreatePosts < ActiveRecord::Migration
2
- def self.up
3
- create_table :posts do |t|
4
- t.string :title
5
- t.text :body
6
- t.string :author
7
-
8
- t.timestamps
9
- end
10
- end
11
-
12
- def self.down
13
- drop_table :posts
14
- end
15
- end
1
+ class CreatePosts < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :posts do |t|
4
+ t.string :title
5
+ t.text :body
6
+ t.string :author
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :posts
14
+ end
15
+ end