revtree 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/lib/revtree.rb +10 -5
  4. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1e3a7315f79eab2d444a7b708fa4412dc14fa0d17aff060848a74c4275eefcc
4
- data.tar.gz: 712bbd90a68a4cd071c1bd647cb9c36752aa01c0c0122cff32d585895695bd1f
3
+ metadata.gz: e7467c75fbcedb571b34585f6f91f6c41454819402da7b476725f0928486f5e7
4
+ data.tar.gz: b00a508bafaae9f6cb4e6aea55ea7e83091a7cea7a84bb12f079581465d6e38b
5
5
  SHA512:
6
- metadata.gz: abeccda61e8bd8afbdc553550d43a22e786e20e57e0563f2d3e64e8accf2b67152cfc449b9417a8f10ecc3acf9bd58be2a6cde8402d1d0709586368b3f34054b
7
- data.tar.gz: a90318c8711df1e9ce50d0fde521c7713e4923316be3e5f65e18a73489fbb76a3b9563651a2031f5ba69e19c11f511eeb713f2700e85c64a13cb22817ed5f2f1
6
+ metadata.gz: ff58e04caa7b1afac85ceb19b2076e2cffbb28f6cd38dfe1b9f8b2b45824a70b80743fe2b6b3c42e1691b945f639f605c531d17a06aa546e26973bbe779c7a76
7
+ data.tar.gz: 35cfb5161ae3d0a8edfbf7a80cef8b5d4e7a56f6e80005d5cbabe6ecb430113725a7a68dde43a7efa0b082fb682ef8903e3ea93e15940f7dcfb5e555e2f1298e
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # RevTree
2
+ [![Gem Version](https://badge.fury.io/rb/revtree.svg)](https://badge.fury.io/rb/revtree)
2
3
 
3
4
  ## Introduction
4
5
 
@@ -41,7 +42,7 @@ sudo make install
41
42
  git clone https://github.com/juliankahlert/revtree.git
42
43
  cd revtree
43
44
  gem build revtree.gemspec
44
- sudo gem install --local revtree-0.1.2.gem
45
+ sudo gem install --local revtree-0.1.4.gem
45
46
  ```
46
47
 
47
48
  ## API Documentation
data/lib/revtree.rb CHANGED
@@ -123,7 +123,7 @@ class RevTree
123
123
  def for_each(status_whitelist = [:unmodified, :modified, :added, :removed], &block)
124
124
  return unless block_given?
125
125
 
126
- RevTree.traverse_tree(self, status_whitelist, @path, &block)
126
+ RevTree.traverse_tree(self, status_whitelist, @path, nil, &block)
127
127
  end
128
128
 
129
129
  # Watches the tree for changes
@@ -342,20 +342,25 @@ class RevTree
342
342
  #
343
343
  # @param node [RevTree] the current node being traversed
344
344
  # @param status_whitelist [Array<Symbol>] the list of statuses to match
345
+ # @param root [Pathname] the root path
345
346
  # @param current_path [Pathname] the current path
346
347
  # @yield [node, full_path] the block to be executed for each matching file
347
348
  # @yieldparam node [RevTree] the current node being traversed
348
349
  # @yieldparam full_path [String] the full path of the current node
349
350
  # @return [void]
350
- def self.traverse_tree(node, status_whitelist, current_path, &block)
351
+ def self.traverse_tree(node, status_whitelist, root, current_path, &block)
352
+ full_path = if current_path
353
+ File.join(current_path.to_s, node.name.to_s)
354
+ else
355
+ root
356
+ end
357
+
351
358
  if node.type == :file && status_whitelist.include?(node.status)
352
359
  block.call(node, File.expand_path(current_path.to_s))
353
360
  end
354
361
 
355
- full_path = File.join(current_path.to_s, node.name.to_s)
356
-
357
362
  node.children.each do |child|
358
- traverse_tree(child, status_whitelist, full_path, &block)
363
+ traverse_tree(child, status_whitelist, root, full_path, &block)
359
364
  end
360
365
  end
361
366
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Kahlert
@@ -65,7 +65,8 @@ homepage: https://github.com/juliankahlert/revtree
65
65
  licenses:
66
66
  - MIT
67
67
  metadata:
68
- homepage_uri: https://github.com/juliankahlert/revtree
68
+ homepage_uri: https://juliankahlert.github.io/revtree/
69
+ documentation_uri: https://www.rubydoc.info/gems/revtree/0.1.4
69
70
  source_code_uri: https://github.com/juliankahlert/revtree
70
71
  post_install_message:
71
72
  rdoc_options: []