identity-mind 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab894a81e39a568bcba5651b8a73b7fd67d7835711e3d632ce834d8405668dc9
4
- data.tar.gz: 40f883749a81be686b27bfd4f09415283bdf20621d30d7071c0a3a3ab4b5dab2
3
+ metadata.gz: da6526edce7fa6e91a75e76feb59047782702dd53cbaf79de53e1ac1f9035d8d
4
+ data.tar.gz: d0c246af70be71fb4de5bc5e54f97faf468f3a21822fb0a3bc77588d077f317c
5
5
  SHA512:
6
- metadata.gz: bf775c565b136fd3493804baa9e44fbf900166a74cc133c639f4cc615736fa6d01175fef26c0fcd0dc41ecad85282b0aa28e84ac2e9648f374eeb982b3031f3f
7
- data.tar.gz: 1e836aed333d398ee0e61e09ec0808e1f78bdca3f0d20da90e79856d81454a4cef120469b026ee50e0107d2cd23ded0875db246e65ddb9f8dcd4bdbc47ce0cae
6
+ metadata.gz: c11292a8e10a87d3f31c7bb5340baa231bdb88a59610e0b64fd5dc8f588add61a4d5bace7356e8d2026f2d5a718baf0b0806d9424c0e4b4458aa54172321626f
7
+ data.tar.gz: abcb04f5d7726fe6afc6fd55b3948cf596e49543ec836f1939991a2e17ba169ae9dc7e2ad4961c62d8e377458d9fc9b09beadb232663d67ebfc1bccd34904da2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.2.3
2
+ - Trim parameters base on params_length_limit.yml
3
+
1
4
  # 0.2.1
2
5
  - Cut param value by bytesize
3
6
 
@@ -1,5 +1,10 @@
1
1
  module IdentityMind
2
2
  class Params < OpenStruct
3
+ LENGTH_LIMITS =
4
+ YAML.load_file(
5
+ File.join(__dir__, 'params_length_limits.yml')
6
+ ).freeze
7
+
3
8
  def self.[](hash)
4
9
  return hash if hash.is_a?(self)
5
10
 
@@ -11,12 +16,12 @@ module IdentityMind
11
16
  return unless hash
12
17
 
13
18
  hash.each_pair do |k, v|
14
- @table[k.to_sym] = parse_param(v)
19
+ @table[k.to_sym] = parse_param(v, k)
15
20
  end
16
21
  end
17
22
 
18
23
  def []=(name, value)
19
- super(name, parse_param(value))
24
+ super(name, parse_param(value, name))
20
25
  end
21
26
 
22
27
  def to_json(opts = {})
@@ -24,7 +29,7 @@ module IdentityMind
24
29
  end
25
30
 
26
31
  def method_missing(mid, *args)
27
- args[0] = parse_param(args[0]) if args[0]
32
+ args[0] = parse_param(args[0], mid) if args[0]
28
33
  super
29
34
  end
30
35
 
@@ -39,17 +44,19 @@ module IdentityMind
39
44
  unless singleton_class.method_defined?(name)
40
45
  define_singleton_method(name) { @table[name] }
41
46
  define_singleton_method("#{name}=") do |x|
42
- modifiable?[name] = parse_param(x)
47
+ modifiable?[name] = parse_param(x, name)
43
48
  end
44
49
  end
45
50
  name
46
51
  end
47
52
 
48
- def parse_param(value)
53
+ def parse_param(value, key)
49
54
  value = value.to_s if value.is_a?(Symbol)
50
55
  return value unless value.is_a?(String)
51
56
 
52
- result = value[0, IdentityMind.configuration.param_length_limit]
57
+ limit = LENGTH_LIMITS[key.to_s] ||
58
+ IdentityMind.configuration.param_length_limit
59
+ result = value[0, limit]
53
60
 
54
61
  while result.bytesize > IdentityMind.configuration.param_length_limit
55
62
  result = result[0...-1]
@@ -0,0 +1,31 @@
1
+ ---
2
+ bco: 2
3
+ sco: 2
4
+ ccy: 3
5
+ bz: 20
6
+ sz: 20
7
+ bfn: 30
8
+ bc: 30
9
+ bs: 30
10
+ sfn: 30
11
+ sc: 30
12
+ ss: 30
13
+ tid: 40
14
+ ip: 40
15
+ bln: 50
16
+ sln: 50
17
+ man: 60
18
+ tea: 60
19
+ phn: 60
20
+ pm: 60
21
+ pw: 60
22
+ pcct: 64
23
+ ptoken: 64
24
+ bsn: 100
25
+ ssn: 100
26
+ aflid: 100
27
+ pccn: 128
28
+ phash: 128
29
+ pach: 128
30
+ pbc: 128
31
+
@@ -1,3 +1,3 @@
1
1
  module IdentityMind
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: identity-mind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wojciech Widenka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-06 00:00:00.000000000 Z
11
+ date: 2019-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,6 +102,7 @@ files:
102
102
  - lib/identity_mind/account.rb
103
103
  - lib/identity_mind/entity.rb
104
104
  - lib/identity_mind/params.rb
105
+ - lib/identity_mind/params_length_limits.yml
105
106
  - lib/identity_mind/response_error.rb
106
107
  - lib/identity_mind/version.rb
107
108
  homepage: https://github.com/BankToTheFuture/identity_mind_ruby