rubytree 0.9.6 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2dbe7b7742a7beba443f03362ae6022369091af3
4
- data.tar.gz: abd8e15e9c052a75c19d2f73e9083aedbf8e24af
3
+ metadata.gz: 76d30f00380e7ea4594dda970de679d6949a61b9
4
+ data.tar.gz: 11a9fe380940e988200f84e2f69dff3752e4e380
5
5
  SHA512:
6
- metadata.gz: cd494ba10200d91f96708e6528f07b42f1d8b881b7697ea378168fdade34407a637876bdd8b612558ea144f5bce64624d7c33a41fcb1970ccc3662776ad58d2c
7
- data.tar.gz: 9bb44f611d7847eaff5b9888be9e07608583e4b63fc1701f33004fd061e1f685b9c9a2c7b7cfe3c8606d710123fc1068cfd88875260fc33d0e16c5f51f3d4691
6
+ metadata.gz: b7e9ee7173158d02e55c29ea3122076bc164f3bc180a717bce34bf0ca29d65e9e60bd9f0d13fccb16cf4339e064a56d05e2a0bb120b2bf2a65edb83cef29b7ec
7
+ data.tar.gz: cf1ced56a4092931a7f8439a466c68a338a3fb86cac941862885bbdd4ac3c34abd8e2c3921e76504681bb075309112cd5b0b5b50faddb9a10e1a7a172c3c7d5f
data/Gemfile CHANGED
@@ -7,6 +7,7 @@ group :development, :test do
7
7
  gem "rake", "~> 10.4"
8
8
  gem "test-unit", "~> 3.0"
9
9
  gem "coveralls", ">= 0.7", :require => false, :platforms => :mri_21
10
+ gem "rspec", ">= 3.4"
10
11
  end
11
12
 
12
13
  # Local Variables:
@@ -1,49 +1,65 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubytree (0.9.6)
4
+ rubytree (0.9.7)
5
5
  json (~> 1.8)
6
6
  structured_warnings (~> 0.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- coveralls (0.8.1)
11
+ coveralls (0.8.10)
12
12
  json (~> 1.8)
13
13
  rest-client (>= 1.6.8, < 2)
14
- simplecov (~> 0.10.0)
14
+ simplecov (~> 0.11.0)
15
15
  term-ansicolor (~> 1.3)
16
16
  thor (~> 0.19.1)
17
+ tins (~> 1.6.0)
18
+ diff-lcs (1.2.5)
17
19
  docile (1.1.5)
18
- domain_name (0.5.24)
20
+ domain_name (0.5.25)
19
21
  unf (>= 0.0.5, < 1.0.0)
20
22
  http-cookie (1.0.2)
21
23
  domain_name (~> 0.5)
22
- json (1.8.2)
23
- mime-types (2.6.1)
24
- netrc (0.10.3)
25
- power_assert (0.2.3)
24
+ json (1.8.3)
25
+ mime-types (2.99)
26
+ netrc (0.11.0)
27
+ power_assert (0.2.6)
26
28
  rake (10.4.2)
27
- rdoc (4.2.0)
29
+ rdoc (4.2.1)
30
+ json (~> 1.4)
28
31
  rest-client (1.8.0)
29
32
  http-cookie (>= 1.0.2, < 2.0)
30
33
  mime-types (>= 1.16, < 3.0)
31
34
  netrc (~> 0.7)
35
+ rspec (3.4.0)
36
+ rspec-core (~> 3.4.0)
37
+ rspec-expectations (~> 3.4.0)
38
+ rspec-mocks (~> 3.4.0)
39
+ rspec-core (3.4.1)
40
+ rspec-support (~> 3.4.0)
41
+ rspec-expectations (3.4.0)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.4.0)
44
+ rspec-mocks (3.4.0)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.4.0)
47
+ rspec-support (3.4.1)
32
48
  rtags (0.97)
33
49
  rtagstask (0.0.4)
34
50
  rtags (> 0.0.0)
35
- simplecov (0.10.0)
51
+ simplecov (0.11.1)
36
52
  docile (~> 1.1.0)
37
53
  json (~> 1.8)
38
54
  simplecov-html (~> 0.10.0)
39
55
  simplecov-html (0.10.0)
40
56
  structured_warnings (0.2.0)
41
- term-ansicolor (1.3.0)
57
+ term-ansicolor (1.3.2)
42
58
  tins (~> 1.0)
43
- test-unit (3.1.1)
59
+ test-unit (3.1.5)
44
60
  power_assert
45
61
  thor (0.19.1)
46
- tins (1.5.2)
62
+ tins (1.6.0)
47
63
  unf (0.1.4)
48
64
  unf_ext
49
65
  unf_ext (0.0.7.1)
@@ -57,6 +73,7 @@ DEPENDENCIES
57
73
  coveralls (>= 0.7)
58
74
  rake (~> 10.4)
59
75
  rdoc (~> 4.2)
76
+ rspec (>= 3.4)
60
77
  rtagstask (~> 0.0)
61
78
  rubytree!
62
79
  test-unit (~> 3.0)
@@ -1,7 +1,19 @@
1
- # @markup rdoc
2
-
3
1
  = History of Changes
4
2
 
3
+ === 0.9.7 / 2015-12-31
4
+
5
+ * Released 0.9.6. This is a minor bug-fix release.
6
+
7
+ * This release allows the {Tree::TreeNode#print_tree} method to be used on
8
+ non-root nodes. Thanks to {https://github.com/ojab Ojab}.
9
+
10
+ * The spaceship operator ('<=>') now returns 'nil' if the object being compared
11
+ to is itself 'nil' or not another {Tree::TreeNode}.
12
+
13
+ === 0.9.6 / 2015-05-30
14
+
15
+ * Released 0.9.6, which is same as 0.9.5, except for an update to the Gem release date.
16
+
5
17
  === 0.9.5 / 2015-05-30
6
18
 
7
19
  * Released 0.9.5.
data/README.md CHANGED
@@ -11,7 +11,6 @@
11
11
  [![Dependency Status](https://gemnasium.com/evolve75/RubyTree.png)](https://gemnasium.com/evolve75/RubyTree)
12
12
  [![Code Climate](https://codeclimate.com/github/evolve75/RubyTree.png)](https://codeclimate.com/github/evolve75/RubyTree)
13
13
  [![Coverage Status](https://coveralls.io/repos/evolve75/RubyTree/badge.png)](https://coveralls.io/r/evolve75/RubyTree)
14
- [![githalytics.com alpha](https://cruel-carlota.pagodabox.com/473b881f1075bf9f255f0181dde6068f)](http://githalytics.com/evolve75/RubyTree)
15
14
 
16
15
  ## DESCRIPTION: ##
17
16
 
@@ -104,6 +103,9 @@ siblings_of_child1 = child1.siblings
104
103
  # ..... Retrieve immediate children of the root node as an array.
105
104
  children_of_root = root_node.children
106
105
 
106
+ # ..... Retrieve the parent of a node.
107
+ parent = child1.parent
108
+
107
109
  # ..... This is a depth-first and L-to-R pre-ordered traversal.
108
110
  root_node.each { |node| node.content.reverse }
109
111
 
@@ -130,6 +132,7 @@ This example can also be found at
130
132
  * [Bundler][] for creating the stable build environment
131
133
  * [Rake][] for building the package
132
134
  * [Yard][] for the documentation
135
+ * [RSpec][] for additional Ruby Spec test files
133
136
 
134
137
  ## INSTALL: ##
135
138
 
@@ -261,6 +264,6 @@ A big thanks to the following contributors for helping improve **RubyTree**:
261
264
  [rt_site]: http://rubytree.anupamsg.me "RubyTree Site"
262
265
  [structured_warnings]: http://github.com/schmidt/structured_warnings "structured_warnings"
263
266
  [tree_data_structure]: http://en.wikipedia.org/wiki/Tree_data_structure "Tree Data Structure"
264
-
267
+ [RSpec]: https://relishapp.com/rspec/
265
268
 
266
269
  [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/evolve75/rubytree/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
data/Rakefile CHANGED
@@ -45,6 +45,7 @@ task :default do
45
45
  Rake::Task["test:coverage"].invoke
46
46
  else
47
47
  Rake::Task["test:unit"].invoke
48
+ Rake::Task["spec"].invoke
48
49
  end
49
50
  end
50
51
 
@@ -133,6 +134,17 @@ namespace :test do # ................................ Test related
133
134
 
134
135
  end
135
136
 
137
+ begin # ................................ rspec tests
138
+ require 'rspec/core/rake_task'
139
+
140
+ RSpec::Core::RakeTask.new(:spec) do |t|
141
+ t.fail_on_error = false
142
+ t.rspec_opts = ["--color", "--format doc"]
143
+ end
144
+ rescue LoadError
145
+ # Cannot load rspec.
146
+ end
147
+
136
148
  namespace :tag do # ................................ Emacs Tags
137
149
  begin
138
150
  require 'rtagstask'
@@ -3,8 +3,8 @@
3
3
  # example_basic.rb:: Basic usage of the tree library.
4
4
  #
5
5
  # Author: Anupam Sengupta
6
- # Time-stamp: <2013-12-28 12:14:20 anupam>
7
- # Copyright (C) 2013 Anupam Sengupta <anupamsg@gmail.com>
6
+ # Time-stamp: <2015-12-31 22:17:30 anupam>
7
+ # Copyright (C) 2013, 2015 Anupam Sengupta <anupamsg@gmail.com>
8
8
  #
9
9
  # The following example implements this tree structure:
10
10
  #
@@ -46,6 +46,9 @@ siblings_of_child1 = child1.siblings
46
46
  # ..... Lets retrieve immediate children of the root node as an array.
47
47
  children_of_root = root_node.children
48
48
 
49
+ # ..... Retrieve the parent of a node.
50
+ parent = child1.parent
51
+
49
52
  # ..... This is a depth-first and L-to-R pre-ordered traversal.
50
53
  root_node.each { |node| node.content.reverse }
51
54
 
@@ -922,9 +922,10 @@ module Tree
922
922
  # @param [Tree::TreeNode] other The other node to compare against.
923
923
  #
924
924
  # @return [Integer] +1 if this node is a 'successor', 0 if equal and -1 if
925
- # this node is a 'predecessor'.
925
+ # this node is a 'predecessor'. Returns 'nil' if the other
926
+ # object is not a 'Tree::TreeNode'.
926
927
  def <=>(other)
927
- return +1 if other == nil
928
+ return nil if other == nil || other.class != Tree::TreeNode
928
929
  self.name <=> other.name
929
930
  end
930
931
 
@@ -934,7 +935,7 @@ module Tree
934
935
  # @param [Integer] max_depth optional maximum depth at which the printing
935
936
  # with stop.
936
937
  # @param [Proc] block optional block to use for rendering
937
- def print_tree(level = 0, max_depth = nil,
938
+ def print_tree(level = node_depth, max_depth = nil,
938
939
  block = lambda { |node, prefix|
939
940
  puts "#{prefix} #{node.name}" })
940
941
  prefix = ''
@@ -37,5 +37,5 @@
37
37
  #
38
38
  module Tree
39
39
  # Rubytree Package Version
40
- VERSION = '0.9.6'
40
+ VERSION = '0.9.7'
41
41
  end
@@ -12,7 +12,7 @@ require "tree/version"
12
12
 
13
13
  Gem::Specification.new do |s|
14
14
  s.name = 'rubytree'
15
- s.date = '2015-05-30'
15
+ s.date = '2015-12-31'
16
16
  s.version = Tree::VERSION
17
17
  s.license = 'BSD'
18
18
 
@@ -54,6 +54,7 @@ Gem::Specification.new do |s|
54
54
  s.files = Dir['lib/**/*.rb'] # The actual code
55
55
  s.files += Dir['[A-Z]*'] # Various documentation files
56
56
  s.files += Dir['test/**/*.rb'] # Test cases
57
+ s.files += Dir['spec/**/*.rb'] # Rspec Test cases
57
58
  s.files += Dir['examples/**/*.rb'] # Examples
58
59
 
59
60
  s.files += ['.gemtest'] # Support for gem-test
@@ -74,6 +75,7 @@ Gem::Specification.new do |s|
74
75
  s.add_development_dependency 'rdoc' , '~> 4.2'
75
76
  s.add_development_dependency 'yard' , '~> 0.8'
76
77
  s.add_development_dependency 'rtagstask' , '~> 0.0'
78
+ s.add_development_dependency 'rspec' , '~> 3.4'
77
79
 
78
80
  s.post_install_message = <<-EOF
79
81
  ========================================================================
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # spec_helper.rb
4
+ #
5
+ # Author: Anupam Sengupta
6
+ # Time-stamp: <2015-12-31 21:00:36 anupam>
7
+ # Copyright (C) 2015 Anupam Sengupta <anupamsg@gmail.com>
8
+ #
9
+
10
+ require "tree"
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # tree_spec.rb
4
+ #
5
+ # Author: Anupam Sengupta
6
+ # Time-stamp: <2015-12-31 22:57:59 anupam>
7
+ # Copyright (C) 2015 Anupam Sengupta <anupamsg@gmail.com>
8
+ #
9
+
10
+ require "rspec"
11
+ require "spec_helper"
12
+
13
+ describe Tree do
14
+
15
+ shared_examples_for "any detached node" do
16
+ it 'should not equal "Object.new"' do
17
+ expect(@tree).not_to eq(Object.new)
18
+ end
19
+ it 'should not equal 1 or any other fixnum' do
20
+ expect(@tree).not_to eq(1)
21
+ end
22
+ it 'identifies itself as a root node' do
23
+ expect(@tree.is_root?).to eq(true)
24
+ end
25
+ it "does not have a parent node" do
26
+ expect(@tree.parent).to eq(nil)
27
+ end
28
+
29
+ end
30
+ context "#initialize", "with empty name and nil content" do
31
+ before(:each) do
32
+ @tree = Tree::TreeNode.new("")
33
+ end
34
+ it 'creates the tree node with name as ""' do
35
+ expect(@tree.name).to eq("")
36
+ end
37
+ it "has 'nil' content" do
38
+ expect(@tree.content).to eq(nil)
39
+ end
40
+
41
+ it_behaves_like "any detached node"
42
+ end
43
+
44
+ context "#initialize", "with name 'A' and nil content" do
45
+ before(:each) do
46
+ @tree = Tree::TreeNode.new("A")
47
+ end
48
+
49
+ it 'creates the tree node with name as "A"' do
50
+ expect(@tree.name).to eq("A")
51
+ end
52
+ it "has 'nil' content" do
53
+ expect(@tree.content).to eq(nil)
54
+ end
55
+
56
+ it_behaves_like "any detached node"
57
+ end
58
+
59
+ context "#initialize", "with node name 'A' and some content" do
60
+ before(:each) do
61
+ @sample = "sample"
62
+ @tree = Tree::TreeNode.new("A", @sample)
63
+ end
64
+
65
+ it 'creates the tree node with name as "A"' do
66
+ expect(@tree.name).to eq("A")
67
+ end
68
+ it "has some content #{@sample}" do
69
+ expect(@tree.content).to eq(@sample)
70
+ end
71
+
72
+ it_behaves_like "any detached node"
73
+ end
74
+ end
@@ -316,7 +316,7 @@ module TestTree
316
316
  first_node = Tree::TreeNode.new(1)
317
317
  second_node = Tree::TreeNode.new(2)
318
318
 
319
- assert_equal(+1, first_node <=> nil)
319
+ assert_nil(first_node <=> nil)
320
320
  assert_equal(-1, first_node <=> second_node)
321
321
 
322
322
  second_node = Tree::TreeNode.new(1)
@@ -325,7 +325,7 @@ module TestTree
325
325
  first_node = Tree::TreeNode.new("ABC")
326
326
  second_node = Tree::TreeNode.new("XYZ")
327
327
 
328
- assert_equal(+1, first_node <=> nil)
328
+ assert_nil(first_node <=> nil)
329
329
  assert_equal(-1, first_node <=> second_node)
330
330
 
331
331
  second_node = Tree::TreeNode.new("ABC")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubytree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.6
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anupam Sengupta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-30 00:00:00.000000000 Z
11
+ date: 2015-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: structured_warnings
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.4'
97
111
  description: |2+
98
112
 
99
113
  RubyTree is a pure Ruby implementation of the generic tree data structure. It
@@ -154,6 +168,8 @@ files:
154
168
  - lib/tree/version.rb
155
169
  - rubytree.gemspec
156
170
  - setup.rb
171
+ - spec/spec_helper.rb
172
+ - spec/tree_spec.rb
157
173
  - test/run_test.rb
158
174
  - test/test_binarytree.rb
159
175
  - test/test_rubytree_require.rb