basic_tree 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -1,21 +1,3 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
1
+ .bundle
2
+ *.gem
3
+ pkg/*
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2@basic_tree
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in basic_tree.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,24 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ basic_tree (0.1.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.2)
10
+ rspec (2.3.0)
11
+ rspec-core (~> 2.3.0)
12
+ rspec-expectations (~> 2.3.0)
13
+ rspec-mocks (~> 2.3.0)
14
+ rspec-core (2.3.1)
15
+ rspec-expectations (2.3.0)
16
+ diff-lcs (~> 1.1.2)
17
+ rspec-mocks (2.3.0)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ basic_tree!
24
+ rspec (>= 2)
data/Rakefile CHANGED
@@ -1,45 +1,3 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ require 'bundler'
3
2
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "basic_tree"
8
- gem.summary = %Q{A basic tree structure}
9
- gem.description = %Q{A basic tree structure}
10
- gem.email = "soccer022483@gmail.com"
11
- gem.homepage = "http://github.com/soccer022483/basic_tree"
12
- gem.authors = ["Austin Schneider"]
13
- gem.add_development_dependency "rspec", ">= 1.2.9"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
- end
20
-
21
- require 'spec/rake/spectask'
22
- Spec::Rake::SpecTask.new(:spec) do |spec|
23
- spec.libs << 'lib' << 'spec'
24
- spec.spec_files = FileList['spec/**/*_spec.rb']
25
- end
26
-
27
- Spec::Rake::SpecTask.new(:rcov) do |spec|
28
- spec.libs << 'lib' << 'spec'
29
- spec.pattern = 'spec/**/*_spec.rb'
30
- spec.rcov = true
31
- end
32
-
33
- task :spec => :check_dependencies
34
-
35
- task :default => :spec
36
-
37
- require 'rake/rdoctask'
38
- Rake::RDocTask.new do |rdoc|
39
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
-
41
- rdoc.rdoc_dir = 'rdoc'
42
- rdoc.title = "basic_tree #{version}"
43
- rdoc.rdoc_files.include('README*')
44
- rdoc.rdoc_files.include('lib/**/*.rb')
45
- end
3
+ Bundler::GemHelper.install_tasks
data/basic_tree.gemspec CHANGED
@@ -1,55 +1,23 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "basic_tree"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{basic_tree}
8
- s.version = "0.1.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.name = "basic_tree"
7
+ s.version = BasicTree::VERSION
8
+ s.platform = Gem::Platform::RUBY
11
9
  s.authors = ["Austin Schneider"]
12
- s.date = %q{2010-07-01}
13
- s.description = %q{A basic tree structure}
14
- s.email = %q{soccer022483@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "basic_tree.gemspec",
27
- "lib/basic_tree.rb",
28
- "spec/basic_tree_spec.rb",
29
- "spec/spec.opts",
30
- "spec/spec_helper.rb"
31
- ]
32
- s.homepage = %q{http://github.com/soccer022483/basic_tree}
33
- s.rdoc_options = ["--charset=UTF-8"]
34
- s.require_paths = ["lib"]
35
- s.rubygems_version = %q{1.3.7}
36
- s.summary = %q{A basic tree structure}
37
- s.test_files = [
38
- "spec/basic_tree_spec.rb",
39
- "spec/spec_helper.rb"
40
- ]
10
+ s.email = ["soccer022483@gmail.com"]
11
+ s.homepage = "http://github.com/soccer022483/basic_tree"
12
+ s.summary = %q{A basic tree structure.}
13
+ s.description = %q{A basic tree structure.}
41
14
 
42
- if s.respond_to? :specification_version then
43
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
- s.specification_version = 3
15
+ s.rubyforge_project = "basic_tree"
45
16
 
46
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
48
- else
49
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
50
- end
51
- else
52
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
53
- end
54
- end
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
55
21
 
22
+ s.add_development_dependency 'rspec', ">= 2"
23
+ end
data/lib/basic_tree.rb CHANGED
@@ -1,14 +1,16 @@
1
1
  class BasicTree
2
-
2
+
3
3
  include Enumerable
4
-
4
+
5
+ VERSION = "0.1.1"
6
+
5
7
  def initialize(object, &block)
6
8
  self.object = object
7
9
  yield self if block_given?
8
10
  end
9
-
11
+
10
12
  attr_accessor :object, :parent
11
-
13
+
12
14
  def add(object, &block)
13
15
  self.class.new(object) do |child|
14
16
  children << child
@@ -16,45 +18,45 @@ class BasicTree
16
18
  yield child if block_given?
17
19
  end
18
20
  end
19
-
21
+
20
22
  def path
21
23
  ancestors << self
22
24
  end
23
-
25
+
24
26
  def ancestors
25
27
  root? ? [] : (parent.ancestors << parent)
26
28
  end
27
-
29
+
28
30
  def descendants
29
31
  children.map { |c| [c] + c.descendants }.flatten
30
32
  end
31
-
33
+
32
34
  def subtree
33
35
  [self] + descendants
34
36
  end
35
-
37
+
36
38
  def siblings
37
39
  root? ? [] : parent.children.select { |child| child != self }
38
40
  end
39
-
41
+
40
42
  def root
41
43
  path.first
42
44
  end
43
-
45
+
44
46
  def level
45
47
  path.size
46
48
  end
47
-
49
+
48
50
  def root?
49
51
  !parent
50
52
  end
51
-
53
+
52
54
  def leaf?
53
55
  children.empty?
54
56
  end
55
-
57
+
56
58
  def children
57
59
  @children ||= []
58
60
  end
59
-
61
+
60
62
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basic_tree
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 0
10
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
11
10
  platform: ruby
12
11
  authors:
13
12
  - Austin Schneider
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-07-01 00:00:00 -04:00
17
+ date: 2010-12-21 00:00:00 -05:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,30 +25,28 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 13
30
28
  segments:
31
- - 1
32
29
  - 2
33
- - 9
34
- version: 1.2.9
30
+ version: "2"
35
31
  type: :development
36
32
  version_requirements: *id001
37
- description: A basic tree structure
38
- email: soccer022483@gmail.com
33
+ description: A basic tree structure.
34
+ email:
35
+ - soccer022483@gmail.com
39
36
  executables: []
40
37
 
41
38
  extensions: []
42
39
 
43
- extra_rdoc_files:
44
- - LICENSE
45
- - README.rdoc
40
+ extra_rdoc_files: []
41
+
46
42
  files:
47
- - .document
48
43
  - .gitignore
44
+ - .rvmrc
45
+ - Gemfile
46
+ - Gemfile.lock
49
47
  - LICENSE
50
48
  - README.rdoc
51
49
  - Rakefile
52
- - VERSION
53
50
  - basic_tree.gemspec
54
51
  - lib/basic_tree.rb
55
52
  - spec/basic_tree_spec.rb
@@ -60,8 +57,8 @@ homepage: http://github.com/soccer022483/basic_tree
60
57
  licenses: []
61
58
 
62
59
  post_install_message:
63
- rdoc_options:
64
- - --charset=UTF-8
60
+ rdoc_options: []
61
+
65
62
  require_paths:
66
63
  - lib
67
64
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -69,7 +66,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
66
  requirements:
70
67
  - - ">="
71
68
  - !ruby/object:Gem::Version
72
- hash: 3
73
69
  segments:
74
70
  - 0
75
71
  version: "0"
@@ -78,17 +74,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
74
  requirements:
79
75
  - - ">="
80
76
  - !ruby/object:Gem::Version
81
- hash: 3
82
77
  segments:
83
78
  - 0
84
79
  version: "0"
85
80
  requirements: []
86
81
 
87
- rubyforge_project:
82
+ rubyforge_project: basic_tree
88
83
  rubygems_version: 1.3.7
89
84
  signing_key:
90
85
  specification_version: 3
91
- summary: A basic tree structure
92
- test_files:
93
- - spec/basic_tree_spec.rb
94
- - spec/spec_helper.rb
86
+ summary: A basic tree structure.
87
+ test_files: []
88
+
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.0