speedflow 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/sf +28 -0
- data/lib/speedflow/commands/flow.rb +8 -8
- data/lib/speedflow/flow.rb +10 -10
- data/lib/speedflow/message.rb +1 -1
- data/lib/speedflow/plugin/manager.rb +4 -4
- data/lib/speedflow/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d413c3a17a899e968628efd0384146168ec0aaa
|
4
|
+
data.tar.gz: 8fd189ddacc5df83366167350c3067e64445922d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0df3efbcafd6374dc1891ba69698d16536a6c3003b55deaee9d55244a3637619f731897e4ab42ffff8b5a8bd6349cdcba7738f89858100d090c3c1832ef8a84
|
7
|
+
data.tar.gz: 0767fae862569b343a63468f0a505e78209a528ea2a67a9529e1b05ec0e060090ab5b353c5c0ef0cdd27c00b55f8d08c3fb0992a131fff98c4557c9d382995c4
|
data/bin/sf
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
STDOUT.sync = true
|
3
|
+
|
4
|
+
require 'mercenary'
|
5
|
+
require 'speedflow'
|
6
|
+
|
7
|
+
# Kill exiting error
|
8
|
+
Signal.trap('SIGINT') { exit 130 }
|
9
|
+
|
10
|
+
# Speedflow program
|
11
|
+
Mercenary.program(:speedflow) do |program|
|
12
|
+
program.version Speedflow::VERSION
|
13
|
+
program.description 'Speedflow is a CLI to help you to keep your time.'
|
14
|
+
program.syntax "speedflow [OPTIONS] COMMAND [arg...]\n" \
|
15
|
+
' speedflow [ --help | -v | --version | --trace ]'
|
16
|
+
program.option(
|
17
|
+
'config',
|
18
|
+
'-c FILE1[,FILE2[,FILE3...]]',
|
19
|
+
'--config FILE1[,FILE2[,FILE3...]]',
|
20
|
+
Array,
|
21
|
+
'Custom configuration file')
|
22
|
+
|
23
|
+
# program.logger(Logger::DEBUG)
|
24
|
+
|
25
|
+
Speedflow::Command.subclasses.each { |c| c.init_with_program(program) }
|
26
|
+
|
27
|
+
program.default_command(:help)
|
28
|
+
end
|
@@ -53,14 +53,14 @@ module Speedflow
|
|
53
53
|
# Returns nothing.
|
54
54
|
def process_trigger(trigger, config, options)
|
55
55
|
flow = Speedflow::Flow.new(config)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
56
|
+
flow.trigger(trigger, options)
|
57
|
+
success "Trigger '#{trigger}' successful"
|
58
|
+
rescue FlowTriggerNotFound => exception
|
59
|
+
error "Trigger '#{trigger}' error: #{exception.message}"
|
60
|
+
rescue Plugin::PluginNotFound => exception
|
61
|
+
error "Plugin error: #{exception.message}"
|
62
|
+
rescue Plugin::PluginActionNotFound => exception
|
63
|
+
error exception.message
|
64
64
|
end
|
65
65
|
|
66
66
|
# Add options from flow arguents.
|
data/lib/speedflow/flow.rb
CHANGED
@@ -12,7 +12,7 @@ module Speedflow
|
|
12
12
|
#
|
13
13
|
# Returns a Hash of config.
|
14
14
|
def initialize(config)
|
15
|
-
# TODO:
|
15
|
+
# TODO: Reinforce the SOI.
|
16
16
|
@config = config
|
17
17
|
end
|
18
18
|
|
@@ -23,13 +23,13 @@ module Speedflow
|
|
23
23
|
#
|
24
24
|
# Returns nothing.
|
25
25
|
def trigger(trigger, input)
|
26
|
-
# TODO:
|
27
|
-
# TODO:
|
26
|
+
# TODO: Change by: Configuration.not_empty_key?
|
27
|
+
# TODO: Move to this class: Flow.trigger?
|
28
28
|
unless @config.flow_trigger?(trigger)
|
29
29
|
raise FlowTriggerNotFound, "Unable to trigger: #{trigger}"
|
30
30
|
end
|
31
31
|
|
32
|
-
# TODO:
|
32
|
+
# TODO: Move in a normal object tree: Flow > Trigger > Action
|
33
33
|
output_by_tag = {}
|
34
34
|
output = {}
|
35
35
|
@config['flow'][trigger.to_s].each do |step|
|
@@ -48,11 +48,11 @@ module Speedflow
|
|
48
48
|
def trigger_step(step, input, output, output_by_tag)
|
49
49
|
arguments = step['arguments'] || {}
|
50
50
|
|
51
|
-
# TODO:
|
51
|
+
# TODO: Move to a normal object: TriggerArgument
|
52
52
|
step['arguments'] = transform_arguments(arguments, output, input)
|
53
53
|
step['arguments'] = add_config_argument(arguments)
|
54
54
|
|
55
|
-
# TODO:
|
55
|
+
# TODO: Move to a normal object: TriggerArgument
|
56
56
|
output = plugin_manager.action_from_step(step)
|
57
57
|
output_by_tag[step['tag']] = output if step.key? 'tag'
|
58
58
|
|
@@ -61,7 +61,7 @@ module Speedflow
|
|
61
61
|
|
62
62
|
# Public: Add config arguement
|
63
63
|
#
|
64
|
-
# TODO:
|
64
|
+
# TODO: Move to a normal object: TriggerArgument
|
65
65
|
#
|
66
66
|
# arguments - Hash of arguments.
|
67
67
|
#
|
@@ -77,7 +77,7 @@ module Speedflow
|
|
77
77
|
|
78
78
|
# Public: Transform arguments (to add value)
|
79
79
|
#
|
80
|
-
# TODO:
|
80
|
+
# TODO: Move to a normal object: TriggerArgument
|
81
81
|
#
|
82
82
|
# arguments - Hash of arguments.
|
83
83
|
# prev_values - Hash of previous values.
|
@@ -91,7 +91,7 @@ module Speedflow
|
|
91
91
|
arguments[arg_name]['value'] = ''
|
92
92
|
if inputs.key?(arg_name)
|
93
93
|
arguments[arg_name]['value'] = inputs[arg_name]
|
94
|
-
elsif
|
94
|
+
elsif arg_values.is_a?(Hash) && arg_values.key?('default')
|
95
95
|
arguments[arg_name]['value'] = arg_values['default']
|
96
96
|
end
|
97
97
|
end
|
@@ -99,7 +99,7 @@ module Speedflow
|
|
99
99
|
|
100
100
|
# Public: Get flat arguments from flow.
|
101
101
|
#
|
102
|
-
# TODO:
|
102
|
+
# TODO: Move to a normal object: TriggerArgument
|
103
103
|
#
|
104
104
|
# Returns flat Array of arguments.
|
105
105
|
def flat_arguments
|
data/lib/speedflow/message.rb
CHANGED
@@ -4,7 +4,7 @@ module Speedflow
|
|
4
4
|
# Used to manage the plugins
|
5
5
|
class Manager
|
6
6
|
include ActiveSupport::Inflector
|
7
|
-
# TODO:
|
7
|
+
# TODO: Remove underground prompt.
|
8
8
|
include Message
|
9
9
|
|
10
10
|
PLUGIN_BASE = 'speedflow-plugin-'.freeze
|
@@ -80,12 +80,12 @@ module Speedflow
|
|
80
80
|
plugin_name = plugin.class.name.split('::')[-2].downcase
|
81
81
|
action_name = action_name.prepend('action_').underscore
|
82
82
|
|
83
|
-
unless plugin.respond_to?(action_name)
|
83
|
+
unless plugin.respond_to?(action_name)
|
84
84
|
message = "Unable to call action: #{plugin_name}.#{action_name}"
|
85
85
|
raise PluginActionNotFound, message
|
86
86
|
end
|
87
87
|
|
88
|
-
# TODO:
|
88
|
+
# TODO: Remove underground prompt.
|
89
89
|
success "Run action '#{action_name}' of '#{plugin_name}' plugin."
|
90
90
|
|
91
91
|
plugin.send action_name
|
@@ -95,7 +95,7 @@ module Speedflow
|
|
95
95
|
#
|
96
96
|
# plugin_name - Plugin name.
|
97
97
|
#
|
98
|
-
# TODO:
|
98
|
+
# TODO: Create Utils::name_to_object method.
|
99
99
|
#
|
100
100
|
# Returns Object.
|
101
101
|
def plugin_object(plugin_name)
|
data/lib/speedflow/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: speedflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Breux
|
@@ -240,6 +240,7 @@ email:
|
|
240
240
|
- julien.breux@gmail.com
|
241
241
|
executables:
|
242
242
|
- speedflow
|
243
|
+
- sf
|
243
244
|
extensions: []
|
244
245
|
extra_rdoc_files: []
|
245
246
|
files:
|
@@ -247,6 +248,7 @@ files:
|
|
247
248
|
- README.md
|
248
249
|
- bin/console
|
249
250
|
- bin/setup
|
251
|
+
- bin/sf
|
250
252
|
- bin/speedflow
|
251
253
|
- lib/speedflow.rb
|
252
254
|
- lib/speedflow/command.rb
|