sycamore 0.2.0 → 0.2.1

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: 96576ab7442d55fd614afdad27de3ec3aca8d6d5
4
- data.tar.gz: 35541c8d3106ee6118521772c5b1f949dee22f5b
3
+ metadata.gz: 17dce2903bbad75bfd5c528662e0857d2505cf1f
4
+ data.tar.gz: b0314f85b8c211cc3fe324dfd304c14e07c96bcb
5
5
  SHA512:
6
- metadata.gz: 03b10ac2b86de83ef79fd2ec420ddcbfc0b7482d2aba51b052e338d295e8a975e5ee867e61eebf4dc80e6a339db5fd95cdfb470f747c4e528b07b297c7574d8b
7
- data.tar.gz: e11355d50ae83691faabab59def13d2f5e840cb164f90d7db53b62886122c46b176c5c1bcb9bde1113bdbe24fde1c08beae872869659eddc346ef65e3c56c007
6
+ metadata.gz: 008f0f0f027983a40aed89c98af2726711ab7297af755f3894e7b82d8e7b5e84154dfa318add0d27aa51ca56f4d28e66767fca8e0acf6419064f861d20efa0fc
7
+ data.tar.gz: e4c7b8096a0aad94b6702747c1fd26e7efa09102ec10c3d14b63672f89bca237cb88d9119439a03c5d10eada7f42714d699bd00653fc62a637419edbd9cbb3fa
data/.travis.yml CHANGED
@@ -4,6 +4,7 @@ rvm:
4
4
  - 2.2.4
5
5
  - 2.3.0
6
6
  - jruby-9.0.4.0
7
+ - rbx-2
7
8
  cache: bundler
8
9
  before_install:
9
10
  - gem update bundler
data/CHANGELOG.md CHANGED
@@ -4,9 +4,26 @@ All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/) and
5
5
  [Keep a CHANGELOG](http://keepachangelog.com).
6
6
 
7
+
7
8
  ## [Unreleased]
8
9
 
10
+
11
+
12
+ ## [0.2.1] - 2016-04-07
13
+
14
+ ### Added
15
+
16
+ - assigning `nil` via `Tree#[]=` removes a child tree, similar to the assignment
17
+ of `Sycamore::Nothing`
18
+
19
+ ### Fixed
20
+
21
+ - #2: Rubinius support
22
+
23
+
24
+
9
25
  ## [0.2.0] - 2016-04-05
26
+
10
27
  ### Added
11
28
 
12
29
  - assigning `Sycamore::Nothing` via `Tree#[]=` removes a child tree
@@ -14,10 +31,13 @@ This project adheres to [Semantic Versioning](http://semver.org/) and
14
31
  - `Tree#node!` as a more strict variant of `Tree#node`, which raises an error
15
32
  when no node present
16
33
 
34
+
35
+
17
36
  ## 0.1.0 - 2016-03-28
18
37
 
19
38
  Initial release
20
39
 
21
40
 
22
- [Unreleased]: https://github.com/marcelotto/sycamore/compare/v0.2.0...HEAD
41
+ [Unreleased]: https://github.com/marcelotto/sycamore/compare/v0.2.1...HEAD
42
+ [0.2.1]: https://github.com/marcelotto/sycamore/compare/v0.2.0...v0.2.1
23
43
  [0.2.0]: https://github.com/marcelotto/sycamore/compare/v0.1.0...v0.2.0
data/README.md CHANGED
@@ -48,6 +48,7 @@ With Sycamore this is a thing of the past.
48
48
 
49
49
  - MRI >= 2.1
50
50
  - JRuby
51
+ - Rubinius
51
52
 
52
53
 
53
54
  ## Dependencies
@@ -449,17 +450,24 @@ tree[:foo] = []
449
450
  tree[:foo] = {}
450
451
  ```
451
452
 
452
- To remove a child tree entirely, you can assign `Nothing` to the parent node.
453
+ To remove a child tree entirely, you can assign `Nothing` or `nil` to the parent node.
453
454
 
454
455
  ```ruby
455
456
  tree[:foo] = Nothing
457
+ tree[:foo] = nil
456
458
  ```
457
459
 
458
- Note that these values are interpreted similarly inside tree structures, i.e. empty Enumerables become empty child trees, while `Nothing` or `nil` are used as place holders for the explicit negation of a child.
460
+ If you really want to overwrite the current child nodes with a single `nil` node, you have to do it in the following way.
459
461
 
460
462
  ```ruby
461
- puts Tree[ a: { b: nil }, c: { d: []} ]
462
- >Tree[:a=>:b, :c=>{:d=>[]}]
463
+ tree[:foo] = [nil]
464
+ ```
465
+
466
+ Note that all of these values are interpreted consistently inside input tree structures on creation, addition, deletion etc., i.e. empty Enumerables become empty child trees, `Nothing` or `nil` are used as place holders for the explicit negation of a child and `[nil]` is used for a child trees with a single `nil` node.
467
+
468
+ ```ruby
469
+ puts Tree[ a: { b: nil }, c: { d: []}, d: [nil] ]
470
+ >Tree[:a=>:b, :c=>{:d=>[]}, :d=>[nil]]
463
471
  ```
464
472
 
465
473
  Beside the deletion of all elements with the already mentioned `clear` method, single or multiple nodes and entire tree structures can be removed with `delete` or the `>>` operator.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/lib/sycamore/tree.rb CHANGED
@@ -326,7 +326,7 @@ module Sycamore
326
326
  end
327
327
 
328
328
  private def delete_tree(tree)
329
- tree.each do |node, child|
329
+ tree.each { |node, child| # using a {} block to circumvent this Rubinius issue: https://github.com/rubinius/rubinius-code/issues/7
330
330
  raise InvalidNode, "#{node} is not a valid tree node" if node.is_a? Enumerable
331
331
  next unless include? node
332
332
  if Nothing.like?(child) or (child.respond_to?(:empty?) and child.empty?)
@@ -337,7 +337,7 @@ module Sycamore
337
337
  delete_node(node) if this_child.empty?
338
338
  end
339
339
  end
340
- end
340
+ }
341
341
 
342
342
  self
343
343
  end
@@ -380,8 +380,12 @@ module Sycamore
380
380
  # Note that even if you assign a {Sycamore::Tree} directly the given tree
381
381
  # will not become part of this tree by reference.
382
382
  #
383
- # An exception is the assignment of the {Nothing} tree: it will delete the
384
- # child tree at the given path entirely.
383
+ # An exception is the assignment of +nil+ or the {Nothing} tree: it will
384
+ # delete the child tree at the given path entirely. If you really want to
385
+ # overwrite the current child nodes with a single +nil+ node, you'll have to
386
+ # assign an array containing only +nil+.
387
+ #
388
+ # tree[:foo] = [nil]
385
389
  #
386
390
  # @overload []=(*path, node)
387
391
  # Replaces the contents of the child at the given path with a single node.
@@ -422,7 +426,7 @@ module Sycamore
422
426
  path, nodes_or_tree = args[0..-2], args[-1]
423
427
  raise ArgumentError, 'wrong number of arguments (given 1, expected 2)' if path.empty?
424
428
 
425
- if nodes_or_tree.equal? Sycamore::Nothing
429
+ if Nothing.like? nodes_or_tree
426
430
  if path.size == 1
427
431
  clear_child_of_node(path.first)
428
432
  else
data/sycamore.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['marcelotto@gmx.de']
11
11
 
12
12
  spec.summary = %q{An unordered tree data structure for Ruby.}
13
- spec.description = %q{Sycamore is an implementation of an unordered tree data structure of immutable values solely based on Ruby Hashes.}
13
+ spec.description = %q{Sycamore is an unordered tree data structure.}
14
14
  spec.homepage = 'https://github.com/marcelotto/sycamore'
15
15
  spec.license = 'MIT'
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sycamore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcel Otto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-04 00:00:00.000000000 Z
11
+ date: 2016-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,8 +108,7 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- description: Sycamore is an implementation of an unordered tree data structure of
112
- immutable values solely based on Ruby Hashes.
111
+ description: Sycamore is an unordered tree data structure.
113
112
  email:
114
113
  - marcelotto@gmx.de
115
114
  executables: []