lalala 4.0.0.dev.136 → 4.0.0.dev.141

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. checksums.yaml +4 -4
  2. data/.gitmodules +0 -3
  3. data/lalala.gemspec +2 -6
  4. data/lib/lalala/version.rb +1 -1
  5. data/lib/lalala.rb +0 -1
  6. metadata +19 -53
  7. data/vendor/deps/closure_tree/.gitignore +0 -12
  8. data/vendor/deps/closure_tree/.travis.yml +0 -22
  9. data/vendor/deps/closure_tree/.yardopts +0 -3
  10. data/vendor/deps/closure_tree/Gemfile +0 -2
  11. data/vendor/deps/closure_tree/MIT-LICENSE +0 -19
  12. data/vendor/deps/closure_tree/README.md +0 -641
  13. data/vendor/deps/closure_tree/Rakefile +0 -26
  14. data/vendor/deps/closure_tree/ci/Gemfile.rails-3.0.x +0 -5
  15. data/vendor/deps/closure_tree/ci/Gemfile.rails-3.1.x +0 -4
  16. data/vendor/deps/closure_tree/ci/Gemfile.rails-3.2.x +0 -4
  17. data/vendor/deps/closure_tree/closure_tree.gemspec +0 -31
  18. data/vendor/deps/closure_tree/lib/closure_tree/acts_as_tree.rb +0 -55
  19. data/vendor/deps/closure_tree/lib/closure_tree/columns.rb +0 -123
  20. data/vendor/deps/closure_tree/lib/closure_tree/deterministic_ordering.rb +0 -49
  21. data/vendor/deps/closure_tree/lib/closure_tree/model.rb +0 -386
  22. data/vendor/deps/closure_tree/lib/closure_tree/numeric_deterministic_ordering.rb +0 -93
  23. data/vendor/deps/closure_tree/lib/closure_tree/version.rb +0 -3
  24. data/vendor/deps/closure_tree/lib/closure_tree/with_advisory_lock.rb +0 -18
  25. data/vendor/deps/closure_tree/lib/closure_tree.rb +0 -8
  26. data/vendor/deps/closure_tree/spec/cuisine_type_spec.rb +0 -30
  27. data/vendor/deps/closure_tree/spec/db/database.yml +0 -19
  28. data/vendor/deps/closure_tree/spec/db/schema.rb +0 -109
  29. data/vendor/deps/closure_tree/spec/fixtures/labels.yml +0 -55
  30. data/vendor/deps/closure_tree/spec/fixtures/tags.yml +0 -98
  31. data/vendor/deps/closure_tree/spec/hash_tree_spec.rb +0 -91
  32. data/vendor/deps/closure_tree/spec/label_spec.rb +0 -356
  33. data/vendor/deps/closure_tree/spec/namespace_type_spec.rb +0 -13
  34. data/vendor/deps/closure_tree/spec/parallel_prepend_sibling_spec.rb +0 -45
  35. data/vendor/deps/closure_tree/spec/parallel_spec.rb +0 -59
  36. data/vendor/deps/closure_tree/spec/spec_helper.rb +0 -57
  37. data/vendor/deps/closure_tree/spec/support/models.rb +0 -74
  38. data/vendor/deps/closure_tree/spec/tag_spec.rb +0 -469
  39. data/vendor/deps/closure_tree/spec/user_spec.rb +0 -136
  40. data/vendor/deps/closure_tree/tests.sh +0 -19
@@ -1,93 +0,0 @@
1
- # This module is only included if the order column is an integer.
2
- module ClosureTree
3
- module DeterministicNumericOrdering
4
- extend ActiveSupport::Concern
5
-
6
- def self_and_descendants_preordered
7
- # TODO: raise NotImplementedError if sort_order is not numeric and not null?
8
- h = connection.select_one(<<-SQL)
9
- SELECT
10
- count(*) as total_descendants,
11
- max(generations) as max_depth
12
- FROM #{quoted_hierarchy_table_name}
13
- WHERE ancestor_id = #{ct_quote(self.id)}
14
- SQL
15
- join_sql = <<-SQL
16
- JOIN #{quoted_hierarchy_table_name} anc_hier
17
- ON anc_hier.descendant_id = #{quoted_hierarchy_table_name}.descendant_id
18
- JOIN #{quoted_table_name} anc
19
- ON anc.id = anc_hier.ancestor_id
20
- JOIN #{quoted_hierarchy_table_name} depths
21
- ON depths.ancestor_id = #{ct_quote(self.id)} AND depths.descendant_id = anc.id
22
- SQL
23
- node_score = "(1 + anc.#{quoted_order_column(false)}) * " +
24
- "power(#{h['total_descendants']}, #{h['max_depth'].to_i + 1} - depths.generations)"
25
- order_by = "sum(#{node_score})"
26
- self_and_descendants.joins(join_sql).group("#{quoted_table_name}.id").reorder(order_by)
27
- end
28
-
29
- module ClassMethods
30
- def roots_and_descendants_preordered
31
- h = connection.select_one(<<-SQL)
32
- SELECT
33
- count(*) as total_descendants,
34
- max(generations) as max_depth
35
- FROM #{quoted_hierarchy_table_name}
36
- SQL
37
- join_sql = <<-SQL
38
- JOIN #{quoted_hierarchy_table_name} anc_hier
39
- ON anc_hier.descendant_id = #{quoted_table_name}.id
40
- JOIN #{quoted_table_name} anc
41
- ON anc.id = anc_hier.ancestor_id
42
- JOIN (
43
- SELECT descendant_id, max(generations) AS max_depth
44
- FROM #{quoted_hierarchy_table_name}
45
- GROUP BY 1
46
- ) AS depths ON depths.descendant_id = anc.id
47
- SQL
48
- node_score = "(1 + anc.#{quoted_order_column(false)}) * " +
49
- "power(#{h['total_descendants']}, #{h['max_depth'].to_i + 1} - depths.max_depth)"
50
- order_by = "sum(#{node_score})"
51
- joins(join_sql).group("#{quoted_table_name}.id").reorder(order_by)
52
- end
53
- end
54
-
55
- def append_sibling(sibling_node, use_update_all = true)
56
- add_sibling(sibling_node, use_update_all, true)
57
- end
58
-
59
- def prepend_sibling(sibling_node, use_update_all = true)
60
- add_sibling(sibling_node, use_update_all, false)
61
- end
62
-
63
- def add_sibling(sibling_node, use_update_all = true, add_after = true)
64
- fail "can't add self as sibling" if self == sibling_node
65
- # issue 40: we need to lock the parent to prevent deadlocks on parallel sibling additions
66
- ct_with_advisory_lock do
67
- # issue 18: we need to set the order_value explicitly so subsequent orders will work.
68
- update_attribute(:order_value, 0) if self.order_value.nil?
69
- sibling_node.order_value = self.order_value.to_i + (add_after ? 1 : -1)
70
- # We need to incr the before_siblings to make room for sibling_node:
71
- if use_update_all
72
- col = quoted_order_column(false)
73
- # issue 21: we have to use the base class, so STI doesn't get in the way of only updating the child class instances:
74
- ct_base_class.update_all(
75
- ["#{col} = #{col} #{add_after ? '+' : '-'} 1", "updated_at = now()"],
76
- ["#{quoted_parent_column_name} = ? AND #{col} #{add_after ? '>=' : '<='} ?",
77
- ct_parent_id,
78
- sibling_node.order_value])
79
- else
80
- last_value = sibling_node.order_value.to_i
81
- (add_after ? siblings_after : siblings_before.reverse).each do |ea|
82
- last_value += (add_after ? 1 : -1)
83
- ea.order_value = last_value
84
- ea.save!
85
- end
86
- end
87
- sibling_node.parent = self.parent
88
- sibling_node.save!
89
- sibling_node.reload
90
- end
91
- end
92
- end
93
- end
@@ -1,3 +0,0 @@
1
- module ClosureTree
2
- VERSION = "3.10.0" unless defined?(::ClosureTree::VERSION)
3
- end
@@ -1,18 +0,0 @@
1
- require 'with_advisory_lock'
2
-
3
- module ClosureTree
4
- module WithAdvisoryLock
5
- def ct_with_advisory_lock(&block)
6
- if closure_tree_options[:with_advisory_lock]
7
- with_advisory_lock("closure_tree") do
8
- transaction do
9
- yield
10
- end
11
- end
12
- else
13
- yield
14
- end
15
- end
16
- end
17
- end
18
-
@@ -1,8 +0,0 @@
1
- require 'active_support'
2
- require 'active_record'
3
-
4
- ActiveSupport.on_load :active_record do
5
- require 'closure_tree/acts_as_tree'
6
-
7
- ActiveRecord::Base.send :extend, ClosureTree::ActsAsTree
8
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- def assert_lineage(e, m)
4
- m.parent.should == e
5
- m.self_and_ancestors.should == [m, e]
6
-
7
- # make sure reloading doesn't affect the self_and_ancestors:
8
- m.reload
9
- m.self_and_ancestors.should == [m, e]
10
- end
11
-
12
- describe CuisineType do
13
- it "finds self and parents when children << is used" do
14
- e = CuisineType.new(:name => "e")
15
- m = CuisineType.new(:name => "m")
16
- e.children << m
17
- e.save
18
- assert_lineage(e, m)
19
- end
20
-
21
- it "finds self and parents properly if the constructor is used" do
22
- e = CuisineType.create(:name => "e")
23
- m = CuisineType.create(:name => "m", :parent => e)
24
- assert_lineage(e, m)
25
- end
26
-
27
- it "sets the table_name of the hierarchy class properly" do
28
- CuisineTypeHierarchy.table_name.should == ActiveRecord::Base.table_name_prefix + "cuisine_type_hierarchies" + ActiveRecord::Base.table_name_suffix
29
- end
30
- end
@@ -1,19 +0,0 @@
1
- sqlite:
2
- adapter: <%= "jdbc" if defined? JRUBY_VERSION %>sqlite3
3
- database: spec/sqlite3.db
4
- pool: 50
5
- timeout: 5000
6
-
7
- postgresql:
8
- adapter: postgresql
9
- username: postgres
10
- database: closure_tree_test
11
- min_messages: ERROR
12
- pool: 50
13
-
14
- mysql:
15
- adapter: mysql2
16
- host: localhost
17
- username: root
18
- database: closure_tree_test
19
- pool: 50
@@ -1,109 +0,0 @@
1
- # encoding: UTF-8
2
- class ActiveRecord::ConnectionAdapters::AbstractAdapter
3
- def force_add_index(table_name, columns, options = {})
4
- begin
5
- remove_index!(table_name, options[:name])
6
- rescue ActiveRecord::StatementInvalid, ArgumentError
7
- end
8
- add_index table_name, columns, options
9
- end
10
- end
11
-
12
- ActiveRecord::Schema.define(:version => 0) do
13
-
14
- create_table "tags", :force => true do |t|
15
- t.string "name"
16
- t.string "title"
17
- t.integer "parent_id"
18
- t.integer "sort_order"
19
- t.datetime "created_at"
20
- t.datetime "updated_at"
21
- end
22
-
23
- create_table "tag_hierarchies", :id => false, :force => true do |t|
24
- t.integer "ancestor_id", :null => false
25
- t.integer "descendant_id", :null => false
26
- t.integer "generations", :null => false
27
- end
28
-
29
- create_table "tags_uuid", :id => false, :force => true do |t|
30
- t.string "id", :unique => true
31
- t.string "name"
32
- t.string "title"
33
- t.string "parent_id"
34
- t.integer "sort_order"
35
- t.datetime "created_at"
36
- t.datetime "updated_at"
37
- end
38
-
39
- create_table "tag_hierarchies_uuid", :id => false, :force => true do |t|
40
- t.string "ancestor_id", :null => false
41
- t.string "descendant_id", :null => false
42
- t.integer "generations", :null => false
43
- end
44
-
45
- create_table "destroyed_tags", :force => true do |t|
46
- t.string "name"
47
- end
48
-
49
- force_add_index "tag_hierarchies", [:ancestor_id, :descendant_id], :unique => true, :name => "tag_anc_desc_idx"
50
- force_add_index "tag_hierarchies", [:descendant_id], :name => "tag_desc_idx"
51
-
52
- create_table "users", :force => true do |t|
53
- t.string "email"
54
- t.integer "referrer_id"
55
- t.datetime "created_at"
56
- t.datetime "updated_at"
57
- end
58
-
59
- create_table "contracts", :force => true do |t|
60
- t.integer "user_id", :null => false
61
- end
62
-
63
- create_table "referral_hierarchies", :id => false, :force => true do |t|
64
- t.integer "ancestor_id", :null => false
65
- t.integer "descendant_id", :null => false
66
- t.integer "generations", :null => false
67
- end
68
-
69
- force_add_index "referral_hierarchies", [:ancestor_id, :descendant_id], :unique => true, :name => "ref_anc_desc_idx"
70
- force_add_index "referral_hierarchies", [:descendant_id], :name => "ref_desc_idx"
71
-
72
- create_table "labels", :force => true do |t|
73
- t.string "name"
74
- t.string "type"
75
- t.integer "sort_order"
76
- t.integer "mother_id"
77
- end
78
-
79
- create_table "label_hierarchies", :id => false, :force => true do |t|
80
- t.integer "ancestor_id", :null => false
81
- t.integer "descendant_id", :null => false
82
- t.integer "generations", :null => false
83
- end
84
-
85
- force_add_index "label_hierarchies", [:ancestor_id, :descendant_id], :unique => true, :name => "lh_anc_desc_idx"
86
- force_add_index "label_hierarchies", [:descendant_id], :name => "lh_desc_idx"
87
-
88
- create_table "cuisine_types", :force => true do |t|
89
- t.string "name"
90
- t.integer "parent_id"
91
- end
92
-
93
- create_table "cuisine_type_hierarchies", :id => false, :force => true do |t|
94
- t.integer "ancestor_id", :null => false
95
- t.integer "descendant_id", :null => false
96
- t.integer "generations", :null => false
97
- end
98
-
99
- create_table "namespace_types", :force => true do |t|
100
- t.string "name"
101
- t.integer "parent_id"
102
- end
103
-
104
- create_table "namespace_type_hierarchies", :id => false, :force => true do |t|
105
- t.integer "ancestor_id", :null => false
106
- t.integer "descendant_id", :null => false
107
- t.integer "generations", :null => false
108
- end
109
- end
@@ -1,55 +0,0 @@
1
- a1:
2
- name: a1
3
- sort_order: 1
4
-
5
- b1:
6
- name: b1
7
- parent: a1
8
- sort_order: 1
9
-
10
- b2:
11
- name: b2
12
- parent: a1
13
- sort_order: 2
14
-
15
- # Note that the names are not alphabetically ordered:
16
- c16:
17
- name: c1-six
18
- parent: b1
19
- sort_order: 6
20
-
21
- c17:
22
- name: c1-seven
23
- parent: b1
24
- sort_order: 7
25
-
26
- c18:
27
- name: c1-eight
28
- parent: b1
29
- sort_order: 8
30
-
31
- c19:
32
- name: c1-nine
33
- parent: b1
34
- sort_order: 9
35
-
36
- c2:
37
- name: c2
38
- parent: b2
39
- sort_order: 1
40
-
41
- d2:
42
- name: d2
43
- parent: c2
44
- sort_order: 1
45
-
46
- e2:
47
- name: e2
48
- parent: d2
49
- sort_order: 1
50
-
51
- f3:
52
- name: f3
53
-
54
- f4:
55
- name: f4
@@ -1,98 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html
2
-
3
- grandparent:
4
- name: grandparent
5
- title: Nonnie
6
-
7
- parent:
8
- name: parent
9
- parent: grandparent
10
- title: Mom
11
-
12
- child:
13
- name: child
14
- parent: parent
15
- title: Kid
16
-
17
- people:
18
- name: people
19
-
20
- # people has no children
21
-
22
- events:
23
- name: events
24
-
25
- # events has only one child
26
-
27
- birthday:
28
- name: birthday
29
- parent: events
30
-
31
- places:
32
- name: places
33
-
34
- # places has many children, with many depths
35
-
36
- home:
37
- name: home
38
- parent: places
39
-
40
- indoor:
41
- name: indoor
42
- parent: places
43
-
44
- outdoor:
45
- name: outdoor
46
- parent: places
47
-
48
- museum:
49
- name: museum
50
- parent: places
51
-
52
- united_states:
53
- name: united_states
54
- parent: places
55
-
56
- california:
57
- name: california
58
- parent: united_states
59
-
60
- san_francisco:
61
- name: san_francisco
62
- parent: california
63
-
64
-
65
- # Move and deletion test tree
66
-
67
- a1:
68
- name: a1
69
-
70
- b1:
71
- name: b1
72
- parent: a1
73
-
74
- b2:
75
- name: b2
76
- parent: a1
77
-
78
- c1a:
79
- name: c1a
80
- parent: b1
81
- sort_order: 2
82
-
83
- c1b:
84
- name: c1b
85
- parent: b1
86
- sort_order: 1
87
-
88
- c2:
89
- name: c2
90
- parent: b2
91
-
92
- d2:
93
- name: d2
94
- parent: c2
95
-
96
- e2:
97
- name: e2
98
- parent: d2
@@ -1,91 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Tag do
4
-
5
- before :each do
6
- @b = Tag.find_or_create_by_path %w(a b)
7
- @a = @b.parent
8
- @b2 = Tag.find_or_create_by_path %w(a b2)
9
- @d1 = @b.find_or_create_by_path %w(c1 d1)
10
- @c1 = @d1.parent
11
- @d2 = @b.find_or_create_by_path %w(c2 d2)
12
- @c2 = @d2.parent
13
- @full_tree = {@a => {@b => {@c1 => {@d1 => {}}, @c2 => {@d2 => {}}}, @b2 => {}}}
14
- end
15
-
16
- context "#hash_tree" do
17
- it "returns {} for depth 0" do
18
- Tag.hash_tree(:limit_depth => 0).should == {}
19
- end
20
- it "limit_depth 1" do
21
- Tag.hash_tree(:limit_depth => 1).should == {@a => {}}
22
- end
23
- it "limit_depth 2" do
24
- Tag.hash_tree(:limit_depth => 2).should == {@a => {@b => {}, @b2 => {}}}
25
- end
26
- it "limit_depth 3" do
27
- Tag.hash_tree(:limit_depth => 3).should == {@a => {@b => {@c1 => {}, @c2 => {}}, @b2 => {}}}
28
- end
29
- it "limit_depth 4" do
30
- Tag.hash_tree(:limit_depth => 4).should == @full_tree
31
- end
32
- it "no limit holdum" do
33
- Tag.hash_tree.should == @full_tree
34
- end
35
- end
36
-
37
- def assert_no_dupes(scope)
38
- # the named scope is complicated enough that an incorrect join could result in unnecessarily
39
- # duplicated rows:
40
- a = scope.collect { |ea| ea.id }
41
- a.should == a.uniq
42
- end
43
-
44
- context "#hash_tree_scope" do
45
- it "no dupes for any depth" do
46
- (0..5).each do |ea|
47
- assert_no_dupes(Tag.hash_tree_scope(ea))
48
- end
49
- end
50
- it "no limit holdum" do
51
- assert_no_dupes(Tag.hash_tree_scope)
52
- end
53
- end
54
-
55
- context ".hash_tree_scope" do
56
- it "no dupes for any depth" do
57
- (0..5).each do |ea|
58
- assert_no_dupes(@a.hash_tree_scope(ea))
59
- end
60
- end
61
- it "no limit holdum" do
62
- assert_no_dupes(@a.hash_tree_scope)
63
- end
64
- end
65
-
66
- context ".hash_tree" do
67
- before :each do
68
- end
69
- it "returns {} for depth 0" do
70
- @b.hash_tree(:limit_depth => 0).should == {}
71
- end
72
- it "limit_depth 1" do
73
- @b.hash_tree(:limit_depth => 1).should == {@b => {}}
74
- end
75
- it "limit_depth 2" do
76
- @b.hash_tree(:limit_depth => 2).should == {@b => {@c1 => {}, @c2 => {}}}
77
- end
78
- it "limit_depth 3" do
79
- @b.hash_tree(:limit_depth => 3).should == {@b => {@c1 => {@d1 => {}}, @c2 => {@d2 => {}}}}
80
- end
81
- it "no limit holdum from subsubroot" do
82
- @c1.hash_tree.should == {@c1 => {@d1 => {}}}
83
- end
84
- it "no limit holdum from subroot" do
85
- @b.hash_tree.should == {@b => {@c1 => {@d1 => {}}, @c2 => {@d2 => {}}}}
86
- end
87
- it "no limit holdum from root" do
88
- @a.hash_tree.should == @full_tree
89
- end
90
- end
91
- end