usd 0.1.3 → 0.1.4
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 +2 -3
- data/bin/rusdc +34 -30
- data/usd.gemspec +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1dc348116c2ad35950bcea88ca80863c751b7b50c8d30e9f7e1b61555f6d08dd
         | 
| 4 | 
            +
              data.tar.gz: 4fb82b76d1aa8ba9277ac3512e6d4fd0bc40e29fdff4054192de6f94709ee27a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2b99881822e2e345d1dc7c227806f7df202af50d51fef1d3bc4dd16563dd58e3e01b95249aab6cb910ba7209e78fc0bad04ad39613895c9bc7ad1d1e070d749a
         | 
| 7 | 
            +
              data.tar.gz: ddb9e9db898df0849150849d75fae4d848bc0d5305f6605ca881a3e5ae2c1c6498af3ac4c8f7d3370f81a278b7d41b6990853a94cf4e3dcf4e275df5cddc46c1
         | 
    
        data/README.md
    CHANGED
    
    | @@ -23,12 +23,11 @@ yum install ruby-devel | |
| 23 23 |  | 
| 24 24 | 
             
            # external tools
         | 
| 25 25 |  | 
| 26 | 
            -
             | 
| 26 | 
            +
            If you use the `rusdc find` command with `--format mlr` option then you need `mlr`.
         | 
| 27 27 |  | 
| 28 | 
            -
            - [jq](https://stedolan.github.io/jq/) - a great tool for query and manipulate json-data
         | 
| 29 28 | 
             
            - [mlr - Miller](http://johnkerl.org/miller/doc/index.html) - a great tool for data-transforming to and from json, csv and many more
         | 
| 30 29 |  | 
| 31 | 
            -
             | 
| 30 | 
            +
            Place the `mlr`-binary in a path, which is in your PATH-Environment.
         | 
| 32 31 |  | 
| 33 32 | 
             
            # funktions from the commandline-tool `rusdc`
         | 
| 34 33 |  | 
    
        data/bin/rusdc
    CHANGED
    
    | @@ -84,10 +84,32 @@ class Rusdc < Thor | |
| 84 84 | 
             
              option :nice_time, :type => :boolean, :default => true
         | 
| 85 85 | 
             
              option :debug, :type => :boolean, :default => false
         | 
| 86 86 | 
             
              def find(object, wc, fields="*")
         | 
| 87 | 
            -
                 | 
| 88 | 
            -
             | 
| 89 | 
            -
                 | 
| 90 | 
            -
             | 
| 87 | 
            +
                unless (fields =~ /^[\w\_,@]+$/)
         | 
| 88 | 
            +
                  puts "fields-problem: there must be only letters, numbers, comma and underscore, nothing else!"
         | 
| 89 | 
            +
                else
         | 
| 90 | 
            +
                  con = loadcon
         | 
| 91 | 
            +
                  con.debug = options[:debug]
         | 
| 92 | 
            +
                  e = con.search(object,{'fields' => fields,"wc" => wc})
         | 
| 93 | 
            +
                  fields_array=fields.split(/,/)
         | 
| 94 | 
            +
                  e.each do |elem|
         | 
| 95 | 
            +
                    elem.keys.each do |elem_key|
         | 
| 96 | 
            +
                      if fields_array.include?(elem_key)
         | 
| 97 | 
            +
                        if elem[elem_key].class == Hash
         | 
| 98 | 
            +
                          elem_value = elem[elem_key]["@COMMON_NAME"]
         | 
| 99 | 
            +
                          elem.delete(elem_key)
         | 
| 100 | 
            +
                          elem[elem_key] = elem_value
         | 
| 101 | 
            +
                        end
         | 
| 102 | 
            +
                      else
         | 
| 103 | 
            +
                        elem.delete(elem_key)
         | 
| 104 | 
            +
                      end
         | 
| 105 | 
            +
                    end
         | 
| 106 | 
            +
                    # fill up not found keys
         | 
| 107 | 
            +
                    fields_array.each do |elem_key|
         | 
| 108 | 
            +
                      unless elem.has_key?(elem_key)
         | 
| 109 | 
            +
                        elem[elem_key]=""
         | 
| 110 | 
            +
                      end
         | 
| 111 | 
            +
                    end
         | 
| 112 | 
            +
                  end
         | 
| 91 113 | 
             
                  if options[:nice_time]
         | 
| 92 114 | 
             
                    e.each_index do |i|
         | 
| 93 115 | 
             
                      e[i].keys.each do |key|
         | 
| @@ -103,35 +125,17 @@ class Rusdc < Thor | |
| 103 125 | 
             
                  when "yaml"
         | 
| 104 126 | 
             
                    puts e.to_yaml
         | 
| 105 127 | 
             
                  when "mlr"
         | 
| 106 | 
            -
                    # hierfuer  | 
| 107 | 
            -
                     | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
                            jq_mapping << %("#{key}": ."#{key}"."@COMMON_NAME")
         | 
| 114 | 
            -
                          else
         | 
| 115 | 
            -
                            jq_mapping << %("#{key}": ."#{key}")
         | 
| 116 | 
            -
                          end
         | 
| 117 | 
            -
                        end
         | 
| 118 | 
            -
                      end
         | 
| 119 | 
            -
                      jq_mapping_string = jq_mapping.join(",")
         | 
| 120 | 
            -
                      file = Tempfile.new('inner_cmd')
         | 
| 121 | 
            -
                      cmd = %(jq "[.[]|{#{jq_mapping_string}}]" #{file.path} | mlr --ijson --o#{options[:mlr_format]} cat)
         | 
| 122 | 
            -
                      file.write(e.jp)
         | 
| 123 | 
            -
                      file.close
         | 
| 124 | 
            -
                      puts `#{cmd}`
         | 
| 125 | 
            -
                      file.unlink
         | 
| 126 | 
            -
                    else
         | 
| 127 | 
            -
                      puts "fields Problem: es sind nur Buchstaben, Ziffern, Komma und Unterstrich zulaessig."
         | 
| 128 | 
            -
                    end
         | 
| 128 | 
            +
                    # hierfuer muss mlr verfuegbar sein
         | 
| 129 | 
            +
                    file = Tempfile.new('json')
         | 
| 130 | 
            +
                    cmd = %(mlr --ijson --o#{options[:mlr_format]} cat #{file.path})
         | 
| 131 | 
            +
                    file.write(e.jp)
         | 
| 132 | 
            +
                    file.close
         | 
| 133 | 
            +
                    puts `#{cmd}`
         | 
| 134 | 
            +
                    file.unlink
         | 
| 129 135 | 
             
                  else
         | 
| 130 136 | 
             
                    puts "das Format #{options[:format]} ist nicht hinterlegt. Es gibt nur json, yaml oder mlr."
         | 
| 131 137 | 
             
                  end
         | 
| 132 | 
            -
                 | 
| 133 | 
            -
                  puts "keine Einträge gefunden!"
         | 
| 134 | 
            -
                end
         | 
| 138 | 
            +
                end # fields check
         | 
| 135 139 | 
             
              end
         | 
| 136 140 |  | 
| 137 141 | 
             
              desc "get", "get <object> <cn>"
         | 
    
        data/usd.gemspec
    CHANGED