factor 0.1.01 → 0.1.02
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.
- data/lib/cli/server_task.rb +12 -11
- data/lib/client/client.rb +4 -6
- data/lib/runtime/engine.rb +2 -13
- metadata +1 -1
data/lib/cli/server_task.rb
CHANGED
|
@@ -7,42 +7,43 @@ module Factor
|
|
|
7
7
|
desc "start", "start the server"
|
|
8
8
|
method_option :tags, :alias=>"-t", :type=>:hash, :desc=>"Optional tags to identify from workflow"
|
|
9
9
|
method_option :channels, :type=>:array, :desc=>"Optional channel ruby file list for development"
|
|
10
|
+
method_option :verbose, :type=>:boolean, :desc=>"Display everything"
|
|
10
11
|
def start
|
|
11
12
|
engine = Factor::Runtime::Engine.new(get_config[:email],get_config[:token])
|
|
12
13
|
|
|
13
14
|
options.tags.each {|tag,value| engine.tag(tag,value)} if options.tags?
|
|
14
15
|
|
|
15
16
|
# load channels from server
|
|
16
|
-
say "loading channels from server"
|
|
17
|
+
say "loading channels from server" if options.verbose?
|
|
17
18
|
engine = @client.load_channels(engine) do |message|
|
|
18
|
-
say " #{message}"
|
|
19
|
+
say " #{message}" if options.verbose?
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
# load channels from files
|
|
22
23
|
if options.channels?
|
|
23
24
|
options.channels.each do |file|
|
|
24
25
|
full_file=File.expand_path(file)
|
|
25
|
-
say " loading '#{full_file}'"
|
|
26
|
+
say " loading '#{full_file}'" if options.verbose?
|
|
26
27
|
engine.load_channel(full_file)
|
|
27
|
-
say " loaded '#{full_file}'"
|
|
28
|
+
say " loaded '#{full_file}'" if options.verbose?
|
|
28
29
|
end
|
|
29
30
|
end
|
|
30
31
|
|
|
31
|
-
say "loading channels complete"
|
|
32
|
+
say "loading channels complete" if options.verbose?
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
# load workflows from server
|
|
35
|
-
say "loading workflows from server"
|
|
36
|
+
say "loading workflows from server" if options.verbose?
|
|
36
37
|
engine = @client.load_workflows(engine) do |message|
|
|
37
|
-
say " #{message}"
|
|
38
|
+
say " #{message}" if options.verbose?
|
|
38
39
|
end
|
|
39
|
-
say "loading workflows complete"
|
|
40
|
+
say "loading workflows complete" if options.verbose?
|
|
40
41
|
|
|
41
|
-
say "loading credentials from server"
|
|
42
|
+
say "loading credentials from server" if options.verbose?
|
|
42
43
|
engine = @client.load_credentials(engine) do |message|
|
|
43
|
-
say " #{message}"
|
|
44
|
+
say " #{message}" if options.verbose?
|
|
44
45
|
end
|
|
45
|
-
say "loading credentials complete"
|
|
46
|
+
say "loading credentials complete" if options.verbose?
|
|
46
47
|
|
|
47
48
|
say "starting the server...", :green
|
|
48
49
|
message = engine.start
|
data/lib/client/client.rb
CHANGED
|
@@ -11,7 +11,6 @@ module Factor
|
|
|
11
11
|
attr_accessor :host
|
|
12
12
|
|
|
13
13
|
def initialize(host="http://factor.io")
|
|
14
|
-
#def initialize(host="http://localhost:3000/")
|
|
15
14
|
@host=host
|
|
16
15
|
end
|
|
17
16
|
|
|
@@ -78,11 +77,10 @@ module Factor
|
|
|
78
77
|
# unzip download zip into unzipped directory
|
|
79
78
|
unzip(temp_file.path,unzip_dir)
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
filename = unzip_dir + "/" + channel['name'].split(/(?=[A-Z])/).map{ |x| x.downcase }.join('_') + ".rb"
|
|
81
|
+
|
|
82
|
+
code.call("loading '#{filename}' into engine")
|
|
83
|
+
engine.load_channel(filename)
|
|
86
84
|
end
|
|
87
85
|
|
|
88
86
|
|
data/lib/runtime/engine.rb
CHANGED
|
@@ -80,27 +80,16 @@ module Factor
|
|
|
80
80
|
target = activity["target"]
|
|
81
81
|
params_template = activity["params"]
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
if match(target)
|
|
85
|
-
|
|
83
|
+
if match(target)
|
|
86
84
|
values = message.body.merge(@credentials)
|
|
87
|
-
# this maps the input values passed in with the templated defined in the workflow
|
|
88
85
|
|
|
89
|
-
#
|
|
90
|
-
#puts "[values] #{values}"
|
|
86
|
+
# this maps the input values passed in with the templated defined in the workflow
|
|
91
87
|
params = render_template(params_template,values)
|
|
92
|
-
puts "[rendered params] #{params}"
|
|
93
|
-
|
|
94
88
|
event = call_channel_method(channel,action,params)
|
|
95
|
-
|
|
96
|
-
# puts "event #{event.inspect}"
|
|
97
89
|
response_message = message.respond(event.params,event.class.name.split("::").last)
|
|
98
90
|
|
|
99
|
-
# puts "response #{response_message.inspect}"
|
|
100
|
-
|
|
101
91
|
@message_bus.send response_message
|
|
102
92
|
end
|
|
103
|
-
|
|
104
93
|
end
|
|
105
94
|
else
|
|
106
95
|
# workflow doesn't exist
|