factor 0.5.05 → 0.5.06

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bddfffa82901828336ac74f9e5d7e4a36b6e7f7a
4
+ data.tar.gz: c59c12d7fcc496dc86913fdb3700ffd643a6b833
5
+ SHA512:
6
+ metadata.gz: 603c84c45c762bd51b582bef876c0a5a3e8284c0967f8af863a504fcbec93975eab9857375c5a536eaa53a1866d1f71344fd4ce104705bae36401d1398ebf551
7
+ data.tar.gz: 016fcc9526e20f0550a5bc92c1dce3c00bdfdc44da357647646db8ac9d5e356d7f5dbaffb50667500a0370086188c1cdcfb72c6adac819824ba1e1f41e8d3122
@@ -4,3 +4,11 @@ rvm:
4
4
  env:
5
5
  matrix:
6
6
  secure: Tq2/ECBrOTUmGLk/IaoeukgjCZ3ZfBVvAh8rvX6c2GJ0MopTXbWGRAaOxK+CXPqEW1X3NCtvJx26ti+QiXfEufACHllfYFpGeD9+AEreDyyFjA10X4/vgh5k4EiFP7p+3VAj8N1i2/+H5554IRxJgmhWNR7iATOavRf7g05nfec=
7
+ deploy:
8
+ provider: rubygems
9
+ api_key:
10
+ secure: EVy47RrKK9cntDCXnc+akDp51TwsOl9saXvELArQSUOVsY3CaPhnvd1KPFW/EJoJ3OQiDG8xiR1j8sMn8ldwjSdjQ64q66eEMQBBSQBnwxDqv2vZbCZYcAu9MQpQfX1LdY5E2wvkos5nB1/d138wWoXzD2Ylvlf15YI7CxiV/hA=
11
+ gem: factor
12
+ on:
13
+ tags: true
14
+ repo: factor-io/factor
@@ -11,7 +11,7 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- codeclimate-test-reporter (0.3.0)
14
+ codeclimate-test-reporter (0.4.0)
15
15
  simplecov (>= 0.7.1, < 1.0.0)
16
16
  colored (1.2)
17
17
  commander (4.2.0)
@@ -52,7 +52,7 @@ PLATFORMS
52
52
  ruby
53
53
 
54
54
  DEPENDENCIES
55
- codeclimate-test-reporter (~> 0.3.0)
55
+ codeclimate-test-reporter (~> 0.4.0)
56
56
  factor!
57
57
  rake (~> 10.3.2)
58
58
  rspec (~> 3.0.0)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) {{{year}}} {{{fullname}}}
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/Rakefile CHANGED
@@ -1,5 +1,12 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'bundler/gem_tasks'
1
4
  require 'rspec/core/rake_task'
2
5
 
3
- RSpec::Core::RakeTask.new(:spec)
6
+ desc 'Run specs'
7
+ RSpec::Core::RakeTask.new do |t|
8
+ t.verbose = false
9
+ t.rspec_opts = '--color --order random'
10
+ end
4
11
 
5
- task :default => :spec
12
+ task default: :spec
@@ -1,27 +1,30 @@
1
- $:.push File.expand_path("../lib", __FILE__)
2
- require 'factor/version'
1
+ # encoding: UTF-8
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'factor/version'
3
4
 
4
- Gem::Specification.new do |s|
5
- s.name = "factor"
5
+ Gem::Specification.new do |s|
6
+ s.name = 'factor'
6
7
  s.version = Factor::VERSION
7
8
  s.platform = Gem::Platform::RUBY
8
- s.authors = ["Maciej Skierkowski"]
9
- s.email = ["maciej@factor.io"]
10
- s.homepage = "https://factor.io"
11
- s.summary = %q{CLI to manager workflows on Factor.io}
12
- s.description = %q{CLI to manager workflows on Factor.io}
9
+ s.authors = ['Maciej Skierkowski']
10
+ s.email = ['maciej@factor.io']
11
+ s.homepage = 'https://factor.io'
12
+ s.summary = 'CLI to manager workflows on Factor.io'
13
+ s.description = 'CLI to manager workflows on Factor.io'
13
14
 
14
- s.files = %x{git ls-files}.split("\n")
15
- s.test_files = %x{git ls-files -- {test,spec,features}/*}.split("\n")
16
- s.executables = %x{git ls-files -- bin/*}.split("\n").map{ |f| File.basename(f) }
17
- s.require_paths = ["lib"]
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map do |f|
18
+ File.basename(f)
19
+ end
20
+ s.require_paths = ['lib']
18
21
 
19
22
  s.add_runtime_dependency 'commander', '~> 4.2.0'
20
23
  s.add_runtime_dependency 'rest_client', '~> 1.7.3'
21
24
  s.add_runtime_dependency 'faye-websocket', '~> 0.7.4'
22
25
  s.add_runtime_dependency 'colored', '~> 1.2'
23
26
  s.add_runtime_dependency 'configatron', '~> 4.2.0'
24
- s.add_development_dependency 'codeclimate-test-reporter', '~> 0.3.0'
27
+ s.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.0'
25
28
  s.add_development_dependency 'rspec', '~> 3.0.0'
26
29
  s.add_development_dependency 'rake', '~> 10.3.2'
27
- end
30
+ end
@@ -7,7 +7,6 @@ require 'fileutils'
7
7
 
8
8
  module Factor
9
9
  module Commands
10
-
11
10
  # Base command with common methods used by all commands
12
11
  class Command
13
12
  DEFAULT_FILENAME = {
@@ -33,9 +32,6 @@ module Factor
33
32
  log_line :success, options
34
33
  end
35
34
 
36
- def debug(options = {})
37
- end
38
-
39
35
  def exception(message, exception)
40
36
  error 'message' => message
41
37
  error 'message' => " #{exception.message}"
@@ -54,11 +50,11 @@ module Factor
54
50
  def load_config_data(config_type, options = {})
55
51
  relative_path = options[config_type] || DEFAULT_FILENAME[config_type]
56
52
  absolute_path = File.expand_path(relative_path)
57
- info message: "Loading #{config_type.to_s} from #{absolute_path}"
53
+ info message: "Loading #{config_type} from #{absolute_path}"
58
54
  data = YAML.load(File.read(absolute_path))
59
55
  configatron[config_type].configure_from_hash(data)
60
56
  rescue => ex
61
- exception "Couldn't load #{config_type.to_s} from #{absolute_path}", ex
57
+ exception "Couldn't load #{config_type} from #{absolute_path}", ex
62
58
  end
63
59
 
64
60
  def log_line(section, options = {})
@@ -81,19 +77,17 @@ module Factor
81
77
  end
82
78
 
83
79
  def tag(options)
84
- tag = ''
85
- if options['workflow_id'] && options['instance_id']
86
- tag = "[#{options['workflow_id']}:#{options['instance_id']}]"
87
- elsif options['workflow_id'] && !options['instance_id']
88
- tag = "[#{options['workflow_id']}]"
89
- elsif !options['workflow_id'] && options['instance_id']
90
- tag = "[#{options['instance_id']}]"
91
- end
92
- tag
80
+ primary = options['service_id'] || options['instance_id']
81
+ secondary = if options['service_id'] && options['instance_id']
82
+ ":#{options['instane_id']}"
83
+ else
84
+ ''
85
+ end
86
+ primary ? "[#{primary}#{secondary}]" : ''
93
87
  end
94
88
 
95
89
  def time
96
- Time.now.localtime.strftime('%m/%d/%y %T.%L')
90
+ Time.now.localtime.strftime('%m/%d/%y %T.%L')
97
91
  end
98
92
 
99
93
  def write(message)
@@ -103,4 +97,4 @@ module Factor
103
97
  end
104
98
  end
105
99
  end
106
- end
100
+ end
@@ -7,15 +7,13 @@ require 'runtime'
7
7
 
8
8
  module Factor
9
9
  module Commands
10
-
11
10
  # Workflow is a Command to start the factor runtime from the CLI
12
11
  class Workflow < Factor::Commands::Command
13
-
14
12
  def initialize
15
13
  @workflows = {}
16
14
  end
17
15
 
18
- def server(args, options)
16
+ def server(_args, options)
19
17
  config_settings = {}
20
18
  config_settings[:credentials] = options.credentials
21
19
  config_settings[:connectors] = options.connectors
@@ -46,7 +44,7 @@ module Factor
46
44
  def block_until_interupt
47
45
  log_message 'status' => 'info', 'message' => 'Ctrl-c to exit'
48
46
  begin
49
- while true
47
+ loop do
50
48
  sleep 1
51
49
  end
52
50
  rescue Interrupt
@@ -75,7 +73,7 @@ module Factor
75
73
  connector_settings = configatron.connectors.to_hash
76
74
  credential_settings = configatron.credentials.to_hash
77
75
  runtime = Runtime.new(connector_settings, credential_settings)
78
- runtime.logger = self.method(:log_message)
76
+ runtime.logger = method(:log_message)
79
77
  rescue => ex
80
78
  message = "Couldn't setup workflow process for #{workflow_filename}"
81
79
  exception message, ex
@@ -106,10 +104,9 @@ module Factor
106
104
  when 'info' then info message_info
107
105
  when 'success' then success message_info
108
106
  when 'warn' then warn message_info
109
- when 'debug' then debug message_info
110
107
  else error message_info
111
108
  end
112
109
  end
113
110
  end
114
111
  end
115
- end
112
+ end
@@ -1,5 +1,22 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'factor/base'
3
+ require 'commander/import'
4
+
4
5
  require 'factor/version'
5
- require 'cli'
6
+ require 'commands/workflows'
7
+
8
+ program :name, 'Factor.io Server'
9
+ program :version, Factor::VERSION
10
+ program :description, 'Factor.io Server to run workflows'
11
+
12
+ command 'server' do |c|
13
+ c.syntax = 'factor server [options]'
14
+ c.description = 'Start the Factor.io Server in the current local directory'
15
+ c.option '--log FILE', String, 'Log file path. Default is stdout.'
16
+ c.option '--credentials FILE', String, 'credentials.yml file path.'
17
+ c.option '--connectors FILE', String, 'connectors.yml file path'
18
+ c.option '--path FILE', String, 'Path to workflows'
19
+ c.when_called Factor::Commands::Workflow, :server
20
+ end
21
+
22
+ alias_command 's', 'server'
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Primary Factor.io module
4
4
  module Factor
5
- VERSION = '0.5.05'
5
+ VERSION = '0.5.06'
6
6
  end
@@ -4,10 +4,8 @@ require 'rest_client'
4
4
  require 'websocket_manager'
5
5
 
6
6
  module Factor
7
-
8
7
  # Class Listener for integrating with connector service
9
8
  class Listener
10
-
11
9
  def initialize(url)
12
10
  @url = url
13
11
  end
@@ -16,14 +14,12 @@ module Factor
16
14
  get("#{@url}/definition")
17
15
  end
18
16
 
19
- def listener(listener_id, &block)
20
- ws = listen("#{@url}/listeners/#{listener_id}")
21
- ws
17
+ def listener(listener_id)
18
+ listen("#{@url}/listeners/#{listener_id}")
22
19
  end
23
20
 
24
- def action(action_id, &block)
25
- ws = listen("#{@url}/actions/#{action_id}")
26
- ws
21
+ def action(action_id)
22
+ listen("#{@url}/actions/#{action_id}")
27
23
  end
28
24
 
29
25
  private
@@ -45,4 +41,4 @@ module Factor
45
41
  WebSocketManager.new(uri_path)
46
42
  end
47
43
  end
48
- end
44
+ end
@@ -6,6 +6,7 @@ require 'yaml'
6
6
  require 'eventmachine'
7
7
  require 'uri'
8
8
  require 'faye/websocket'
9
+ require 'ostruct'
9
10
 
10
11
  require 'listener'
11
12
  require 'commands/base'
@@ -41,24 +42,17 @@ module Factor
41
42
 
42
43
  def load(workflow_definition)
43
44
  EM.run do
44
- self.instance_eval(workflow_definition)
45
+ instance_eval(workflow_definition)
45
46
  end
46
47
  end
47
48
 
48
- def workflow(key, value)
49
- @workflow_spec[key] = value
50
- @name = value if @key == 'name'
51
- @id = value if @key == 'id'
52
- @description = value if @key == 'description'
53
- end
54
-
55
- def listen(service_id, listener_id, params = {}, &block)
56
-
49
+ def listen(service_ref, params = {}, &block)
50
+ service_id, listener_id = service_ref.split('::')
57
51
  ws = @connectors[service_id.to_sym].listener(listener_id)
58
52
 
59
53
  handle_on_open(service_id, listener_id, 'Listener', ws, params)
60
54
 
61
- ws.on :close do |event|
55
+ ws.on :close do
62
56
  error 'Listener disconnected'
63
57
  if @reconnect
64
58
  warn 'Reconnecting...'
@@ -73,7 +67,7 @@ module Factor
73
67
  when'start_workflow'
74
68
  success "Workflow '#{service_id}::#{listener_id}' triggered"
75
69
  error_handle_call(listener_response, &block)
76
- when 'started'
70
+ when 'return'
77
71
  success "Workflow '#{service_id}::#{listener_id}' started"
78
72
  when 'fail'
79
73
  error "Workflow '#{service_id}::#{listener_id}' failed to start"
@@ -105,12 +99,13 @@ module Factor
105
99
  @sockets << ws
106
100
  end
107
101
 
108
- def run(service_id, action_id, params = {}, &block)
102
+ def run(service_ref, params = {}, &block)
103
+ service_id, action_id = service_ref.split('::')
109
104
  ws = @connectors[service_id.to_sym].action(action_id)
110
105
 
111
106
  handle_on_open(service_id, action_id, 'Action', ws, params)
112
107
 
113
- ws.on :error do |event|
108
+ ws.on :error do
114
109
  error 'Connection dropped while calling action'
115
110
  end
116
111
 
@@ -141,7 +136,7 @@ module Factor
141
136
  private
142
137
 
143
138
  def handle_on_open(service_id, action_id, dsl_type, ws, params)
144
- ws.on :open do |event|
139
+ ws.on :open do
145
140
  params.merge!(@credentials[service_id.to_sym] || {})
146
141
  success "#{dsl_type.capitalize} '#{service_id}::#{action_id}' called"
147
142
  ws.send(params.to_json)
@@ -149,7 +144,7 @@ module Factor
149
144
  end
150
145
 
151
146
  def error_handle_call(listener_response, &block)
152
- block.call(listener_response['payload']) if block
147
+ block.call(OpenStruct.new(listener_response['payload'])) if block
153
148
  rescue => ex
154
149
  error "Error in workflow definition: #{ex.message}"
155
150
  ex.backtrace.each do |line|
@@ -178,15 +173,5 @@ module Factor
178
173
  message_info['workflow_id'] = @id
179
174
  @logger.call(message_info) if @logger
180
175
  end
181
-
182
- def define_method_in_class(class_ref, class_id, method_id, &block)
183
- class_name = class_id.classify
184
- method_name = method_id.underscore
185
- class_ref.class.instance_eval do
186
- define_method(method_name) do |params = {}, &passed_block|
187
- block.call(class_name, method_name, params, &passed_block)
188
- end
189
- end
190
- end
191
176
  end
192
- end
177
+ end
@@ -3,92 +3,92 @@
3
3
  require 'faye/websocket'
4
4
  require 'uri'
5
5
 
6
- # class for managing the web socket connections
7
- class WebSocketManager
8
- attr_accessor :keep_open, :events, :state
9
-
10
- def initialize(uri, headers = {})
11
- u = URI(uri)
12
- u.scheme = 'wss' if u.scheme == 'https'
13
- @uri = u.to_s
14
- @settings = { ping: 10, retry: 5 }
15
- @settings[:headers] = headers if headers && headers != {}
16
- @state = :closed
17
- @events = {}
18
- end
19
-
20
- def open
21
- if closed?
22
- @state = :opening
23
- connect
6
+ module Factor
7
+ # class for managing the web socket connections
8
+ class WebSocketManager
9
+ attr_accessor :keep_open, :events, :state
10
+
11
+ def initialize(uri, headers = {})
12
+ u = URI(uri)
13
+ @uri = u.to_s
14
+ @settings = { ping: 10, retry: 5 }
15
+ @settings[:headers] = headers if headers && headers != {}
16
+ @state = :closed
17
+ @events = {}
24
18
  end
25
- @state
26
- end
27
19
 
28
- def close
29
- if open?
30
- @state = :closing
31
- @ws.close
20
+ def open
21
+ if closed?
22
+ @state = :opening
23
+ connect
24
+ end
25
+ @state
32
26
  end
33
- @state
34
- end
35
-
36
- def on(event, &block)
37
- @events[event] = block
38
- end
39
27
 
40
- def open?
41
- @state == :open
42
- end
43
-
44
- def opening?
45
- @state == :opening
46
- end
47
-
48
- def closed?
49
- @state == :closed
50
- end
28
+ def close
29
+ if open?
30
+ @state = :closing
31
+ @ws.close
32
+ end
33
+ @state
34
+ end
51
35
 
52
- def closing?
53
- @state == :closing
54
- end
36
+ def on(event, &block)
37
+ @events[event] = block
38
+ end
55
39
 
56
- def send(msg)
57
- @ws.send(msg)
58
- end
40
+ def open?
41
+ @state == :open
42
+ end
59
43
 
60
- private
44
+ def opening?
45
+ @state == :opening
46
+ end
61
47
 
62
- def call_event(event, data)
63
- @events[event].call(data) if @events[event]
64
- end
48
+ def closed?
49
+ @state == :closed
50
+ end
65
51
 
66
- def connect
67
- EM.run do
68
- begin
69
- @ws = Faye::WebSocket::Client.new(@uri, nil, @settings)
52
+ def closing?
53
+ @state == :closing
54
+ end
70
55
 
71
- @ws.on :close do |event|
72
- @state = :closed
73
- call_event :close, event
74
- end
56
+ def send(msg)
57
+ @ws.send(msg)
58
+ end
75
59
 
76
- @ws.on :message do |msg|
77
- call_event :message, msg
78
- end
60
+ private
79
61
 
80
- @ws.on :open do |event|
81
- @state = :open
82
- call_event :open, event
83
- end
62
+ def call_event(event, data)
63
+ @events[event].call(data) if @events[event]
64
+ end
84
65
 
85
- @ws.on :error do |event|
86
- call_event :error, event
66
+ def connect
67
+ EM.run do
68
+ begin
69
+ @ws = Faye::WebSocket::Client.new(@uri, nil, @settings)
70
+
71
+ @ws.on :close do |event|
72
+ @state = :closed
73
+ call_event :close, event
74
+ end
75
+
76
+ @ws.on :message do |msg|
77
+ call_event :message, msg
78
+ end
79
+
80
+ @ws.on :open do |event|
81
+ @state = :open
82
+ call_event :open, event
83
+ end
84
+
85
+ @ws.on :error do |event|
86
+ call_event :error, event
87
+ end
88
+ rescue => ex
89
+ call_event :fail, ex.message
87
90
  end
88
- rescue => ex
89
- call_event :fail, ex.message
90
91
  end
91
92
  end
92
93
  end
93
-
94
- end
94
+ end
@@ -0,0 +1,105 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+ require 'tempfile'
5
+ require 'yaml'
6
+ require 'commander'
7
+
8
+ describe Factor::Commands::Command do
9
+ before :each do
10
+ @command = Factor::Commands::Command.new
11
+ end
12
+
13
+ output_methods = %w(info warn error success)
14
+
15
+ output_methods.each do |method_name|
16
+ describe ".#{method_name}" do
17
+ it "logs #{method_name}" do
18
+
19
+ test_string = 'Hello World'
20
+ output = capture_stdout do
21
+ @command.method(method_name.to_sym).call message: test_string
22
+ end
23
+
24
+ expect(output).to include(test_string)
25
+ expect(output).to include(method_name.upcase)
26
+ end
27
+ end
28
+ end
29
+
30
+ describe '.exception' do
31
+ it 'logs exception' do
32
+
33
+ test_string = 'Hello World'
34
+ exception_string = 'Something be busted'
35
+ output = capture_stdout do
36
+ begin
37
+ fail ArgumentError, exception_string
38
+ rescue => ex
39
+ @command.exception test_string, ex
40
+ end
41
+ end
42
+
43
+ expect(output).to include(test_string)
44
+ expect(output).to include(exception_string)
45
+ expect(output).to include('ERROR')
46
+
47
+ end
48
+ end
49
+
50
+ describe '.load_config' do
51
+ it 'can load credentials and connectors' do
52
+ credentials_file = Tempfile.new('credentials')
53
+ connectors_file = Tempfile.new('connectors')
54
+
55
+ credentials_content = {
56
+ 'github' => {
57
+ 'api_key' => 'fake_github_key'
58
+ },
59
+ 'heroku' => {
60
+ 'api_key' => 'fake_heroku_key'
61
+ }
62
+ }
63
+
64
+ connectors_content = {
65
+ 'timer' => 'http://localhost:9294/v0.4/timer',
66
+ 'web' => 'http://localhost:9294/v0.4/web',
67
+ 'github' => 'http://localhost:9294/v0.4/github',
68
+ 'heroku' => 'http://localhost:9294/v0.4/heroku'
69
+ }
70
+
71
+ credentials_file.write(YAML.dump(credentials_content))
72
+ connectors_file.write(YAML.dump(connectors_content))
73
+
74
+ credentials_file.rewind
75
+ connectors_file.rewind
76
+
77
+ options = Commander::Command::Options.new
78
+ options.credentials = credentials_file.path
79
+ options.connectors = connectors_file.path
80
+
81
+ config_settings = {
82
+ credentials: options.credentials,
83
+ connectors: options.connectors
84
+ }
85
+
86
+ output = capture_stdout do
87
+ @command.load_config config_settings
88
+ end
89
+
90
+ expect(output).to include('Loading credentials')
91
+ expect(output).to include('Loading connectors')
92
+
93
+ expect(configatron.credentials.github.api_key).to eq('fake_github_key')
94
+ expect(configatron.credentials.heroku.api_key).to eq('fake_heroku_key')
95
+ connectors_content.keys.each do |expected_connector_key|
96
+ actual_connector = configatron.connectors[expected_connector_key]
97
+ expected_connector = connectors_content[expected_connector_key]
98
+ expect(actual_connector).to eq(expected_connector)
99
+ end
100
+
101
+ credentials_file.close
102
+ connectors_file.close
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Factor::Listener do
6
+ it 'does stuff' do
7
+ expect(true).to eq(true)
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'codeclimate-test-reporter'
4
+ require 'stringio'
5
+
6
+ CodeClimate::TestReporter.start do
7
+ add_filter '/spec/'
8
+ end
9
+
10
+ # include anything that could be tested
11
+ require 'commands/base'
12
+ require 'commands/workflows'
13
+ require 'listener'
14
+ require 'runtime'
15
+ require 'websocket_manager'
16
+
17
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
18
+
19
+ def capture_stdout(&_block)
20
+ original_stdout = $stdout
21
+ $stdout = fake = StringIO.new
22
+ begin
23
+ yield
24
+ ensure
25
+ $stdout = original_stdout
26
+ end
27
+ fake.string
28
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Factor::Commands::Workflow do
6
+ describe '.server' do
7
+ it 'can run a basic workflow' do
8
+
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.05
5
- prerelease:
4
+ version: 0.5.06
6
5
  platform: ruby
7
6
  authors:
8
7
  - Maciej Skierkowski
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-07-23 00:00:00.000000000 Z
11
+ date: 2014-08-31 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: commander
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rest_client
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: faye-websocket
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: colored
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: configatron
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,23 +83,20 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: codeclimate-test-reporter
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
101
- version: 0.3.0
89
+ version: 0.4.0
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
109
- version: 0.3.0
96
+ version: 0.4.0
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rspec
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -126,7 +111,6 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: rake
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - ~>
132
116
  - !ruby/object:Gem::Version
@@ -134,7 +118,6 @@ dependencies:
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
122
  - - ~>
140
123
  - !ruby/object:Gem::Version
@@ -151,43 +134,47 @@ files:
151
134
  - .travis.yml
152
135
  - Gemfile
153
136
  - Gemfile.lock
137
+ - LICENSE
154
138
  - README.md
155
139
  - Rakefile
156
140
  - bin/factor
157
141
  - factor.gemspec
158
- - lib/cli.rb
159
142
  - lib/commands/base.rb
160
143
  - lib/commands/workflows.rb
161
144
  - lib/factor.rb
162
- - lib/factor/base.rb
163
145
  - lib/factor/version.rb
164
146
  - lib/listener.rb
165
147
  - lib/runtime.rb
166
148
  - lib/websocket_manager.rb
167
- - spec/rspec_helper.rb
149
+ - spec/base_spec.rb
150
+ - spec/listener_spec.rb
151
+ - spec/spec_helper.rb
152
+ - spec/workflow_spec.rb
168
153
  homepage: https://factor.io
169
154
  licenses: []
155
+ metadata: {}
170
156
  post_install_message:
171
157
  rdoc_options: []
172
158
  require_paths:
173
159
  - lib
174
160
  required_ruby_version: !ruby/object:Gem::Requirement
175
- none: false
176
161
  requirements:
177
- - - ! '>='
162
+ - - '>='
178
163
  - !ruby/object:Gem::Version
179
164
  version: '0'
180
165
  required_rubygems_version: !ruby/object:Gem::Requirement
181
- none: false
182
166
  requirements:
183
- - - ! '>='
167
+ - - '>='
184
168
  - !ruby/object:Gem::Version
185
169
  version: '0'
186
170
  requirements: []
187
171
  rubyforge_project:
188
- rubygems_version: 1.8.25
172
+ rubygems_version: 2.0.3
189
173
  signing_key:
190
- specification_version: 3
174
+ specification_version: 4
191
175
  summary: CLI to manager workflows on Factor.io
192
176
  test_files:
193
- - spec/rspec_helper.rb
177
+ - spec/base_spec.rb
178
+ - spec/listener_spec.rb
179
+ - spec/spec_helper.rb
180
+ - spec/workflow_spec.rb
data/lib/cli.rb DELETED
@@ -1,21 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'commander/import'
4
-
5
- require 'commands/workflows'
6
-
7
- program :name, 'Factor.io Server'
8
- program :version, Factor::VERSION
9
- program :description, 'Factor.io Server to run workflows'
10
-
11
- command 'server' do |c|
12
- c.syntax = 'factor server [options]'
13
- c.description = 'Start the Factor.io Server in the current local directory'
14
- c.option '--log FILE', String, 'Log file path. Default is stdout.'
15
- c.option '--credentials FILE', String, 'credentials.yml file path.'
16
- c.option '--connectors FILE', String, 'connectors.yml file path'
17
- c.option '--path FILE', String, 'Path to workflows'
18
- c.when_called Factor::Commands::Workflow, :server
19
- end
20
-
21
- alias_command 's', 'server'
@@ -1,17 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- # Primary Factor.io module
4
- module Factor
5
-
6
- String.send :define_method, :classify do
7
- self.split('_').collect! { |w| w.capitalize }.join
8
- end
9
-
10
- String.send :define_method, :underscore do
11
- self.gsub(/::/, '/')
12
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
13
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
14
- .tr('-', '_')
15
- .downcase
16
- end
17
- end
@@ -1,2 +0,0 @@
1
- require "codeclimate-test-reporter"
2
- CodeClimate::TestReporter.start