Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gemspec
29 changes: 14 additions & 15 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
require 'rake/testtask'
require 'rdoc/task'
require 'bundler/gem_tasks'
require "rake/testtask"
require "rdoc/task"
require "bundler/gem_tasks"

desc 'Default: run unit tests.'
task :default => :test
desc "Default: run unit tests."
task default: :test

desc 'Test the acts_as_dag plugin.'
desc "Test the acts_as_dag plugin."
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.libs << "lib"
t.pattern = "test/**/*_test.rb"
t.verbose = true
end

desc 'Generate documentation for the acts_as_dag plugin.'
desc "Generate documentation for the acts_as_dag plugin."
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'ActsAsDag'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/dag/dag.rb')
rdoc.rdoc_dir = "rdoc"
rdoc.title = "ActsAsDag"
rdoc.options << "--line-numbers" << "--inline-source"
rdoc.rdoc_files.include("README.rdoc")
rdoc.rdoc_files.include("lib/dag/dag.rb")
end

23 changes: 11 additions & 12 deletions acts-as-dag.gemspec
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
$LOAD_PATH.push File.expand_path("lib", __dir__)
require "acts-as-dag/version"

Gem::Specification.new do |s|
s.name = "acts-as-dag"
s.version = Acts::As::Dag::VERSION
s.authors = ['Matthew Leventi', 'Robert Schmitt']
s.authors = ["Matthew Leventi", "Robert Schmitt"]
s.email = ["[email protected]"]
s.homepage = 'https://github.com/resgraph/acts-as-dag'
s.summary = %q{Directed Acyclic Graph hierarchy for Rail's ActiveRecord}
s.description = %q{Directed Acyclic Graph hierarchy for Rail's ActiveRecord, supporting Rails 4.x}
s.homepage = "https://github.com/resgraph/acts-as-dag"
s.summary = "Directed Acyclic Graph hierarchy for Rail's ActiveRecord"
s.description = "Directed Acyclic Graph hierarchy for Rail's ActiveRecord, supporting Rails 4.x"

s.rubyforge_project = "acts-as-dag"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
s.require_paths = ["lib"]

# As specified in test/dag_test.rb
s.add_development_dependency 'rake'
s.add_development_dependency 'sqlite3'
s.add_runtime_dependency 'activemodel'
s.add_runtime_dependency 'activerecord', '>= 4.0.0'
s.add_development_dependency "rake"
s.add_development_dependency "sqlite3"
s.add_dependency "activemodel"
s.add_dependency "activerecord", ">= 4.0.0"
s.metadata["rubygems_mfa_required"] = "true"
end
4 changes: 1 addition & 3 deletions lib/acts-as-dag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@

$LOAD_PATH.shift

if defined?(ActiveRecord::Base)
ActiveRecord::Base.extend Dag
end
ActiveRecord::Base.extend Dag if defined?(ActiveRecord::Base)
2 changes: 1 addition & 1 deletion lib/acts-as-dag/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Acts
module As
module Dag
VERSION = "4.0.0"
VERSION = "5.0.0"
end
end
end
44 changes: 26 additions & 18 deletions lib/dag/columns.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
module Dag

#Methods that show columns
# Methods that show columns
module Columns
def ancestor_id_column_name
acts_as_dag_options[:ancestor_id_column]
end
def ancestor_id_column_name
acts_as_dag_options[:ancestor_id_column]
end

def descendant_id_column_name
acts_as_dag_options[:descendant_id_column]
end
def descendant_id_column_name
acts_as_dag_options[:descendant_id_column]
end

def direct_column_name
acts_as_dag_options[:direct_column]
end
def scoped_record_id_column_name
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jméno sloupce s id záznamu, ke kterému se daná část stromu vztahuje

acts_as_dag_options[:scoped_record_id_column]
end

def count_column_name
acts_as_dag_options[:count_column]
end
def direct_column_name
acts_as_dag_options[:direct_column]
end

def acts_as_dag_polymorphic?
acts_as_dag_options[:polymorphic]
end
def count_column_name
acts_as_dag_options[:count_column]
end

end
def acts_as_dag_polymorphic?
acts_as_dag_options[:polymorphic]
end

def scoped_record_id
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id sloupce scoped_record_id_column_name. Pokud není definován, vrací se nil. Jde pořád o volitelný parametr a vše musí fungovat i bez něj.

return unless scoped_record_id_column_name && respond_to?(scoped_record_id_column_name)

public_send(scoped_record_id_column_name)
end
end
end
Loading