mxhero-api 0.1.33 → 0.1.34

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjQyMjQzMGIzZWJjY2YxZGQ0ZDQ1OTRhODc4YjA1NmZjMjg0NGU2MQ==
4
+ ZWM3MjU1MTU3MjhmMjA4MzJiNDJiYjZjN2IzMTEzNjU0NzJiYmRlOQ==
5
5
  data.tar.gz: !binary |-
6
- MDQzZWI4ZTQ2ZDAyYjYwYzhjZjZhNTE4YmVmYWNmMDkyZGY5Zjg4ZQ==
6
+ MmM2MzU1OTU3MDI4MjE3OWI4Y2RiZGRiOGI0YzgzYTdiN2I5ODM1OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTMyY2RkMTNkNzI5MzMyMDY1MDgyYjBhMTMyMWUxMzA4NWVkZjEyYzJhZmNj
10
- N2QzNjc1MjBmY2ZiMDIyY2QxYzQ2YWM4YTg2Y2FiM2VlYzJjNjMyZDQ2MDlm
11
- NGM3NTUxNjA0YTdkNTRhMDIyNzA3NmY0ZjQ3YTA4OGQ5OTczY2E=
9
+ ODYwOWUwMzlhZTZjZjI0NDhiZDljN2Y2ODQ2MDY1OGI5YTY5MTYxMzI4NTA3
10
+ MzY2ZDY1OGE1MjdiNmNmM2FjNTY0MDRiYzMyZjBmNGVjMWU3NzI0ZThhNTEy
11
+ ZDVkMDRkNzBjYWE3MWRiNDZjOTI0MDE0MDJjOGE1OTVjYjc2MTA=
12
12
  data.tar.gz: !binary |-
13
- MWQxNWI1NWU4NjZmZDZiYjFkOTU0Yzk0MDA2MTY2ZTAxZWRkODgwM2UwODBh
14
- NTEzNmNjMzljY2ViODI5ZjE3MGJlYzRjNDc1Y2FlMmJkN2MxNGZjODRlMDQw
15
- ZjcyNjNiYTRlODk5YzM2NmNhMWM0MjMyNGNlNDAzMjhiNzA0MWU=
13
+ YWRiYTRlZjVlYTQxZTM5NTRmNTk4MGM2YWVmNjg5MDY2ZWU2ZjgwMmU2NWQ1
14
+ ZTRmYzk2NTYzNTMyYjBlOGM3YTQyY2QyYTI5ZThjZTUxMGMyMDE5NTAxY2Uy
15
+ NjczNjE0NGU5MTQ2NmE1Mzg2NWE3YmYxMmNiNmZiODgyMDEyMGU=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.33
1
+ 0.1.34
@@ -1,5 +1,23 @@
1
1
  module MxHero::API
2
+
3
+ module MetadataLoader
4
+
5
+ def initialize(data = {})
6
+ super(data)
7
+ load_metadata
8
+ end
9
+
10
+ private
2
11
 
12
+ def load_metadata
13
+ is_empty = metadata.nil? || metadata == '' || metadata == 'null'
14
+ #@metadata = JSON.parse(metadata) if metadata
15
+ @metadata = is_empty ? nil : JSON.parse(metadata, symbolize_names: true)
16
+ end
17
+
18
+ end
19
+
20
+
3
21
  class Domain < Resource
4
22
 
5
23
  attributes :domain, :server,
@@ -11,11 +29,13 @@ module MxHero::API
11
29
  attribute :source
12
30
  attribute :metadata
13
31
 
32
+ include MetadataLoader
33
+
14
34
  def initialize(data = {})
15
35
  super(data)
16
36
  load_features(features)
17
37
  load_cos(cos)
18
- load_metadata
38
+ # load_metadata
19
39
  end
20
40
 
21
41
  def change_to_trial
@@ -34,36 +54,28 @@ module MxHero::API
34
54
  @features = features.map { |feature| Feature.new feature }
35
55
  end
36
56
 
37
- def load_metadata
38
- @metadata = JSON.parse(metadata) if metadata
39
- end
40
-
41
57
  end
42
58
 
59
+
43
60
 
44
61
  class Feature < Resource
45
62
  attribute :component, map: 'feature'
46
63
  attributes :created, :updated, :metadata
47
64
  attribute :max_rules_amount, map: 'maxRulesAmount'
48
65
 
66
+ include MetadataLoader
67
+
49
68
  def initialize(data = {})
50
69
  super(data)
51
70
  if max_rules_amount == 0 || max_rules_amount.nil?
52
71
  @max_rules_amount = Float::INFINITY
53
72
  end
54
- load_metadata
55
73
  end
56
74
 
57
75
  def unlimited_use?
58
76
  max_rules_amount == Float::INFINITY
59
77
  end
60
78
 
61
- private
62
-
63
- def load_metadata
64
- @metadata = JSON.parse(metadata, symbolize_names: true) if metadata
65
- end
66
-
67
79
  end
68
80
 
69
81
 
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: mxhero-api 0.1.33 ruby lib
2
+ # stub: mxhero-api 0.1.34 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "mxhero-api"
6
- s.version = "0.1.33"
6
+ s.version = "0.1.34"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.authors = ["Maximiliano Dello Russo", "Juan Pablo Royo", "mxHero"]
@@ -12,6 +12,14 @@ class DomainTest < MiniTest::Unit::TestCase
12
12
  assert_equal data[:source], domain.source
13
13
  end
14
14
 
15
+ def test_empty_metadata
16
+ [ '', 'null', nil ].each do |value|
17
+ data[:metadata] = value
18
+ domain = MxHero::API::Domain.new data
19
+ assert domain.metadata.nil?, "Is not empty in case of '#{value}'"
20
+ end
21
+ end
22
+
15
23
  def test_change_domain_to_trial
16
24
  domain = MxHero::API::Domain.new data
17
25
  domain.change_to_trial
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mxhero-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.33
4
+ version: 0.1.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maximiliano Dello Russo