acts_as_list_with_sti_support 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_list_with_sti_support
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
4
  prerelease: false
6
5
  segments:
7
6
  - 1
8
7
  - 0
9
- - 1
10
- version: 1.0.1
8
+ - 2
9
+ version: 1.0.2
11
10
  platform: ruby
12
11
  authors:
13
12
  - Coroutine
@@ -16,7 +15,7 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2010-11-05 00:00:00 -05:00
18
+ date: 2010-12-13 00:00:00 -06:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
@@ -27,7 +26,6 @@ dependencies:
27
26
  requirements:
28
27
  - - ">="
29
28
  - !ruby/object:Gem::Version
30
- hash: 11
31
29
  segments:
32
30
  - 2
33
31
  - 3
@@ -43,7 +41,6 @@ dependencies:
43
41
  requirements:
44
42
  - - ">="
45
43
  - !ruby/object:Gem::Version
46
- hash: 11
47
44
  segments:
48
45
  - 2
49
46
  - 3
@@ -52,7 +49,7 @@ dependencies:
52
49
  type: :development
53
50
  version_requirements: *id002
54
51
  description: This acts_as extension does everything acts_as_list does, but it also works in single table inheritance designs and accepts less brain-damaged scope syntax.
55
- email: jdugan@coroutine.com
52
+ email: gem@coroutine.com
56
53
  executables: []
57
54
 
58
55
  extensions: []
@@ -87,7 +84,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
84
  requirements:
88
85
  - - ">="
89
86
  - !ruby/object:Gem::Version
90
- hash: 3
91
87
  segments:
92
88
  - 0
93
89
  version: "0"
@@ -96,7 +92,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
92
  requirements:
97
93
  - - ">="
98
94
  - !ruby/object:Gem::Version
99
- hash: 3
100
95
  segments:
101
96
  - 0
102
97
  version: "0"
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Rakefile CHANGED
@@ -1,7 +1,8 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
1
4
  require "rake"
2
5
  require "rake/testtask"
3
- require "rake/rdoctask"
4
- require "jeweler"
5
6
 
6
7
 
7
8
  desc "Default: run tests."
@@ -13,33 +14,4 @@ Rake::TestTask.new(:test) do |t|
13
14
  t.libs << ["lib", "test"]
14
15
  t.pattern = "test/**/*_test.rb"
15
16
  t.verbose = true
16
- end
17
-
18
-
19
- desc 'Generate documentation for the gem.'
20
- Rake::RDocTask.new(:rdoc) do |rdoc|
21
- rdoc.rdoc_dir = "rdoc"
22
- rdoc.title = "acts_as_list_with_sti_support"
23
- rdoc.options << "--line-numbers --inline-source"
24
- rdoc.rdoc_files.include("README")
25
- rdoc.rdoc_files.include("lib/**/*.rb")
26
- end
27
-
28
-
29
- begin
30
- Jeweler::Tasks.new do |gemspec|
31
- gemspec.authors = ["Coroutine", "John Dugan"]
32
- gemspec.description = "This acts_as extension does everything acts_as_list does, but it also works in single table inheritance designs and accepts less brain-damaged scope syntax."
33
- gemspec.email = "gem@coroutine.com"
34
- gemspec.homepage = "http://github.com/coroutine/acts_as_list_with_sti_support"
35
- gemspec.name = "acts_as_list_with_sti_support"
36
- gemspec.summary = "Gem version of acts_as_list_with_sti_support Rails plugin, a smarter version of acts_as_list."
37
-
38
- gemspec.add_dependency("activerecord", ">=2.3.4")
39
- gemspec.add_development_dependency("activesupport", ">=2.3.4")
40
- gemspec.files.include("lib/**/*.rb")
41
- end
42
- Jeweler::GemcutterTasks.new
43
- rescue LoadError
44
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
45
17
  end
@@ -1,59 +1,25 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "acts_as_list_with_sti_support/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{acts_as_list_with_sti_support}
8
- s.version = "1.0.2"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Coroutine", "John Dugan"]
12
- s.date = %q{2010-12-13}
6
+ s.name = "acts_as_list_with_sti_support"
7
+ s.version = Coroutine::ActsAsList::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Coroutine", "John Dugan"]
10
+ s.email = ["gems@coroutine.com"]
11
+ s.homepage = "http://github.com/coroutine/acts_as_list_with_sti_support"
12
+ s.summary = %q{This acts_as extension is just like acts_as_list, only better.}
13
13
  s.description = %q{This acts_as extension does everything acts_as_list does, but it also works in single table inheritance designs and accepts less brain-damaged scope syntax.}
14
- s.email = %q{gem@coroutine.com}
15
- s.extra_rdoc_files = [
16
- "README.rdoc"
17
- ]
18
- s.files = [
19
- ".gitignore",
20
- ".specification",
21
- "MIT-LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "acts_as_list_with_sti_support.gemspec",
26
- "init.rb",
27
- "lib/acts_as_list_with_sti_support.rb",
28
- "lib/acts_as_list_with_sti_support/base.rb",
29
- "rails/init.rb",
30
- "test/acts_as_list_with_sti_support_test.rb",
31
- "test/test_helper.rb"
32
- ]
33
- s.homepage = %q{http://github.com/coroutine/acts_as_list_with_sti_support}
34
- s.rdoc_options = ["--charset=UTF-8"]
35
- s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.3.7}
37
- s.summary = %q{Gem version of acts_as_list_with_sti_support Rails plugin, a smarter version of acts_as_list.}
38
- s.test_files = [
39
- "test/acts_as_list_with_sti_support_test.rb",
40
- "test/test_helper.rb"
41
- ]
42
14
 
43
- if s.respond_to? :specification_version then
44
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
- s.specification_version = 3
46
-
47
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
- s.add_runtime_dependency(%q<activerecord>, [">= 2.3.4"])
49
- s.add_development_dependency(%q<activesupport>, [">= 2.3.4"])
50
- else
51
- s.add_dependency(%q<activerecord>, [">= 2.3.4"])
52
- s.add_dependency(%q<activesupport>, [">= 2.3.4"])
53
- end
54
- else
55
- s.add_dependency(%q<activerecord>, [">= 2.3.4"])
56
- s.add_dependency(%q<activesupport>, [">= 2.3.4"])
57
- end
58
- end
15
+ s.add_dependency "rails", ">= 3.0.0"
16
+
17
+ s.add_development_dependency "rspec", ">= 2.0.0"
18
+
19
+ s.rubyforge_project = "acts_as_list_with_sti_support"
59
20
 
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+ end
data/init.rb CHANGED
@@ -1 +1 @@
1
- require File.dirname(__FILE__) + "/rails/init.rb"
1
+ require "acts_as_list_with_sti_support"
@@ -54,40 +54,31 @@ module Coroutine #:nodoc:
54
54
  #--------------------------------------------
55
55
  class_eval do
56
56
 
57
- # Add inheritable accessors
58
- write_inheritable_attribute :acts_as_list_column, column
59
- class_inheritable_reader :acts_as_list_column
60
- write_inheritable_attribute :acts_as_list_scope, scope
61
- class_inheritable_reader :acts_as_list_scope
62
- write_inheritable_attribute :acts_as_list_default_scope, "1 = 1"
63
- class_inheritable_reader :acts_as_list_default_scope
64
- write_inheritable_attribute :acts_as_list_scope_condition, nil
65
- class_inheritable_reader :acts_as_list_scope_condition
57
+ # define attributes
58
+ class_attribute :acts_as_list_column
59
+ class_attribute :acts_as_list_scope
60
+ class_attribute :acts_as_list_default_scope
61
+ class_attribute :acts_as_list_scope_condition
66
62
 
63
+ # set values from options
64
+ self.acts_as_list_column = column
65
+ self.acts_as_list_scope = scope
66
+ self.acts_as_list_default_scope = "1 = 1"
67
+ self.acts_as_list_scope_condition = nil
67
68
 
68
- # Add validations (column is allowed to be nil to support soft deletes)
69
+
70
+ # validations (column is allowed to be nil to support soft deletes)
69
71
  validates_numericality_of column, :only_integer => true, :greater_than => 0, :allow_nil => true
70
72
 
71
73
 
72
- # Include instance methods
74
+ # instance methods
73
75
  include Coroutine::ActsAsList::Base::InstanceMethods
74
76
 
75
77
 
76
- # rails 3
77
- if self.respond_to?(:arel_table)
78
- before_validation :add_to_list_bottom, :if => :position_blank?, :on => :create
79
- before_destroy :remove_from_list
80
-
81
- # rails 2
82
- else
83
- before_validation_on_create :add_to_list_bottom, :if => :position_blank?
84
- before_destroy :remove_from_list
78
+ # callbacks
79
+ before_validation :add_to_list_bottom, :if => :position_blank?, :on => :create
80
+ before_destroy :remove_from_list
85
81
 
86
- if self.default_scoping.empty?
87
- default_scope :order => column.to_s
88
- end
89
- end
90
-
91
82
  end
92
83
 
93
84
  end
@@ -229,11 +220,8 @@ module Coroutine #:nodoc:
229
220
  def higher_item
230
221
  return nil unless in_list?
231
222
  conditions = "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i - 1).to_s}"
232
- if self.rails_3?
233
- acts_as_list_class.where(conditions).first
234
- else
235
- acts_as_list_class.find(:first, :conditions => conditions)
236
- end
223
+
224
+ acts_as_list_class.where(conditions).first
237
225
  end
238
226
 
239
227
  # This method returns the next lower item in the list.
@@ -241,11 +229,8 @@ module Coroutine #:nodoc:
241
229
  def lower_item
242
230
  return nil unless in_list?
243
231
  conditions = "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i + 1).to_s}"
244
- if self.rails_3?
245
- acts_as_list_class.where(conditions).first
246
- else
247
- acts_as_list_class.find(:first, :conditions => conditions)
248
- end
232
+
233
+ acts_as_list_class.where(conditions).first
249
234
  end
250
235
 
251
236
  # Test if this record is in a list
@@ -258,12 +243,6 @@ module Coroutine #:nodoc:
258
243
  return self.send(position_column).blank?
259
244
  end
260
245
 
261
- # This method indicates whether or not the gem is being used within the
262
- # rails 3 environment.
263
- def rails_3?
264
- return acts_as_list_class.respond_to?(:arel_table)
265
- end
266
-
267
246
 
268
247
 
269
248
  private
@@ -289,11 +268,8 @@ module Coroutine #:nodoc:
289
268
  conditions = scope_condition
290
269
  conditions = "#{conditions} AND #{self.class.primary_key} != #{except.id}" unless except.blank?
291
270
  order_by = "#{position_column} DESC"
292
- if self.rails_3?
293
- acts_as_list_class.where(conditions).order(order_by).first
294
- else
295
- acts_as_list_class.find(:first, :conditions => conditions, :order => order_by)
296
- end
271
+
272
+ acts_as_list_class.where(conditions).order(order_by).first
297
273
  end
298
274
 
299
275
  # This method forces item to assume the bottom position in the list.
@@ -0,0 +1,5 @@
1
+ module Coroutine
2
+ module ActsAsList
3
+ VERSION = "1.0.3"
4
+ end
5
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_list_with_sti_support
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 17
5
+ prerelease:
5
6
  segments:
6
7
  - 1
7
8
  - 0
8
- - 2
9
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - Coroutine
@@ -15,59 +16,62 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-12-13 00:00:00 -06:00
19
+ date: 2011-11-16 00:00:00 -06:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
- name: activerecord
23
+ name: rails
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
25
26
  none: false
26
27
  requirements:
27
28
  - - ">="
28
29
  - !ruby/object:Gem::Version
30
+ hash: 7
29
31
  segments:
30
- - 2
31
32
  - 3
32
- - 4
33
- version: 2.3.4
33
+ - 0
34
+ - 0
35
+ version: 3.0.0
34
36
  type: :runtime
35
37
  version_requirements: *id001
36
38
  - !ruby/object:Gem::Dependency
37
- name: activesupport
39
+ name: rspec
38
40
  prerelease: false
39
41
  requirement: &id002 !ruby/object:Gem::Requirement
40
42
  none: false
41
43
  requirements:
42
44
  - - ">="
43
45
  - !ruby/object:Gem::Version
46
+ hash: 15
44
47
  segments:
45
48
  - 2
46
- - 3
47
- - 4
48
- version: 2.3.4
49
+ - 0
50
+ - 0
51
+ version: 2.0.0
49
52
  type: :development
50
53
  version_requirements: *id002
51
54
  description: This acts_as extension does everything acts_as_list does, but it also works in single table inheritance designs and accepts less brain-damaged scope syntax.
52
- email: gem@coroutine.com
55
+ email:
56
+ - gems@coroutine.com
53
57
  executables: []
54
58
 
55
59
  extensions: []
56
60
 
57
- extra_rdoc_files:
58
- - README.rdoc
61
+ extra_rdoc_files: []
62
+
59
63
  files:
60
64
  - .gitignore
61
65
  - .specification
66
+ - Gemfile
62
67
  - MIT-LICENSE
63
68
  - README.rdoc
64
69
  - Rakefile
65
- - VERSION
66
70
  - acts_as_list_with_sti_support.gemspec
67
71
  - init.rb
68
72
  - lib/acts_as_list_with_sti_support.rb
69
73
  - lib/acts_as_list_with_sti_support/base.rb
70
- - rails/init.rb
74
+ - lib/acts_as_list_with_sti_support/version.rb
71
75
  - test/acts_as_list_with_sti_support_test.rb
72
76
  - test/test_helper.rb
73
77
  has_rdoc: true
@@ -75,8 +79,8 @@ homepage: http://github.com/coroutine/acts_as_list_with_sti_support
75
79
  licenses: []
76
80
 
77
81
  post_install_message:
78
- rdoc_options:
79
- - --charset=UTF-8
82
+ rdoc_options: []
83
+
80
84
  require_paths:
81
85
  - lib
82
86
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -84,6 +88,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
88
  requirements:
85
89
  - - ">="
86
90
  - !ruby/object:Gem::Version
91
+ hash: 3
87
92
  segments:
88
93
  - 0
89
94
  version: "0"
@@ -92,16 +97,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
97
  requirements:
93
98
  - - ">="
94
99
  - !ruby/object:Gem::Version
100
+ hash: 3
95
101
  segments:
96
102
  - 0
97
103
  version: "0"
98
104
  requirements: []
99
105
 
100
- rubyforge_project:
101
- rubygems_version: 1.3.7
106
+ rubyforge_project: acts_as_list_with_sti_support
107
+ rubygems_version: 1.6.2
102
108
  signing_key:
103
109
  specification_version: 3
104
- summary: Gem version of acts_as_list_with_sti_support Rails plugin, a smarter version of acts_as_list.
110
+ summary: This acts_as extension is just like acts_as_list, only better.
105
111
  test_files:
106
112
  - test/acts_as_list_with_sti_support_test.rb
107
113
  - test/test_helper.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.0.2
@@ -1 +0,0 @@
1
- require "acts_as_list_with_sti_support"