ruby-graphviz-mindmap 1.0.0
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/.document +5 -0
 - data/.rdebugrc +2 -0
 - data/.rspec +1 -0
 - data/Gemfile +22 -0
 - data/Gemfile.lock +57 -0
 - data/Guardfile +9 -0
 - data/LICENSE.txt +20 -0
 - data/README.md +19 -0
 - data/Rakefile +49 -0
 - data/VERSION +1 -0
 - data/lib/graph_viz/mind_map.rb +8 -0
 - data/lib/graph_viz/mind_map/node.rb +132 -0
 - data/lib/ruby-graphviz-mindmap.rb +3 -0
 - data/ruby-graphviz-mindmap.gemspec +77 -0
 - data/spec/lib/graph_viz/mind_map/node_spec.rb +186 -0
 - data/spec/lib/graph_viz/mind_map_spec.rb +15 -0
 - data/spec/spec_helper.rb +12 -0
 - metadata +157 -0
 
    
        data/.document
    ADDED
    
    
    
        data/.rdebugrc
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --color
         
     | 
    
        data/Gemfile
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            source "http://rubygems.org"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            gem 'ruby-graphviz', "~> 1.0.5"
         
     | 
| 
      
 4 
     | 
    
         
            +
            # gem 'activesupport', '~> 3.0.0'
         
     | 
| 
      
 5 
     | 
    
         
            +
            # gem 'i18n' #required by activesupport inflections
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            # Add dependencies required to use your gem here.
         
     | 
| 
      
 8 
     | 
    
         
            +
            # Example:
         
     | 
| 
      
 9 
     | 
    
         
            +
            #   gem "activesupport", ">= 2.3.5"
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            # Add dependencies to develop your gem here.
         
     | 
| 
      
 12 
     | 
    
         
            +
            # Include everything needed to run rake, tests, features, etc.
         
     | 
| 
      
 13 
     | 
    
         
            +
            group :development do
         
     | 
| 
      
 14 
     | 
    
         
            +
              gem "rspec", "~> 2.8.0"
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem "rdoc", "~> 3.12"
         
     | 
| 
      
 16 
     | 
    
         
            +
              gem "bundler", "~> 1.0.0"
         
     | 
| 
      
 17 
     | 
    
         
            +
              gem "jeweler", "~> 1.8.3"
         
     | 
| 
      
 18 
     | 
    
         
            +
              gem 'ruby-debug19'
         
     | 
| 
      
 19 
     | 
    
         
            +
              #gem "rcov", ">= 0"
         
     | 
| 
      
 20 
     | 
    
         
            +
              gem "guard"
         
     | 
| 
      
 21 
     | 
    
         
            +
              gem "guard-rspec"
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
    
        data/Gemfile.lock
    ADDED
    
    | 
         @@ -0,0 +1,57 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            GEM
         
     | 
| 
      
 2 
     | 
    
         
            +
              remote: http://rubygems.org/
         
     | 
| 
      
 3 
     | 
    
         
            +
              specs:
         
     | 
| 
      
 4 
     | 
    
         
            +
                archive-tar-minitar (0.5.2)
         
     | 
| 
      
 5 
     | 
    
         
            +
                columnize (0.3.6)
         
     | 
| 
      
 6 
     | 
    
         
            +
                diff-lcs (1.1.3)
         
     | 
| 
      
 7 
     | 
    
         
            +
                ffi (1.0.11)
         
     | 
| 
      
 8 
     | 
    
         
            +
                git (1.2.5)
         
     | 
| 
      
 9 
     | 
    
         
            +
                guard (1.0.0)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  ffi (>= 0.5.0)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  thor (~> 0.14.6)
         
     | 
| 
      
 12 
     | 
    
         
            +
                guard-rspec (0.6.0)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  guard (>= 0.10.0)
         
     | 
| 
      
 14 
     | 
    
         
            +
                jeweler (1.8.3)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  bundler (~> 1.0)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  git (>= 1.2.5)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  rake
         
     | 
| 
      
 18 
     | 
    
         
            +
                  rdoc
         
     | 
| 
      
 19 
     | 
    
         
            +
                json (1.6.5)
         
     | 
| 
      
 20 
     | 
    
         
            +
                linecache19 (0.5.12)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  ruby_core_source (>= 0.1.4)
         
     | 
| 
      
 22 
     | 
    
         
            +
                rake (0.9.2.2)
         
     | 
| 
      
 23 
     | 
    
         
            +
                rdoc (3.12)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  json (~> 1.4)
         
     | 
| 
      
 25 
     | 
    
         
            +
                rspec (2.8.0)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  rspec-core (~> 2.8.0)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  rspec-expectations (~> 2.8.0)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  rspec-mocks (~> 2.8.0)
         
     | 
| 
      
 29 
     | 
    
         
            +
                rspec-core (2.8.0)
         
     | 
| 
      
 30 
     | 
    
         
            +
                rspec-expectations (2.8.0)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  diff-lcs (~> 1.1.2)
         
     | 
| 
      
 32 
     | 
    
         
            +
                rspec-mocks (2.8.0)
         
     | 
| 
      
 33 
     | 
    
         
            +
                ruby-debug-base19 (0.11.25)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  columnize (>= 0.3.1)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  linecache19 (>= 0.5.11)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  ruby_core_source (>= 0.1.4)
         
     | 
| 
      
 37 
     | 
    
         
            +
                ruby-debug19 (0.11.6)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  columnize (>= 0.3.1)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  linecache19 (>= 0.5.11)
         
     | 
| 
      
 40 
     | 
    
         
            +
                  ruby-debug-base19 (>= 0.11.19)
         
     | 
| 
      
 41 
     | 
    
         
            +
                ruby-graphviz (1.0.5)
         
     | 
| 
      
 42 
     | 
    
         
            +
                ruby_core_source (0.1.5)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  archive-tar-minitar (>= 0.5.2)
         
     | 
| 
      
 44 
     | 
    
         
            +
                thor (0.14.6)
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            PLATFORMS
         
     | 
| 
      
 47 
     | 
    
         
            +
              ruby
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            DEPENDENCIES
         
     | 
| 
      
 50 
     | 
    
         
            +
              bundler (~> 1.0.0)
         
     | 
| 
      
 51 
     | 
    
         
            +
              guard
         
     | 
| 
      
 52 
     | 
    
         
            +
              guard-rspec
         
     | 
| 
      
 53 
     | 
    
         
            +
              jeweler (~> 1.8.3)
         
     | 
| 
      
 54 
     | 
    
         
            +
              rdoc (~> 3.12)
         
     | 
| 
      
 55 
     | 
    
         
            +
              rspec (~> 2.8.0)
         
     | 
| 
      
 56 
     | 
    
         
            +
              ruby-debug19
         
     | 
| 
      
 57 
     | 
    
         
            +
              ruby-graphviz (~> 1.0.5)
         
     | 
    
        data/Guardfile
    ADDED
    
    | 
         @@ -0,0 +1,9 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # A sample Guardfile
         
     | 
| 
      
 2 
     | 
    
         
            +
            # More info at https://github.com/guard/guard#readme
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            guard 'rspec', :cli => '-d -c', :version => 2 do
         
     | 
| 
      
 5 
     | 
    
         
            +
              watch(%r{^spec/.+_spec\.rb$})
         
     | 
| 
      
 6 
     | 
    
         
            +
              watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
         
     | 
| 
      
 7 
     | 
    
         
            +
              watch('spec/spec_helper.rb')  { "spec" }
         
     | 
| 
      
 8 
     | 
    
         
            +
            end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2012 Joshua Szmajda
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 4 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 5 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 6 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 7 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 8 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 9 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 12 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 15 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 16 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 17 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 18 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 19 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 20 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # ruby-graphviz-mindmap
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            So this actually isn't using the ruby GraphViz library right now, but I mean to make it do so. It mostly just generates [dot][http://www.graphviz.org/pdf/dotguide.pdf] format files at the moment. Look at the specs to see how.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## Contributing to ruby-graphviz-mindmap
         
     | 
| 
      
 6 
     | 
    
         
            +
             
         
     | 
| 
      
 7 
     | 
    
         
            +
            * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
         
     | 
| 
      
 8 
     | 
    
         
            +
            * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
         
     | 
| 
      
 9 
     | 
    
         
            +
            * Fork the project.
         
     | 
| 
      
 10 
     | 
    
         
            +
            * Start a feature/bugfix branch.
         
     | 
| 
      
 11 
     | 
    
         
            +
            * Commit and push until you are happy with your contribution.
         
     | 
| 
      
 12 
     | 
    
         
            +
            * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
         
     | 
| 
      
 13 
     | 
    
         
            +
            * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            ## Copyright
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            Copyright (c) 2012 Joshua Szmajda. See LICENSE.txt for
         
     | 
| 
      
 18 
     | 
    
         
            +
            further details.
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,49 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'bundler'
         
     | 
| 
      
 5 
     | 
    
         
            +
            begin
         
     | 
| 
      
 6 
     | 
    
         
            +
              Bundler.setup(:default, :development)
         
     | 
| 
      
 7 
     | 
    
         
            +
            rescue Bundler::BundlerError => e
         
     | 
| 
      
 8 
     | 
    
         
            +
              $stderr.puts e.message
         
     | 
| 
      
 9 
     | 
    
         
            +
              $stderr.puts "Run `bundle install` to install missing gems"
         
     | 
| 
      
 10 
     | 
    
         
            +
              exit e.status_code
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
            require 'rake'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            require 'jeweler'
         
     | 
| 
      
 15 
     | 
    
         
            +
            Jeweler::Tasks.new do |gem|
         
     | 
| 
      
 16 
     | 
    
         
            +
              # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
         
     | 
| 
      
 17 
     | 
    
         
            +
              gem.name = "ruby-graphviz-mindmap"
         
     | 
| 
      
 18 
     | 
    
         
            +
              gem.homepage = "http://github.com/joshsz/ruby-graphviz-mindmap"
         
     | 
| 
      
 19 
     | 
    
         
            +
              gem.license = "MIT"
         
     | 
| 
      
 20 
     | 
    
         
            +
              gem.summary = %Q{A library that takes a ruby description of a mind map and outputs a graphviz dot file}
         
     | 
| 
      
 21 
     | 
    
         
            +
              gem.description = gem.summary
         
     | 
| 
      
 22 
     | 
    
         
            +
              gem.email = "josh@optoro.com"
         
     | 
| 
      
 23 
     | 
    
         
            +
              gem.authors = ["Joshua Szmajda"]
         
     | 
| 
      
 24 
     | 
    
         
            +
              # dependencies defined in Gemfile
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
      
 26 
     | 
    
         
            +
            Jeweler::RubygemsDotOrgTasks.new
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            require 'rspec/core'
         
     | 
| 
      
 29 
     | 
    
         
            +
            require 'rspec/core/rake_task'
         
     | 
| 
      
 30 
     | 
    
         
            +
            RSpec::Core::RakeTask.new(:spec) do |spec|
         
     | 
| 
      
 31 
     | 
    
         
            +
              spec.pattern = FileList['spec/**/*_spec.rb']
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            RSpec::Core::RakeTask.new(:rcov) do |spec|
         
     | 
| 
      
 35 
     | 
    
         
            +
              spec.pattern = 'spec/**/*_spec.rb'
         
     | 
| 
      
 36 
     | 
    
         
            +
              spec.rcov = true
         
     | 
| 
      
 37 
     | 
    
         
            +
            end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            task :default => :spec
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            require 'rdoc/task'
         
     | 
| 
      
 42 
     | 
    
         
            +
            Rake::RDocTask.new do |rdoc|
         
     | 
| 
      
 43 
     | 
    
         
            +
              version = File.exist?('VERSION') ? File.read('VERSION') : ""
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              rdoc.rdoc_dir = 'rdoc'
         
     | 
| 
      
 46 
     | 
    
         
            +
              rdoc.title = "ruby-graphviz-mindmap #{version}"
         
     | 
| 
      
 47 
     | 
    
         
            +
              rdoc.rdoc_files.include('README*')
         
     | 
| 
      
 48 
     | 
    
         
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         
     | 
| 
      
 49 
     | 
    
         
            +
            end
         
     | 
    
        data/VERSION
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            1.0.0
         
     | 
| 
         @@ -0,0 +1,132 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class GraphViz
         
     | 
| 
      
 2 
     | 
    
         
            +
              class MindMap
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
                class Node
         
     | 
| 
      
 5 
     | 
    
         
            +
                  attr_accessor :name
         
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_accessor :options
         
     | 
| 
      
 7 
     | 
    
         
            +
                  attr_accessor :parent
         
     | 
| 
      
 8 
     | 
    
         
            +
                  attr_accessor :nodes
         
     | 
| 
      
 9 
     | 
    
         
            +
                  attr_accessor :used_identifiers
         
     | 
| 
      
 10 
     | 
    
         
            +
                  attr_accessor :pass_on_options
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  def initialize *args
         
     | 
| 
      
 13 
     | 
    
         
            +
                    @options = args.last.is_a?(Hash) ? args.pop : {}
         
     | 
| 
      
 14 
     | 
    
         
            +
                    @name = args.first
         
     | 
| 
      
 15 
     | 
    
         
            +
                    @nodes = []
         
     | 
| 
      
 16 
     | 
    
         
            +
                    @used_identifiers = []
         
     | 
| 
      
 17 
     | 
    
         
            +
                    @pass_on_options = false
         
     | 
| 
      
 18 
     | 
    
         
            +
                    raise ArgumentError.new("You need to name this mind map") unless name
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  def inherit!; @pass_on_options = true end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  def no_inherit!; @pass_on_options = false end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def node(*args, &block)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    @nodes << Node.new(*args).tap do |n| 
         
     | 
| 
      
 26 
     | 
    
         
            +
                      n.parent = self
         
     | 
| 
      
 27 
     | 
    
         
            +
                      if @pass_on_options
         
     | 
| 
      
 28 
     | 
    
         
            +
                        n.options = options.dup.merge(n.options)
         
     | 
| 
      
 29 
     | 
    
         
            +
                        n.pass_on_options = true
         
     | 
| 
      
 30 
     | 
    
         
            +
                      end
         
     | 
| 
      
 31 
     | 
    
         
            +
                    end
         
     | 
| 
      
 32 
     | 
    
         
            +
                    if block_given?
         
     | 
| 
      
 33 
     | 
    
         
            +
                      @nodes.last.instance_eval &block
         
     | 
| 
      
 34 
     | 
    
         
            +
                    end
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  # tree walking things
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  def at(dot_path)
         
     | 
| 
      
 40 
     | 
    
         
            +
                    path = dot_path.split(/\./)
         
     | 
| 
      
 41 
     | 
    
         
            +
                    if path.any?
         
     | 
| 
      
 42 
     | 
    
         
            +
                      index = path.shift.to_i
         
     | 
| 
      
 43 
     | 
    
         
            +
                      nodes[index].at(path.join('.'))
         
     | 
| 
      
 44 
     | 
    
         
            +
                    else
         
     | 
| 
      
 45 
     | 
    
         
            +
                      self
         
     | 
| 
      
 46 
     | 
    
         
            +
                    end
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                  def root
         
     | 
| 
      
 50 
     | 
    
         
            +
                    parent ? parent.root : self
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                  # dot generation things
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  def node_def
         
     | 
| 
      
 56 
     | 
    
         
            +
                    opts = dot_options
         
     | 
| 
      
 57 
     | 
    
         
            +
                    o = [dot_identifier]
         
     | 
| 
      
 58 
     | 
    
         
            +
                    if opts.length > 0
         
     | 
| 
      
 59 
     | 
    
         
            +
                      o << ' '
         
     | 
| 
      
 60 
     | 
    
         
            +
                      o << opts
         
     | 
| 
      
 61 
     | 
    
         
            +
                    end
         
     | 
| 
      
 62 
     | 
    
         
            +
                    o.join
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                  def dot_identifier
         
     | 
| 
      
 66 
     | 
    
         
            +
                    @dot_identifier ||= make_dot_identifier
         
     | 
| 
      
 67 
     | 
    
         
            +
                  end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                  def make_dot_identifier
         
     | 
| 
      
 70 
     | 
    
         
            +
                    id = name.downcase.gsub(/[^ a-z]/,'').sub(/ +$/,'').gsub(/ +/,'_')
         
     | 
| 
      
 71 
     | 
    
         
            +
                    if root.used_identifiers.include? id
         
     | 
| 
      
 72 
     | 
    
         
            +
                      id = "#{parent.dot_identifier}_#{id}"
         
     | 
| 
      
 73 
     | 
    
         
            +
                    end
         
     | 
| 
      
 74 
     | 
    
         
            +
                    root.used_identifiers << id
         
     | 
| 
      
 75 
     | 
    
         
            +
                    id
         
     | 
| 
      
 76 
     | 
    
         
            +
                  end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                  def dot_options
         
     | 
| 
      
 79 
     | 
    
         
            +
                    o=[]
         
     | 
| 
      
 80 
     | 
    
         
            +
                    unless parent.nil?
         
     | 
| 
      
 81 
     | 
    
         
            +
                      o << "label=\"#{name}\""
         
     | 
| 
      
 82 
     | 
    
         
            +
                    end
         
     | 
| 
      
 83 
     | 
    
         
            +
                    options.each_pair do |k,v|
         
     | 
| 
      
 84 
     | 
    
         
            +
                      o << "#{k}=\"#{v}\""
         
     | 
| 
      
 85 
     | 
    
         
            +
                    end
         
     | 
| 
      
 86 
     | 
    
         
            +
                    if o.any?
         
     | 
| 
      
 87 
     | 
    
         
            +
                      "[#{o.join(' ')}]"
         
     | 
| 
      
 88 
     | 
    
         
            +
                    else
         
     | 
| 
      
 89 
     | 
    
         
            +
                      ''
         
     | 
| 
      
 90 
     | 
    
         
            +
                    end
         
     | 
| 
      
 91 
     | 
    
         
            +
                  end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                  # assumes the node you call #to_dot on is the root of the graph and should be treated like a graph
         
     | 
| 
      
 94 
     | 
    
         
            +
                  def to_dot(output=nil, indent=0)
         
     | 
| 
      
 95 
     | 
    
         
            +
                    if indent == 0
         
     | 
| 
      
 96 
     | 
    
         
            +
                      build_dot_from_root
         
     | 
| 
      
 97 
     | 
    
         
            +
                    else
         
     | 
| 
      
 98 
     | 
    
         
            +
                      build_dot_at_index(output,indent)
         
     | 
| 
      
 99 
     | 
    
         
            +
                    end
         
     | 
| 
      
 100 
     | 
    
         
            +
                  end
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
                  def build_dot_from_root
         
     | 
| 
      
 103 
     | 
    
         
            +
                    o = []
         
     | 
| 
      
 104 
     | 
    
         
            +
                    o << "graph #{dot_identifier} {"
         
     | 
| 
      
 105 
     | 
    
         
            +
                    opts = dot_options
         
     | 
| 
      
 106 
     | 
    
         
            +
                    if opts.length > 0
         
     | 
| 
      
 107 
     | 
    
         
            +
                      o << "  graph #{dot_options}"
         
     | 
| 
      
 108 
     | 
    
         
            +
                    end
         
     | 
| 
      
 109 
     | 
    
         
            +
                    nodes.each do |node|
         
     | 
| 
      
 110 
     | 
    
         
            +
                      node.to_dot(o, 1)
         
     | 
| 
      
 111 
     | 
    
         
            +
                    end
         
     | 
| 
      
 112 
     | 
    
         
            +
                    o << "}"
         
     | 
| 
      
 113 
     | 
    
         
            +
                    o.join("\n")
         
     | 
| 
      
 114 
     | 
    
         
            +
                  end
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
                  def build_dot_at_index(o, idx)
         
     | 
| 
      
 117 
     | 
    
         
            +
                    leader = " "*(idx * 2)
         
     | 
| 
      
 118 
     | 
    
         
            +
                    o << "#{leader}#{node_def}"
         
     | 
| 
      
 119 
     | 
    
         
            +
                    if parent && idx > 1
         
     | 
| 
      
 120 
     | 
    
         
            +
                      o << "#{leader}#{parent.dot_identifier} -- #{dot_identifier}"
         
     | 
| 
      
 121 
     | 
    
         
            +
                    end
         
     | 
| 
      
 122 
     | 
    
         
            +
                    if nodes.any?
         
     | 
| 
      
 123 
     | 
    
         
            +
                      o << "#{leader}subgraph sg_#{dot_identifier} {"
         
     | 
| 
      
 124 
     | 
    
         
            +
                      nodes.each do |node|
         
     | 
| 
      
 125 
     | 
    
         
            +
                        node.to_dot(o, idx + 1)
         
     | 
| 
      
 126 
     | 
    
         
            +
                      end
         
     | 
| 
      
 127 
     | 
    
         
            +
                      o << "#{leader}}"
         
     | 
| 
      
 128 
     | 
    
         
            +
                    end
         
     | 
| 
      
 129 
     | 
    
         
            +
                  end
         
     | 
| 
      
 130 
     | 
    
         
            +
                end
         
     | 
| 
      
 131 
     | 
    
         
            +
              end
         
     | 
| 
      
 132 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,77 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Generated by jeweler
         
     | 
| 
      
 2 
     | 
    
         
            +
            # DO NOT EDIT THIS FILE DIRECTLY
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
         
     | 
| 
      
 4 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.name = "ruby-graphviz-mindmap"
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "1.0.0"
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.authors = ["Joshua Szmajda"]
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = "2012-02-10"
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.description = "A library that takes a ruby description of a mind map and outputs a graphviz dot file"
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.email = "josh@optoro.com"
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.extra_rdoc_files = [
         
     | 
| 
      
 16 
     | 
    
         
            +
                "LICENSE.txt",
         
     | 
| 
      
 17 
     | 
    
         
            +
                "README.md"
         
     | 
| 
      
 18 
     | 
    
         
            +
              ]
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.files = [
         
     | 
| 
      
 20 
     | 
    
         
            +
                ".document",
         
     | 
| 
      
 21 
     | 
    
         
            +
                ".rdebugrc",
         
     | 
| 
      
 22 
     | 
    
         
            +
                ".rspec",
         
     | 
| 
      
 23 
     | 
    
         
            +
                "Gemfile",
         
     | 
| 
      
 24 
     | 
    
         
            +
                "Gemfile.lock",
         
     | 
| 
      
 25 
     | 
    
         
            +
                "Guardfile",
         
     | 
| 
      
 26 
     | 
    
         
            +
                "LICENSE.txt",
         
     | 
| 
      
 27 
     | 
    
         
            +
                "README.md",
         
     | 
| 
      
 28 
     | 
    
         
            +
                "Rakefile",
         
     | 
| 
      
 29 
     | 
    
         
            +
                "VERSION",
         
     | 
| 
      
 30 
     | 
    
         
            +
                "lib/graph_viz/mind_map.rb",
         
     | 
| 
      
 31 
     | 
    
         
            +
                "lib/graph_viz/mind_map/node.rb",
         
     | 
| 
      
 32 
     | 
    
         
            +
                "lib/ruby-graphviz-mindmap.rb",
         
     | 
| 
      
 33 
     | 
    
         
            +
                "ruby-graphviz-mindmap.gemspec",
         
     | 
| 
      
 34 
     | 
    
         
            +
                "spec/lib/graph_viz/mind_map/node_spec.rb",
         
     | 
| 
      
 35 
     | 
    
         
            +
                "spec/lib/graph_viz/mind_map_spec.rb",
         
     | 
| 
      
 36 
     | 
    
         
            +
                "spec/spec_helper.rb"
         
     | 
| 
      
 37 
     | 
    
         
            +
              ]
         
     | 
| 
      
 38 
     | 
    
         
            +
              s.homepage = "http://github.com/joshsz/ruby-graphviz-mindmap"
         
     | 
| 
      
 39 
     | 
    
         
            +
              s.licenses = ["MIT"]
         
     | 
| 
      
 40 
     | 
    
         
            +
              s.require_paths = ["lib"]
         
     | 
| 
      
 41 
     | 
    
         
            +
              s.rubygems_version = "1.8.10"
         
     | 
| 
      
 42 
     | 
    
         
            +
              s.summary = "A library that takes a ruby description of a mind map and outputs a graphviz dot file"
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              if s.respond_to? :specification_version then
         
     | 
| 
      
 45 
     | 
    
         
            +
                s.specification_version = 3
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         
     | 
| 
      
 48 
     | 
    
         
            +
                  s.add_runtime_dependency(%q<ruby-graphviz>, ["~> 1.0.5"])
         
     | 
| 
      
 49 
     | 
    
         
            +
                  s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
         
     | 
| 
      
 50 
     | 
    
         
            +
                  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
         
     | 
| 
      
 51 
     | 
    
         
            +
                  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
         
     | 
| 
      
 52 
     | 
    
         
            +
                  s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
         
     | 
| 
      
 53 
     | 
    
         
            +
                  s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
         
     | 
| 
      
 54 
     | 
    
         
            +
                  s.add_development_dependency(%q<guard>, [">= 0"])
         
     | 
| 
      
 55 
     | 
    
         
            +
                  s.add_development_dependency(%q<guard-rspec>, [">= 0"])
         
     | 
| 
      
 56 
     | 
    
         
            +
                else
         
     | 
| 
      
 57 
     | 
    
         
            +
                  s.add_dependency(%q<ruby-graphviz>, ["~> 1.0.5"])
         
     | 
| 
      
 58 
     | 
    
         
            +
                  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
         
     | 
| 
      
 59 
     | 
    
         
            +
                  s.add_dependency(%q<rdoc>, ["~> 3.12"])
         
     | 
| 
      
 60 
     | 
    
         
            +
                  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         
     | 
| 
      
 61 
     | 
    
         
            +
                  s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
         
     | 
| 
      
 62 
     | 
    
         
            +
                  s.add_dependency(%q<ruby-debug19>, [">= 0"])
         
     | 
| 
      
 63 
     | 
    
         
            +
                  s.add_dependency(%q<guard>, [">= 0"])
         
     | 
| 
      
 64 
     | 
    
         
            +
                  s.add_dependency(%q<guard-rspec>, [">= 0"])
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
              else
         
     | 
| 
      
 67 
     | 
    
         
            +
                s.add_dependency(%q<ruby-graphviz>, ["~> 1.0.5"])
         
     | 
| 
      
 68 
     | 
    
         
            +
                s.add_dependency(%q<rspec>, ["~> 2.8.0"])
         
     | 
| 
      
 69 
     | 
    
         
            +
                s.add_dependency(%q<rdoc>, ["~> 3.12"])
         
     | 
| 
      
 70 
     | 
    
         
            +
                s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         
     | 
| 
      
 71 
     | 
    
         
            +
                s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
         
     | 
| 
      
 72 
     | 
    
         
            +
                s.add_dependency(%q<ruby-debug19>, [">= 0"])
         
     | 
| 
      
 73 
     | 
    
         
            +
                s.add_dependency(%q<guard>, [">= 0"])
         
     | 
| 
      
 74 
     | 
    
         
            +
                s.add_dependency(%q<guard-rspec>, [">= 0"])
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
            end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,186 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe GraphViz::MindMap::Node do
         
     | 
| 
      
 4 
     | 
    
         
            +
              it "exists" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                GraphViz::MindMap::Node.should_not be_nil
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              describe "#initialize" do
         
     | 
| 
      
 9 
     | 
    
         
            +
                it "initializes with a graph name" do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  map = GraphViz::MindMap::Node.new "foo"
         
     | 
| 
      
 11 
     | 
    
         
            +
                  map.name.should == "foo"
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                it "initializes with options" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                  map = GraphViz::MindMap::Node.new "foo", a: 2
         
     | 
| 
      
 16 
     | 
    
         
            +
                  map.options[:a].should == 2
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              let(:node) do
         
     | 
| 
      
 21 
     | 
    
         
            +
                GraphViz::MindMap::Node.new "foo", a: 2
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              let(:spaced_node) do
         
     | 
| 
      
 25 
     | 
    
         
            +
                GraphViz::MindMap::Node.new "Some Thing", a: 4, shape: :box
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              let(:weird_node) do
         
     | 
| 
      
 29 
     | 
    
         
            +
                GraphViz::MindMap::Node.new "dumb   other thing ++?* !"
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              let(:complex_graph) do
         
     | 
| 
      
 33 
     | 
    
         
            +
                base = GraphViz::MindMap::Node.new "foo", overlap: false
         
     | 
| 
      
 34 
     | 
    
         
            +
                base.node 'baz', color: :red do
         
     | 
| 
      
 35 
     | 
    
         
            +
                  node 'bar' do
         
     | 
| 
      
 36 
     | 
    
         
            +
                    node 'ha'
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  node 'two', color: :blue do
         
     | 
| 
      
 40 
     | 
    
         
            +
                    node 'three' do
         
     | 
| 
      
 41 
     | 
    
         
            +
                      node 'Four And'
         
     | 
| 
      
 42 
     | 
    
         
            +
                      node 'ha'
         
     | 
| 
      
 43 
     | 
    
         
            +
                    end
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
                base
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              let(:graph_with_carries) do
         
     | 
| 
      
 50 
     | 
    
         
            +
                base = GraphViz::MindMap::Node.new "foo", overlap: false
         
     | 
| 
      
 51 
     | 
    
         
            +
                base.node 'baz', color: :red, shape: :box do
         
     | 
| 
      
 52 
     | 
    
         
            +
                  node 'bar' do
         
     | 
| 
      
 53 
     | 
    
         
            +
                    node 'ha'
         
     | 
| 
      
 54 
     | 
    
         
            +
                  end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                  node 'two', color: :blue do
         
     | 
| 
      
 57 
     | 
    
         
            +
                    inherit!
         
     | 
| 
      
 58 
     | 
    
         
            +
                    node 'three' do
         
     | 
| 
      
 59 
     | 
    
         
            +
                      node 'Four And'
         
     | 
| 
      
 60 
     | 
    
         
            +
                      node 'ha', color: :green
         
     | 
| 
      
 61 
     | 
    
         
            +
                    end
         
     | 
| 
      
 62 
     | 
    
         
            +
                  end
         
     | 
| 
      
 63 
     | 
    
         
            +
                end
         
     | 
| 
      
 64 
     | 
    
         
            +
                base
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              describe "#dot_identifier" do
         
     | 
| 
      
 68 
     | 
    
         
            +
                it "outputs something dot understands" do
         
     | 
| 
      
 69 
     | 
    
         
            +
                  node.dot_identifier.should == 'foo'
         
     | 
| 
      
 70 
     | 
    
         
            +
                  spaced_node.dot_identifier.should == 'some_thing'
         
     | 
| 
      
 71 
     | 
    
         
            +
                  weird_node.dot_identifier.should == 'dumb_other_thing'
         
     | 
| 
      
 72 
     | 
    
         
            +
                end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                it "doesn't cross names when multiple nodes exist in the same tree with the same name" do
         
     | 
| 
      
 75 
     | 
    
         
            +
                  map = complex_graph
         
     | 
| 
      
 76 
     | 
    
         
            +
                  map.at('0.0.0').name.should == 'ha'
         
     | 
| 
      
 77 
     | 
    
         
            +
                  map.at('0.1.0.1').name.should == 'ha'
         
     | 
| 
      
 78 
     | 
    
         
            +
                  map.at('0.0.0').dot_identifier.should == 'ha'
         
     | 
| 
      
 79 
     | 
    
         
            +
                  map.at('0.1.0.1').dot_identifier.should == 'three_ha'
         
     | 
| 
      
 80 
     | 
    
         
            +
                end
         
     | 
| 
      
 81 
     | 
    
         
            +
              end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
              describe "#dot_options" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                it "outputs something dot understands" do
         
     | 
| 
      
 85 
     | 
    
         
            +
                  node.dot_options.should == '[a="2"]'
         
     | 
| 
      
 86 
     | 
    
         
            +
                  spaced_node.dot_options.should == '[a="4" shape="box"]'
         
     | 
| 
      
 87 
     | 
    
         
            +
                  weird_node.dot_options.should == ''
         
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
              describe "#node_def" do
         
     | 
| 
      
 92 
     | 
    
         
            +
                it "outputs the correct definitions" do
         
     | 
| 
      
 93 
     | 
    
         
            +
                  node.node_def.should == 'foo [a="2"]'
         
     | 
| 
      
 94 
     | 
    
         
            +
                  spaced_node.node_def.should == 'some_thing [a="4" shape="box"]'
         
     | 
| 
      
 95 
     | 
    
         
            +
                  weird_node.node_def.should == 'dumb_other_thing'
         
     | 
| 
      
 96 
     | 
    
         
            +
                end
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              describe "#node" do
         
     | 
| 
      
 100 
     | 
    
         
            +
                it "creates a child node" do
         
     | 
| 
      
 101 
     | 
    
         
            +
                  base = GraphViz::MindMap::Node.new "foo"
         
     | 
| 
      
 102 
     | 
    
         
            +
                  base.node 'bar'
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                  base.nodes.first.name.should == 'bar'
         
     | 
| 
      
 105 
     | 
    
         
            +
                end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
                it "creates a child node with options too" do
         
     | 
| 
      
 108 
     | 
    
         
            +
                  base = GraphViz::MindMap::Node.new "foo"
         
     | 
| 
      
 109 
     | 
    
         
            +
                  base.node 'bar', color: :red
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
                  base.nodes.first.options[:color].should == :red
         
     | 
| 
      
 112 
     | 
    
         
            +
                end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                describe "block builder syntax" do
         
     | 
| 
      
 115 
     | 
    
         
            +
                  it "constructs a tree" do
         
     | 
| 
      
 116 
     | 
    
         
            +
                    base = GraphViz::MindMap::Node.new "foo"
         
     | 
| 
      
 117 
     | 
    
         
            +
                    base.node 'baz' do
         
     | 
| 
      
 118 
     | 
    
         
            +
                      node 'bar'
         
     | 
| 
      
 119 
     | 
    
         
            +
                    end
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                    base.nodes.first.name.should == 'baz'
         
     | 
| 
      
 122 
     | 
    
         
            +
                    base.nodes.first.nodes.first.name.should == 'bar'
         
     | 
| 
      
 123 
     | 
    
         
            +
                  end
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                  it "makes a complex graph" do
         
     | 
| 
      
 126 
     | 
    
         
            +
                    base = complex_graph
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
                    base.nodes.size.should == 1
         
     | 
| 
      
 129 
     | 
    
         
            +
                    base.nodes.first.name.should == 'baz'
         
     | 
| 
      
 130 
     | 
    
         
            +
                    base.nodes.first.nodes.size.should == 2
         
     | 
| 
      
 131 
     | 
    
         
            +
                    base.nodes.first.nodes.first.name.should == 'bar'
         
     | 
| 
      
 132 
     | 
    
         
            +
                    base.nodes.first.nodes.first.nodes.first.name.should == 'ha'
         
     | 
| 
      
 133 
     | 
    
         
            +
                    base.nodes.first.nodes.last.name.should == 'two'
         
     | 
| 
      
 134 
     | 
    
         
            +
                    base.nodes.first.nodes.last.nodes.first.name.should == 'three'
         
     | 
| 
      
 135 
     | 
    
         
            +
                    base.nodes.first.nodes.last.nodes.first.nodes.first.name.should == 'Four And'
         
     | 
| 
      
 136 
     | 
    
         
            +
                  end
         
     | 
| 
      
 137 
     | 
    
         
            +
                end
         
     | 
| 
      
 138 
     | 
    
         
            +
              end
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
              it "allows dot-index mapping into the tree" do
         
     | 
| 
      
 141 
     | 
    
         
            +
                complex_graph.at('0.1.0.1').name.should == 'ha'
         
     | 
| 
      
 142 
     | 
    
         
            +
              end
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
              describe "inheriting options" do
         
     | 
| 
      
 145 
     | 
    
         
            +
                it "assigns the same options to its children when inerhit! is called" do
         
     | 
| 
      
 146 
     | 
    
         
            +
                  map = graph_with_carries
         
     | 
| 
      
 147 
     | 
    
         
            +
                  map.at('0.1.0').options[:color].should == :blue
         
     | 
| 
      
 148 
     | 
    
         
            +
                  map.at('0.1.0.0').options[:color].should == :blue
         
     | 
| 
      
 149 
     | 
    
         
            +
                  map.at('0.1.0.1').options[:color].should == :green
         
     | 
| 
      
 150 
     | 
    
         
            +
                end
         
     | 
| 
      
 151 
     | 
    
         
            +
              end
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
              describe "the whole shebang" do
         
     | 
| 
      
 154 
     | 
    
         
            +
                it "converts the complex_graph into the right dot syntax" do
         
     | 
| 
      
 155 
     | 
    
         
            +
                  expected = <<-EOT.chop
         
     | 
| 
      
 156 
     | 
    
         
            +
            graph foo {
         
     | 
| 
      
 157 
     | 
    
         
            +
              graph [overlap="false"]
         
     | 
| 
      
 158 
     | 
    
         
            +
              baz [label="baz" color="red" shape="box"]
         
     | 
| 
      
 159 
     | 
    
         
            +
              subgraph sg_baz {
         
     | 
| 
      
 160 
     | 
    
         
            +
                bar [label="bar"]
         
     | 
| 
      
 161 
     | 
    
         
            +
                baz -- bar
         
     | 
| 
      
 162 
     | 
    
         
            +
                subgraph sg_bar {
         
     | 
| 
      
 163 
     | 
    
         
            +
                  ha [label="ha"]
         
     | 
| 
      
 164 
     | 
    
         
            +
                  bar -- ha
         
     | 
| 
      
 165 
     | 
    
         
            +
                }
         
     | 
| 
      
 166 
     | 
    
         
            +
                two [label="two" color="blue"]
         
     | 
| 
      
 167 
     | 
    
         
            +
                baz -- two
         
     | 
| 
      
 168 
     | 
    
         
            +
                subgraph sg_two {
         
     | 
| 
      
 169 
     | 
    
         
            +
                  three [label="three" color="blue"]
         
     | 
| 
      
 170 
     | 
    
         
            +
                  two -- three
         
     | 
| 
      
 171 
     | 
    
         
            +
                  subgraph sg_three {
         
     | 
| 
      
 172 
     | 
    
         
            +
                    four_and [label="Four And" color="blue"]
         
     | 
| 
      
 173 
     | 
    
         
            +
                    three -- four_and
         
     | 
| 
      
 174 
     | 
    
         
            +
                    three_ha [label="ha" color="green"]
         
     | 
| 
      
 175 
     | 
    
         
            +
                    three -- three_ha
         
     | 
| 
      
 176 
     | 
    
         
            +
                  }
         
     | 
| 
      
 177 
     | 
    
         
            +
                }
         
     | 
| 
      
 178 
     | 
    
         
            +
              }
         
     | 
| 
      
 179 
     | 
    
         
            +
            }
         
     | 
| 
      
 180 
     | 
    
         
            +
                  EOT
         
     | 
| 
      
 181 
     | 
    
         
            +
                  graph_with_carries.to_dot.should == expected
         
     | 
| 
      
 182 
     | 
    
         
            +
                  File.open("/tmp/out.dot",'wb'){|f| f << graph_with_carries.to_dot }
         
     | 
| 
      
 183 
     | 
    
         
            +
                end
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
              end
         
     | 
| 
      
 186 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe GraphViz::MindMap do
         
     | 
| 
      
 4 
     | 
    
         
            +
              it "exists" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                GraphViz::MindMap.should_not be_nil
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              describe "#build" do
         
     | 
| 
      
 9 
     | 
    
         
            +
                it "returns a Node" do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  map = GraphViz::MindMap.build "foo"
         
     | 
| 
      
 11 
     | 
    
         
            +
                  map.should be_kind_of(GraphViz::MindMap::Node)
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         
     | 
| 
      
 2 
     | 
    
         
            +
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rspec'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'ruby-graphviz-mindmap'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            # Requires supporting files with custom matchers and macros, etc,
         
     | 
| 
      
 7 
     | 
    
         
            +
            # in ./support/ and its subdirectories.
         
     | 
| 
      
 8 
     | 
    
         
            +
            Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 11 
     | 
    
         
            +
              
         
     | 
| 
      
 12 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,157 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: ruby-graphviz-mindmap
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: 
         
     | 
| 
      
 6 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 7 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Joshua Szmajda
         
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 10 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 11 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-02-10 00:00:00.000000000Z
         
     | 
| 
      
 13 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 14 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 15 
     | 
    
         
            +
              name: ruby-graphviz
         
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: &19153480 !ruby/object:Gem::Requirement
         
     | 
| 
      
 17 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: 1.0.5
         
     | 
| 
      
 22 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: *19153480
         
     | 
| 
      
 25 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 26 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 27 
     | 
    
         
            +
              requirement: &19152840 !ruby/object:Gem::Requirement
         
     | 
| 
      
 28 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 29 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 30 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 31 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 32 
     | 
    
         
            +
                    version: 2.8.0
         
     | 
| 
      
 33 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 34 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 35 
     | 
    
         
            +
              version_requirements: *19152840
         
     | 
| 
      
 36 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 37 
     | 
    
         
            +
              name: rdoc
         
     | 
| 
      
 38 
     | 
    
         
            +
              requirement: &19152220 !ruby/object:Gem::Requirement
         
     | 
| 
      
 39 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 40 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 41 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 42 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 43 
     | 
    
         
            +
                    version: '3.12'
         
     | 
| 
      
 44 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 45 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 46 
     | 
    
         
            +
              version_requirements: *19152220
         
     | 
| 
      
 47 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 48 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 49 
     | 
    
         
            +
              requirement: &19151580 !ruby/object:Gem::Requirement
         
     | 
| 
      
 50 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: 1.0.0
         
     | 
| 
      
 55 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 56 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 57 
     | 
    
         
            +
              version_requirements: *19151580
         
     | 
| 
      
 58 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 59 
     | 
    
         
            +
              name: jeweler
         
     | 
| 
      
 60 
     | 
    
         
            +
              requirement: &19150980 !ruby/object:Gem::Requirement
         
     | 
| 
      
 61 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 62 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 63 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 64 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 65 
     | 
    
         
            +
                    version: 1.8.3
         
     | 
| 
      
 66 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 67 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 68 
     | 
    
         
            +
              version_requirements: *19150980
         
     | 
| 
      
 69 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 70 
     | 
    
         
            +
              name: ruby-debug19
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: &19150380 !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 73 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 74 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 75 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 76 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 77 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 78 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 79 
     | 
    
         
            +
              version_requirements: *19150380
         
     | 
| 
      
 80 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 81 
     | 
    
         
            +
              name: guard
         
     | 
| 
      
 82 
     | 
    
         
            +
              requirement: &19127100 !ruby/object:Gem::Requirement
         
     | 
| 
      
 83 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 84 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 85 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 86 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 87 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 88 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 89 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 90 
     | 
    
         
            +
              version_requirements: *19127100
         
     | 
| 
      
 91 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 92 
     | 
    
         
            +
              name: guard-rspec
         
     | 
| 
      
 93 
     | 
    
         
            +
              requirement: &19126580 !ruby/object:Gem::Requirement
         
     | 
| 
      
 94 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 95 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 96 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 97 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 98 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 99 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 100 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 101 
     | 
    
         
            +
              version_requirements: *19126580
         
     | 
| 
      
 102 
     | 
    
         
            +
            description: A library that takes a ruby description of a mind map and outputs a graphviz
         
     | 
| 
      
 103 
     | 
    
         
            +
              dot file
         
     | 
| 
      
 104 
     | 
    
         
            +
            email: josh@optoro.com
         
     | 
| 
      
 105 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 106 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 107 
     | 
    
         
            +
            extra_rdoc_files:
         
     | 
| 
      
 108 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 109 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 110 
     | 
    
         
            +
            files:
         
     | 
| 
      
 111 
     | 
    
         
            +
            - .document
         
     | 
| 
      
 112 
     | 
    
         
            +
            - .rdebugrc
         
     | 
| 
      
 113 
     | 
    
         
            +
            - .rspec
         
     | 
| 
      
 114 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 115 
     | 
    
         
            +
            - Gemfile.lock
         
     | 
| 
      
 116 
     | 
    
         
            +
            - Guardfile
         
     | 
| 
      
 117 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 118 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 119 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 120 
     | 
    
         
            +
            - VERSION
         
     | 
| 
      
 121 
     | 
    
         
            +
            - lib/graph_viz/mind_map.rb
         
     | 
| 
      
 122 
     | 
    
         
            +
            - lib/graph_viz/mind_map/node.rb
         
     | 
| 
      
 123 
     | 
    
         
            +
            - lib/ruby-graphviz-mindmap.rb
         
     | 
| 
      
 124 
     | 
    
         
            +
            - ruby-graphviz-mindmap.gemspec
         
     | 
| 
      
 125 
     | 
    
         
            +
            - spec/lib/graph_viz/mind_map/node_spec.rb
         
     | 
| 
      
 126 
     | 
    
         
            +
            - spec/lib/graph_viz/mind_map_spec.rb
         
     | 
| 
      
 127 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 128 
     | 
    
         
            +
            homepage: http://github.com/joshsz/ruby-graphviz-mindmap
         
     | 
| 
      
 129 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 130 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 131 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 132 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 133 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 134 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 135 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 136 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 137 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 138 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 139 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 140 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 141 
     | 
    
         
            +
                  segments:
         
     | 
| 
      
 142 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 143 
     | 
    
         
            +
                  hash: -4154940806686702544
         
     | 
| 
      
 144 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 145 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 146 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 147 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 148 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 149 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 150 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 151 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 152 
     | 
    
         
            +
            rubygems_version: 1.8.10
         
     | 
| 
      
 153 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 154 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 155 
     | 
    
         
            +
            summary: A library that takes a ruby description of a mind map and outputs a graphviz
         
     | 
| 
      
 156 
     | 
    
         
            +
              dot file
         
     | 
| 
      
 157 
     | 
    
         
            +
            test_files: []
         
     |