acts-as-dag 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f9877ef3e8a02c7abe9783aecd4baecc299eedd2
4
+ data.tar.gz: ab13f7dcf3c411dda2f238edf2d6d52307a3547b
5
+ SHA512:
6
+ metadata.gz: 2a213bdbf6c023a145623e4c0839dad678c3540a48a06cda7b0fac15630c27a7320f154fe4b0f2f67d14534e156c0716761f44ad6de1e5030762627000222c63
7
+ data.tar.gz: a00bb1e52e0a2e12e5c14605aa9a945a788cb3e2fdf97e1e6924ca23909d3a8c9c9b961eb068048ae759d3172719ac2c9522076a6409a0643b5d2dbb17894a4f
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem 'bundler'
4
4
  gem 'rake'
5
- gem 'rails', '3.2.12'
5
+ gem 'rails', '>= 4.0.0'
6
6
  gem 'rack'
7
7
  gem 'jeweler'
8
8
  gem 'sqlite3'
@@ -12,6 +12,8 @@ Version 2.0.x tested using Rails 3.0.0 and Ruby 1.9.2-p0, without major structur
12
12
 
13
13
  Version 2.5.3 is based on Rails 3.0.0 and uses all of the new ActiveModel/ActiveRecord goodness found there.
14
14
 
15
+ Version 3.0.0 is based on Rails 3.2.12 and tested against Ruby 1.9.3-p385. 3.0.0 fixes issues with the ActiveRecord method connected? being overwritten by acts-as-dag. Thanks to Ryan Glover (@ersatzryan) for the patch.
16
+
15
17
  === What's a DAG?
16
18
 
17
19
  http://en.wikipedia.org/wiki/Directed_acyclic_graph
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.email = ["resgraph@cox.net"]
10
10
  s.homepage = 'https://github.com/resgraph/acts-as-dag'
11
11
  s.summary = %q{Directed Acyclic Graph hierarchy for Rail's ActiveRecord}
12
- s.description = %q{Directed Acyclic Graph hierarchy for Rail's ActiveRecord}
12
+ s.description = %q{Directed Acyclic Graph hierarchy for Rail's ActiveRecord, supporting Rails 4.x}
13
13
 
14
14
  s.rubyforge_project = "acts-as-dag"
15
15
 
@@ -19,9 +19,8 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  # As specified in test/dag_test.rb
22
- s.add_development_dependency 'activerecord', '~> 3.2.12'
23
22
  s.add_development_dependency 'rake'
24
23
  s.add_development_dependency 'sqlite3'
25
24
  s.add_runtime_dependency 'activemodel'
26
- s.add_runtime_dependency 'activerecord'
25
+ s.add_runtime_dependency 'activerecord', '~> 4.0', '>= 4.0.0'
27
26
  end
@@ -1,7 +1,7 @@
1
1
  module Acts
2
2
  module As
3
3
  module Dag
4
- VERSION = "3.0.0"
4
+ VERSION = "4.0.0"
5
5
  end
6
6
  end
7
7
  end
@@ -93,12 +93,11 @@ module Dag
93
93
  include Standard
94
94
  end
95
95
 
96
- # TODO: rename? breaks when using 'where' query because :direct scope name and :direct => true parameter conflict?
97
- scope :direct, :conditions => {:direct => true}
98
- scope :indirect, :conditions => {:direct => false}
96
+ scope :direct, lambda { where(:direct => true) }
97
+ scope :indirect, lambda { where(:direct => false) }
99
98
 
100
- scope :ancestor_nodes, :joins => :ancestor
101
- scope :descendant_nodes, :joins => :descendant
99
+ scope :ancestor_nodes, lambda { joins(:ancestor) }
100
+ scope :descendant_nodes, lambda { joins(:descendant) }
102
101
 
103
102
  validates ancestor_id_column_name.to_sym, :presence => true,
104
103
  :numericality => true
@@ -163,8 +162,8 @@ module Dag
163
162
  has_many :#{prefix}links_as_ancestor, :as => :ancestor, :class_name => '#{dag_link_class_name}'
164
163
  has_many :#{prefix}links_as_descendant, :as => :descendant, :class_name => '#{dag_link_class_name}'
165
164
 
166
- has_many :#{prefix}links_as_parent, :as => :ancestor, :class_name => '#{dag_link_class_name}', :conditions => {'#{dag_link_class.direct_column_name}' => true}
167
- has_many :#{prefix}links_as_child, :as => :descendant, :class_name => '#{dag_link_class_name}', :conditions => {'#{dag_link_class.direct_column_name}' => true}
165
+ has_many :#{prefix}links_as_parent, lambda { where('#{dag_link_class.direct_column_name}' => true) }, :as => :ancestor, :class_name => '#{dag_link_class_name}'
166
+ has_many :#{prefix}links_as_child, lambda { where('#{dag_link_class.direct_column_name}' => true) }, :as => :descendant, :class_name => '#{dag_link_class_name}'
168
167
 
169
168
  EOL
170
169
 
@@ -173,9 +172,9 @@ module Dag
173
172
  conf[:ancestor_class_names].each do |class_name|
174
173
  table_name = class_name.tableize
175
174
  self.class_eval <<-EOL2
176
- has_many :#{prefix}links_as_descendant_for_#{table_name}, :as => :descendant, :class_name => '#{dag_link_class_name}', :conditions => {'#{dag_link_class.ancestor_type_column_name}' => '#{class_name}'}
175
+ has_many :#{prefix}links_as_descendant_for_#{table_name}, lambda { where('#{dag_link_class.ancestor_type_column_name}' => '#{class_name}') }, :as => :descendant, :class_name => '#{dag_link_class_name}'
177
176
  has_many :#{prefix}ancestor_#{table_name}, :through => :#{prefix}links_as_descendant_for_#{table_name}, :source => :ancestor, :source_type => '#{class_name}'
178
- has_many :#{prefix}links_as_child_for_#{table_name}, :as => :descendant, :class_name => '#{dag_link_class_name}', :conditions => {'#{dag_link_class.ancestor_type_column_name}' => '#{class_name}','#{dag_link_class.direct_column_name}' => true}
177
+ has_many :#{prefix}links_as_child_for_#{table_name}, lambda { where('#{dag_link_class.ancestor_type_column_name}' => '#{class_name}','#{dag_link_class.direct_column_name}' => true) }, :as => :descendant, :class_name => '#{dag_link_class_name}'
179
178
  has_many :#{prefix}parent_#{table_name}, :through => :#{prefix}links_as_child_for_#{table_name}, :source => :ancestor, :source_type => '#{class_name}'
180
179
 
181
180
  def #{prefix}root_for_#{table_name}?
@@ -223,10 +222,10 @@ module Dag
223
222
  conf[:descendant_class_names].each do |class_name|
224
223
  table_name = class_name.tableize
225
224
  self.class_eval <<-EOL3
226
- has_many :#{prefix}links_as_ancestor_for_#{table_name}, :as => :ancestor, :class_name => '#{dag_link_class_name}', :conditions => {'#{dag_link_class.descendant_type_column_name}' => '#{class_name}'}
225
+ has_many :#{prefix}links_as_ancestor_for_#{table_name}, lambda { where('#{dag_link_class.descendant_type_column_name}' => '#{class_name}') }, :as => :ancestor, :class_name => '#{dag_link_class_name}'
227
226
  has_many :#{prefix}descendant_#{table_name}, :through => :#{prefix}links_as_ancestor_for_#{table_name}, :source => :descendant, :source_type => '#{class_name}'
228
227
 
229
- has_many :#{prefix}links_as_parent_for_#{table_name}, :as => :ancestor, :class_name => '#{dag_link_class_name}', :conditions => {'#{dag_link_class.descendant_type_column_name}' => '#{class_name}','#{dag_link_class.direct_column_name}' => true}
228
+ has_many :#{prefix}links_as_parent_for_#{table_name}, lambda { where('#{dag_link_class.descendant_type_column_name}' => '#{class_name}','#{dag_link_class.direct_column_name}' => true) }, :as => :ancestor, :class_name => '#{dag_link_class_name}'
230
229
  has_many :#{prefix}child_#{table_name}, :through => :#{prefix}links_as_parent_for_#{table_name}, :source => :descendant, :source_type => '#{class_name}'
231
230
 
232
231
  def #{prefix}leaf_for_#{table_name}?
@@ -275,8 +274,8 @@ module Dag
275
274
  has_many :#{prefix}ancestors, :through => :#{prefix}links_as_descendant, :source => :ancestor
276
275
  has_many :#{prefix}descendants, :through => :#{prefix}links_as_ancestor, :source => :descendant
277
276
 
278
- has_many :#{prefix}links_as_parent, :foreign_key => '#{dag_link_class.ancestor_id_column_name}', :class_name => '#{dag_link_class_name}', :conditions => {'#{dag_link_class.direct_column_name}' => true}
279
- has_many :#{prefix}links_as_child, :foreign_key => '#{dag_link_class.descendant_id_column_name}', :class_name => '#{dag_link_class_name}', :conditions => {'#{dag_link_class.direct_column_name}' => true}
277
+ has_many :#{prefix}links_as_parent, lambda { where('#{dag_link_class.direct_column_name}' => true) }, :foreign_key => '#{dag_link_class.ancestor_id_column_name}', :class_name => '#{dag_link_class_name}'
278
+ has_many :#{prefix}links_as_child, lambda { where('#{dag_link_class.direct_column_name}' => true) }, :foreign_key => '#{dag_link_class.descendant_id_column_name}', :class_name => '#{dag_link_class_name}'
280
279
 
281
280
  has_many :#{prefix}parents, :through => :#{prefix}links_as_child, :source => :ancestor
282
281
  has_many :#{prefix}children, :through => :#{prefix}links_as_parent, :source => :descendant
@@ -20,14 +20,14 @@ module Dag
20
20
  def find_edge(ancestor, descendant)
21
21
  source = self::EndPoint.from(ancestor)
22
22
  sink = self::EndPoint.from(descendant)
23
- self.first :conditions => self.conditions_for(source, sink).merge!({direct_column_name => true})
23
+ self.where(self.conditions_for(source, sink).merge!({direct_column_name => true})).first
24
24
  end
25
25
 
26
26
  #Finds a link between two points
27
27
  def find_link(ancestor, descendant)
28
28
  source = self::EndPoint.from(ancestor)
29
29
  sink = self::EndPoint.from(descendant)
30
- self.first :conditions => self.conditions_for(source, sink)
30
+ self.where(self.conditions_for(source, sink)).first
31
31
  end
32
32
 
33
33
  #Finds or builds an edge between two points
@@ -1,8 +1,8 @@
1
1
  require 'test/unit'
2
2
  require 'rubygems'
3
- gem 'activerecord', '~> 3.2.8'
3
+ gem 'activerecord', '~> 4.1.0'
4
4
  require "./init"
5
-
5
+ I18n.enforce_available_locales = true
6
6
 
7
7
  ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => "#{File.dirname(__FILE__)}/database.test")
8
8
 
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts-as-dag
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
5
- prerelease:
4
+ version: 4.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matthew Leventi
@@ -10,96 +9,79 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-02-18 00:00:00.000000000 Z
12
+ date: 2014-04-09 00:00:00.000000000 Z
14
13
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: activerecord
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: 3.2.12
23
- type: :development
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ~>
29
- - !ruby/object:Gem::Version
30
- version: 3.2.12
31
14
  - !ruby/object:Gem::Dependency
32
15
  name: rake
33
16
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
17
  requirements:
36
- - - ! '>='
18
+ - - ">="
37
19
  - !ruby/object:Gem::Version
38
20
  version: '0'
39
21
  type: :development
40
22
  prerelease: false
41
23
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
24
  requirements:
44
- - - ! '>='
25
+ - - ">="
45
26
  - !ruby/object:Gem::Version
46
27
  version: '0'
47
28
  - !ruby/object:Gem::Dependency
48
29
  name: sqlite3
49
30
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
31
  requirements:
52
- - - ! '>='
32
+ - - ">="
53
33
  - !ruby/object:Gem::Version
54
34
  version: '0'
55
35
  type: :development
56
36
  prerelease: false
57
37
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
38
  requirements:
60
- - - ! '>='
39
+ - - ">="
61
40
  - !ruby/object:Gem::Version
62
41
  version: '0'
63
42
  - !ruby/object:Gem::Dependency
64
43
  name: activemodel
65
44
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
45
  requirements:
68
- - - ! '>='
46
+ - - ">="
69
47
  - !ruby/object:Gem::Version
70
48
  version: '0'
71
49
  type: :runtime
72
50
  prerelease: false
73
51
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
52
  requirements:
76
- - - ! '>='
53
+ - - ">="
77
54
  - !ruby/object:Gem::Version
78
55
  version: '0'
79
56
  - !ruby/object:Gem::Dependency
80
57
  name: activerecord
81
58
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
59
  requirements:
84
- - - ! '>='
60
+ - - "~>"
85
61
  - !ruby/object:Gem::Version
86
- version: '0'
62
+ version: '4.0'
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 4.0.0
87
66
  type: :runtime
88
67
  prerelease: false
89
68
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
69
  requirements:
92
- - - ! '>='
70
+ - - "~>"
93
71
  - !ruby/object:Gem::Version
94
- version: '0'
95
- description: Directed Acyclic Graph hierarchy for Rail's ActiveRecord
72
+ version: '4.0'
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 4.0.0
76
+ description: Directed Acyclic Graph hierarchy for Rail's ActiveRecord, supporting
77
+ Rails 4.x
96
78
  email:
97
79
  - resgraph@cox.net
98
80
  executables: []
99
81
  extensions: []
100
82
  extra_rdoc_files: []
101
83
  files:
102
- - .gitignore
84
+ - ".gitignore"
103
85
  - Gemfile
104
86
  - MIT-LICENSE
105
87
  - README.rdoc
@@ -118,30 +100,26 @@ files:
118
100
  - test/dag_test.rb
119
101
  homepage: https://github.com/resgraph/acts-as-dag
120
102
  licenses: []
103
+ metadata: {}
121
104
  post_install_message:
122
105
  rdoc_options: []
123
106
  require_paths:
124
107
  - lib
125
108
  required_ruby_version: !ruby/object:Gem::Requirement
126
- none: false
127
109
  requirements:
128
- - - ! '>='
110
+ - - ">="
129
111
  - !ruby/object:Gem::Version
130
112
  version: '0'
131
- segments:
132
- - 0
133
- hash: -251717266432713559
134
113
  required_rubygems_version: !ruby/object:Gem::Requirement
135
- none: false
136
114
  requirements:
137
- - - ! '>='
115
+ - - ">="
138
116
  - !ruby/object:Gem::Version
139
117
  version: '0'
140
118
  requirements: []
141
119
  rubyforge_project: acts-as-dag
142
- rubygems_version: 1.8.25
120
+ rubygems_version: 2.2.2
143
121
  signing_key:
144
- specification_version: 3
122
+ specification_version: 4
145
123
  summary: Directed Acyclic Graph hierarchy for Rail's ActiveRecord
146
124
  test_files:
147
125
  - test/dag_test.rb