Skip to content

Commit

Permalink
Merging our version with tag v2.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Parker Young committed Apr 15, 2015
2 parents 52ec222 + 64cc8bc commit 9a7bd62
Show file tree
Hide file tree
Showing 20 changed files with 500 additions and 128 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -4,4 +4,5 @@ rdoc
coverage
pkg
*.gem
Gemfile.lock
Gemfile.lock
gemfiles/Gemfile*.lock
19 changes: 14 additions & 5 deletions .travis.yml
@@ -1,13 +1,22 @@
before_install: gem install bundler --pre
language: ruby
notifications:
email:
- parndt@gmail.com
script: bundle exec rspec spec
env:
- DB=sqlite3
- DB=sqlite3mem
- DB=postgresql
- DB=mysql
rvm:
- 1.8.7
- 1.9.2
- 2.0.0
- 1.9.3
- rbx
- jruby
- 1.8.7
- rbx-19mode
- jruby-19mode
- rbx-18mode
- jruby-18mode
gemfile:
- gemfiles/Gemfile.rails-3.0.rb
- gemfiles/Gemfile.rails-3.1.rb
- gemfiles/Gemfile.rails-3.2.rb
21 changes: 20 additions & 1 deletion CHANGELOG
@@ -1,3 +1,22 @@
2.1.6
* Fixed rebuild! when there is a default_scope with order [Adrian Serafin]
* Testing with stable bundler, ruby 2.0, MySQL and PostgreSQL [Philip Arndt]
* Optimized move_to for large trees [ericsmith66]

2.1.5
* Worked around issues where AR#association wasn't present on Rails 3.0.x. [Philip Arndt]
* Adds option 'order_column' which defaults to 'left_column_name'. [gudata]
* Added moving with order functionality. [Sytse Sijbrandij]
* Use tablename in all select queries. [Mikhail Dieterle]
* Made sure all descendants' depths are updated when moving parent, not just immediate child. [Phil Thompson]
* Add documentation of the callbacks. [Tobias Maier]

2.1.4
* nested_set_options accept both Class & AR Relation. [Semyon Perepelitsa]
* Reduce the number of queries triggered by the canonical usage of `i.level` in the `nested_set` helpers. [thedarkone]
* Specifically require active_record [Bogdan Gusiev]
* compute_level now checks for a non nil association target. [Joel Nimety]

2.1.3
* Update child depth when parent node is moved. [Amanda Wagener]
* Added move_to_child_with_index. [Ben Zhang]
Expand Down Expand Up @@ -35,4 +54,4 @@
* Expect Rails 3
* Changed how callbacks work. Returning false in a before_move action does not block save operations. Use a validation or exception in the callback if you need that.
* Switched to RSpec
* Remove use of Comparable
* Remove use of Comparable
32 changes: 25 additions & 7 deletions Gemfile
@@ -1,13 +1,31 @@
source 'http://rubygems.org'
gem 'combustion', :github => 'pat/combustion'

gemspec
source 'https://rubygems.org'

gem 'mysql2', :platform => :ruby
gem 'pg', :platform => :ruby
gem 'sqlite3', :platform => :ruby
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
gem 'rspec-rails', '~> 2.8'
gemspec :path => File.expand_path('../', __FILE__)

platforms :jruby do
gem 'activerecord-jdbcsqlite3-adapter'
gem 'activerecord-jdbcmysql-adapter'
gem 'activerecord-jdbcpostgresql-adapter'
gem 'jruby-openssl'
end

platforms :ruby do
gem 'sqlite3'
gem 'mysql2', (MYSQL2_VERSION if defined? MYSQL2_VERSION)
gem 'pg'
end

RAILS_VERSION = nil unless defined? RAILS_VERSION
gem 'railties', RAILS_VERSION
gem 'activerecord', RAILS_VERSION
gem 'actionpack', RAILS_VERSION

# Add Oracle Adapters
# gem 'ruby-oci8'
# gem 'activerecord-oracle_enhanced-adapter'

# Debuggers
# gem 'pry'
# gem 'pry-nav'
51 changes: 51 additions & 0 deletions README.rdoc
Expand Up @@ -59,6 +59,57 @@ Enable the nested set functionality by declaring acts_as_nested_set on your mode

Run `rake rdoc` to generate the API docs and see CollectiveIdea::Acts::NestedSet for more info.

== Callbacks

There are three callbacks called when moving a node. `before_move`, `after_move` and `around_move`.

class Category < ActiveRecord::Base
acts_as_nested_set

after_move :rebuild_slug
around_move :da_fancy_things_around

private

def rebuild_slug
# do whatever
end

def da_fancy_things_around
# do something...
yield # actually moves
# do something else...
end
end

Beside this there are also hooks to act on the newly added or removed children.

class Category < ActiveRecord::Base
acts_as_nested_set :before_add => :do_before_add_stuff,
:after_add => :do_after_add_stuff,
:before_remove => :do_before_remove_stuff,
:after_remove => :do_after_remove_stuff

private

def do_before_add_stuff(child_node)
# do whatever with the child
end

def do_after_add_stuff(child_node)
# do whatever with the child
end

def do_before_remove_stuff(child_node)
# do whatever with the child
end

def do_after_remove_stuff(child_node)
# do whatever with the child
end
end


== Protecting attributes from mass assignment

It's generally best to "white list" the attributes that can be used in mass assignment:
Expand Down
10 changes: 7 additions & 3 deletions Rakefile
Expand Up @@ -4,11 +4,15 @@ require 'rubygems'
require 'bundler/setup'
require 'awesome_nested_set/version'

require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)

task :default => :spec

task :spec do
%w(3.0 3.1 3.2).each do |rails_version|
puts "\n" + (cmd = "BUNDLE_GEMFILE='gemfiles/Gemfile.rails-#{rails_version}.rb' bundle exec rspec spec")
system cmd
end
end

task :build do
system "gem build awesome_nested_set.gemspec"
end
Expand Down
14 changes: 8 additions & 6 deletions awesome_nested_set.gemspec
@@ -1,22 +1,24 @@
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
require 'awesome_nested_set/version'
require File.expand_path('../lib/awesome_nested_set/version', __FILE__)

Gem::Specification.new do |s|
s.name = %q{awesome_nested_set}
s.version = ::AwesomeNestedSet::VERSION
s.authors = ["Brandon Keepers", "Daniel Morrison", "Philip Arndt"]
s.description = %q{An awesome nested set implementation for Active Record}
s.email = %q{info@collectiveidea.com}
s.extra_rdoc_files = [
"README.rdoc"
]
s.extra_rdoc_files = %w[README.rdoc]
s.files = Dir.glob("lib/**/*") + %w(MIT-LICENSE README.rdoc CHANGELOG)
s.homepage = %q{http://github.com/collectiveidea/awesome_nested_set}
s.rdoc_options = ["--main", "README.rdoc", "--inline-source", "--line-numbers"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.6}
s.summary = %q{An awesome nested set implementation for Active Record}
s.license = %q{MIT}

s.add_runtime_dependency 'activerecord', '>= 3.0.0'

s.add_development_dependency 'rspec-rails', '~> 2.12'
s.add_development_dependency 'rake', '~> 10'
s.add_development_dependency 'combustion', '>= 0.3.3'
end
4 changes: 4 additions & 0 deletions gemfiles/Gemfile.rails-3.0.rb
@@ -0,0 +1,4 @@
MYSQL2_VERSION = '~> 0.2.18'
RAILS_VERSION = '~> 3.0.17'

eval File.read(File.expand_path('../../Gemfile', __FILE__))
4 changes: 4 additions & 0 deletions gemfiles/Gemfile.rails-3.1.rb
@@ -0,0 +1,4 @@
MYSQL2_VERSION = '>= 0.3'
RAILS_VERSION = '~> 3.1.0'

eval File.read(File.expand_path('../../Gemfile', __FILE__))
4 changes: 4 additions & 0 deletions gemfiles/Gemfile.rails-3.2.rb
@@ -0,0 +1,4 @@
MYSQL2_VERSION = '>= 0.3'
RAILS_VERSION = '~> 3.2.0'

eval File.read(File.expand_path('../../Gemfile', __FILE__))
1 change: 1 addition & 0 deletions lib/awesome_nested_set.rb
@@ -1,4 +1,5 @@
require 'awesome_nested_set/awesome_nested_set'
require 'active_record'
ActiveRecord::Base.send :extend, CollectiveIdea::Acts::NestedSet

if defined?(ActionView)
Expand Down

0 comments on commit 9a7bd62

Please sign in to comment.