dm-is-tree 0.9.11 → 0.10.0

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.
@@ -1,3 +1,7 @@
1
+ === 0.10.0 / 2009-10-15
2
+
3
+ * Updated to work with dm-core 0.10.0
4
+
1
5
  === 0.9.11 / 2009-03-29
2
6
 
3
7
  * No changes this version
@@ -1,7 +1,7 @@
1
- History.txt
1
+ History.rdoc
2
2
  LICENSE
3
3
  Manifest.txt
4
- README.txt
4
+ README.rdoc
5
5
  Rakefile
6
6
  TODO
7
7
  lib/dm-is-tree.rb
File without changes
data/Rakefile CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'pathname'
2
- require 'rubygems'
3
2
 
4
3
  ROOT = Pathname(__FILE__).dirname.expand_path
5
4
  JRUBY = RUBY_PLATFORM =~ /java/
@@ -14,10 +13,10 @@ GEM_NAME = 'dm-is-tree'
14
13
  GEM_VERSION = DataMapper::Is::Tree::VERSION
15
14
  GEM_DEPENDENCIES = [['dm-core', GEM_VERSION]]
16
15
  GEM_CLEAN = %w[ log pkg coverage ]
17
- GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO History.txt ] }
16
+ GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.rdoc LICENSE TODO History.rdoc ] }
18
17
 
19
18
  PROJECT_NAME = 'datamapper'
20
- PROJECT_URL = "http://github.com/sam/dm-more/tree/master/#{GEM_NAME}"
19
+ PROJECT_URL = "http://github.com/datamapper/dm-more/tree/master/#{GEM_NAME}"
21
20
  PROJECT_DESCRIPTION = PROJECT_SUMMARY = 'DataMapper plugin allowing the creation of tree structures from data models'
22
21
 
23
22
  [ ROOT, ROOT.parent ].each do |dir|
@@ -1,7 +1 @@
1
- require 'rubygems'
2
- require 'pathname'
3
-
4
- gem 'dm-core', '0.9.11'
5
- require 'dm-core'
6
-
7
- require Pathname(__FILE__).dirname.expand_path / 'dm-is-tree' / 'is' / 'tree.rb'
1
+ require 'dm-is-tree/is/tree'
@@ -59,13 +59,19 @@ module DataMapper
59
59
  #
60
60
  # * <tt>child_key</tt> - specifies the column name to use for tracking of the tree (default: +parent_id+)
61
61
  def is_tree(options = {})
62
- options = { :class_name => name, :child_key => :parent_id }.merge(options) if Hash === options
62
+
63
+ if options[:class_name]
64
+ warn '+options[:class_name]+ is deprecated, use :model instead'
65
+ options[:model] = options.delete(:class_name)
66
+ end
67
+
68
+ options = { :model => name, :child_key => :parent_id }.merge(options) if Hash === options
63
69
  @tree_options = options
64
70
 
65
71
  include DataMapper::Is::Tree::InstanceMethods
66
72
  extend DataMapper::Is::Tree::ClassMethods
67
73
 
68
- assc_options = { :class_name => options[:class_name], :child_key => Array(options[:child_key]) }
74
+ assc_options = { :model => options[:model], :child_key => Array(options[:child_key]) }
69
75
  has_n_options = options[:order] ? { :order => Array(options[:order]) }.merge(assc_options) : assc_options
70
76
 
71
77
  belongs_to :parent, assc_options
@@ -123,7 +129,7 @@ module DataMapper
123
129
  #
124
130
  # grandchild1.siblings # => [grandchild2]
125
131
  def siblings
126
- generation - [self]
132
+ generation.reject{|r| r.key == self.key }
127
133
  end
128
134
 
129
135
  # Returns all children of the current node’s parent.
@@ -1,7 +1,7 @@
1
1
  module DataMapper
2
2
  module Is
3
3
  module Tree
4
- VERSION = '0.9.11'
4
+ VERSION = '0.10.0'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -1,10 +1,10 @@
1
- require File.dirname(__FILE__) + "/../spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
4
4
 
5
5
  describe DataMapper::Is::Tree do
6
6
 
7
- class ::Category
7
+ class Category
8
8
  include DataMapper::Resource
9
9
 
10
10
  property :id, Serial
@@ -1 +1,2 @@
1
1
  --colour
2
+ --loadby random
@@ -1,10 +1,14 @@
1
- require 'pathname'
2
1
  require 'rubygems'
3
2
 
4
- gem 'rspec', '~>1.2'
5
- require 'spec'
3
+ # use local dm-core if running from a typical dev checkout.
4
+ lib = File.join('..', '..', 'dm-core', 'lib')
5
+ $LOAD_PATH.unshift(lib) if File.directory?(lib)
6
+ require 'dm-core'
6
7
 
7
- require Pathname(__FILE__).dirname.expand_path.parent + 'lib/dm-is-tree'
8
+ # Support running specs with 'rake spec' and 'spec'
9
+ $LOAD_PATH.unshift('lib') unless $LOAD_PATH.include?('lib')
10
+
11
+ require 'dm-is-tree'
8
12
 
9
13
  def load_driver(name, default_uri)
10
14
  return false if ENV['ADAPTER'] != name.to_s
@@ -1,9 +1,9 @@
1
- require File.dirname(__FILE__) + "/../spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Is::Tree do
4
4
 
5
5
  before do
6
- class Category
6
+ class ::Category
7
7
  include DataMapper::Resource
8
8
 
9
9
  property :id, Serial
@@ -59,22 +59,26 @@ describe DataMapper::Is::Tree do
59
59
 
60
60
  describe "parent relationship" do
61
61
 
62
- it "should set the class_name from the current class" do
62
+ it "should set the model from the current class" do
63
+ # Internals of relationships has changed
63
64
  Category.is :tree
64
- Category.relationships[:parent].options[:class_name].should == Category.name
65
+ Category.relationships[:parent].child_model.should == Category
65
66
  end
66
67
 
67
68
  it "should use the default child_key of :parent_id if none is supplied in the options" do
69
+ # Internals of relationships has changed
68
70
  Category.is :tree
69
- Category.relationships[:parent].options[:child_key].should == Array(:parent_id)
71
+ Category.relationships[:parent].options[:child_key].should == [ :parent_id ]
70
72
  end
71
73
 
72
74
  it "should use the child_key from the options if it is supplied" do
75
+ # Internals of relationships has changed
73
76
  Category.is :tree, :child_key => :other_id
74
- Category.relationships[:parent].options[:child_key].should == Array(:other_id)
77
+ Category.relationships[:parent].options[:child_key].should == [ :other_id ]
75
78
  end
76
79
 
77
80
  it "should not set any order" do
81
+ # Internals of relationships has changed
78
82
  Category.is :tree, :order => :name
79
83
  Category.relationships[:parent].options.should_not have_key(:order)
80
84
  end
@@ -83,29 +87,34 @@ describe DataMapper::Is::Tree do
83
87
 
84
88
  describe "children relationship" do
85
89
 
86
- it "should set the class_name from the current class" do
90
+ it "should set the model from the current class" do
91
+ # Internals of relationships has changed
87
92
  Category.is :tree
88
- Category.relationships[:children].options[:class_name].should == Category.name
93
+ Category.relationships[:children].child_model.should == Category
89
94
  end
90
95
 
91
96
  it "should use the default child_key of :parent_id if none is supplied in the options" do
97
+ # Internals of relationships has changed
92
98
  Category.is :tree
93
- Category.relationships[:children].options[:child_key].should == Array(:parent_id)
99
+ Category.relationships[:children].options[:child_key].should == [ :parent_id ]
94
100
  end
95
101
 
96
102
  it "should use the child_key from the options if it is supplied" do
103
+ # Internals of relationships has changed
97
104
  Category.is :tree, :child_key => :other_id
98
- Category.relationships[:children].options[:child_key].should == Array(:other_id)
105
+ Category.relationships[:children].options[:child_key].should == [ :other_id ]
99
106
  end
100
107
 
101
108
  it "should not set any order if none is supplied in the options" do
109
+ # Internals of relationships has changed
102
110
  Category.is :tree
103
111
  Category.relationships[:children].options.should_not have_key(:order)
104
112
  end
105
113
 
106
114
  it "should use the order from the options if it is supplied" do
115
+ # Internals of relationships has changed
107
116
  Category.is :tree, :order => :name
108
- Category.relationships[:children].options[:order].should == Array(:name)
117
+ Category.relationships[:children].options[:order].should == [ :name ]
109
118
  end
110
119
 
111
120
  end
@@ -4,7 +4,7 @@ end
4
4
 
5
5
  desc "Install #{GEM_NAME} #{GEM_VERSION}"
6
6
  task :install => [ :package ] do
7
- sudo_gem "install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources"
7
+ sudo_gem "install pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources"
8
8
  end
9
9
 
10
10
  desc "Uninstall #{GEM_NAME} #{GEM_VERSION}"
@@ -1,6 +1,4 @@
1
1
  begin
2
- gem 'rspec', '~>1.2'
3
- require 'spec'
4
2
  require 'spec/rake/spectask'
5
3
 
6
4
  task :default => [ :spec ]
@@ -8,16 +6,18 @@ begin
8
6
  desc 'Run specifications'
9
7
  Spec::Rake::SpecTask.new(:spec) do |t|
10
8
  t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
11
- t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s).map { |f| f.to_s }
9
+ t.libs << 'lib' << 'spec' # needed for CI rake spec task, duplicated in spec_helper
12
10
 
13
11
  begin
14
- gem 'rcov', '~>0.8'
12
+ require 'rcov'
15
13
  t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
16
14
  t.rcov_opts << '--exclude' << 'spec'
17
15
  t.rcov_opts << '--text-summary'
18
16
  t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
19
17
  rescue LoadError
20
18
  # rcov not installed
19
+ rescue SyntaxError
20
+ # rcov syntax invalid
21
21
  end
22
22
  end
23
23
  rescue LoadError
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-is-tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.11
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timothy Bennett
@@ -9,19 +9,10 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-29 00:00:00 -07:00
12
+ date: 2009-09-16 00:00:00 -07:00
13
13
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: dm-core
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - "="
22
- - !ruby/object:Gem::Version
23
- version: 0.9.11
24
- version:
14
+ dependencies: []
15
+
25
16
  description: DataMapper plugin allowing the creation of tree structures from data models
26
17
  email:
27
18
  - leapord729 [a] comcast.net
@@ -30,15 +21,15 @@ executables: []
30
21
  extensions: []
31
22
 
32
23
  extra_rdoc_files:
33
- - README.txt
24
+ - README.rdoc
34
25
  - LICENSE
35
26
  - TODO
36
- - History.txt
27
+ - History.rdoc
37
28
  files:
38
- - History.txt
29
+ - History.rdoc
39
30
  - LICENSE
40
31
  - Manifest.txt
41
- - README.txt
32
+ - README.rdoc
42
33
  - Rakefile
43
34
  - TODO
44
35
  - lib/dm-is-tree.rb
@@ -51,11 +42,13 @@ files:
51
42
  - tasks/install.rb
52
43
  - tasks/spec.rb
53
44
  has_rdoc: true
54
- homepage: http://github.com/sam/dm-more/tree/master/dm-is-tree
45
+ homepage: http://github.com/datamapper/dm-more/tree/master/dm-is-tree
46
+ licenses: []
47
+
55
48
  post_install_message:
56
49
  rdoc_options:
57
50
  - --main
58
- - README.txt
51
+ - README.rdoc
59
52
  require_paths:
60
53
  - lib
61
54
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -73,9 +66,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
66
  requirements: []
74
67
 
75
68
  rubyforge_project: datamapper
76
- rubygems_version: 1.3.1
69
+ rubygems_version: 1.3.5
77
70
  signing_key:
78
- specification_version: 2
71
+ specification_version: 3
79
72
  summary: DataMapper plugin allowing the creation of tree structures from data models
80
73
  test_files: []
81
74