WhiteCloth 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -1,5 +1,26 @@
1
1
  RELEASE HISTORY
2
2
 
3
+ v0.0.4 / 2011-05-17
4
+
5
+ Regenerate gemspec for version 0.0.4 (David Love david@homeunix.org.uk)
6
+
7
+ Changes:
8
+
9
+ * 6 Patch Enhancements
10
+
11
+ * Update the HISTORY file
12
+ * Added foundations for the Standard Tree, including tests.
13
+ * Add a next function to UUIDTools::UUID to allow the generation of sequential UUID's
14
+ * Added basic sanity tests for the Gibberish library
15
+ * Update HISTORY file after tagging a version
16
+ * Remove FluxTuna from the testing namespace
17
+
18
+ * 2 General Enhancements
19
+
20
+ * Version bump to 0.0.4
21
+ * Regenerate gemspec for version 0.0.2
22
+
23
+
3
24
  v0.0.2 / 2011-05-16
4
25
 
5
26
  Regenerate gemspec for version 0.0.2 (David Love david@homeunix.org.uk)
@@ -34,21 +55,17 @@ Changes:
34
55
  * Initial commit to WhiteCloth.
35
56
 
36
57
 
37
- HEAD / 2011-05-18
58
+ HEAD / 2011-05-19
38
59
 
39
60
  Current Development (David Love)
40
61
 
41
62
  Changes:
42
63
 
43
- * 5 Patch Enhancements
64
+ * 1 Bugfix Enhancements
44
65
 
45
- * Added foundations for the Standard Tree, including tests.
46
- * Add a next function to UUIDTools::UUID to allow the generation of sequential UUID's
47
- * Added basic sanity tests for the Gibberish library
48
- * Update HISTORY file after tagging a version
49
- * Remove FluxTuna from the testing namespace
66
+ * Changed the node adding logic to make the 'Node not found' case clearer, and updated the function documentation to point out a potential problem using argument hashes.
50
67
 
51
68
  * 1 General Enhancements
52
69
 
53
- * Regenerate gemspec for version 0.0.2
70
+ * Regenerate gemspec for version 0.0.4
54
71
 
data/Rakefile CHANGED
@@ -95,6 +95,7 @@ YARD::Rake::YardocTask.new
95
95
  task :before_release do
96
96
  # Update the HISTORY file
97
97
  `vclog history -f gnu > HISTORY`
98
+ `git commit -a -m "Update HISTORY file"`
98
99
  end
99
100
 
100
101
  ## Update the HISTORY file before a version bump
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{WhiteCloth}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Love"]
12
- s.date = %q{2011-05-17}
12
+ s.date = %q{2011-05-18}
13
13
  s.default_executable = %q{whitecloth}
14
14
  s.description = %q{See: http://research.homeunix.org.uk}
15
15
  s.email = %q{david@homeunix.org.uk}
@@ -39,18 +39,23 @@ module WhiteCloth::DataStructures
39
39
  self.add(child_node)
40
40
  end
41
41
 
42
- # Look for the designated block within tree starting at the current node.
42
+ # Look for the designated block within tree starting at the current node. If the +block_name+
43
+ # is +nil+ or +ROOT+, than we return the root of the current tree (i.e. ourselves).
43
44
  def [] (block_name)
44
45
 
45
46
  # We need to work out which node has the right content. Since
46
47
  # the nodes are effectively unordered, we have to look (potentially)
47
48
  # at every node
48
- self.each{|child|
49
- if child.content === block_name then
50
- return child
51
- end
52
- }
53
-
49
+ unless block_name.nil? or block_name == "ROOT"
50
+ self.each{|child|
51
+ if child.content === block_name then
52
+ return child
53
+ end
54
+ }
55
+ return nil
56
+ else
57
+ return self
58
+ end
54
59
  end
55
60
 
56
61
  ###
@@ -51,14 +51,19 @@ module WhiteCloth::DataStructures
51
51
 
52
52
  # Adds the specified nodes to the tree. The +node_list+ is a block, which is taken
53
53
  # to be a hash of node names/node identities and the contents to add to the identified
54
- # nodes.
54
+ # nodes. If the +block_name+ is +nil+ or +ROOT+, than we add to the root of the tree.
55
+ #
56
+ # @note: Since the argument list is a {Hash}, each node in the list *must* be unique.
57
+ # Otherwise later arguments will override earlier ones, and you *will not* get the
58
+ # behaviour you think.
55
59
  def << (node_list)
56
60
  Hash[*node_list.flatten].each{|parent, contents|
57
61
  add_child(parent, contents)
58
62
  }
59
63
  end
60
64
 
61
- # Look for the designated block within tree starting at the current node.
65
+ # Look for the designated block within tree starting at the current node. If the
66
+ # +block_name+ is +nil+ or +ROOT+, than we add to the root of the tree.
62
67
  def [] (block_name)
63
68
  return @nodes[block_name]
64
69
  end
@@ -78,9 +78,9 @@ module Test::DataStructures
78
78
  setup {
79
79
  @root = StandardTree.new("b081eabd-8799-4885-8c4d-eb3cf76b30b4")
80
80
 
81
- @root << {nil => "Child 1"}
82
- @root << {nil => "Child 2", nil => "Child 3"}
83
- @root << {nil => "Child 3", "Child Node 3" => "Grand Child 1"}
81
+ @root << {"ROOT" => "Child 1", nil => "Child 5"}
82
+ @root << {nil => "Child 2"}
83
+ @root << {nil => "Child 3", "Child 3" => "Grand Child 1"}
84
84
  @root << {nil => "Child 4"}
85
85
  @root << {"Child 4" => "Grand Child 2", "Grand Child 1" => "Great Grand Child 1"}
86
86
 
@@ -89,10 +89,12 @@ module Test::DataStructures
89
89
 
90
90
  asserts("root's root is self") { topic[nil].root == topic[nil] }
91
91
  asserts("child 1's root should be ROOT") { topic["Child 1"].root == topic[nil] }
92
- asserts("child 4's root should be ROOT") { topic["Child 4"].root == topic[nil] }
92
+ asserts("child 4's root should be ROOT") { topic["Child 4"].root == topic[nil] }
93
+ asserts("child 2 is a kind of WhiteCloth::DataStructures::StandardNode") { topic["Child 2"].kind_of?(WhiteCloth::DataStructures::StandardNode) }
94
+ asserts("child 2's id (name)") { topic["Child 2"].id }.equals("b081eabd-8799-4885-8c4d-eb3cf76b30b7")
93
95
  asserts("great grand child 1's parent should be \"Grand Child 1\"") { topic["Great Grand Child 1"].parent == topic["Grand Child 1"] }
94
96
  denies("great grand child 1's parent should be \"Child 3\"") { topic["Great Grand Child 1"].parent == topic["Child 3"] }
95
- asserts("root's height after adding the children") { topic[nil].node_height }.equals(2)
97
+ asserts("root's height after adding the children") { topic[nil].node_height }.equals(3)
96
98
  end
97
99
 
98
100
  context "Test the new nodes have no content" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: WhiteCloth
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.4
5
+ version: 0.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - David Love
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-17 00:00:00 +01:00
13
+ date: 2011-05-18 00:00:00 +01:00
14
14
  default_executable: whitecloth
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -282,7 +282,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
282
282
  requirements:
283
283
  - - ">="
284
284
  - !ruby/object:Gem::Version
285
- hash: -1095565922106216962
285
+ hash: -1575231288095777273
286
286
  segments:
287
287
  - 0
288
288
  version: "0"