catalyst_automation 0.0.0.4 → 0.0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/catalyst_automation.rb +106 -41
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a84486d4ea2c2a7921d65a7f09816f384849fb9
|
4
|
+
data.tar.gz: 320b180bd1147dc3e5590f0c1ecb2c87df68e54c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2c402702a10feb993cfa11d31870a4f849c9982baa0754413a136dce2d6a675fd095b7f9e8e4d0554ab51d52d9194d1c24ee6e1ad5ece0cf4da73d95532f9f2
|
7
|
+
data.tar.gz: b58276c27a3cbeba968522ac8ec95c671b2d856672ae2b1bcde30388b818828512efdd20c8e9c3bfc0772bec60f6734a83917ed6196671e00d2d4fef860acb99
|
data/lib/catalyst_automation.rb
CHANGED
@@ -3,35 +3,48 @@ require 'json'
|
|
3
3
|
require 'bson'
|
4
4
|
require 'site_prism'
|
5
5
|
|
6
|
-
|
7
6
|
module CatalystAutomation
|
8
7
|
|
9
8
|
class WithJson
|
10
|
-
|
11
|
-
def self.initialize(pages)
|
12
|
-
|
9
|
+
|
10
|
+
def self.initialize(test_data, pages, actions, sections)
|
11
|
+
test_data_json = JSON.parse(test_data)
|
12
|
+
pages_json = JSON.parse(pages)
|
13
|
+
#actions_json = JSON.parse(actions)
|
13
14
|
sections_json = JSON.parse(sections)
|
14
|
-
|
15
|
+
|
16
|
+
Base.create_test_data(test_data_json)
|
15
17
|
Base.create_sections(sections_json)
|
18
|
+
Base.create_iframes(pages_json, sections_json)
|
19
|
+
Base.create_pages(pages_json, sections_json)
|
20
|
+
Base.create_iframe_actions(actions_json)
|
21
|
+
#Base.create_actions(actions_json)
|
16
22
|
end
|
17
|
-
|
23
|
+
|
18
24
|
end
|
19
25
|
|
20
26
|
class WithDataBase
|
21
|
-
|
27
|
+
|
22
28
|
def self.initialize(conn_str)
|
23
29
|
Base.connect_db(conn_str) do |db|
|
30
|
+
db_test_data = Base.get_db_info(db, :test_data)
|
24
31
|
db_pages = Base.get_db_info(db, :pages)
|
32
|
+
#db_actions = Base.get_db_info(db, :actions)
|
25
33
|
db_sections = Base.get_db_info(db, :sections)
|
26
|
-
|
34
|
+
|
35
|
+
Base.create_test_data(db_test_data)
|
27
36
|
Base.create_sections(db_sections)
|
37
|
+
Base.create_iframes(db_pages, db_sections)
|
38
|
+
Base.create_pages(db_pages, db_sections)
|
39
|
+
#Base.create_iframe_actions(db_actions)
|
40
|
+
#Base.create_actions(db_actions)
|
28
41
|
end
|
29
42
|
end
|
30
|
-
|
43
|
+
|
31
44
|
end
|
32
|
-
|
45
|
+
|
33
46
|
class Base
|
34
|
-
|
47
|
+
|
35
48
|
def self.create_const(const_name, key, const_type)
|
36
49
|
Object.const_set(const_name[(const_name.class.eql?(Symbol) ? key : key.to_s)], const_type)
|
37
50
|
end
|
@@ -57,7 +70,7 @@ module CatalystAutomation
|
|
57
70
|
end
|
58
71
|
end
|
59
72
|
end
|
60
|
-
|
73
|
+
|
61
74
|
def self.set_iframes(const_name, key, db_pages)
|
62
75
|
Object.const_get(const_name[(const_name.kind_of?(Symbol) ? :name : "name")]).class_eval do
|
63
76
|
const_name[(const_name.kind_of?(Symbol) ? :iframes : "iframes")].each do |iframe|
|
@@ -66,12 +79,13 @@ module CatalystAutomation
|
|
66
79
|
if iframe[:iframe_id].to_s.eql?(db_page[:_id].to_s)
|
67
80
|
m_iframe_name = db_page[const_name.kind_of?(Symbol) ? :name : "name"]
|
68
81
|
end
|
82
|
+
|
69
83
|
end
|
70
84
|
send(:iframe, iframe[(const_name.kind_of?(Symbol) ? :name : "name")], Object.const_get(m_iframe_name), iframe[(const_name.kind_of?(Symbol) ? :path : "path")])
|
71
|
-
|
85
|
+
end
|
72
86
|
end
|
73
87
|
end
|
74
|
-
|
88
|
+
|
75
89
|
def self.connect_db(conn_str)
|
76
90
|
db_conn = Mongo::Client.new(conn_str)
|
77
91
|
begin
|
@@ -80,7 +94,7 @@ module CatalystAutomation
|
|
80
94
|
raise error
|
81
95
|
end
|
82
96
|
end
|
83
|
-
|
97
|
+
|
84
98
|
def self.get_db_info(db_con, info)
|
85
99
|
m_info = []
|
86
100
|
db_info = db_con.database[info].find()
|
@@ -89,7 +103,7 @@ module CatalystAutomation
|
|
89
103
|
end
|
90
104
|
return m_info
|
91
105
|
end
|
92
|
-
|
106
|
+
|
93
107
|
def self.create_sections(db_pages)
|
94
108
|
db_pages.each do |section|
|
95
109
|
create_const(section, :name, Class.new(SitePrism::Section))
|
@@ -119,31 +133,82 @@ module CatalystAutomation
|
|
119
133
|
end
|
120
134
|
end
|
121
135
|
end
|
122
|
-
|
123
|
-
def self.
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
136
|
+
|
137
|
+
# def self.create_iframe_actions(db_actions)
|
138
|
+
# db_actions.each do |page|
|
139
|
+
# if page[page.class.eql?(Symbol) ? :type : "type"].eql? "iframe_action"
|
140
|
+
# Object.const_get(page[(page.class.eql?(Symbol) ? :name : "name")]).class_eval do
|
141
|
+
# page[(page.class.eql?(Symbol) ? :actions : "actions")].each do |iaction|
|
142
|
+
# define_method iaction[page.kind_of?(Symbol) ? :name : "name"].to_sym do
|
143
|
+
# iaction[page.kind_of?(Symbol) ? :action_methods : "action_methods"].each do |action_method|
|
144
|
+
# m_iframe = iaction[page.kind_of?(Symbol) ? :iframe_name : "iframe_name"]
|
145
|
+
# m_func = action_method[page.kind_of?(Symbol) ? :name : "name"].split('_').last
|
146
|
+
# elem_array = action_method[page.kind_of?(Symbol) ? :name : "name"].split('_')
|
147
|
+
# elem_array.pop
|
148
|
+
# func_name = ""
|
149
|
+
# elem_array.each do |e|
|
150
|
+
# func_name = func_name + "#{e}_"
|
151
|
+
# end
|
152
|
+
# func_name = func_name[0...-1]
|
153
|
+
# func_name = "#{func_name}.#{m_func}"
|
154
|
+
# param = action_method[page.kind_of?(Symbol) ? :param : "param"]
|
155
|
+
# if !param.eql?("no_param")
|
156
|
+
# eval("#{m_iframe} { |frame| frame.#{func_name}(#{param})}")
|
157
|
+
# else
|
158
|
+
# eval("#{m_iframe} { |frame| frame.#{func_name}}")
|
159
|
+
# end
|
160
|
+
# end
|
161
|
+
# end
|
162
|
+
# end
|
163
|
+
# end
|
164
|
+
# end
|
165
|
+
# end
|
166
|
+
# #end
|
167
|
+
# end
|
168
|
+
|
169
|
+
# def self.create_actions(db_actions)
|
170
|
+
# db_actions.each do |page|
|
171
|
+
# if page[page.class.eql?(Symbol) ? :type : "type"].eql? "page_action"
|
172
|
+
# Object.const_get(page[(page.class.eql?(Symbol) ? :name : "name")]).class_eval do
|
173
|
+
# page[page.class.eql?(Symbol) ? :actions : "actions"].each do |action|
|
174
|
+
# define_method action[page.kind_of?(Symbol) ? :name : "name"].to_sym do
|
175
|
+
# action[page.kind_of?(Symbol) ? :action_methods : "action_methods"].each do |method|
|
176
|
+
# m_func = method[page.kind_of?(Symbol) ? :name : "name"].split('_').last
|
177
|
+
# elem_array = method[page.kind_of?(Symbol) ? :name : "name"].split('_')
|
178
|
+
# elem_array.pop
|
179
|
+
# func_name = ""
|
180
|
+
# elem_array.each do |e|
|
181
|
+
# func_name = func_name + "#{e}_"
|
182
|
+
# end
|
183
|
+
# func_name = func_name[0...-1]
|
184
|
+
# func_name = "#{func_name}.#{m_func}"
|
185
|
+
# param = method[page.kind_of?(Symbol) ? :param : "param"]
|
186
|
+
# if !param.eql?("no_param")
|
187
|
+
# eval("#{func_name}(#{param})")
|
188
|
+
# else
|
189
|
+
# eval("#{func_name}")
|
190
|
+
# end
|
191
|
+
# end
|
192
|
+
# end
|
193
|
+
# end
|
194
|
+
# end
|
195
|
+
# end
|
196
|
+
# end
|
197
|
+
# end
|
198
|
+
|
199
|
+
def self.create_test_data(db_test_data)
|
200
|
+
db_test_data.each do |data|
|
201
|
+
create_const(data, :name, Class.new)
|
202
|
+
Object.const_get(data[(data.class.eql?(Symbol) ? :name : "name")]).class_eval do
|
203
|
+
data[(data.class.eql?(Symbol) ? :attributes : "attributes")].each do |attrs|
|
204
|
+
name = attrs[(data.kind_of?(Symbol) ? :name : "name")]
|
205
|
+
value = attrs[(data.kind_of?(Symbol) ? :value : "value")]
|
206
|
+
define_method name.to_sym do
|
207
|
+
value
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
145
211
|
end
|
146
212
|
end
|
147
|
-
|
148
213
|
end
|
149
|
-
end
|
214
|
+
end
|