usd 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -3
  3. data/bin/rusdc +34 -30
  4. data/usd.gemspec +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd0b2054000b2def693dfdb2fed2dd4ac34b844b733ef332424d642023a4f088
4
- data.tar.gz: c604209a6723f2c17185399019ab7008930874df3a9ba2cdf157b3f4e2ccabe4
3
+ metadata.gz: 1dc348116c2ad35950bcea88ca80863c751b7b50c8d30e9f7e1b61555f6d08dd
4
+ data.tar.gz: 4fb82b76d1aa8ba9277ac3512e6d4fd0bc40e29fdff4054192de6f94709ee27a
5
5
  SHA512:
6
- metadata.gz: b47d3d45583358c0f8f2fe4beb335145adcee61db83162fa70df0012be146e1e08f728b93d7c18bcfc911adc6868cea6854e0bfd0f3023afb023f642449a09fa
7
- data.tar.gz: f89aa581d81e20ec819518be185ad5d794bd601ed78ae0a6c4a17c943dd22d3ad5f1c5ab243f09a27eac77b005c622a113ec98421725371a3f79b49d345a455f
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
- Some external dependencies are:
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
- place both binaries `jq` und `mlr` in a path, which is in your PATH-Environment.
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
- con = loadcon
88
- con.debug = options[:debug]
89
- e = con.search(object,{'fields' => fields,"wc" => wc})
90
- if e.length > 0
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 muessen jq und mlr verfuegbar sein
107
- if (fields =~ /^[\w\_,@]+$/)
108
- fields_array=fields.split(/,/)
109
- jq_mapping = []
110
- fields_array.each do |key|
111
- if e[0].keys.include?(key)
112
- if e[0][key].class == Hash
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
- else
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'usd'
3
- spec.version = '0.1.3'
3
+ spec.version = '0.1.4'
4
4
  spec.date = '2019-10-31'
5
5
  spec.summary = "SDM REST-API-Calls"
6
6
  spec.description = "a Ruby class and a commandlinetool for SDM REST-API-Calls"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Gaida