usd 0.1.9 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/bin/rusdc +51 -11
  4. data/change_log.md +20 -1
  5. data/usd.gemspec +2 -2
  6. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d94c304443320d3205ae4b734dbf236bec892f3dff927e98d902e584c76099b
4
- data.tar.gz: a9dcbf0faf5798169948c08590556fbb4da405ed8a6a77f616caacf8ffedc54e
3
+ metadata.gz: 20e10b3d05b2877410dd4f039533d7e9c8281fe9b5b96bfb8a77b29992327dcc
4
+ data.tar.gz: a12edecd3c4078d5d9a0f107693d4af9b5d90496c53e8128016d68ca0bf6c7f2
5
5
  SHA512:
6
- metadata.gz: 0ffd4b1fa7f5cf03667b0c1523958945e2e1dbd1b65386ab05cd4abfd095b474e149d5db055c8845b57a9c44131339a1251d0a4849701d03b43675f983a5b8cd
7
- data.tar.gz: 352ea30499ce9a4f2d8b26cb6c0ee002a707dca331ad25f3eec694bf36a91d3ff442c3bb2c23557f54ceab8ea47cbe2224aa3c6a58b7b73f335703c5f2741f13
6
+ metadata.gz: 07b9914696ee9028670074977518c4486ce5febd6edb6e2855d1afb933527a3a54af7f1668dd47631d2ab4349c8c6eb672a5d9af7a1cbdcdbc3d4fb7ec99c1e9
7
+ data.tar.gz: 3ea37ce6ec628daf61b61ddd86e02ca1791ae86ded68c0aea437086e9bb17b39c4be399d2fd2b6cf8b750e52ec495bfcda07a573d768138816ef8cfd99b31ff6
data/README.md CHANGED
@@ -27,7 +27,7 @@ If you use the `rusdc find` command with `--format mlr` option then you need `ml
27
27
 
28
28
  - [mlr - Miller](http://johnkerl.org/miller/doc/index.html) - a great tool for data-transforming to and from json, csv and many more
29
29
 
30
- Place the `mlr`-binary in a path, which is in your PATH-Environment.
30
+ Place the `mlr`-binary in a path, which is in your PATH-Environment. Download-Url for mlr-releases: [https://github.com/johnkerl/miller/releases](https://github.com/johnkerl/miller/releases)
31
31
 
32
32
  # functions from the commandline-tool `rusdc`
33
33
 
data/bin/rusdc CHANGED
@@ -35,13 +35,15 @@ class Rusdc < Thor
35
35
  puts loadcon.create({:type => "json", :data => STDIN.read})
36
36
  end
37
37
 
38
- desc "field_names <object-type>","list all fields of an object including its format"
39
- def field_names(object)
40
- e = loadcon.search(object,{'fields' => "*","start" => "1", "size" => "1"})[0]
38
+ desc "field_names <object-type> [wc]","list all fields of an object including its format"
39
+ def field_names(object,wc="")
40
+ e = loadcon.search(object,{'fields' => "*","wc"=>wc,"start" => "1", "size" => "1"})[0]
41
41
  e.keys.sort.each do |k|
42
- puts "#{k} (#{e[k].class})"
43
42
  if e[k].class == Hash
43
+ puts "#{k} (#{e[k].class}):"
44
44
  puts e[k].jp
45
+ else
46
+ puts "#{k} (#{e[k].class}) : #{e[k]}"
45
47
  end
46
48
  end
47
49
  end
@@ -140,10 +142,15 @@ class Rusdc < Thor
140
142
  end # fields check
141
143
  end
142
144
 
143
- desc "get <object-type> <common_name>", "shows one object"
145
+ desc "get <object-type> <common_name|id>", "shows one object by name or id"
146
+ option :by_id, :type => :boolean, :default => false
144
147
  option :yaml, :type => :boolean, :default => false
145
- def get(object, cn)
146
- e = loadcon.request("/caisd-rest/#{object}/COMMON_NAME-#{cn}")
148
+ def get(object, ident)
149
+ if options[:by_id] || ident =~ /^U'[0-9A-F]/i
150
+ e = loadcon.request("/caisd-rest/#{object}/#{ident}")
151
+ else
152
+ e = loadcon.request("/caisd-rest/#{object}/COMMON_NAME-#{ident}")
153
+ end
147
154
  if e.class == Hash
148
155
  puts options[:yaml] ? e[object].to_yaml : e[object].jp
149
156
  elsif e.message == "409 Conflict"
@@ -274,15 +281,47 @@ class Rusdc < Thor
274
281
  end
275
282
 
276
283
  desc "update_attr <obj> <common_name> <key> <value>", "updates a direct (not referenced) attribute of one object."
284
+ option :plain_text, :type => :boolean, :default => false
277
285
  def update_attr(obj, cn, k, v)
278
286
  if k =~ /(date|last_mod|warranty_start|warranty_end|time_stamp)$/
279
287
  v=Time.parse(v).to_i
280
288
  end
289
+ if options[:plain_text]
290
+ data={
291
+ obj => {
292
+ "@COMMON_NAME" => cn,
293
+ k => v
294
+ }
295
+ }
296
+ json = JSON.pretty_generate(data)
297
+ else
298
+ template = ERB.new <<-EOF
299
+ {
300
+ "<%= obj %>": {
301
+ "@COMMON_NAME": "<%= cn %>",
302
+ "<%= k %>": "<%= v %>"
303
+ }
304
+ }
305
+ EOF
306
+ json = template.result_with_hash({
307
+ :obj => obj,
308
+ :cn => cn,
309
+ :k => k,
310
+ :v => v
311
+ })
312
+ end
313
+ puts loadcon.update({:type => "json", :data => json})
314
+ end
315
+
316
+ desc "update_ref_attr <obj> <common_name> <key> <value>", "updates a referenced attribute of one object."
317
+ def update_ref_attr(obj, cn, k, v)
281
318
  template = ERB.new <<-EOF
282
319
  {
283
320
  "<%= obj %>": {
284
321
  "@COMMON_NAME": "<%= cn %>",
285
- "<%= k %>": "<%= v %>"
322
+ "<%= k %>": {
323
+ "@COMMON_NAME": "<%= v %>"
324
+ }
286
325
  }
287
326
  }
288
327
  EOF
@@ -295,14 +334,14 @@ class Rusdc < Thor
295
334
  puts loadcon.update({:type => "json", :data => json})
296
335
  end
297
336
 
298
- desc "update_ref_attr <obj> <common_name> <key> <value>", "updates a referenced attribute of one object."
299
- def update_ref_attr(obj, cn, k, v)
337
+ desc "update_ref_attr_by_id <obj> <common_name> <key> <id>", "updates a referenced attribute of one object by id"
338
+ def update_ref_attr_by_id(obj, cn, k, v)
300
339
  template = ERB.new <<-EOF
301
340
  {
302
341
  "<%= obj %>": {
303
342
  "@COMMON_NAME": "<%= cn %>",
304
343
  "<%= k %>": {
305
- "@COMMON_NAME": "<%= v %>"
344
+ "@id": "<%= v %>"
306
345
  }
307
346
  }
308
347
  }
@@ -316,6 +355,7 @@ class Rusdc < Thor
316
355
  puts loadcon.update({:type => "json", :data => json})
317
356
  end
318
357
 
358
+
319
359
  private
320
360
 
321
361
  def loadcon
@@ -1,6 +1,25 @@
1
1
  # changelog
2
2
 
3
- ## 0.1.9 (noch nicht gepushed)
3
+ ## 0.2.0
4
+
5
+ - function `update_attr` has a new option for putting plain text with linebreaks in it.
6
+
7
+ - new funciton `update_ref_attr_by_id` sometimes there are problem if you try to update via common_name, so here you can use the `@id` instead.
8
+
9
+ - `rusdc get` now supports id too
10
+
11
+ - rusdc field_names , now there is a second parameter [wc]. So that's a way to show all fields of a special opbject.
12
+
13
+ Example:
14
+
15
+ ```
16
+ rusdc field_names wf "@id = 1535123" | head -3
17
+ @COMMON_NAME (String) :
18
+ @REL_ATTR (String) : 1535123
19
+ @id (String) : 1535123
20
+ ```
21
+
22
+ ## 0.1.9
4
23
 
5
24
  - function update_attr will parse with Time-Module if the key match the regular expression: `(date|last_mod|warranty_start|warranty_end|time_stamp)`. And then the value will be change to epoche-seconds
6
25
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'usd'
3
- spec.version = '0.1.9'
4
- spec.date = '2019-11-07'
3
+ spec.version = '0.2.1'
4
+ spec.date = '2019-11-26'
5
5
  spec.summary = "SDM REST-API-Calls"
6
6
  spec.description = "a Ruby class and a commandlinetool for SDM REST-API-Calls"
7
7
  spec.authors = ["Oliver Gaida"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Gaida
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-07 00:00:00.000000000 Z
11
+ date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor