factor 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,10 +30,12 @@ module Factor
30
30
  end
31
31
 
32
32
  desc "token", "login with token"
33
+ method_option :email, :alias=>"-e", :type=>:string, :desc=>"Email address for Factor account", :required=>true
33
34
  method_option :token, :alias=>"-t", :type=>:string, :desc=>"Token value to set", :required=>true
34
35
  def token
35
36
  config = get_config
36
37
  config[:token]=options[:token]
38
+ config[:email]=options[:email]
37
39
  save_config(config)
38
40
  end
39
41
  end
@@ -6,9 +6,9 @@ module Factor
6
6
  class ServerTask < Command
7
7
  desc "start", "start the server"
8
8
  def start
9
- engine = Factor::Engine.new
9
+ engine = Factor::Runtime::Engine.new(get_config[:email],get_config[:token])
10
10
 
11
- client = Factor::Client.new
11
+ client = Factor::Client::Client.new
12
12
  client.login_token(get_config[:token])
13
13
 
14
14
  puts "loading channels"
@@ -35,7 +35,7 @@ module Factor
35
35
 
36
36
  desc "logs", "listen to incoming logs"
37
37
  def logs
38
- engine = Factor::Engine.new
38
+ engine = Factor::Runtime::Engine.new(get_config[:email],get_config[:token])
39
39
  puts "Listening..."
40
40
  engine.logs do |message|
41
41
  puts "[#{message.route}] #{message.body}"
@@ -10,7 +10,7 @@ module Factor
10
10
  def call(workflow_name)
11
11
  puts "starting workflow #{workflow_name} with options #{options.parameters.to_s}"
12
12
 
13
- engine = Factor::Engine.new
13
+ engine = Factor::Runtime::Engine.new(get_config[:email],get_config[:token])
14
14
  id = engine.launch(workflow_name,options.parameters)
15
15
 
16
16
  puts "workflow executed with id #{id}"
data/lib/client/client.rb CHANGED
@@ -23,7 +23,7 @@ module Factor
23
23
  workflows = rest_get("workflows")
24
24
  workflows.each do |workflow|
25
25
  workflow_definition = JSON.parse(workflow['definition'])
26
- workflow=Factor::Workflow.new(workflow_definition)
26
+ workflow=Factor::Runtime::Workflow.new(workflow_definition)
27
27
  engine.load_workflow(workflow)
28
28
  end
29
29
  engine
@@ -9,13 +9,14 @@ module Factor
9
9
  attr_accessor :channel_modules, :workflows, :message_bus
10
10
 
11
11
  # Engine needs modules that contain the code, workflows to run, and message bus for communication
12
- def initialize
12
+ def initialize(username,token)
13
13
  @channel_modules=Hash.new
14
14
  @workflows = Hash.new
15
- @message_bus ||= MessageBus.new
15
+ @message_bus = MessageBus.new(username,token)
16
16
  @credentials = Hash.new
17
17
  end
18
18
 
19
+
19
20
  # load the channel by referencing the .rb file
20
21
  # the filename is lowercase with "_" for spaces
21
22
  # and the module inside must be camal cased to match
@@ -1,21 +1,28 @@
1
1
  require 'rubygems'
2
2
  require 'SecureRandom'
3
+ require 'eventmachine'
4
+ require 'amqp'
3
5
 
4
6
  module Factor
5
7
  module Runtime
6
8
  class MessageBus
7
- attr_accessor :host, :connection, :channel, :exchange, :queue
9
+ attr_accessor :host, :vhost, :username, :token, :connection, :channel, :exchange, :queue
8
10
 
9
- def initialize(host="queue.factor.io")
10
- @host = host
11
+ def initialize(email,token)
12
+ @host = "queue.factor.io"
13
+ @vhost = email
14
+ @username=email
15
+ @token=token
11
16
  end
17
+
12
18
 
13
19
  # Creates the connection and creates a topic exchange
14
20
  # An exchange references a place to send messages to
15
21
  # the exchange routes it to the queues based on the route_key
16
22
  def start(topic="workflow",&code)
17
23
  EventMachine.run do
18
- @connection = AMQP.connect(:host=>@host)
24
+ connection_settings={:host=>@host,:user=>@username,:password=>@token,:vhost=>@vhost}
25
+ @connection = AMQP.connect(connection_settings)
19
26
  @channel = AMQP::Channel.new(connection)
20
27
  @exchange = @channel.topic(topic,:auto_delete=>true) # new topic exchange
21
28
  code.call
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,119 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-12-09 00:00:00.000000000 Z
13
- dependencies: []
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.16.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.16.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rest-client
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 1.6.7
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.6.7
46
+ - !ruby/object:Gem::Dependency
47
+ name: zip
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 2.0.2
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.0.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: mustache
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 0.99.4
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 0.99.4
78
+ - !ruby/object:Gem::Dependency
79
+ name: eventmachine
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: 1.0.0
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 1.0.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: json
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: 1.7.5
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 1.7.5
110
+ - !ruby/object:Gem::Dependency
111
+ name: amqp
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.9.8
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: 0.9.8
14
126
  description: Friendly command-line interface and library for Factor
15
127
  email: maciej@skierkowski.com
16
128
  executables:
@@ -37,7 +149,7 @@ files:
37
149
  - lib/runtime/workflow.rb
38
150
  - lib/runtime/workflow_instance.rb
39
151
  - bin/factor
40
- homepage: https://github.com/factor-io/factor-gem
152
+ homepage: http://rubygems.org/gems/factor
41
153
  licenses: []
42
154
  post_install_message:
43
155
  rdoc_options: []