lazyme 1.0.0 → 1.0.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 +25 -28
- data/lib/lazyme.rb +14 -8
- data/lib/lazyme/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f50ecb308bcaae7e0fbcf71786c9fc90ba4eb53f
         | 
| 4 | 
            +
              data.tar.gz: 0fcba3824fd50f877a946d7cc2d879f0b29f3ec7
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: d4a06691f85e1a70323c3c01a1eee688c3ca674249d1e8085a4fc6166def03c62484a342a86122e78e49ee34ab845a91833434b6a815a48c147d6a0ecf925a43
         | 
| 7 | 
            +
              data.tar.gz: 4ecfdd239ddc9ac85d5d5a143b82093c77124873bd22f73512d69679ea33cabda25d727830583d9b5e4adada9f9a240d64629208cba3f9521aaecb69439cf417
         | 
    
        data/README.md
    CHANGED
    
    | @@ -10,34 +10,31 @@ gem install lazyme | |
| 10 10 | 
             
            ## Usage
         | 
| 11 11 | 
             
            ```
         | 
| 12 12 | 
             
            lazyme =>
         | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
            |  | 
| 17 | 
            -
            |  | 
| 18 | 
            -
            |  | 
| 19 | 
            -
            |  | 
| 20 | 
            -
            |  | 
| 21 | 
            -
            |  | 
| 22 | 
            -
            |  | 
| 23 | 
            -
            |  | 
| 24 | 
            -
            |  | 
| 25 | 
            -
            | c | 
| 26 | 
            -
            |  | 
| 27 | 
            -
            |  | 
| 28 | 
            -
            |  | 
| 29 | 
            -
            |  | 
| 30 | 
            -
            |  | 
| 31 | 
            -
            |  | 
| 32 | 
            -
            |  | 
| 33 | 
            -
            |  | 
| 34 | 
            -
            |  | 
| 35 | 
            -
             | 
| 36 | 
            -
            |  | 
| 37 | 
            -
             | 
| 38 | 
            -
            | gaa                                     | 14 |
         | 
| 39 | 
            -
            | g                                       | 43 |
         | 
| 40 | 
            -
            +-----------------------------------------+----+
         | 
| 13 | 
            +
            +---------------------------------------------+-------+
         | 
| 14 | 
            +
            |                     Lazyme                          |
         | 
| 15 | 
            +
            +---------------------------------------------+-------+
         | 
| 16 | 
            +
            |...                                          | ...   |
         | 
| 17 | 
            +
            | ei                                          | 21    |
         | 
| 18 | 
            +
            | gpstg                                       | 22    |
         | 
| 19 | 
            +
            | gstp                                        | 23    |
         | 
| 20 | 
            +
            | zs                                          | 28    |
         | 
| 21 | 
            +
            | s .                                         | 30    |
         | 
| 22 | 
            +
            | zrr                                         | 32    |
         | 
| 23 | 
            +
            | gpshh                                       | 60    |
         | 
| 24 | 
            +
            | rss                                         | 70    |
         | 
| 25 | 
            +
            | c                                           | 75    |
         | 
| 26 | 
            +
            | gd                                          | 107   |
         | 
| 27 | 
            +
            | o .                                         | 123   |
         | 
| 28 | 
            +
            | gst                                         | 130   |
         | 
| 29 | 
            +
            | ls                                          | 179   |
         | 
| 30 | 
            +
            | gl                                          | 310   |
         | 
| 31 | 
            +
            | gp                                          | 445   |
         | 
| 32 | 
            +
            | gds                                         | 540   |
         | 
| 33 | 
            +
            | gaa                                         | 817   |
         | 
| 34 | 
            +
            | g                                           | 3365  |
         | 
| 35 | 
            +
            +---------------------------------------------+-------+
         | 
| 36 | 
            +
            | Command                                     | Count |
         | 
| 37 | 
            +
            +---------------------------------------------+-------+
         | 
| 41 38 | 
             
            ```
         | 
| 42 39 |  | 
| 43 40 | 
             
            You can set aliases by adding following lines into your `.bashrc` or `.zshrc` files:
         | 
    
        data/lib/lazyme.rb
    CHANGED
    
    | @@ -12,28 +12,34 @@ module Lazyme | |
| 12 12 | 
             
                end
         | 
| 13 13 |  | 
| 14 14 | 
             
                def call
         | 
| 15 | 
            -
                   | 
| 16 | 
            -
                  data = file.read.force_encoding('BINARY').
         | 
| 15 | 
            +
                  count = Hash.new(0)
         | 
| 17 16 |  | 
| 17 | 
            +
                  File.read(history_file_path).force_encoding('BINARY').
         | 
| 18 18 | 
             
                  encode("UTF-8", invalid: :replace, undef: :replace).
         | 
| 19 19 | 
             
                  split("\n").map do |line|
         | 
| 20 20 | 
             
                    line.split(';').last
         | 
| 21 | 
            -
                  end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                  count = Hash.new(0)
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                  data.each do |item|
         | 
| 21 | 
            +
                  end.each do |item|
         | 
| 26 22 | 
             
                    if trimmed = trim(item)
         | 
| 27 23 | 
             
                      count[trimmed] = count[trimmed] + 1
         | 
| 28 24 | 
             
                    end
         | 
| 29 25 | 
             
                  end
         | 
| 30 26 |  | 
| 31 27 | 
             
                  rows = count.sort_by {|_, v| v }.select { |el| el[1] > COUNT_LIMIT }
         | 
| 32 | 
            -
             | 
| 28 | 
            +
             | 
| 29 | 
            +
                  puts build_table(rows)
         | 
| 33 30 | 
             
                end
         | 
| 34 31 |  | 
| 35 32 | 
             
                private
         | 
| 36 33 |  | 
| 34 | 
            +
                def build_table(rows)
         | 
| 35 | 
            +
                  Terminal::Table.new do |table|
         | 
| 36 | 
            +
                    headings = ['Command', 'Count']
         | 
| 37 | 
            +
                    table.title = "Lazyme"
         | 
| 38 | 
            +
                    table.rows = rows << :separator << headings
         | 
| 39 | 
            +
                    table.headings = headings
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 37 43 | 
             
                def trim(item)
         | 
| 38 44 | 
             
                  if item && item.length == SIZE_LIMIT
         | 
| 39 45 | 
             
                    item.slice(0, SIZE_LIMIT)
         | 
    
        data/lib/lazyme/version.rb
    CHANGED