maestrano-connector-rails 0.2.18 → 0.2.19

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
  SHA1:
3
- metadata.gz: f94f571529c54189a2416028f32c9eaf10f0f496
4
- data.tar.gz: ec2a9b0396f561cb157aa909f758b66b07d50cd9
3
+ metadata.gz: 84ed969991a93b3632339f112511a4baa3848ae9
4
+ data.tar.gz: 133ac31a7b246b0d5f7f7aa096fdd859ab2b7e19
5
5
  SHA512:
6
- metadata.gz: 580f8d9921831198e67a9102ddce992fbe6359b08f0346a32c35af69385ca4f51c6c35a34975b71e7744e74b24fa8d7a03cc4e48ab0e8d31464da2d729091c33
7
- data.tar.gz: 46749aca76d739411ea64a4187a7fdfdbe2d1c795481306458c338bac8586628a6706cae51132e1c5538de1c6f490ffed6357f2a52057efacb0dd889b7444c50
6
+ metadata.gz: 14cbd5436d31186f909ce2c66b01b10e027a5b31fb6f932e2387eabb754aa349f170679d523af24327c79e659a4fad5333e4dd51bbf43a74c468ec0f938add90
7
+ data.tar.gz: 5befbf8603f56588e5501bc16594266d3a592ac775c27ebc3c39b4647ce26fb409e96b4fd7dbb384f26e00575c8628217cc79c9d52e6b0ed4d189416993497a4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.18
1
+ 0.2.19
@@ -1,158 +1,5 @@
1
1
  module Maestrano::Connector::Rails
2
2
  class ComplexEntity
3
-
4
- @@external_name = External.external_name
5
-
6
- # -------------------------------------------------------------
7
- # Complex specific methods
8
- # Those methods needs to be implemented in each complex entity
9
- # -------------------------------------------------------------
10
- def connec_entities_names
11
- raise "Not implemented"
12
- end
13
-
14
- def external_entities_names
15
- raise "Not implemented"
16
- end
17
-
18
- # input : {
19
- # connec_entities_names[0]: [unmapped_connec_entitiy1, unmapped_connec_entitiy2],
20
- # connec_entities_names[1]: [unmapped_connec_entitiy3, unmapped_connec_entitiy4]
21
- # }
22
- # output : {
23
- # connec_entities_names[0]: {
24
- # external_entities_names[0]: [unmapped_connec_entitiy1, unmapped_connec_entitiy2]
25
- # },
26
- # connec_entities_names[1]: {
27
- # external_entities_names[0]: [unmapped_connec_entitiy3],
28
- # external_entities_names[1]: [unmapped_connec_entitiy4]
29
- # }
30
- # }
31
- def connec_model_to_external_model(connec_hash_of_entities)
32
- raise "Not implemented"
33
- end
34
-
35
- # input : {
36
- # external_entities_names[0]: [unmapped_external_entity1}, unmapped_external_entity2],
37
- # external_entities_names[1]: [unmapped_external_entity3}, unmapped_external_entity4]
38
- # }
39
- # output : {
40
- # external_entities_names[0]: {
41
- # connec_entities_names[0]: [unmapped_external_entity1],
42
- # connec_entities_names[1]: [unmapped_external_entity2]
43
- # },
44
- # external_entities_names[1]: {
45
- # connec_entities_names[0]: [unmapped_external_entity3, unmapped_external_entity4]
46
- # }
47
- # }
48
- def external_model_to_connec_model(external_hash_of_entities)
49
- raise "Not implemented"
50
- end
51
-
52
- # -------------------------------------------------------------
53
- # General methods
54
- # -------------------------------------------------------------
55
- def map_to_external_with_idmap(entity, organization, external_entity_name, sub_entity_instance)
56
- idmap = sub_entity_instance.find_idmap({connec_id: entity['id'], external_entity: external_entity_name, organization_id: organization.id})
57
-
58
- if idmap && ((!idmap.to_external) || idmap.last_push_to_external && idmap.last_push_to_external > entity['updated_at'])
59
- ConnectorLogger.log('info', organization, "Discard Connec! #{sub_entity_instance.entity_name} : #{entity}")
60
- nil
61
- else
62
- {entity: sub_entity_instance.map_to(external_entity_name, entity, organization), idmap: idmap || sub_entity_instance.create_idmap_from_connec_entity(entity, external_entity_name, organization)}
63
- end
64
- end
65
-
66
- # -------------------------------------------------------------
67
- # Entity equivalent methods
68
- # -------------------------------------------------------------
69
- def get_connec_entities(client, last_synchronization, organization, opts={})
70
- entities = ActiveSupport::HashWithIndifferentAccess.new
71
-
72
- self.connec_entities_names.each do |connec_entity_name|
73
- sub_entity_instance = "Entities::SubEntities::#{connec_entity_name.titleize.split.join}".constantize.new
74
- entities[connec_entity_name] = sub_entity_instance.get_connec_entities(client, last_synchronization, organization, opts)
75
- end
76
- entities
77
- end
78
-
79
- def get_external_entities(client, last_synchronization, organization, opts={})
80
- entities = ActiveSupport::HashWithIndifferentAccess.new
81
-
82
- self.external_entities_names.each do |external_entity_name|
83
- sub_entity_instance = "Entities::SubEntities::#{external_entity_name.titleize.split.join}".constantize.new
84
- entities[external_entity_name] = sub_entity_instance.get_external_entities(client, last_synchronization, organization, opts)
85
- end
86
- entities
87
- end
88
-
89
- def consolidate_and_map_data(connec_entities, external_entities, organization, opts)
90
- modeled_external_entities = external_model_to_connec_model(external_entities)
91
- modeled_connec_entities = connec_model_to_external_model(connec_entities)
92
-
93
- modeled_external_entities.each do |external_entity_name, entities_in_connec_model|
94
- entities_in_connec_model.each do |connec_entity_name, entities|
95
- sub_entity_instance = "Entities::SubEntities::#{external_entity_name.titleize.split.join}".constantize.new
96
-
97
- entities.map!{|entity|
98
- idmap = sub_entity_instance.find_idmap(external_id: sub_entity_instance.get_id_from_external_entity_hash(entity), connec_entity: connec_entity_name, organization_id: organization.id)
99
-
100
- # No idmap: creating one, nothing else to do
101
- unless idmap
102
- next {entity: sub_entity_instance.map_to(connec_entity_name, entity, organization), idmap: sub_entity_instance.create_idmap_from_external_entity(entity, connec_entity_name, organization)}
103
- end
104
-
105
- # Not pushing entity to Connec!
106
- next nil unless idmap.to_connec
107
-
108
- # Entity has not been modified since its last push to connec!
109
- next nil if Maestrano::Connector::Rails::Entity.not_modified_since_last_push_to_connec(idmap, entity, sub_entity_instance, organization)
110
-
111
- # Check for conflict with entities from connec!
112
- equivalent_connec_entities = modeled_connec_entities[connec_entity_name][external_entity_name] || []
113
- Maestrano::Connector::Rails::Entity.solve_conflict(entity, sub_entity_instance, equivalent_connec_entities, connec_entity_name, idmap, organization, opts)
114
- }.compact!
115
- end
116
- end
117
-
118
- modeled_connec_entities.each do |connec_entity_name, entities_in_external_model|
119
- entities_in_external_model.each do |external_entity_name, entities|
120
- sub_entity_instance = "Entities::SubEntities::#{connec_entity_name.titleize.split.join}".constantize.new
121
- entities.map!{|entity|
122
- self.map_to_external_with_idmap(entity, organization, external_entity_name, sub_entity_instance)
123
- }.compact!
124
- end
125
- end
126
-
127
- return {connec_entities: modeled_connec_entities, external_entities: modeled_external_entities}
128
- end
129
-
130
- # input : {
131
- # external_entities_names[0]: {
132
- # connec_entities_names[0]: [mapped_external_entity1],
133
- # connec_entities_names[1]: [mapped_external_entity2]
134
- # },
135
- # external_entities_names[1]: {
136
- # connec_entities_names[0]: [mapped_external_entity3, mapped_external_entity4]
137
- # }
138
- # }
139
- def push_entities_to_connec(connec_client, mapped_external_entities_with_idmaps, organization)
140
- mapped_external_entities_with_idmaps.each do |external_entity_name, entities_in_connec_model|
141
- sub_entity_instance = "Entities::SubEntities::#{external_entity_name.titleize.split.join}".constantize.new
142
- entities_in_connec_model.each do |connec_entity_name, mapped_entities_with_idmaps|
143
- sub_entity_instance.push_entities_to_connec_to(connec_client, mapped_entities_with_idmaps, connec_entity_name, organization)
144
- end
145
- end
146
- end
147
-
148
-
149
- def push_entities_to_external(external_client, mapped_connec_entities_with_idmaps, organization)
150
- mapped_connec_entities_with_idmaps.each do |connec_entity_name, entities_in_external_model|
151
- sub_entity_instance = "Entities::SubEntities::#{connec_entity_name.titleize.split.join}".constantize.new
152
- entities_in_external_model.each do |external_entity_name, mapped_entities_with_idmaps|
153
- sub_entity_instance.push_entities_to_external_to(external_client, mapped_entities_with_idmaps, external_entity_name, organization)
154
- end
155
- end
156
- end
3
+ include Maestrano::Connector::Rails::Concerns::ComplexEntity
157
4
  end
158
5
  end
@@ -0,0 +1,157 @@
1
+ module Maestrano::Connector::Rails::Concerns::ComplexEntity
2
+ extend ActiveSupport::Concern
3
+
4
+ @@external_name = Maestrano::Connector::Rails::External.external_name
5
+
6
+ # -------------------------------------------------------------
7
+ # Complex specific methods
8
+ # Those methods needs to be implemented in each complex entity
9
+ # -------------------------------------------------------------
10
+ def connec_entities_names
11
+ raise "Not implemented"
12
+ end
13
+
14
+ def external_entities_names
15
+ raise "Not implemented"
16
+ end
17
+
18
+ # input : {
19
+ # connec_entities_names[0]: [unmapped_connec_entitiy1, unmapped_connec_entitiy2],
20
+ # connec_entities_names[1]: [unmapped_connec_entitiy3, unmapped_connec_entitiy4]
21
+ # }
22
+ # output : {
23
+ # connec_entities_names[0]: {
24
+ # external_entities_names[0]: [unmapped_connec_entitiy1, unmapped_connec_entitiy2]
25
+ # },
26
+ # connec_entities_names[1]: {
27
+ # external_entities_names[0]: [unmapped_connec_entitiy3],
28
+ # external_entities_names[1]: [unmapped_connec_entitiy4]
29
+ # }
30
+ # }
31
+ def connec_model_to_external_model(connec_hash_of_entities)
32
+ raise "Not implemented"
33
+ end
34
+
35
+ # input : {
36
+ # external_entities_names[0]: [unmapped_external_entity1}, unmapped_external_entity2],
37
+ # external_entities_names[1]: [unmapped_external_entity3}, unmapped_external_entity4]
38
+ # }
39
+ # output : {
40
+ # external_entities_names[0]: {
41
+ # connec_entities_names[0]: [unmapped_external_entity1],
42
+ # connec_entities_names[1]: [unmapped_external_entity2]
43
+ # },
44
+ # external_entities_names[1]: {
45
+ # connec_entities_names[0]: [unmapped_external_entity3, unmapped_external_entity4]
46
+ # }
47
+ # }
48
+ def external_model_to_connec_model(external_hash_of_entities)
49
+ raise "Not implemented"
50
+ end
51
+
52
+ # -------------------------------------------------------------
53
+ # General methods
54
+ # -------------------------------------------------------------
55
+ def map_to_external_with_idmap(entity, organization, external_entity_name, sub_entity_instance)
56
+ idmap = sub_entity_instance.find_idmap({connec_id: entity['id'], external_entity: external_entity_name, organization_id: organization.id})
57
+
58
+ if idmap && ((!idmap.to_external) || idmap.last_push_to_external && idmap.last_push_to_external > entity['updated_at'])
59
+ Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Discard Connec! #{sub_entity_instance.entity_name} : #{entity}")
60
+ nil
61
+ else
62
+ {entity: sub_entity_instance.map_to(external_entity_name, entity, organization), idmap: idmap || sub_entity_instance.create_idmap_from_connec_entity(entity, external_entity_name, organization)}
63
+ end
64
+ end
65
+
66
+ # -------------------------------------------------------------
67
+ # Entity equivalent methods
68
+ # -------------------------------------------------------------
69
+ def get_connec_entities(client, last_synchronization, organization, opts={})
70
+ entities = ActiveSupport::HashWithIndifferentAccess.new
71
+
72
+ self.connec_entities_names.each do |connec_entity_name|
73
+ sub_entity_instance = "Entities::SubEntities::#{connec_entity_name.titleize.split.join}".constantize.new
74
+ entities[connec_entity_name] = sub_entity_instance.get_connec_entities(client, last_synchronization, organization, opts)
75
+ end
76
+ entities
77
+ end
78
+
79
+ def get_external_entities(client, last_synchronization, organization, opts={})
80
+ entities = ActiveSupport::HashWithIndifferentAccess.new
81
+
82
+ self.external_entities_names.each do |external_entity_name|
83
+ sub_entity_instance = "Entities::SubEntities::#{external_entity_name.titleize.split.join}".constantize.new
84
+ entities[external_entity_name] = sub_entity_instance.get_external_entities(client, last_synchronization, organization, opts)
85
+ end
86
+ entities
87
+ end
88
+
89
+ def consolidate_and_map_data(connec_entities, external_entities, organization, opts={})
90
+ modeled_external_entities = external_model_to_connec_model(external_entities)
91
+ modeled_connec_entities = connec_model_to_external_model(connec_entities)
92
+
93
+ modeled_external_entities.each do |external_entity_name, entities_in_connec_model|
94
+ entities_in_connec_model.each do |connec_entity_name, entities|
95
+ sub_entity_instance = "Entities::SubEntities::#{external_entity_name.titleize.split.join}".constantize.new
96
+
97
+ entities.map!{|entity|
98
+ idmap = sub_entity_instance.find_idmap(external_id: sub_entity_instance.get_id_from_external_entity_hash(entity), connec_entity: connec_entity_name, organization_id: organization.id)
99
+
100
+ # No idmap: creating one, nothing else to do
101
+ unless idmap
102
+ next {entity: sub_entity_instance.map_to(connec_entity_name, entity, organization), idmap: sub_entity_instance.create_idmap_from_external_entity(entity, connec_entity_name, organization)}
103
+ end
104
+
105
+ # Not pushing entity to Connec!
106
+ next nil unless idmap.to_connec
107
+
108
+ # Entity has not been modified since its last push to connec!
109
+ next nil if Maestrano::Connector::Rails::Entity.not_modified_since_last_push_to_connec(idmap, entity, sub_entity_instance, organization)
110
+
111
+ # Check for conflict with entities from connec!
112
+ equivalent_connec_entities = modeled_connec_entities[connec_entity_name][external_entity_name] || []
113
+ Maestrano::Connector::Rails::Entity.solve_conflict(entity, sub_entity_instance, equivalent_connec_entities, connec_entity_name, idmap, organization, opts)
114
+ }.compact!
115
+ end
116
+ end
117
+
118
+ modeled_connec_entities.each do |connec_entity_name, entities_in_external_model|
119
+ entities_in_external_model.each do |external_entity_name, entities|
120
+ sub_entity_instance = "Entities::SubEntities::#{connec_entity_name.titleize.split.join}".constantize.new
121
+ entities.map!{|entity|
122
+ self.map_to_external_with_idmap(entity, organization, external_entity_name, sub_entity_instance)
123
+ }.compact!
124
+ end
125
+ end
126
+
127
+ return {connec_entities: modeled_connec_entities, external_entities: modeled_external_entities}
128
+ end
129
+
130
+ # input : {
131
+ # external_entities_names[0]: {
132
+ # connec_entities_names[0]: [mapped_external_entity1],
133
+ # connec_entities_names[1]: [mapped_external_entity2]
134
+ # },
135
+ # external_entities_names[1]: {
136
+ # connec_entities_names[0]: [mapped_external_entity3, mapped_external_entity4]
137
+ # }
138
+ # }
139
+ def push_entities_to_connec(connec_client, mapped_external_entities_with_idmaps, organization)
140
+ mapped_external_entities_with_idmaps.each do |external_entity_name, entities_in_connec_model|
141
+ sub_entity_instance = "Entities::SubEntities::#{external_entity_name.titleize.split.join}".constantize.new
142
+ entities_in_connec_model.each do |connec_entity_name, mapped_entities_with_idmaps|
143
+ sub_entity_instance.push_entities_to_connec_to(connec_client, mapped_entities_with_idmaps, connec_entity_name, organization)
144
+ end
145
+ end
146
+ end
147
+
148
+
149
+ def push_entities_to_external(external_client, mapped_connec_entities_with_idmaps, organization)
150
+ mapped_connec_entities_with_idmaps.each do |connec_entity_name, entities_in_external_model|
151
+ sub_entity_instance = "Entities::SubEntities::#{connec_entity_name.titleize.split.join}".constantize.new
152
+ entities_in_external_model.each do |external_entity_name, mapped_entities_with_idmaps|
153
+ sub_entity_instance.push_entities_to_external_to(external_client, mapped_entities_with_idmaps, external_entity_name, organization)
154
+ end
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,9 @@
1
+ module Maestrano::Connector::Rails::Concerns::ConnectorLogger
2
+ extend ActiveSupport::Concern
3
+
4
+ module ClassMethods
5
+ def log(level, organization, msg)
6
+ Rails.logger.method(level).call("org: #{organization.uid} (#{organization.tenant}). Msg: #{msg}")
7
+ end
8
+ end
9
+ end
@@ -332,7 +332,7 @@ module Maestrano::Connector::Rails::Concerns::Entity
332
332
  module ClassMethods
333
333
  def not_modified_since_last_push_to_connec(idmap, entity, entity_instance, organization)
334
334
  result = idmap.last_push_to_connec && idmap.last_push_to_connec > entity_instance.get_last_update_date_from_external_entity_hash(entity)
335
- Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Discard #{entity_instance.external_entity_name} : #{entity}") unless result
335
+ Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Discard #{entity_instance.external_entity_name} : #{entity}") if result
336
336
  result
337
337
  end
338
338
 
@@ -0,0 +1,71 @@
1
+ module Maestrano::Connector::Rails::Concerns::SubEntityBase
2
+ extend ActiveSupport::Concern
3
+
4
+ def external?
5
+ raise "Not implemented"
6
+ end
7
+
8
+ def entity_name
9
+ raise "Not implemented"
10
+ end
11
+
12
+ def map_to(name, entity, organization)
13
+ raise "Not implemented"
14
+ end
15
+
16
+ def external_entity_name
17
+ if external?
18
+ entity_name
19
+ else
20
+ raise "Forbidden call: cannot call external_entity_name for a connec entity"
21
+ end
22
+ end
23
+
24
+ def connec_entity_name
25
+ if external?
26
+ raise "Forbidden call: cannot call connec_entity_name for an external entity"
27
+ else
28
+ entity_name
29
+ end
30
+ end
31
+
32
+ def names_hash
33
+ if external?
34
+ {external_entity: entity_name.downcase}
35
+ else
36
+ {connec_entity: entity_name.downcase}
37
+ end
38
+ end
39
+
40
+ def create_idmap_from_external_entity(entity, connec_entity_name, organization)
41
+ if external?
42
+ h = names_hash.merge({
43
+ external_id: get_id_from_external_entity_hash(entity),
44
+ name: object_name_from_external_entity_hash(entity),
45
+ connec_entity: connec_entity_name.downcase,
46
+ organization_id: organization.id
47
+ })
48
+ Maestrano::Connector::Rails::IdMap.create(h)
49
+ else
50
+ raise 'Forbidden call: cannot call create_idmap_from_external_entity for a connec entity'
51
+ end
52
+ end
53
+
54
+ def create_idmap_from_connec_entity(entity, external_entity_name, organization)
55
+ if external?
56
+ raise 'Forbidden call: cannot call create_idmap_from_connec_entity for an external entity'
57
+ else
58
+ h = names_hash.merge({
59
+ connec_id: entity['id'],
60
+ name: object_name_from_connec_entity_hash(entity),
61
+ external_entity: external_entity_name.downcase,
62
+ organization_id: organization.id
63
+ })
64
+ Maestrano::Connector::Rails::IdMap.create(h)
65
+ end
66
+ end
67
+
68
+ def map_external_entity_with_idmap(external_entity, connec_entity_name, idmap, organization)
69
+ {entity: map_to(connec_entity_name, external_entity, organization), idmap: idmap}
70
+ end
71
+ end
@@ -1,9 +1,5 @@
1
1
  module Maestrano::Connector::Rails
2
2
  class ConnectorLogger
3
-
4
- def self.log(level, organization, msg)
5
- Rails.logger.method(level).call("org: #{organization.uid} (#{organization.tenant}). Msg: #{msg}")
6
- end
7
-
3
+ include Maestrano::Connector::Rails::Concerns::ConnectorLogger
8
4
  end
9
5
  end
@@ -1,72 +1,5 @@
1
1
  module Maestrano::Connector::Rails
2
2
  class SubEntityBase < Entity
3
-
4
- def external?
5
- raise "Not implemented"
6
- end
7
-
8
- def entity_name
9
- raise "Not implemented"
10
- end
11
-
12
- def map_to(name, entity, organization)
13
- raise "Not implemented"
14
- end
15
-
16
- def external_entity_name
17
- if external?
18
- entity_name
19
- else
20
- raise "Forbidden call: cannot call external_entity_name for a connec entity"
21
- end
22
- end
23
-
24
- def connec_entity_name
25
- if external?
26
- raise "Forbidden call: cannot call connec_entity_name for an external entity"
27
- else
28
- entity_name
29
- end
30
- end
31
-
32
- def names_hash
33
- if external?
34
- {external_entity: entity_name.downcase}
35
- else
36
- {connec_entity: entity_name.downcase}
37
- end
38
- end
39
-
40
- def create_idmap_from_external_entity(entity, connec_entity_name, organization)
41
- if external?
42
- h = names_hash.merge({
43
- external_id: get_id_from_external_entity_hash(entity),
44
- name: object_name_from_external_entity_hash(entity),
45
- connec_entity: connec_entity_name.downcase,
46
- organization_id: organization.id
47
- })
48
- Maestrano::Connector::Rails::IdMap.create(h)
49
- else
50
- raise 'Forbidden call: cannot call create_idmap_from_external_entity for a connec entity'
51
- end
52
- end
53
-
54
- def create_idmap_from_connec_entity(entity, external_entity_name, organization)
55
- if external?
56
- raise 'Forbidden call: cannot call create_idmap_from_connec_entity for an external entity'
57
- else
58
- h = names_hash.merge({
59
- connec_id: entity['id'],
60
- name: object_name_from_connec_entity_hash(entity),
61
- external_entity: external_entity_name.downcase,
62
- organization_id: organization.id
63
- })
64
- Maestrano::Connector::Rails::IdMap.create(h)
65
- end
66
- end
67
-
68
- def map_external_entity_with_idmap(external_entity, connec_entity_name, idmap, organization)
69
- {entity: map_to(connec_entity_name, external_entity, organization), idmap: idmap}
70
- end
3
+ include Maestrano::Connector::Rails::Concerns::SubEntityBase
71
4
  end
72
5
  end
@@ -21,13 +21,13 @@ class Maestrano::Connector::Rails::Entity
21
21
  # Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Received data: Source=#{@@external_name}, Entity=#{self.external_entity_name}, Response=#{entities}")
22
22
  end
23
23
 
24
- def create_entity_to_external(client, mapped_connec_entity, external_entity_name, organization)
24
+ def create_external_entity(client, mapped_connec_entity, external_entity_name, organization)
25
25
  Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Sending create #{external_entity_name}: #{mapped_connec_entity} to #{@@external_name}")
26
26
  # TODO
27
27
  # This method creates the entity in the external app and returns the external id
28
28
  end
29
29
 
30
- def update_entity_to_external(client, mapped_connec_entity, external_id, external_entity_name)
30
+ def update_external_entity(client, mapped_connec_entity, external_id, external_entity_name, organization)
31
31
  Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Sending update #{external_entity_name} (id=#{external_id}): #{mapped_connec_entity} to #{@@external_name}")
32
32
  # TODO
33
33
  # This method updates the entity with the given id in the external app
@@ -49,7 +49,7 @@ describe HomeController, :type => :controller do
49
49
 
50
50
  context 'when user is not admin' do
51
51
  before {
52
- allow_any_instance_of(ApplicationHelper).to receive(:is_admin).and_return(false)
52
+ allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin).and_return(false)
53
53
  }
54
54
 
55
55
  it { expect(subject).to redirect_to back_path }
@@ -62,7 +62,7 @@ describe HomeController, :type => :controller do
62
62
 
63
63
  context 'when user is admin' do
64
64
  before {
65
- allow_any_instance_of(ApplicationHelper).to receive(:is_admin).and_return(true)
65
+ allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin).and_return(true)
66
66
  }
67
67
 
68
68
  it { expect(subject).to redirect_to back_path }
@@ -95,7 +95,7 @@ describe HomeController, :type => :controller do
95
95
 
96
96
  context 'when user is not an admin' do
97
97
  before {
98
- allow_any_instance_of(ApplicationHelper).to receive(:is_admin).and_return(false)
98
+ allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin).and_return(false)
99
99
  }
100
100
  it { expect(subject).to redirect_to back_path }
101
101
 
@@ -106,7 +106,7 @@ describe HomeController, :type => :controller do
106
106
 
107
107
  context 'when user is admin' do
108
108
  before {
109
- allow_any_instance_of(ApplicationHelper).to receive(:is_admin).and_return(true)
109
+ allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin).and_return(true)
110
110
  }
111
111
  it { expect(subject).to redirect_to back_path }
112
112
 
@@ -121,21 +121,4 @@ describe HomeController, :type => :controller do
121
121
  end
122
122
  end
123
123
  end
124
-
125
- describe 'redirect_to_external' do
126
- subject { get :redirect_to_external }
127
-
128
- context 'when organization has a redirect url' do
129
- let(:organization) { create(:organization, instance_url: 'url') }
130
- before {
131
- allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:current_organization).and_return(organization)
132
- }
133
-
134
- it {expect(subject).to redirect_to('url')}
135
- end
136
-
137
- context 'otherwise' do
138
- it {expect(subject).to redirect_to('https://login.salesforce.com')}
139
- end
140
- end
141
124
  end
@@ -12,7 +12,7 @@
12
12
  .container-fluid
13
13
  .collapse.navbar-collapse#maestrano-navbar-collapse
14
14
  %ul.nav.navbar-nav
15
- =image_tag "logos/default.png", class: 'external-logo'
15
+ =image_tag "logos/default.png", class: 'logo'
16
16
 
17
17
  %ul.nav.navbar-nav
18
18
  %li=link_to "Status", root_path
@@ -11,7 +11,7 @@ describe SharedEntitiesController, :type => :controller do
11
11
  let(:idmap) { create(:idmap, organization: organization) }
12
12
  before {
13
13
  allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:current_organization).and_return(organization)
14
- allow_any_instance_of(ApplicationHelper).to receive(:is_admin).and_return(true)
14
+ allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:is_admin).and_return(true)
15
15
  }
16
16
 
17
17
  it 'assigns the idmaps' do
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: maestrano-connector-rails 0.2.18 ruby lib
5
+ # stub: maestrano-connector-rails 0.2.19 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "maestrano-connector-rails"
9
- s.version = "0.2.18"
9
+ s.version = "0.2.19"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Pierre Berard"]
14
- s.date = "2016-03-08"
14
+ s.date = "2016-03-10"
15
15
  s.description = "Maestrano is the next generation marketplace for SME applications. See https://maestrano.com for details."
16
16
  s.email = "pierre.berard@maestrano.com"
17
17
  s.executables = ["rails"]
@@ -39,8 +39,11 @@ Gem::Specification.new do |s|
39
39
  "app/jobs/maestrano/connector/rails/push_to_connec_job.rb",
40
40
  "app/jobs/maestrano/connector/rails/synchronization_job.rb",
41
41
  "app/models/maestrano/connector/rails/complex_entity.rb",
42
+ "app/models/maestrano/connector/rails/concerns/complex_entity.rb",
43
+ "app/models/maestrano/connector/rails/concerns/connector_logger.rb",
42
44
  "app/models/maestrano/connector/rails/concerns/entity.rb",
43
45
  "app/models/maestrano/connector/rails/concerns/external.rb",
46
+ "app/models/maestrano/connector/rails/concerns/sub_entity_base.rb",
44
47
  "app/models/maestrano/connector/rails/connector_logger.rb",
45
48
  "app/models/maestrano/connector/rails/entity.rb",
46
49
  "app/models/maestrano/connector/rails/external.rb",
@@ -86,8 +89,8 @@ Gem::Specification.new do |s|
86
89
  "lib/generators/connector/templates/stylesheets/layout.sass",
87
90
  "lib/generators/connector/templates/stylesheets/spacers.sass",
88
91
  "lib/generators/connector/templates/stylesheets/variables.sass",
89
- "lib/generators/connector/templates/sychronizations_controller_spec.rb",
90
92
  "lib/generators/connector/templates/synchronizations_controller.rb",
93
+ "lib/generators/connector/templates/synchronizations_controller_spec.rb",
91
94
  "lib/generators/connector/templates/synchronizations_index.haml",
92
95
  "lib/maestrano-connector-rails.rb",
93
96
  "lib/maestrano/connector/rails.rb",
@@ -3,7 +3,7 @@ def current_directory
3
3
  if __FILE__ =~ %r{\Ahttps?://}
4
4
  tempdir = Dir.mktmpdir("maestrano-connector-rails-")
5
5
  at_exit { FileUtils.remove_entry(tempdir) }
6
- git :clone => "--quiet https://github.com/berardpi/maestrano-connector-rails/tree/include-frontend #{tempdir}"
6
+ git :clone => "--quiet https://github.com/maestrano/maestrano-connector-rails/ #{tempdir}"
7
7
 
8
8
  "#{tempdir}/template"
9
9
  else
@@ -30,7 +30,7 @@ run 'touch Gemfile'
30
30
  add_source 'https://rubygems.org'
31
31
 
32
32
  if yes?("Use JRuby? [y/n]")
33
- run 'echo "ruby \'2.2.2\', :engine => \'jruby\', :engine_version => \'9.0.4.0\'" | cat - Gemfile > temp && mv temp Gemfile'
33
+ run 'echo "ruby \'2.2.3\', :engine => \'jruby\', :engine_version => \'9.0.5.0\'" | cat - Gemfile > temp && mv temp Gemfile'
34
34
  gem_group :production do
35
35
  gem 'activerecord-jdbcpostgresql-adapter'
36
36
  end
@@ -41,12 +41,17 @@ else
41
41
  gem 'sqlite3'
42
42
  end
43
43
 
44
+ gem 'haml-rails'
45
+ gem 'bootstrap-sass'
46
+ gem 'autoprefixer-rails'
47
+
44
48
  gem 'rails', '4.2.4'
45
49
  gem 'turbolinks'
46
50
  gem 'jquery-rails'
47
51
  gem 'puma'
48
52
  gem 'figaro'
49
53
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
54
+ gem 'uglifier', '>= 1.3.0'
50
55
 
51
56
  gem 'maestrano-connector-rails'
52
57
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maestrano-connector-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.18
4
+ version: 0.2.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Berard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maestrano-rails
@@ -249,8 +249,11 @@ files:
249
249
  - app/jobs/maestrano/connector/rails/push_to_connec_job.rb
250
250
  - app/jobs/maestrano/connector/rails/synchronization_job.rb
251
251
  - app/models/maestrano/connector/rails/complex_entity.rb
252
+ - app/models/maestrano/connector/rails/concerns/complex_entity.rb
253
+ - app/models/maestrano/connector/rails/concerns/connector_logger.rb
252
254
  - app/models/maestrano/connector/rails/concerns/entity.rb
253
255
  - app/models/maestrano/connector/rails/concerns/external.rb
256
+ - app/models/maestrano/connector/rails/concerns/sub_entity_base.rb
254
257
  - app/models/maestrano/connector/rails/connector_logger.rb
255
258
  - app/models/maestrano/connector/rails/entity.rb
256
259
  - app/models/maestrano/connector/rails/external.rb
@@ -296,8 +299,8 @@ files:
296
299
  - lib/generators/connector/templates/stylesheets/layout.sass
297
300
  - lib/generators/connector/templates/stylesheets/spacers.sass
298
301
  - lib/generators/connector/templates/stylesheets/variables.sass
299
- - lib/generators/connector/templates/sychronizations_controller_spec.rb
300
302
  - lib/generators/connector/templates/synchronizations_controller.rb
303
+ - lib/generators/connector/templates/synchronizations_controller_spec.rb
301
304
  - lib/generators/connector/templates/synchronizations_index.haml
302
305
  - lib/maestrano-connector-rails.rb
303
306
  - lib/maestrano/connector/rails.rb