greed-summary 0.1.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.
- checksums.yaml +7 -0
 - data/.gitignore +19 -0
 - data/Gemfile +4 -0
 - data/LICENSE.txt +21 -0
 - data/README.md +41 -0
 - data/Rakefile +2 -0
 - data/bin/console +14 -0
 - data/bin/setup +8 -0
 - data/exe/greed-summary +90 -0
 - data/greed-summary.gemspec +25 -0
 - data/lib/greed/summary.rb +161 -0
 - data/lib/greed/summary/version.rb +5 -0
 - metadata +85 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: d98d96635d6ddcee1a888c3ac3f094b3f9bc6978
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a5cda2b08b6646751be0ef990c34167e6a317746
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 4f1c3184be4f671988e1805b2aab0fbd99b675984c893a5921871fe8cd9e4281e986f68655e044cfb321e76588eb82ce66eed7497406ae6b8cb62868d9205d9c
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 174d7e7fd303f69d3acca74aab5cb2891df44f12dc7d4334880c7ed23565aa2d412bb7c3d915f90523eaccbee9225e33bfd588b390f68727a0988484510583fb
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            The MIT License (MIT)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Copyright (c) 2016 Bell
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
      
 6 
     | 
    
         
            +
            of this software and associated documentation files (the "Software"), to deal
         
     | 
| 
      
 7 
     | 
    
         
            +
            in the Software without restriction, including without limitation the rights
         
     | 
| 
      
 8 
     | 
    
         
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         
     | 
| 
      
 9 
     | 
    
         
            +
            copies of the Software, and to permit persons to whom the Software is
         
     | 
| 
      
 10 
     | 
    
         
            +
            furnished to do so, subject to the following conditions:
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in
         
     | 
| 
      
 13 
     | 
    
         
            +
            all copies or substantial portions of the Software.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
      
 16 
     | 
    
         
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         
     | 
| 
      
 17 
     | 
    
         
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         
     | 
| 
      
 18 
     | 
    
         
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         
     | 
| 
      
 19 
     | 
    
         
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         
     | 
| 
      
 20 
     | 
    
         
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         
     | 
| 
      
 21 
     | 
    
         
            +
            THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Greed::Summary
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/greed/summary`. To experiment with that code, run `bin/console` for an interactive prompt.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            TODO: Delete this and the text above, and describe your gem
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 12 
     | 
    
         
            +
            gem 'greed-summary'
         
     | 
| 
      
 13 
     | 
    
         
            +
            ```
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                $ gem install greed-summary
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            TODO: Write usage instructions here
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            ## Development
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/greed-summary.
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            ## License
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/console
    ADDED
    
    | 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "bundler/setup"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "greed/summary"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            # You can add fixtures and/or initialization code here to make experimenting
         
     | 
| 
      
 7 
     | 
    
         
            +
            # with your gem easier. You can also use a different console, if you like.
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            # (If you use this, don't forget to add pry to your Gemfile!)
         
     | 
| 
      
 10 
     | 
    
         
            +
            # require "pry"
         
     | 
| 
      
 11 
     | 
    
         
            +
            # Pry.start
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            require "irb"
         
     | 
| 
      
 14 
     | 
    
         
            +
            IRB.start
         
     | 
    
        data/bin/setup
    ADDED
    
    
    
        data/exe/greed-summary
    ADDED
    
    | 
         @@ -0,0 +1,90 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "bundler/setup"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "greed/summary"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            require 'getoptlong'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            opts = GetoptLong.new(
         
     | 
| 
      
 9 
     | 
    
         
            +
                ['--title', '-t', GetoptLong::OPTIONAL_ARGUMENT],
         
     | 
| 
      
 10 
     | 
    
         
            +
                ['--directory', '-d', GetoptLong::OPTIONAL_ARGUMENT],
         
     | 
| 
      
 11 
     | 
    
         
            +
                ['--output', '-o', GetoptLong::OPTIONAL_ARGUMENT],
         
     | 
| 
      
 12 
     | 
    
         
            +
                ['--ignore', '-i', GetoptLong::OPTIONAL_ARGUMENT],
         
     | 
| 
      
 13 
     | 
    
         
            +
                ['--suffix', '-s', GetoptLong::OPTIONAL_ARGUMENT],
         
     | 
| 
      
 14 
     | 
    
         
            +
                ['--style', '-S', GetoptLong::OPTIONAL_ARGUMENT],
         
     | 
| 
      
 15 
     | 
    
         
            +
                ['--encode', '-e', GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 16 
     | 
    
         
            +
                ['--autotitle', '-a', GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 17 
     | 
    
         
            +
                ['--help', '-h', GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 18 
     | 
    
         
            +
                ['--version', '-v', GetoptLong::NO_ARGUMENT]
         
     | 
| 
      
 19 
     | 
    
         
            +
            )
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            $title = 'SUMMARY'
         
     | 
| 
      
 22 
     | 
    
         
            +
            $output = './SUMMARY.md'
         
     | 
| 
      
 23 
     | 
    
         
            +
            $directory = './'
         
     | 
| 
      
 24 
     | 
    
         
            +
            $ignore = ['resource', 'Resource']
         
     | 
| 
      
 25 
     | 
    
         
            +
            $suffix = ['.md', '.markdown']
         
     | 
| 
      
 26 
     | 
    
         
            +
            $encode = false
         
     | 
| 
      
 27 
     | 
    
         
            +
            $autotitle = false
         
     | 
| 
      
 28 
     | 
    
         
            +
            $style = 'github'
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            opts.each do |opt, arg|
         
     | 
| 
      
 31 
     | 
    
         
            +
              case opt
         
     | 
| 
      
 32 
     | 
    
         
            +
                when '--title'
         
     | 
| 
      
 33 
     | 
    
         
            +
                  $title = arg
         
     | 
| 
      
 34 
     | 
    
         
            +
                when '--directory'
         
     | 
| 
      
 35 
     | 
    
         
            +
                  $directory = arg
         
     | 
| 
      
 36 
     | 
    
         
            +
                when '--output'
         
     | 
| 
      
 37 
     | 
    
         
            +
                  $output = arg
         
     | 
| 
      
 38 
     | 
    
         
            +
                when '--ignore'
         
     | 
| 
      
 39 
     | 
    
         
            +
                  $ignore = arg
         
     | 
| 
      
 40 
     | 
    
         
            +
                when '--suffix'
         
     | 
| 
      
 41 
     | 
    
         
            +
                  $suffix = arg
         
     | 
| 
      
 42 
     | 
    
         
            +
                when '--style'
         
     | 
| 
      
 43 
     | 
    
         
            +
                  $style = arg
         
     | 
| 
      
 44 
     | 
    
         
            +
                when '--autotitle'
         
     | 
| 
      
 45 
     | 
    
         
            +
                  $autotitle = true
         
     | 
| 
      
 46 
     | 
    
         
            +
                when '--encode'
         
     | 
| 
      
 47 
     | 
    
         
            +
                  $encode = true
         
     | 
| 
      
 48 
     | 
    
         
            +
                when '--help'
         
     | 
| 
      
 49 
     | 
    
         
            +
                  puts <<-EOF
         
     | 
| 
      
 50 
     | 
    
         
            +
            summary.rb [OPTION]
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            -t, --title [string]:
         
     | 
| 
      
 53 
     | 
    
         
            +
               title ,default 'SUMMARY'
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            -d, --directory [directory path]:
         
     | 
| 
      
 56 
     | 
    
         
            +
               target directory path ,default './'
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            -o, --output [file path]:
         
     | 
| 
      
 59 
     | 
    
         
            +
               output file path ,default './SUMMARY.md'
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            -i, --ignore [array]:
         
     | 
| 
      
 62 
     | 
    
         
            +
               ignore string array ,default '['resource', 'Resource']'
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            -s, --suffix [array]:
         
     | 
| 
      
 65 
     | 
    
         
            +
               suffix string array ,default '['.md', '.markdown']'
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            -S, --style [string]:
         
     | 
| 
      
 68 
     | 
    
         
            +
               output style ,could be 'github' or 'gitbook', default 'github'
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            -a, --autotitle:
         
     | 
| 
      
 71 
     | 
    
         
            +
               auto set title through file content
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            -e, --encode:
         
     | 
| 
      
 74 
     | 
    
         
            +
               url encode
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            -h, --help:
         
     | 
| 
      
 77 
     | 
    
         
            +
               show help
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            -v, --version:
         
     | 
| 
      
 80 
     | 
    
         
            +
               show version
         
     | 
| 
      
 81 
     | 
    
         
            +
                  EOF
         
     | 
| 
      
 82 
     | 
    
         
            +
                  exit 0
         
     | 
| 
      
 83 
     | 
    
         
            +
                when '--version'
         
     | 
| 
      
 84 
     | 
    
         
            +
                  puts  Greed::Summary::VERSION
         
     | 
| 
      
 85 
     | 
    
         
            +
                  exit 0
         
     | 
| 
      
 86 
     | 
    
         
            +
              end
         
     | 
| 
      
 87 
     | 
    
         
            +
            end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
            summary = Greed::Summary::GreedSummary.new($title,$output,$directory,$ignore,$suffix,$encode,$autotitle,$style)
         
     | 
| 
      
 90 
     | 
    
         
            +
            summary.run
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'greed/summary/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.name          = "greed-summary"
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.version       = Greed::Summary::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ["Bell"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ["bell@greedlab.com"]
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              spec.summary       = "generate summary for markdown."
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.homepage      = "https://github.com/greedlab/greed-summary"
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.license       = "MIT"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              spec.required_ruby_version = '>= 2.0.0'
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         
     | 
| 
      
 19 
     | 
    
         
            +
              spec.bindir        = "exe"
         
     | 
| 
      
 20 
     | 
    
         
            +
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         
     | 
| 
      
 21 
     | 
    
         
            +
              spec.require_paths = ["lib"]
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              spec.add_development_dependency "bundler", "~> 1.11"
         
     | 
| 
      
 24 
     | 
    
         
            +
              spec.add_development_dependency "rake", "~> 10.0"
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,161 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "greed/summary/version"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'open-uri'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Greed
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Summary
         
     | 
| 
      
 6 
     | 
    
         
            +
                # Your code goes here...
         
     | 
| 
      
 7 
     | 
    
         
            +
                class GreedSummary
         
     | 
| 
      
 8 
     | 
    
         
            +
                  $readme = 'readme'
         
     | 
| 
      
 9 
     | 
    
         
            +
                    def initialize(title='SUMMARY', output='./SUMMARY.md', directory='./', ignore=['resource', 'Resource'],
         
     | 
| 
      
 10 
     | 
    
         
            +
                       suffix=['.md', '.markdown'], encode=false, autotitle=false, style='github')
         
     | 
| 
      
 11 
     | 
    
         
            +
                       @title = title
         
     | 
| 
      
 12 
     | 
    
         
            +
                       @output = output
         
     | 
| 
      
 13 
     | 
    
         
            +
                       @directory = directory
         
     | 
| 
      
 14 
     | 
    
         
            +
                       @ignore = ignore
         
     | 
| 
      
 15 
     | 
    
         
            +
                       @suffix = suffix
         
     | 
| 
      
 16 
     | 
    
         
            +
                       @encode = encode
         
     | 
| 
      
 17 
     | 
    
         
            +
                       @autotitle = autotitle
         
     | 
| 
      
 18 
     | 
    
         
            +
                       @style = style
         
     | 
| 
      
 19 
     | 
    
         
            +
                    end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    def run
         
     | 
| 
      
 22 
     | 
    
         
            +
                      summary_file=File.new(File.join($output), "w+")
         
     | 
| 
      
 23 
     | 
    
         
            +
                      if !summary_file
         
     | 
| 
      
 24 
     | 
    
         
            +
                        puts "Unable to whrite summary_file!"
         
     | 
| 
      
 25 
     | 
    
         
            +
                        exit
         
     | 
| 
      
 26 
     | 
    
         
            +
                      end
         
     | 
| 
      
 27 
     | 
    
         
            +
                      unless File.directory? $directory
         
     | 
| 
      
 28 
     | 
    
         
            +
                        puts "Unable to open target_directory!"
         
     | 
| 
      
 29 
     | 
    
         
            +
                        exit
         
     | 
| 
      
 30 
     | 
    
         
            +
                      end
         
     | 
| 
      
 31 
     | 
    
         
            +
                      if $title != ""
         
     | 
| 
      
 32 
     | 
    
         
            +
                        summary_file.syswrite("# " + $title + "\n\n")
         
     | 
| 
      
 33 
     | 
    
         
            +
                      end
         
     | 
| 
      
 34 
     | 
    
         
            +
                      summary_one_directory(summary_file, $directory, $directory, $ignore, 0)
         
     | 
| 
      
 35 
     | 
    
         
            +
                      puts $output
         
     | 
| 
      
 36 
     | 
    
         
            +
                    end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                    def get_readme(directory)
         
     | 
| 
      
 39 
     | 
    
         
            +
                      # puts("debug" + directory)
         
     | 
| 
      
 40 
     | 
    
         
            +
                      Dir.foreach(directory) do |file|
         
     | 
| 
      
 41 
     | 
    
         
            +
                        $suffix.each do |suffix|
         
     | 
| 
      
 42 
     | 
    
         
            +
                          readme = $readme + suffix
         
     | 
| 
      
 43 
     | 
    
         
            +
                          # puts("debug" + readme + " " + file.downcase)
         
     | 
| 
      
 44 
     | 
    
         
            +
                          if file.downcase.== readme
         
     | 
| 
      
 45 
     | 
    
         
            +
                            return file
         
     | 
| 
      
 46 
     | 
    
         
            +
                          end
         
     | 
| 
      
 47 
     | 
    
         
            +
                        end
         
     | 
| 
      
 48 
     | 
    
         
            +
                      end
         
     | 
| 
      
 49 
     | 
    
         
            +
                    end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                    def get_title(source_file)
         
     | 
| 
      
 52 
     | 
    
         
            +
                      # puts source_file
         
     | 
| 
      
 53 
     | 
    
         
            +
                      File.open(source_file, "r") do |file|
         
     | 
| 
      
 54 
     | 
    
         
            +
                        line = file.gets
         
     | 
| 
      
 55 
     | 
    
         
            +
                        while line && line == "\n"
         
     | 
| 
      
 56 
     | 
    
         
            +
                          line = file.gets
         
     | 
| 
      
 57 
     | 
    
         
            +
                        end
         
     | 
| 
      
 58 
     | 
    
         
            +
                        if !line
         
     | 
| 
      
 59 
     | 
    
         
            +
                          return nil
         
     | 
| 
      
 60 
     | 
    
         
            +
                        end
         
     | 
| 
      
 61 
     | 
    
         
            +
                        line = line.strip
         
     | 
| 
      
 62 
     | 
    
         
            +
                        if line[0, 1] == "#"
         
     | 
| 
      
 63 
     | 
    
         
            +
                          line = line[1, line.length - 1]
         
     | 
| 
      
 64 
     | 
    
         
            +
                        end
         
     | 
| 
      
 65 
     | 
    
         
            +
                        # puts line.strip
         
     | 
| 
      
 66 
     | 
    
         
            +
                        return line.strip
         
     | 
| 
      
 67 
     | 
    
         
            +
                      end
         
     | 
| 
      
 68 
     | 
    
         
            +
                    end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                    def summary_one_directory(summary, base, directory, ignore, deep)
         
     | 
| 
      
 71 
     | 
    
         
            +
                      # puts directory
         
     | 
| 
      
 72 
     | 
    
         
            +
                      if !File.directory?(directory)
         
     | 
| 
      
 73 
     | 
    
         
            +
                        return
         
     | 
| 
      
 74 
     | 
    
         
            +
                      end
         
     | 
| 
      
 75 
     | 
    
         
            +
                      Dir.foreach(directory) do |file|
         
     | 
| 
      
 76 
     | 
    
         
            +
                        # puts file
         
     | 
| 
      
 77 
     | 
    
         
            +
                        if file.index(".") == 0
         
     | 
| 
      
 78 
     | 
    
         
            +
                          next
         
     | 
| 
      
 79 
     | 
    
         
            +
                        end
         
     | 
| 
      
 80 
     | 
    
         
            +
                        fullPath = directory + "/" + file
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                        baseLength = base.length
         
     | 
| 
      
 83 
     | 
    
         
            +
                        if base[baseLength - 1, 1] != "/"
         
     | 
| 
      
 84 
     | 
    
         
            +
                          baseLength += 1
         
     | 
| 
      
 85 
     | 
    
         
            +
                        end
         
     | 
| 
      
 86 
     | 
    
         
            +
                        relativePath = fullPath[baseLength, fullPath.length - baseLength]
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                        # puts fullPath
         
     | 
| 
      
 89 
     | 
    
         
            +
                        if File.directory?(fullPath) # directory
         
     | 
| 
      
 90 
     | 
    
         
            +
                          if ignore.include?(file)
         
     | 
| 
      
 91 
     | 
    
         
            +
                            next
         
     | 
| 
      
 92 
     | 
    
         
            +
                          end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                          string = "    " * deep
         
     | 
| 
      
 95 
     | 
    
         
            +
                          if $style == "gitbook"
         
     | 
| 
      
 96 
     | 
    
         
            +
                            readme = get_readme(fullPath)
         
     | 
| 
      
 97 
     | 
    
         
            +
                            if readme
         
     | 
| 
      
 98 
     | 
    
         
            +
                              relativePath = relativePath + "/" + readme
         
     | 
| 
      
 99 
     | 
    
         
            +
                            else
         
     | 
| 
      
 100 
     | 
    
         
            +
                              relativePath = nil
         
     | 
| 
      
 101 
     | 
    
         
            +
                            end
         
     | 
| 
      
 102 
     | 
    
         
            +
                          end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                          if relativePath
         
     | 
| 
      
 105 
     | 
    
         
            +
                            if $encode
         
     | 
| 
      
 106 
     | 
    
         
            +
                              relativePath = URI::encode(relativePath)
         
     | 
| 
      
 107 
     | 
    
         
            +
                            end
         
     | 
| 
      
 108 
     | 
    
         
            +
                            # puts("debug" + readme)
         
     | 
| 
      
 109 
     | 
    
         
            +
                            string = string + "* [" + file + "](" + relativePath + ")"
         
     | 
| 
      
 110 
     | 
    
         
            +
                          else
         
     | 
| 
      
 111 
     | 
    
         
            +
                            string = string + "* " + file
         
     | 
| 
      
 112 
     | 
    
         
            +
                          end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                          summary.syswrite(string + "\n")
         
     | 
| 
      
 115 
     | 
    
         
            +
                          # puts string
         
     | 
| 
      
 116 
     | 
    
         
            +
                          summary_one_directory(summary, base, fullPath, ignore, deep + 1)
         
     | 
| 
      
 117 
     | 
    
         
            +
                        else # file
         
     | 
| 
      
 118 
     | 
    
         
            +
                          if deep == 0 && file == "SUMMARY.md"
         
     | 
| 
      
 119 
     | 
    
         
            +
                            next
         
     | 
| 
      
 120 
     | 
    
         
            +
                          end
         
     | 
| 
      
 121 
     | 
    
         
            +
                          $suffix.each do |suffix|
         
     | 
| 
      
 122 
     | 
    
         
            +
                            length = suffix.length
         
     | 
| 
      
 123 
     | 
    
         
            +
                            if file[-length, length] != suffix
         
     | 
| 
      
 124 
     | 
    
         
            +
                              next
         
     | 
| 
      
 125 
     | 
    
         
            +
                            end
         
     | 
| 
      
 126 
     | 
    
         
            +
                            # puts "debug" + file
         
     | 
| 
      
 127 
     | 
    
         
            +
                            name = file[0, file.length - length]
         
     | 
| 
      
 128 
     | 
    
         
            +
                            if name.downcase == $readme
         
     | 
| 
      
 129 
     | 
    
         
            +
                              next
         
     | 
| 
      
 130 
     | 
    
         
            +
                            end
         
     | 
| 
      
 131 
     | 
    
         
            +
                            if ignore.include?(name)
         
     | 
| 
      
 132 
     | 
    
         
            +
                              next
         
     | 
| 
      
 133 
     | 
    
         
            +
                            end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                            if $autotitle
         
     | 
| 
      
 136 
     | 
    
         
            +
                              title = get_title(fullPath)
         
     | 
| 
      
 137 
     | 
    
         
            +
                            end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                            if !title || title.length == 0
         
     | 
| 
      
 140 
     | 
    
         
            +
                              title = name
         
     | 
| 
      
 141 
     | 
    
         
            +
                            end
         
     | 
| 
      
 142 
     | 
    
         
            +
                            # puts fullPath
         
     | 
| 
      
 143 
     | 
    
         
            +
                            # puts title
         
     | 
| 
      
 144 
     | 
    
         
            +
                            baseLength = base.length
         
     | 
| 
      
 145 
     | 
    
         
            +
                            if base[baseLength - 1, 1] != "/"
         
     | 
| 
      
 146 
     | 
    
         
            +
                              baseLength += 1
         
     | 
| 
      
 147 
     | 
    
         
            +
                            end
         
     | 
| 
      
 148 
     | 
    
         
            +
                            relativePath = fullPath[baseLength, fullPath.length - baseLength]
         
     | 
| 
      
 149 
     | 
    
         
            +
                            if $encode
         
     | 
| 
      
 150 
     | 
    
         
            +
                              relativePath = URI::encode(relativePath)
         
     | 
| 
      
 151 
     | 
    
         
            +
                            end
         
     | 
| 
      
 152 
     | 
    
         
            +
                            string = "    " * deep + "* [" + title + "](" + relativePath + ")"
         
     | 
| 
      
 153 
     | 
    
         
            +
                            # puts string
         
     | 
| 
      
 154 
     | 
    
         
            +
                            summary.syswrite(string + "\n")
         
     | 
| 
      
 155 
     | 
    
         
            +
                          end
         
     | 
| 
      
 156 
     | 
    
         
            +
                        end
         
     | 
| 
      
 157 
     | 
    
         
            +
                      end
         
     | 
| 
      
 158 
     | 
    
         
            +
                    end
         
     | 
| 
      
 159 
     | 
    
         
            +
                end
         
     | 
| 
      
 160 
     | 
    
         
            +
              end
         
     | 
| 
      
 161 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,85 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: greed-summary
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Bell
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: exe
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-04-27 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '1.11'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '1.11'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            description: 
         
     | 
| 
      
 42 
     | 
    
         
            +
            email:
         
     | 
| 
      
 43 
     | 
    
         
            +
            - bell@greedlab.com
         
     | 
| 
      
 44 
     | 
    
         
            +
            executables:
         
     | 
| 
      
 45 
     | 
    
         
            +
            - greed-summary
         
     | 
| 
      
 46 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 47 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 48 
     | 
    
         
            +
            files:
         
     | 
| 
      
 49 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 50 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 51 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 52 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 53 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 54 
     | 
    
         
            +
            - bin/console
         
     | 
| 
      
 55 
     | 
    
         
            +
            - bin/setup
         
     | 
| 
      
 56 
     | 
    
         
            +
            - exe/greed-summary
         
     | 
| 
      
 57 
     | 
    
         
            +
            - greed-summary.gemspec
         
     | 
| 
      
 58 
     | 
    
         
            +
            - lib/greed/summary.rb
         
     | 
| 
      
 59 
     | 
    
         
            +
            - lib/greed/summary/version.rb
         
     | 
| 
      
 60 
     | 
    
         
            +
            homepage: https://github.com/greedlab/greed-summary
         
     | 
| 
      
 61 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 62 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 63 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 64 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 65 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 66 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 67 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 68 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 69 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 70 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 71 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 72 
     | 
    
         
            +
                  version: 2.0.0
         
     | 
| 
      
 73 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 74 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 75 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 76 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 77 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 78 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 79 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 80 
     | 
    
         
            +
            rubygems_version: 2.6.1
         
     | 
| 
      
 81 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 82 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 83 
     | 
    
         
            +
            summary: generate summary for markdown.
         
     | 
| 
      
 84 
     | 
    
         
            +
            test_files: []
         
     | 
| 
      
 85 
     | 
    
         
            +
            has_rdoc: 
         
     |