rtiss_acts_as_versioned 0.6.2 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  group :development do
4
- gem 'rails', '2.3.16'
4
+ gem 'rails', '3.0.20'
5
5
  gem 'sqlite3-ruby', '1.3.1'
6
- gem 'mysql', '2.8.1'
6
+ gem 'mysql', '2.8.1'
7
7
  end
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ def name
13
13
  end
14
14
 
15
15
  def version
16
- line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
16
+ line = File.read("lib/acts_as_versioned.rb")[/^\s*VERSION\s*=\s*.*/]
17
17
  line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18
18
  end
19
19
 
@@ -70,7 +70,7 @@ end
70
70
 
71
71
  desc "Open an irb session preloaded with this library"
72
72
  task :console do
73
- sh "irb -rubygems -r ./lib/#{name}.rb"
73
+ sh "irb -rubygems -r ./lib/acts_as_versioned.rb"
74
74
  end
75
75
 
76
76
  #############################################################################
@@ -88,8 +88,8 @@ end
88
88
  #############################################################################
89
89
 
90
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!"
91
+ unless `git branch` =~ /^\* master$/
92
+ puts "You must be on the master branch to release!"
93
93
  exit!
94
94
  end
95
95
  sh "git commit --allow-empty -a -m 'Release #{version}'"
@@ -133,9 +133,9 @@ task :gemspec => :validate do
133
133
  end
134
134
 
135
135
  task :validate do
136
- libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
136
+ libfiles = Dir['lib/*'] - ["lib/acts_as_versioned.rb", "lib/acts_as_versioned"]
137
137
  unless libfiles.empty?
138
- puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
138
+ puts "Directory `lib` should only contain a `acts_as_versioned..rb` file and `acts_as_versioned` dir."
139
139
  exit!
140
140
  end
141
141
  unless Dir['VERSION*'].empty?
data/init.rb CHANGED
@@ -1,2 +1,2 @@
1
1
  # encoding: utf-8
2
- require 'rtiss_acts_as_versioned'
2
+ require 'acts_as_versioned'
@@ -20,7 +20,7 @@
20
20
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
 
23
- VERSION = '0.6.2'
23
+ VERSION = '0.7.2'
24
24
 
25
25
  module ActiveRecord #:nodoc:
26
26
  module Acts #:nodoc:
@@ -292,12 +292,12 @@ module ActiveRecord #:nodoc:
292
292
 
293
293
  versioned_class.cattr_accessor :original_class
294
294
  versioned_class.original_class = self
295
- versioned_class.set_table_name versioned_table_name
295
+ versioned_class.table_name = versioned_table_name
296
296
  versioned_class.belongs_to self.to_s.demodulize.underscore.to_sym,
297
297
  :class_name => "::#{self.to_s}",
298
298
  :foreign_key => versioned_foreign_key
299
299
  versioned_class.send :include, options[:extend] if options[:extend].is_a?(Module)
300
- versioned_class.set_sequence_name version_sequence_name if version_sequence_name
300
+ versioned_class.sequence_name = version_sequence_name if version_sequence_name
301
301
  end
302
302
  end
303
303
 
@@ -371,7 +371,7 @@ module ActiveRecord #:nodoc:
371
371
  ret = false
372
372
  without_locking do
373
373
  without_revision do
374
- ret = save(perform_validation)
374
+ ret = save(:validate => perform_validation)
375
375
  end
376
376
  end
377
377
  return ret
@@ -395,9 +395,13 @@ module ActiveRecord #:nodoc:
395
395
  new_model.send("#{col.name}=", orig_model.send(col.name)) if orig_model.has_attribute?(col.name)
396
396
  end
397
397
 
398
- if orig_model.is_a?(self.class.versioned_class)
398
+ clone_inheritance_column(orig_model, new_model)
399
+ end
400
+
401
+ def clone_inheritance_column(orig_model, new_model)
402
+ if orig_model.is_a?(self.class.versioned_class) && new_model.class.column_names.include?(new_model.class.inheritance_column.to_s)
399
403
  new_model[new_model.class.inheritance_column] = orig_model[self.class.versioned_inheritance_column]
400
- elsif new_model.is_a?(self.class.versioned_class)
404
+ elsif new_model.is_a?(self.class.versioned_class) && new_model.class.column_names.include?(self.class.versioned_inheritance_column.to_s)
401
405
  new_model[self.class.versioned_inheritance_column] = orig_model[orig_model.class.inheritance_column]
402
406
  end
403
407
  end
@@ -491,7 +495,7 @@ module ActiveRecord #:nodoc:
491
495
 
492
496
  # Gets the next available version for the current record, or 1 for a new record
493
497
  def next_version
494
- (new_record? ? 0 : versions.calculate(:max, version_column).to_i) + 1
498
+ (new_record? ? 0 : versions.calculate(:maximum, version_column).to_i) + 1
495
499
  end
496
500
 
497
501
  module ClassMethods
@@ -1,4 +1,4 @@
1
- # -*- encoding: utf-8 -*-
1
+ # encoding: utf-8
2
2
 
3
3
  ## This is the rakegem gemspec template. Make sure you read and understand
4
4
  ## all of the comments. Some sections require modification, and others can
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  ## If your rubyforge_project name is different, then edit it and comment out
16
16
  ## the sub! line in the Rakefile
17
17
  s.name = 'rtiss_acts_as_versioned'
18
- s.version = '0.6.2'
18
+ s.version = '0.7.2'
19
19
  s.date = '2014-02-03'
20
20
  s.rubyforge_project = 'rtiss_acts_as_versioned'
21
21
 
@@ -48,7 +48,7 @@ to use technoweenie's version (can be found also on github)"
48
48
 
49
49
  ## List your runtime dependencies here. Runtime dependencies are those
50
50
  ## that are needed for an end user to actually USE your code.
51
- s.add_dependency('activerecord', ["~> 2.3.16"])
51
+ s.add_dependency('activerecord', [">= 3.0.9"])
52
52
 
53
53
  ## List your development dependencies here. Development dependencies are
54
54
  ## those that are only needed during development
@@ -66,7 +66,7 @@ to use technoweenie's version (can be found also on github)"
66
66
  RUNNING_UNIT_TESTS
67
67
  Rakefile
68
68
  init.rb
69
- lib/rtiss_acts_as_versioned.rb
69
+ lib/acts_as_versioned.rb
70
70
  rtiss_acts_as_versioned.gemspec
71
71
  test/abstract_unit.rb
72
72
  test/database.yml
@@ -15,7 +15,7 @@ begin
15
15
  rescue LoadError
16
16
  end
17
17
 
18
- require 'rtiss_acts_as_versioned'
18
+ require 'acts_as_versioned'
19
19
 
20
20
  config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
21
21
  ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
@@ -1,6 +1,6 @@
1
1
  # Same as Rolle except for the presence of the lock_version field
2
2
  class LockedRolle < ActiveRecord::Base
3
- set_table_name 'locked_rolle'
3
+ set_table_name 'locked_rolle'
4
4
  acts_as_versioned
5
5
 
6
6
  validates_presence_of :name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtiss_acts_as_versioned
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -18,17 +18,17 @@ dependencies:
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
- - - ~>
21
+ - - ! '>='
22
22
  - !ruby/object:Gem::Version
23
- version: 2.3.16
23
+ version: 3.0.9
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  none: false
28
28
  requirements:
29
- - - ~>
29
+ - - ! '>='
30
30
  - !ruby/object:Gem::Version
31
- version: 2.3.16
31
+ version: 3.0.9
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: sqlite3-ruby
34
34
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +66,7 @@ files:
66
66
  - RUNNING_UNIT_TESTS
67
67
  - Rakefile
68
68
  - init.rb
69
- - lib/rtiss_acts_as_versioned.rb
69
+ - lib/acts_as_versioned.rb
70
70
  - rtiss_acts_as_versioned.gemspec
71
71
  - test/abstract_unit.rb
72
72
  - test/database.yml
@@ -102,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  segments:
104
104
  - 0
105
- hash: -1039730172068389622
105
+ hash: -4385912415049936283
106
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements: