acts_as_better_tree 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
data/.DS_Store ADDED
Binary file
data/Gemfile.lock ADDED
@@ -0,0 +1,106 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ acts_as_better_tree (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionmailer (3.2.7)
10
+ actionpack (= 3.2.7)
11
+ mail (~> 2.4.4)
12
+ actionpack (3.2.7)
13
+ activemodel (= 3.2.7)
14
+ activesupport (= 3.2.7)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ journey (~> 1.0.4)
18
+ rack (~> 1.4.0)
19
+ rack-cache (~> 1.2)
20
+ rack-test (~> 0.6.1)
21
+ sprockets (~> 2.1.3)
22
+ activemodel (3.2.7)
23
+ activesupport (= 3.2.7)
24
+ builder (~> 3.0.0)
25
+ activerecord (3.2.7)
26
+ activemodel (= 3.2.7)
27
+ activesupport (= 3.2.7)
28
+ arel (~> 3.0.2)
29
+ tzinfo (~> 0.3.29)
30
+ activeresource (3.2.7)
31
+ activemodel (= 3.2.7)
32
+ activesupport (= 3.2.7)
33
+ activesupport (3.2.7)
34
+ i18n (~> 0.6)
35
+ multi_json (~> 1.0)
36
+ arel (3.0.2)
37
+ builder (3.0.0)
38
+ diff-lcs (1.1.3)
39
+ erubis (2.7.0)
40
+ factory_girl (3.6.1)
41
+ activesupport (>= 3.0.0)
42
+ hike (1.2.1)
43
+ i18n (0.6.0)
44
+ journey (1.0.4)
45
+ json (1.7.4)
46
+ mail (2.4.4)
47
+ i18n (>= 0.4.0)
48
+ mime-types (~> 1.16)
49
+ treetop (~> 1.4.8)
50
+ mime-types (1.19)
51
+ multi_json (1.3.6)
52
+ polyglot (0.3.3)
53
+ rack (1.4.1)
54
+ rack-cache (1.2)
55
+ rack (>= 0.4)
56
+ rack-ssl (1.3.2)
57
+ rack
58
+ rack-test (0.6.1)
59
+ rack (>= 1.0)
60
+ rails (3.2.7)
61
+ actionmailer (= 3.2.7)
62
+ actionpack (= 3.2.7)
63
+ activerecord (= 3.2.7)
64
+ activeresource (= 3.2.7)
65
+ activesupport (= 3.2.7)
66
+ bundler (~> 1.0)
67
+ railties (= 3.2.7)
68
+ railties (3.2.7)
69
+ actionpack (= 3.2.7)
70
+ activesupport (= 3.2.7)
71
+ rack-ssl (~> 1.3.2)
72
+ rake (>= 0.8.7)
73
+ rdoc (~> 3.4)
74
+ thor (>= 0.14.6, < 2.0)
75
+ rake (0.9.2.2)
76
+ rdoc (3.12)
77
+ json (~> 1.4)
78
+ rspec (2.11.0)
79
+ rspec-core (~> 2.11.0)
80
+ rspec-expectations (~> 2.11.0)
81
+ rspec-mocks (~> 2.11.0)
82
+ rspec-core (2.11.1)
83
+ rspec-expectations (2.11.2)
84
+ diff-lcs (~> 1.1.3)
85
+ rspec-mocks (2.11.1)
86
+ sprockets (2.1.3)
87
+ hike (~> 1.2)
88
+ rack (~> 1.0)
89
+ tilt (~> 1.1, != 1.3.0)
90
+ sqlite3 (1.3.6)
91
+ thor (0.15.4)
92
+ tilt (1.3.3)
93
+ treetop (1.4.10)
94
+ polyglot
95
+ polyglot (>= 0.3.1)
96
+ tzinfo (0.3.33)
97
+
98
+ PLATFORMS
99
+ ruby
100
+
101
+ DEPENDENCIES
102
+ acts_as_better_tree!
103
+ factory_girl
104
+ rails (>= 3.2.5)
105
+ rspec
106
+ sqlite3
Binary file
Binary file
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ["isaac@isaacsloan.com"]
7
7
  gem.description = %q{acts_as_better_tree is great for anyone who needs a fast tree capable of handling millions of nodes without slowing down on writes like nestedset or on reads like a standard tree.}
8
8
  gem.summary = %q{acts_as_better_tree is backwards compatible with acts_as_tree and remains fast with large datasets by storing the ancestry of every node in the field csv_ids.}
9
- gem.homepage = ""
9
+ gem.homepage = "https://github.com/isaacsloan/acts_as_better_tree"
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
12
12
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
data/gemtest ADDED
Binary file
@@ -1,3 +1,3 @@
1
1
  module ActsAsBetterTree
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ ActiveRecord::Base::establish_connection(:adapter => "sqlite3", :dbfile => ":memory:", :database => "gemtest")
4
+ $stdout = StringIO.new
5
+
6
+ def setup_db
7
+ ActiveRecord::Base.logger
8
+ ActiveRecord::Schema.define(:version => 1) do
9
+ create_table :categories do |t|
10
+ t.column :root_id, :integer
11
+ t.column :parent_id, :integer
12
+ t.column :csv_ids, :string
13
+ t.column :name, :string
14
+ end
15
+ end
16
+ end
17
+
18
+ def teardown_db
19
+ ActiveRecord::Base.connection.tables.each do |table|
20
+ ActiveRecord::Base.connection.drop_table(table)
21
+ end
22
+ end
23
+
24
+ class Category < ActiveRecord::Base
25
+ acts_as_better_tree
26
+ end
27
+
28
+ describe "ActsAsBetterTree" do
29
+ before :all do
30
+ teardown_db
31
+ setup_db
32
+ Category.create(name: "Animals")
33
+ end
34
+
35
+ describe "#roots" do
36
+ it "should find at least one root" do
37
+ Category.roots.size.should >= 1
38
+ end
39
+ end
40
+
41
+ it "should make node child of parent" do
42
+ cat = Category.create(:name => "Cats", :parent_id => Category.roots.first.id)
43
+ lion = Category.create(:name => "Lions")
44
+ lion.move_to_child_of(cat)
45
+ lion.parent.should eql cat
46
+ end
47
+
48
+ it "returns children of node" do
49
+ cats = Category.find_by_name("Cats")
50
+ Category.create(:name => "Tiger", :parent => cats)
51
+ Category.create(:name => "House Cat", :parent => cats)
52
+ Category.create(:name => "Panther", :parent => cats)
53
+ cats.children.count.should eql 4
54
+ end
55
+
56
+ it "returns self and ancestors" do
57
+ tiger = Category.find_by_name("Tiger")
58
+ tiger.self_and_ancestors.map(&:name).should eql ["Animals", "Cats", "Tiger"]
59
+ end
60
+
61
+ it "returns self and siblings" do
62
+ tiger = Category.find_by_name("Tiger")
63
+ tiger.self_and_siblings.map(&:name).should eql ["Lions", "Tiger", "House Cat", "Panther"]
64
+ end
65
+
66
+ it "creates a node as child of parent" do
67
+ cats = Category.find_by_name("Cats")
68
+ bobcats = cats.children.create(:name => "Bobcats")
69
+ bobcats.parent.name.should eql "Cats"
70
+ end
71
+
72
+ end
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+ factory :animals, class: Category do
3
+ name "animals"
4
+ end
5
+
6
+ factory :cats, class: Category do
7
+ name "cats"
8
+ association :parent, factory: :animals, strategy: :build
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ require 'bundler/setup'
2
+ require 'active_record'
3
+ require 'factory_girl'
4
+ require 'acts_as_better_tree'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_better_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -20,15 +20,22 @@ executables: []
20
20
  extensions: []
21
21
  extra_rdoc_files: []
22
22
  files:
23
- - .gitignore
23
+ - .DS_Store
24
24
  - Gemfile
25
+ - Gemfile.lock
25
26
  - LICENSE
26
27
  - README.md
27
28
  - Rakefile
29
+ - acts_as_better_tree-0.0.1.gem
30
+ - acts_as_better_tree-0.9.3.gem
28
31
  - acts_as_better_tree.gemspec
32
+ - gemtest
29
33
  - lib/acts_as_better_tree.rb
30
34
  - lib/acts_as_better_tree/version.rb
31
- homepage: ''
35
+ - spec/acts_as_better_tree_spec.rb
36
+ - spec/factories/categories.rb
37
+ - spec/spec_helper.rb
38
+ homepage: https://github.com/isaacsloan/acts_as_better_tree
32
39
  licenses: []
33
40
  post_install_message:
34
41
  rdoc_options: []
@@ -53,4 +60,7 @@ signing_key:
53
60
  specification_version: 3
54
61
  summary: acts_as_better_tree is backwards compatible with acts_as_tree and remains
55
62
  fast with large datasets by storing the ancestry of every node in the field csv_ids.
56
- test_files: []
63
+ test_files:
64
+ - spec/acts_as_better_tree_spec.rb
65
+ - spec/factories/categories.rb
66
+ - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp