greed-summary 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +35 -5
 - data/exe/greed-summary +1 -1
 - data/lib/greed/summary/version.rb +1 -1
 - data/lib/greed/summary.rb +12 -12
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4fb76e1dd7fd4e72fbbd3d2a78e9dc93a3d316c1
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 72974b2ad6420d553ff29d459dde02bc98db683b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d0697a34cf9497ecf005ac8d44da1e17672c82df21fe781574d70696318a2d919b5cfab2bb542380f344428172a022247fbae67ec348b5578f42c6e73bbc37f4
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 3602c8fcd1108461d86389e3ae8a281744b5b3c4cb02116581630097e64fc85ec37f6b1822caa271a1356b9d10a43e8c39f24b6ec7e9768770d279a00d64681a
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,8 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Greed::Summary
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            TODO: Delete this and the text above, and describe your gem
         
     | 
| 
      
 3 
     | 
    
         
            +
            generate `SUMMARY.md` for Github or Gitbook
         
     | 
| 
       6 
4 
     | 
    
         | 
| 
       7 
5 
     | 
    
         
             
            ## Installation
         
     | 
| 
       8 
6 
     | 
    
         | 
| 
         @@ -22,7 +20,39 @@ Or install it yourself as: 
     | 
|
| 
       22 
20 
     | 
    
         | 
| 
       23 
21 
     | 
    
         
             
            ## Usage
         
     | 
| 
       24 
22 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 23 
     | 
    
         
            +
            ```
         
     | 
| 
      
 24 
     | 
    
         
            +
            greed-summary [OPTION]
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            -t, --title [string]:
         
     | 
| 
      
 27 
     | 
    
         
            +
               title ,default 'SUMMARY'
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            -d, --directory [directory path]:
         
     | 
| 
      
 30 
     | 
    
         
            +
               target directory path ,default './'
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            -o, --output [file path]:
         
     | 
| 
      
 33 
     | 
    
         
            +
               output file path ,default './SUMMARY.md'
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            -i, --ignore [array]:
         
     | 
| 
      
 36 
     | 
    
         
            +
               ignore string array ,default '['resource', 'Resource']'
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            -s, --suffix [array]:
         
     | 
| 
      
 39 
     | 
    
         
            +
               suffix string array ,default '['.md', '.markdown']'
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            -S, --style [string]:
         
     | 
| 
      
 42 
     | 
    
         
            +
               output style ,could be 'github' or 'gitbook', default 'github'
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            -a, --autotitle:
         
     | 
| 
      
 45 
     | 
    
         
            +
               auto set title through file content
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            -e, --encode:
         
     | 
| 
      
 48 
     | 
    
         
            +
               url encode
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            -h, --help:
         
     | 
| 
      
 51 
     | 
    
         
            +
               show help
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            -v, --version:
         
     | 
| 
      
 54 
     | 
    
         
            +
               show version
         
     | 
| 
      
 55 
     | 
    
         
            +
            ```
         
     | 
| 
       26 
56 
     | 
    
         | 
| 
       27 
57 
     | 
    
         
             
            ## Development
         
     | 
| 
       28 
58 
     | 
    
         | 
| 
         @@ -32,7 +62,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To 
     | 
|
| 
       32 
62 
     | 
    
         | 
| 
       33 
63 
     | 
    
         
             
            ## Contributing
         
     | 
| 
       34 
64 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
            Bug reports and pull requests are welcome on GitHub at https://github.com/ 
     | 
| 
      
 65 
     | 
    
         
            +
            Bug reports and pull requests are welcome on GitHub at https://github.com/greedlab/greed-summary.
         
     | 
| 
       36 
66 
     | 
    
         | 
| 
       37 
67 
     | 
    
         | 
| 
       38 
68 
     | 
    
         
             
            ## License
         
     | 
    
        data/exe/greed-summary
    CHANGED
    
    
    
        data/lib/greed/summary.rb
    CHANGED
    
    | 
         @@ -19,26 +19,26 @@ module Greed 
     | 
|
| 
       19 
19 
     | 
    
         
             
                    end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
                    def run
         
     | 
| 
       22 
     | 
    
         
            -
                      summary_file=File.new(File.join( 
     | 
| 
      
 22 
     | 
    
         
            +
                      summary_file=File.new(File.join(@output), "w+")
         
     | 
| 
       23 
23 
     | 
    
         
             
                      if !summary_file
         
     | 
| 
       24 
24 
     | 
    
         
             
                        puts "Unable to whrite summary_file!"
         
     | 
| 
       25 
25 
     | 
    
         
             
                        exit
         
     | 
| 
       26 
26 
     | 
    
         
             
                      end
         
     | 
| 
       27 
     | 
    
         
            -
                      unless File.directory?  
     | 
| 
      
 27 
     | 
    
         
            +
                      unless File.directory? @directory
         
     | 
| 
       28 
28 
     | 
    
         
             
                        puts "Unable to open target_directory!"
         
     | 
| 
       29 
29 
     | 
    
         
             
                        exit
         
     | 
| 
       30 
30 
     | 
    
         
             
                      end
         
     | 
| 
       31 
     | 
    
         
            -
                      if  
     | 
| 
       32 
     | 
    
         
            -
                        summary_file.syswrite("# " +  
     | 
| 
      
 31 
     | 
    
         
            +
                      if @title != ""
         
     | 
| 
      
 32 
     | 
    
         
            +
                        summary_file.syswrite("# " + @title + "\n\n")
         
     | 
| 
       33 
33 
     | 
    
         
             
                      end
         
     | 
| 
       34 
     | 
    
         
            -
                      summary_one_directory(summary_file,  
     | 
| 
       35 
     | 
    
         
            -
                      puts  
     | 
| 
      
 34 
     | 
    
         
            +
                      summary_one_directory(summary_file, @directory, @directory, @ignore, 0)
         
     | 
| 
      
 35 
     | 
    
         
            +
                      puts @output
         
     | 
| 
       36 
36 
     | 
    
         
             
                    end
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
                    def get_readme(directory)
         
     | 
| 
       39 
39 
     | 
    
         
             
                      # puts("debug" + directory)
         
     | 
| 
       40 
40 
     | 
    
         
             
                      Dir.foreach(directory) do |file|
         
     | 
| 
       41 
     | 
    
         
            -
                         
     | 
| 
      
 41 
     | 
    
         
            +
                        @suffix.each do |suffix|
         
     | 
| 
       42 
42 
     | 
    
         
             
                          readme = $readme + suffix
         
     | 
| 
       43 
43 
     | 
    
         
             
                          # puts("debug" + readme + " " + file.downcase)
         
     | 
| 
       44 
44 
     | 
    
         
             
                          if file.downcase.== readme
         
     | 
| 
         @@ -92,7 +92,7 @@ module Greed 
     | 
|
| 
       92 
92 
     | 
    
         
             
                          end
         
     | 
| 
       93 
93 
     | 
    
         | 
| 
       94 
94 
     | 
    
         
             
                          string = "    " * deep
         
     | 
| 
       95 
     | 
    
         
            -
                          if  
     | 
| 
      
 95 
     | 
    
         
            +
                          if @style == "gitbook"
         
     | 
| 
       96 
96 
     | 
    
         
             
                            readme = get_readme(fullPath)
         
     | 
| 
       97 
97 
     | 
    
         
             
                            if readme
         
     | 
| 
       98 
98 
     | 
    
         
             
                              relativePath = relativePath + "/" + readme
         
     | 
| 
         @@ -102,7 +102,7 @@ module Greed 
     | 
|
| 
       102 
102 
     | 
    
         
             
                          end
         
     | 
| 
       103 
103 
     | 
    
         | 
| 
       104 
104 
     | 
    
         
             
                          if relativePath
         
     | 
| 
       105 
     | 
    
         
            -
                            if  
     | 
| 
      
 105 
     | 
    
         
            +
                            if @encode
         
     | 
| 
       106 
106 
     | 
    
         
             
                              relativePath = URI::encode(relativePath)
         
     | 
| 
       107 
107 
     | 
    
         
             
                            end
         
     | 
| 
       108 
108 
     | 
    
         
             
                            # puts("debug" + readme)
         
     | 
| 
         @@ -118,7 +118,7 @@ module Greed 
     | 
|
| 
       118 
118 
     | 
    
         
             
                          if deep == 0 && file == "SUMMARY.md"
         
     | 
| 
       119 
119 
     | 
    
         
             
                            next
         
     | 
| 
       120 
120 
     | 
    
         
             
                          end
         
     | 
| 
       121 
     | 
    
         
            -
                           
     | 
| 
      
 121 
     | 
    
         
            +
                          @suffix.each do |suffix|
         
     | 
| 
       122 
122 
     | 
    
         
             
                            length = suffix.length
         
     | 
| 
       123 
123 
     | 
    
         
             
                            if file[-length, length] != suffix
         
     | 
| 
       124 
124 
     | 
    
         
             
                              next
         
     | 
| 
         @@ -132,7 +132,7 @@ module Greed 
     | 
|
| 
       132 
132 
     | 
    
         
             
                              next
         
     | 
| 
       133 
133 
     | 
    
         
             
                            end
         
     | 
| 
       134 
134 
     | 
    
         | 
| 
       135 
     | 
    
         
            -
                            if  
     | 
| 
      
 135 
     | 
    
         
            +
                            if @autotitle
         
     | 
| 
       136 
136 
     | 
    
         
             
                              title = get_title(fullPath)
         
     | 
| 
       137 
137 
     | 
    
         
             
                            end
         
     | 
| 
       138 
138 
     | 
    
         | 
| 
         @@ -146,7 +146,7 @@ module Greed 
     | 
|
| 
       146 
146 
     | 
    
         
             
                              baseLength += 1
         
     | 
| 
       147 
147 
     | 
    
         
             
                            end
         
     | 
| 
       148 
148 
     | 
    
         
             
                            relativePath = fullPath[baseLength, fullPath.length - baseLength]
         
     | 
| 
       149 
     | 
    
         
            -
                            if  
     | 
| 
      
 149 
     | 
    
         
            +
                            if @encode
         
     | 
| 
       150 
150 
     | 
    
         
             
                              relativePath = URI::encode(relativePath)
         
     | 
| 
       151 
151 
     | 
    
         
             
                            end
         
     | 
| 
       152 
152 
     | 
    
         
             
                            string = "    " * deep + "* [" + title + "](" + relativePath + ")"
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: greed-summary
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Bell
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016-04- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-04-28 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     |