tree_methods 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: aab96d2d92b494cfc332be9008d479d69b0d921f4ed3e62dbef96a6f48d10458
4
+ data.tar.gz: 7e3d7e03769d31579017aa5863cfc56e2957c81e42dfb53f4c23b64004620dda
5
+ SHA512:
6
+ metadata.gz: fad481f6d603919461baefa1c150c15efb66289776381589f33dcf629b222d21d0c1ab1d44dc42eeb1c4510c5123ba05eb0ef4fb3103d8678a68fc0bee8936e2
7
+ data.tar.gz: ff0df081b3eb0bfed369d3df96c691043aa4ece7a5a444fad6a7c4ad6a976209d92f623dc0dc69ac16d3103990364fd83122ce77e887fbaab4068dad5c84546e
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-3.1.2
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in tree_methods.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # TreeMethods
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tree_methods`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tree_methods.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,32 @@
1
+ module EnumerableTreeMethods
2
+ def preorder(include_self = true, &block)
3
+ result = include_self ? [self] : []
4
+ preorder_implementation(result, &block)
5
+ result
6
+ end
7
+
8
+ def postorder(include_self = true, &block)
9
+ result = []
10
+ postorder_implementation(result, &block)
11
+ include_self ? result + [self] : result
12
+ end
13
+
14
+ private
15
+ def preorder_implementation(result, &block)
16
+ block.call(self).each { |node|
17
+ result << node
18
+ node.send(:preorder_implementation, result, &block)
19
+ }
20
+ end
21
+
22
+ def postorder_implementation(result, &block)
23
+ block.call(self).each { |node|
24
+ node.send(:postorder_implementation, result, &block)
25
+ result << node
26
+ }
27
+ end
28
+ end
29
+
30
+
31
+
32
+
@@ -0,0 +1,16 @@
1
+ module ObjectTreeMethods
2
+ def follow(include_self = false, &block)
3
+ result = include_self ? [self] : []
4
+ follow_implementation(result, &block)
5
+ result
6
+ end
7
+
8
+ private
9
+ def follow_implementation(result, &block)
10
+ if follower = block.call(self)
11
+ result << follower
12
+ follower.send(:follow_implementation, result, &block)
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TreeMethods
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "tree_methods/version"
4
+ require_relative "tree_methods/enumerable_tree_methods"
5
+ require_relative "tree_methods/object_tree_methods"
6
+
7
+ module TreeMethods
8
+ class Error < StandardError; end
9
+ end
10
+
11
+ module Enumerable
12
+ include EnumerableTreeMethods # FIXME
13
+ end
14
+
15
+ class Object
16
+ include ObjectTreeMethods # FIXME Whoa!
17
+ end
18
+
@@ -0,0 +1,4 @@
1
+ module TreeMethods
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tree_methods
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Claus Rasmussen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-12-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Gem tree_methods
14
+ email:
15
+ - claus.l.rasmussen@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".rspec"
21
+ - ".ruby-version"
22
+ - Gemfile
23
+ - README.md
24
+ - Rakefile
25
+ - lib/tree_methods.rb
26
+ - lib/tree_methods/enumerable_tree_methods.rb
27
+ - lib/tree_methods/object_tree_methods.rb
28
+ - lib/tree_methods/version.rb
29
+ - sig/tree_methods.rbs
30
+ homepage: http://www.nowhere.com/
31
+ licenses: []
32
+ metadata:
33
+ homepage_uri: http://www.nowhere.com/
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.6.0
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.3.18
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Gem tree_methods
53
+ test_files: []