rtiss_acts_as_versioned 0.6.2

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/CHANGELOG ADDED
@@ -0,0 +1,84 @@
1
+ *GIT* (version numbers are overrated)
2
+
3
+ * 0.6 (19 Jul 2010) Rails 3 refactoring by gvarela!
4
+
5
+ * (16 Jun 2008) Backwards Compatibility is overrated (big updates for rails 2.1)
6
+
7
+ * Use ActiveRecord 2.1's dirty attribute checking instead [Asa Calow]
8
+ * Remove last traces of #non_versioned_fields
9
+ * Remove AR::Base.find_version and AR::Base.find_versions, rely on AR association proxies and named_scope
10
+ * Remove #versions_count, rely on AR association counter caching.
11
+ * Remove #versioned_attributes, basically the same as AR::Base.versioned_columns
12
+
13
+ * (5 Oct 2006) Allow customization of #versions association options [Dan Peterson]
14
+
15
+ *0.5.1*
16
+
17
+ * (8 Aug 2006) Versioned models now belong to the unversioned model. @article_version.article.class => Article [Aslak Hellesoy]
18
+
19
+ *0.5* # do versions even matter for plugins?
20
+
21
+ * (21 Apr 2006) Added without_locking and without_revision methods.
22
+
23
+ Foo.without_revision do
24
+ @foo.update_attributes ...
25
+ end
26
+
27
+ *0.4*
28
+
29
+ * (28 March 2006) Rename non_versioned_fields to non_versioned_columns (old one is kept for compatibility).
30
+ * (28 March 2006) Made explicit documentation note that string column names are required for non_versioned_columns.
31
+
32
+ *0.3.1*
33
+
34
+ * (7 Jan 2006) explicitly set :foreign_key option for the versioned model's belongs_to assocation for STI [Caged]
35
+ * (7 Jan 2006) added tests to prove has_many :through joins work
36
+
37
+ *0.3*
38
+
39
+ * (2 Jan 2006) added ability to share a mixin with versioned class
40
+ * (2 Jan 2006) changed the dynamic version model to MyModel::Version
41
+
42
+ *0.2.4*
43
+
44
+ * (27 Nov 2005) added note about possible destructive behavior of if_changed? [Michael Schuerig]
45
+
46
+ *0.2.3*
47
+
48
+ * (12 Nov 2005) fixed bug with old behavior of #blank? [Michael Schuerig]
49
+ * (12 Nov 2005) updated tests to use ActiveRecord Schema
50
+
51
+ *0.2.2*
52
+
53
+ * (3 Nov 2005) added documentation note to #acts_as_versioned [Martin Jul]
54
+
55
+ *0.2.1*
56
+
57
+ * (6 Oct 2005) renamed dirty? to changed? to keep it uniform. it was aliased to keep it backwards compatible.
58
+
59
+ *0.2*
60
+
61
+ * (6 Oct 2005) added find_versions and find_version class methods.
62
+
63
+ * (6 Oct 2005) removed transaction from create_versioned_table().
64
+ this way you can specify your own transaction around a group of operations.
65
+
66
+ * (30 Sep 2005) fixed bug where find_versions() would order by 'version' twice. (found by Joe Clark)
67
+
68
+ * (26 Sep 2005) added :sequence_name option to acts_as_versioned to set the sequence name on the versioned model
69
+
70
+ *0.1.3* (18 Sep 2005)
71
+
72
+ * First RubyForge release
73
+
74
+ *0.1.2*
75
+
76
+ * check if module is already included when acts_as_versioned is called
77
+
78
+ *0.1.1*
79
+
80
+ * Adding tests and rdocs
81
+
82
+ *0.1*
83
+
84
+ * Initial transfer from Rails ticket: http://dev.rubyonrails.com/ticket/1974
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'rails', '2.3.16'
5
+ gem 'sqlite3-ruby', '1.3.1'
6
+ gem 'mysql', '2.8.1'
7
+ end
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2005 Rick Olson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,24 @@
1
+ = acts_as_versioned
2
+
3
+ This library adds simple versioning to an ActiveRecord module. ActiveRecord is required.
4
+
5
+ == Resources
6
+
7
+ Install
8
+
9
+ * gem install acts_as_versioned
10
+
11
+ <3 GitHub
12
+
13
+ * http://github.com/technoweenie/acts_as_versioned
14
+
15
+ Gemcutter FTW
16
+
17
+ * http://gemcutter.org/gems/acts_as_versioned
18
+
19
+ Subversion
20
+
21
+ * http://svn.github.com/technoweenie/acts_as_versioned.git
22
+
23
+ Special thanks to Dreamer on ##rubyonrails for help in early testing. His ServerSideWiki (http://serversidewiki.com)
24
+ was the first project to use acts_as_versioned <em>in the wild</em>.
@@ -0,0 +1,41 @@
1
+ == Creating the test database
2
+
3
+ The default name for the test databases is "activerecord_versioned". If you
4
+ want to use another database name then be sure to update the connection
5
+ adapter setups you want to test with in test/connections/<your database>/connection.rb.
6
+ When you have the database online, you can import the fixture tables with
7
+ the test/fixtures/db_definitions/*.sql files.
8
+
9
+ Make sure that you create database objects with the same user that you specified in i
10
+ connection.rb otherwise (on Postgres, at least) tests for default values will fail.
11
+
12
+ == Running with Rake
13
+
14
+ The easiest way to run the unit tests is through Rake. The default task runs
15
+ the entire test suite for all the adapters. You can also run the suite on just
16
+ one adapter by using the tasks test_mysql_ruby, test_ruby_mysql, test_sqlite,
17
+ or test_postresql. For more information, checkout the full array of rake tasks with "rake -T"
18
+
19
+ Rake can be found at http://rake.rubyforge.org
20
+
21
+ == Running by hand
22
+
23
+ Unit tests are located in test directory. If you only want to run a single test suite,
24
+ or don't want to bother with Rake, you can do so with something like:
25
+
26
+ cd test; ruby -I "connections/native_mysql" base_test.rb
27
+
28
+ That'll run the base suite using the MySQL-Ruby adapter. Change the adapter
29
+ and test suite name as needed.
30
+
31
+ == Faster tests
32
+
33
+ If you are using a database that supports transactions, you can set the
34
+ "AR_TX_FIXTURES" environment variable to "yes" to use transactional fixtures.
35
+ This gives a very large speed boost. With rake:
36
+
37
+ rake AR_TX_FIXTURES=yes
38
+
39
+ Or, by hand:
40
+
41
+ AR_TX_FIXTURES=yes ruby -I connections/native_sqlite3 base_test.rb
data/Rakefile ADDED
@@ -0,0 +1,145 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'date'
4
+
5
+ #############################################################################
6
+ #
7
+ # Helper functions
8
+ #
9
+ #############################################################################
10
+
11
+ def name
12
+ @name ||= Dir['*.gemspec'].first.split('.').first
13
+ end
14
+
15
+ def version
16
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
17
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18
+ end
19
+
20
+ def date
21
+ Date.today.to_s
22
+ end
23
+
24
+ def rubyforge_project
25
+ name
26
+ end
27
+
28
+ def gemspec_file
29
+ "#{name}.gemspec"
30
+ end
31
+
32
+ def gem_file
33
+ "#{name}-#{version}.gem"
34
+ end
35
+
36
+ def replace_header(head, header_name)
37
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
38
+ end
39
+
40
+ #############################################################################
41
+ #
42
+ # Standard tasks
43
+ #
44
+ #############################################################################
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/testtask'
49
+ Rake::TestTask.new(:test) do |test|
50
+ test.libs << 'lib' << 'test'
51
+ test.pattern = 'test/**/*_test.rb'
52
+ test.verbose = true
53
+ end
54
+
55
+ desc "Generate RCov test coverage and open in your browser"
56
+ task :coverage do
57
+ require 'rcov'
58
+ sh "rm -fr coverage"
59
+ sh "rcov test/test_*.rb"
60
+ sh "open coverage/index.html"
61
+ end
62
+
63
+ require 'rdoc/task'
64
+ Rake::RDocTask.new do |rdoc|
65
+ rdoc.rdoc_dir = 'rdoc'
66
+ rdoc.title = "#{name} #{version}"
67
+ rdoc.rdoc_files.include('README*')
68
+ rdoc.rdoc_files.include('lib/**/*.rb')
69
+ end
70
+
71
+ desc "Open an irb session preloaded with this library"
72
+ task :console do
73
+ sh "irb -rubygems -r ./lib/#{name}.rb"
74
+ end
75
+
76
+ #############################################################################
77
+ #
78
+ # Custom tasks (add your own tasks here)
79
+ #
80
+ #############################################################################
81
+
82
+
83
+
84
+ #############################################################################
85
+ #
86
+ # Packaging tasks
87
+ #
88
+ #############################################################################
89
+
90
+ task :release => :build do
91
+ unless `git branch` =~ /^\* master$/ || `git branch` =~ /^\* rails2$/
92
+ puts "You must be on the master branch or the rails2 branch to release!"
93
+ exit!
94
+ end
95
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
96
+ sh "git tag #{version}"
97
+ sh "git push origin master --tags"
98
+ sh "gem push pkg/#{name}-#{version}.gem"
99
+ end
100
+
101
+ task :build => :gemspec do
102
+ sh "mkdir -p pkg"
103
+ sh "gem build #{gemspec_file}"
104
+ sh "mv #{gem_file} pkg"
105
+ end
106
+
107
+ task :gemspec => :validate do
108
+ # read spec file and split out manifest section
109
+ spec = File.read(gemspec_file)
110
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
111
+
112
+ # replace name version and date
113
+ replace_header(head, :name)
114
+ replace_header(head, :version)
115
+ replace_header(head, :date)
116
+ #comment this out if your rubyforge_project has a different name
117
+ replace_header(head, :rubyforge_project)
118
+
119
+ # determine file list from git ls-files
120
+ files = `git ls-files`.
121
+ split("\n").
122
+ sort.
123
+ reject { |file| file =~ /^\./ }.
124
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
125
+ map { |file| " #{file}" }.
126
+ join("\n")
127
+
128
+ # piece file back together and write
129
+ manifest = " s.files = %w[\n#{files}\n ]\n"
130
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
131
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
132
+ puts "Updated #{gemspec_file}"
133
+ end
134
+
135
+ task :validate do
136
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
137
+ unless libfiles.empty?
138
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
139
+ exit!
140
+ end
141
+ unless Dir['VERSION*'].empty?
142
+ puts "A `VERSION` file at root level violates Gem best practices."
143
+ exit!
144
+ end
145
+ end
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require 'rtiss_acts_as_versioned'