rnsap 0.4.13 → 0.4.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/auth.rb +1 -2
  3. data/lib/rnsap.rb +42 -4
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1d839817ae1d8f4264066df07ca40d636746be3eadb962a36c9b5aa98ff86e9
4
- data.tar.gz: 8ba9e2b2374a100950ba1d4f11f0684b6c63e09e30b0abbeadb7b4bf32da0795
3
+ metadata.gz: 46c579462ff6f422f25681f0294a21888e8f2a22bb0462a11f079cd9b72fbbdd
4
+ data.tar.gz: b727dcb22d0b4672f5cb1b6740bfa3801a06a9ca9a040e1fb93c7bca5794b7e1
5
5
  SHA512:
6
- metadata.gz: 397f61575fdca3c5dcbf9b521bd5e1e6337e21600033463eb7a706bfcf6a26640ce9a9b2c2f7f4d6eac395b6711fef7cddcbb9735440c4826f13fc2a0380d581
7
- data.tar.gz: 976094292a14865df24a8c193a93c4db4d39dc3727a453b3dca2dc3db409852c4d3f4793f17a3ed208269dd90819e3d785ca57ad5ff63e8a82236b4fe49a4f1c
6
+ metadata.gz: 912238c4977896355b9f9fe7cb08bc9f4f1b450f3ce085968ec4bad3bbc70ca01ab0a0ca07e64e315a2dc9383f4021aadc3dd9d17604200d37dbffb84091a417
7
+ data.tar.gz: 8d378a789e570455b8b002a5f6475fc3de4e8462a29ea672993ae02f109a372bc60089c668ba83ec6732388eceeed6618aada48c0f56f1ae9ab97ad0ae1c9bb7
data/lib/auth.rb CHANGED
@@ -6,7 +6,7 @@ class Auth
6
6
  # for an object
7
7
  # @param json containing authorization object and optionaly
8
8
  # the tuples with field and value to be checked
9
- # @return an array of strings with the list of users
9
+ # @return [Array] an array of strings with the list of users
10
10
  def self.for_object(*options)
11
11
  users = []
12
12
  conn, obj, field1, value1, field2, value2 = validate_options(options)
@@ -102,7 +102,6 @@ class Auth
102
102
  filter.push( "'#{ust.auth}' , ")
103
103
  end
104
104
  filter = filter.uniq
105
- puts filter
106
105
 
107
106
  new_last = "#{filter.last[0..(filter.last.length - 4)]} )"
108
107
  filter = filter[0..-1].push(new_last)
data/lib/rnsap.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'nwrfc'
4
4
  require 'read_table/table_column'
5
+ require 'auth'
5
6
 
6
7
  require 'return'
7
8
 
@@ -440,6 +441,37 @@ module RnSap
440
441
 
441
442
  end
442
443
 
444
+ ##
445
+ # Gets a list of users with authorization for a given
446
+ # authorization object and content
447
+ # @params:
448
+ # - obj [String] SAP authorization Object
449
+ # Ex: for Purchase Requisitions M_EINK_FRG
450
+ # - field1 [String] Object authorization's field.
451
+ # Ex: for Release Group FRGGR
452
+ # - value1 [String] Field Value
453
+ # Ex: any valid Release Group in the instalation
454
+ # - field2 [String] Object authorization's field.
455
+ # Ex: for Release Code FRGCO
456
+ # - value2 [String] Field Value
457
+ # Ex: any valid Release Code in the instalation
458
+ # @return [Array] Array of strings with the SAP userids
459
+ def users_for_auth_object(obj, field1, value1, field2, value2)
460
+ Auth.for_object(
461
+ conn: self,
462
+ obj: obj,
463
+ field1: field1,
464
+ value1: value1,
465
+ field2: field2,
466
+ value2: value2,
467
+ )
468
+ end
469
+
470
+
471
+
472
+ private
473
+ attr_writer :conn
474
+
443
475
  def api_return_success(obj=nil )
444
476
  UtilHelper.api_return(0, 'Success!', obj)
445
477
  end
@@ -452,9 +484,7 @@ module RnSap
452
484
  UtilHelper.api_return(rc, message, obj, exception)
453
485
  end
454
486
 
455
- private
456
-
457
- attr_writer :conn
487
+
458
488
 
459
489
  # Dumps to the output the content of an object
460
490
  def dump_instance_variables(obj)
@@ -464,6 +494,8 @@ module RnSap
464
494
  end
465
495
  end
466
496
 
497
+ KLASS_LIST = {}
498
+
467
499
  # Dynamically returns a class instance with the name 'name' and with each
468
500
  # of its fields as an attribute
469
501
  # @param name [String] name of the intended class instance
@@ -471,7 +503,13 @@ module RnSap
471
503
  # @return [Object] instance of the object 'Name'
472
504
  def get_class_instance(name, fields)
473
505
  # puts "Class name: #{name}"
474
- klass = Object.const_set(name, Class.new).new # , Struct.new(*attributes)
506
+ pre_created = KLASS_LIST[name]
507
+ if pre_created
508
+ klass = pre_created.new
509
+ else
510
+ KLASS_LIST[name] = Object.const_set(name, Class.new)
511
+ klass = KLASS_LIST[name].new # , Struct.new(*attributes)
512
+ end
475
513
  fields.each do |field|
476
514
  klass.class.module_eval { attr_accessor field.downcase }
477
515
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rnsap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.13
4
+ version: 0.4.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rogerio Nascimento
@@ -38,8 +38,8 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: By encapsulating SAPs NW RFC library calls, Ruby routines can access
42
- SAP power in a simpler manner
41
+ description: By encapsulating SAPs NW RFC library calls, Ruby routines achieve SAP
42
+ bunsiness functionalitys power in a simpler manner
43
43
  email:
44
44
  executables: []
45
45
  extensions: []