ix-cli 0.0.4 → 0.0.10
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/bin/ix-bcat +32 -0
- data/bin/ix-cat +5 -5
- data/bin/ix-json-stats +88 -0
- data/bin/ix-prepend +8 -0
- data/bin/ix-rot13 +7 -2
- data/bin/ix-rot5 +39 -0
- data/bin/ix-rps +0 -1
- data/bin/ix-timeline +1 -1
- metadata +14 -8
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 9356248fcc4f5fe5c83fedeb01e13166a9764bed70c39fe06132963141f394d9
         | 
| 4 | 
            +
              data.tar.gz: c7676df3c6b0e8427888882bc02fa609e6aa987816f76ef90e656ca6ce196ed7
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 21233826e4b716857231aa89c0abc3263702cf0347b71a2bfc40e3502b79946b98a7b3ae5496bf1975121ef1f3c44952bedd0415d817ac7eee34246ec91007b6
         | 
| 7 | 
            +
              data.tar.gz: fbee1010c9fda5caf7144b8855c6ff8f502413ba3dbee2b81c630340d6c429299878b9b20cc34bc6d9fe2912e3b5e4cee44159f0b31fc947d0467957f7cf6802
         | 
    
        data/bin/ix-bcat
    CHANGED
    
    | @@ -175,10 +175,42 @@ class Bcat | |
| 175 175 | 
             
              end
         | 
| 176 176 | 
             
            end
         | 
| 177 177 |  | 
| 178 | 
            +
            require 'optparse'
         | 
| 179 | 
            +
             | 
| 180 | 
            +
            options = {}
         | 
| 181 | 
            +
             | 
| 182 | 
            +
            OptionParser.new do |opts|
         | 
| 183 | 
            +
             | 
| 184 | 
            +
              opts.banner = "Usage: #{$0} [OPTIONS]"
         | 
| 185 | 
            +
             | 
| 186 | 
            +
              opts.on('-p', '--pre', 'Pre.') do |value|
         | 
| 187 | 
            +
                options[:pre] = value
         | 
| 188 | 
            +
              end
         | 
| 189 | 
            +
             | 
| 190 | 
            +
             | 
| 191 | 
            +
            end.parse!
         | 
| 192 | 
            +
             | 
| 193 | 
            +
            required_options = []
         | 
| 194 | 
            +
            required_options.each do |option|
         | 
| 195 | 
            +
              unless options[option]
         | 
| 196 | 
            +
                $stderr.puts "Can not run #{option.to_s} was not given."
         | 
| 197 | 
            +
                exit 1
         | 
| 198 | 
            +
              end
         | 
| 199 | 
            +
            end
         | 
| 200 | 
            +
             | 
| 178 201 | 
             
            data = []
         | 
| 179 202 |  | 
| 180 203 | 
             
            STDIN.each_line do |line|
         | 
| 181 204 | 
             
              data.push(line)
         | 
| 182 205 | 
             
            end
         | 
| 183 206 |  | 
| 207 | 
            +
            if options[:pre]
         | 
| 208 | 
            +
              puts '<pre>'
         | 
| 209 | 
            +
            end
         | 
| 210 | 
            +
             | 
| 184 211 | 
             
            puts Bcat::ANSI.new(data).to_html
         | 
| 212 | 
            +
             | 
| 213 | 
            +
            if options[:pre]
         | 
| 214 | 
            +
              puts '</pre>'
         | 
| 215 | 
            +
            end
         | 
| 216 | 
            +
             | 
    
        data/bin/ix-cat
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 | 
            -
            #!/usr/bin/env  | 
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 2 |  | 
| 3 | 
            -
            application | 
| 4 | 
            -
            target_path | 
| 5 | 
            -
            target_file=" | 
| 3 | 
            +
            application = ARGV[0]
         | 
| 4 | 
            +
            target_path = File.dirname(__FILE__)
         | 
| 5 | 
            +
            target_file = "#{target_path}/ix-#{application}"
         | 
| 6 6 |  | 
| 7 | 
            -
            cat  | 
| 7 | 
            +
            system "cat #{target_file}"
         | 
    
        data/bin/ix-json-stats
    ADDED
    
    | @@ -0,0 +1,88 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'json'
         | 
| 4 | 
            +
            require 'optparse'
         | 
| 5 | 
            +
            require 'isna'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            options = {}
         | 
| 8 | 
            +
            options[:count] = 10
         | 
| 9 | 
            +
            options[:errors] = false
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            OptionParser.new do |opts|
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              opts.banner = "Usage: #{$0} [OPTIONS]"
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              opts.on('-k', '--keys [KEYS]', 'List of keys to parse from json separated by :.') do |value|
         | 
| 16 | 
            +
                options[:keys] = value
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              opts.on('-c', '--count [NUMBER]', 'Number of top N items to show.') do |value|
         | 
| 20 | 
            +
                options[:count] = value.to_i
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              opts.on('-e', '--errors', 'If we should report errors.') do |value|
         | 
| 24 | 
            +
                options[:errors] = value
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            end.parse!
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            required_options = [:keys]
         | 
| 30 | 
            +
            required_options.each do |option|
         | 
| 31 | 
            +
              unless options[option]
         | 
| 32 | 
            +
                $stderr.puts "Can not run #{option.to_s} was not given."
         | 
| 33 | 
            +
                exit 1
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
            end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            map = {}
         | 
| 38 | 
            +
            keys = options[:keys].split(':')
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            STDIN.each_line do |line|
         | 
| 41 | 
            +
              begin
         | 
| 42 | 
            +
                object = JSON.parse(line)
         | 
| 43 | 
            +
                object.each do |k, v|
         | 
| 44 | 
            +
                  next unless keys.include?(k)
         | 
| 45 | 
            +
                  submap = map[k] ||= {}
         | 
| 46 | 
            +
                  submap[v] ||= 0
         | 
| 47 | 
            +
                  submap[v] += 1
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
              rescue => error
         | 
| 50 | 
            +
                if options[:errors]
         | 
| 51 | 
            +
                  $stderr.puts error.message
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
            end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            def print_map(map, sample)
         | 
| 57 | 
            +
              map.each do |category, stats|
         | 
| 58 | 
            +
                values = []
         | 
| 59 | 
            +
                total = 0
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                counter = 0
         | 
| 62 | 
            +
                stats.values.sort.reverse.each do |value_1|
         | 
| 63 | 
            +
                  stats.each do |key, value_2|
         | 
| 64 | 
            +
                    if value_1 == value_2
         | 
| 65 | 
            +
                      counter += 1
         | 
| 66 | 
            +
                      break if counter > sample
         | 
| 67 | 
            +
                      total += value_1
         | 
| 68 | 
            +
                      values.push({ :value => value_1, :key => key })
         | 
| 69 | 
            +
                    end
         | 
| 70 | 
            +
                  end
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                puts ""
         | 
| 74 | 
            +
                puts "#{category.to_s.to_ansi.cyan.to_s} (#{total})"
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                values.each do |object|
         | 
| 77 | 
            +
                  percentage = "%2.2f" % (object[:value] / total.to_f * 100)
         | 
| 78 | 
            +
                  h_percentage = (percentage.to_s + '%').rjust(6, ' ').to_ansi.yellow.to_s
         | 
| 79 | 
            +
                  value = object[:value].to_s.rjust(10, ' ').to_ansi.green.to_s
         | 
| 80 | 
            +
                  key = object[:key]
         | 
| 81 | 
            +
                  puts "%s %s %s" % [value, h_percentage, key]
         | 
| 82 | 
            +
                end
         | 
| 83 | 
            +
             | 
| 84 | 
            +
              end
         | 
| 85 | 
            +
            end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
            print_map(map, options[:count])
         | 
| 88 | 
            +
             | 
    
        data/bin/ix-prepend
    ADDED
    
    
    
        data/bin/ix-rot13
    CHANGED
    
    | @@ -3,7 +3,12 @@ | |
| 3 3 | 
             
            normal = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
         | 
| 4 4 | 
             
            rot13  = "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"
         | 
| 5 5 |  | 
| 6 | 
            -
            STDIN. | 
| 7 | 
            -
               | 
| 6 | 
            +
            STDIN.each_char do |char|
         | 
| 7 | 
            +
              candidate = char.tr!(normal, rot13)
         | 
| 8 | 
            +
              if candidate
         | 
| 9 | 
            +
                print candidate
         | 
| 10 | 
            +
              else
         | 
| 11 | 
            +
                print char
         | 
| 12 | 
            +
              end
         | 
| 8 13 | 
             
            end
         | 
| 9 14 |  | 
    
        data/bin/ix-rot5
    ADDED
    
    | @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'isna'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            UNIVERSE = (0..9).to_a
         | 
| 6 | 
            +
            ROT = 5
         | 
| 7 | 
            +
            DIGIT_REGEX = /^\d$/
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            def resolve(set, candidate)
         | 
| 10 | 
            +
              needle = set.index(candidate)
         | 
| 11 | 
            +
              if (needle + ROT) > set.size
         | 
| 12 | 
            +
                return (needle - set.size + ROT)
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
              if (needle + ROT) < set.size
         | 
| 15 | 
            +
                return needle + ROT
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
              if (needle == 5)
         | 
| 18 | 
            +
                return 0
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            STDIN.each_char do |char|
         | 
| 23 | 
            +
              next if char.chomp == ''
         | 
| 24 | 
            +
              unless char =~ DIGIT_REGEX
         | 
| 25 | 
            +
                print char
         | 
| 26 | 
            +
                next
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
              rotation = resolve(UNIVERSE, char.to_i)
         | 
| 29 | 
            +
              m = (0..9).to_a.map do |n|
         | 
| 30 | 
            +
                if n.to_s == char
         | 
| 31 | 
            +
                  char.to_ansi.green.to_s
         | 
| 32 | 
            +
                else
         | 
| 33 | 
            +
                  n.to_s
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
              # puts "#{rotation.to_s.to_ansi.red.to_s} = [" + (m * ', ') + "]"
         | 
| 37 | 
            +
              print rotation
         | 
| 38 | 
            +
            end
         | 
| 39 | 
            +
             | 
    
        data/bin/ix-rps
    CHANGED
    
    
    
        data/bin/ix-timeline
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,11 +1,11 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: ix-cli
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.10
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Kazuyoshi Tlacaelel
         | 
| 8 | 
            -
            autorequire: | 
| 8 | 
            +
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 11 | 
             
            date: 2020-02-05 00:00:00.000000000 Z
         | 
| @@ -24,8 +24,8 @@ dependencies: | |
| 24 24 | 
             
                - - '='
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 26 | 
             
                    version: 0.0.4
         | 
| 27 | 
            -
            description: | 
| 28 | 
            -
            email: | 
| 27 | 
            +
            description:
         | 
| 28 | 
            +
            email:
         | 
| 29 29 | 
             
            executables:
         | 
| 30 30 | 
             
            - ix
         | 
| 31 31 | 
             
            - ix-acronym
         | 
| @@ -143,6 +143,7 @@ executables: | |
| 143 143 | 
             
            - ix-json-paths-pretty
         | 
| 144 144 | 
             
            - ix-json-pp
         | 
| 145 145 | 
             
            - ix-json-query
         | 
| 146 | 
            +
            - ix-json-stats
         | 
| 146 147 | 
             
            - ix-json-records-to-array
         | 
| 147 148 | 
             
            - ix-json-remove-key
         | 
| 148 149 | 
             
            - ix-json-replace-values
         | 
| @@ -198,6 +199,7 @@ executables: | |
| 198 199 | 
             
            - ix-pick
         | 
| 199 200 | 
             
            - ix-planning-tickets
         | 
| 200 201 | 
             
            - ix-prefix
         | 
| 202 | 
            +
            - ix-prepend
         | 
| 201 203 | 
             
            - ix-pretty
         | 
| 202 204 | 
             
            - ix-print-and-run
         | 
| 203 205 | 
             
            - ix-psd-to-json
         | 
| @@ -216,6 +218,7 @@ executables: | |
| 216 218 | 
             
            - ix-reverse
         | 
| 217 219 | 
             
            - ix-right
         | 
| 218 220 | 
             
            - ix-rm
         | 
| 221 | 
            +
            - ix-rot5
         | 
| 219 222 | 
             
            - ix-rot13
         | 
| 220 223 | 
             
            - ix-rot3
         | 
| 221 224 | 
             
            - ix-rps
         | 
| @@ -423,6 +426,7 @@ files: | |
| 423 426 | 
             
            - bin/ix-json-records-to-array
         | 
| 424 427 | 
             
            - bin/ix-json-remove-key
         | 
| 425 428 | 
             
            - bin/ix-json-replace-values
         | 
| 429 | 
            +
            - bin/ix-json-stats
         | 
| 426 430 | 
             
            - bin/ix-json-template
         | 
| 427 431 | 
             
            - bin/ix-json-to-csv
         | 
| 428 432 | 
             
            - bin/ix-json-to-dot
         | 
| @@ -475,6 +479,7 @@ files: | |
| 475 479 | 
             
            - bin/ix-pick
         | 
| 476 480 | 
             
            - bin/ix-planning-tickets
         | 
| 477 481 | 
             
            - bin/ix-prefix
         | 
| 482 | 
            +
            - bin/ix-prepend
         | 
| 478 483 | 
             
            - bin/ix-pretty
         | 
| 479 484 | 
             
            - bin/ix-print-and-run
         | 
| 480 485 | 
             
            - bin/ix-psd-to-json
         | 
| @@ -495,6 +500,7 @@ files: | |
| 495 500 | 
             
            - bin/ix-rm
         | 
| 496 501 | 
             
            - bin/ix-rot13
         | 
| 497 502 | 
             
            - bin/ix-rot3
         | 
| 503 | 
            +
            - bin/ix-rot5
         | 
| 498 504 | 
             
            - bin/ix-rps
         | 
| 499 505 | 
             
            - bin/ix-ruby-constructor-arguments
         | 
| 500 506 | 
             
            - bin/ix-ruby-methods
         | 
| @@ -576,10 +582,10 @@ files: | |
| 576 582 | 
             
            - bin/ix-wrap
         | 
| 577 583 | 
             
            - bin/ix-xy
         | 
| 578 584 | 
             
            - bin/ix-zebra
         | 
| 579 | 
            -
            homepage: | 
| 585 | 
            +
            homepage:
         | 
| 580 586 | 
             
            licenses: []
         | 
| 581 587 | 
             
            metadata: {}
         | 
| 582 | 
            -
            post_install_message: | 
| 588 | 
            +
            post_install_message:
         | 
| 583 589 | 
             
            rdoc_options: []
         | 
| 584 590 | 
             
            require_paths:
         | 
| 585 591 | 
             
            - lib
         | 
| @@ -594,8 +600,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 594 600 | 
             
                - !ruby/object:Gem::Version
         | 
| 595 601 | 
             
                  version: '0'
         | 
| 596 602 | 
             
            requirements: []
         | 
| 597 | 
            -
            rubygems_version: 3. | 
| 598 | 
            -
            signing_key: | 
| 603 | 
            +
            rubygems_version: 3.1.2
         | 
| 604 | 
            +
            signing_key:
         | 
| 599 605 | 
             
            specification_version: 4
         | 
| 600 606 | 
             
            summary: ix - string manipulation tools
         | 
| 601 607 | 
             
            test_files: []
         |