wrkflo 0.1.0 → 0.1.1
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/bin/wrkflo +6 -14
- data/lib/wrkflo.rb +13 -0
- data/lib/wrkflo/configurable.rb +44 -25
- data/lib/wrkflo/configurable/property.rb +66 -17
- data/lib/wrkflo/notifier.rb +21 -0
- data/lib/wrkflo/profile.rb +11 -11
- data/lib/wrkflo/project.rb +56 -56
- data/lib/wrkflo/step.rb +78 -61
- data/lib/wrkflo/steps/atom.rb +8 -6
- data/lib/wrkflo/steps/editor.rb +13 -11
- data/lib/wrkflo/steps/emacs.rb +8 -6
- data/lib/wrkflo/steps/filesystem.rb +16 -14
- data/lib/wrkflo/steps/nfs.rb +19 -0
- data/lib/wrkflo/steps/ssh.rb +10 -8
- data/lib/wrkflo/steps/sshfs.rb +14 -12
- data/lib/wrkflo/steps/sublime.rb +9 -7
- data/lib/wrkflo/version.rb +2 -2
- data/lib/wrkflo/wrkflo.rb +43 -43
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 590973490ce5df36fb5a324843678d1f34abf517
|
4
|
+
data.tar.gz: 97c22d905943c69883b41faba0aa445c501c7dc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32e4d2c3c8df4e2b1674c7dac5ddff1a0ee6410e778c2d687c49fb973aaf50332c9bb2a8bb10457fc5f5a64820a41cc86e3d02cb1535085e8a8c17d75f77ca7d
|
7
|
+
data.tar.gz: feca1bf42f31d01176b6875f0940e43fd4a8566c45a24ce8210aa87bf14585f4af1e9802825599dd173ac63a2f405ce0e6d382855bd1d76c33e01c25be029d91
|
data/bin/wrkflo
CHANGED
@@ -4,15 +4,7 @@ require 'optparse'
|
|
4
4
|
require 'pp'
|
5
5
|
require 'yaml'
|
6
6
|
|
7
|
-
require 'wrkflo
|
8
|
-
|
9
|
-
|
10
|
-
# Abort execution with the given message, exiting with the given status code.
|
11
|
-
def error_out message, status: 1
|
12
|
-
$stderr.puts message
|
13
|
-
$stderr.puts "Run `wrkflo --help` for usage information."
|
14
|
-
exit status
|
15
|
-
end
|
7
|
+
require 'wrkflo'
|
16
8
|
|
17
9
|
|
18
10
|
options = {
|
@@ -23,7 +15,7 @@ options = {
|
|
23
15
|
OptionParser.new do |opts|
|
24
16
|
opts.banner = "Usage: wrkflo [options] <project>"
|
25
17
|
opts.separator "Start working on things faster with predefined workflows"
|
26
|
-
opts.version =
|
18
|
+
opts.version = WRKFLO::VERSION
|
27
19
|
|
28
20
|
opts.on("-b", "--backward", "Reverse step order and undo compatible steps") do |b|
|
29
21
|
options[:backward] = b
|
@@ -42,22 +34,22 @@ OptionParser.new do |opts|
|
|
42
34
|
# Without this rescue, Ruby would print the stack trace
|
43
35
|
# of the error. Instead, we want to show the error message,
|
44
36
|
# suggest -h or --help, and exit 1.
|
45
|
-
error_out(error)
|
37
|
+
Notifier.error_out(error)
|
46
38
|
end
|
47
39
|
end
|
48
40
|
|
49
41
|
|
50
42
|
project_name = ARGV[0]
|
51
|
-
error_out('No project specified.') if project_name.nil?
|
43
|
+
Notifier.error_out('No project specified.') if project_name.nil?
|
52
44
|
|
53
45
|
# An object representation of the entire wrkflo profile, merged with
|
54
46
|
# the options given for this run.
|
55
|
-
wrkflo = WrkFlo.new(options)
|
47
|
+
wrkflo = WRKFLO::WrkFlo.new(options)
|
56
48
|
# The project workflow to execute on this run.
|
57
49
|
project = wrkflo[project_name]
|
58
50
|
# If no project was specified, notify and exit
|
59
51
|
if project == nil
|
60
|
-
error_out("Project '#{project_name}' does not exist in '#{wrkflo.profile_source}'.")
|
52
|
+
Notifier.error_out("Project '#{project_name}' does not exist in '#{wrkflo.profile_source}'.")
|
61
53
|
end
|
62
54
|
|
63
55
|
# Run the project workflow in the direction given from the terminal
|
data/lib/wrkflo.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'os'
|
2
|
+
|
3
|
+
require 'wrkflo/version'
|
4
|
+
require 'wrkflo/notifier'
|
5
|
+
|
6
|
+
require 'wrkflo/configurable/property'
|
7
|
+
require 'wrkflo/configurable'
|
8
|
+
|
9
|
+
require 'wrkflo/profile'
|
10
|
+
require 'wrkflo/step'
|
11
|
+
require 'wrkflo/project'
|
12
|
+
|
13
|
+
require 'wrkflo/wrkflo'
|
data/lib/wrkflo/configurable.rb
CHANGED
@@ -1,37 +1,56 @@
|
|
1
|
-
|
1
|
+
module WRKFLO
|
2
|
+
module Configurable
|
3
|
+
module ClassMethods
|
4
|
+
# A list of properties defined by the owner
|
5
|
+
def properties
|
6
|
+
@properties ||= {}
|
7
|
+
end
|
2
8
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@properties ||= {}
|
9
|
+
# Define a new property for the owning object
|
10
|
+
def property name, required: false, type: Object, default: nil
|
11
|
+
properties[name] = Property.new(name, required, type, default)
|
12
|
+
end
|
8
13
|
end
|
9
14
|
|
10
|
-
|
11
|
-
|
12
|
-
properties[name] = Property.new(name, required, default)
|
15
|
+
def self.included base
|
16
|
+
base.extend ClassMethods
|
13
17
|
end
|
14
|
-
end
|
15
18
|
|
16
|
-
def self.included base
|
17
|
-
base.extend ClassMethods
|
18
|
-
end
|
19
19
|
|
20
|
+
def apply_configuration raw_config
|
21
|
+
final_config = self.class.properties.each.with_object({}) do |(name, prop), h|
|
22
|
+
provided_value = raw_config[name.to_s]
|
23
|
+
# Determine the real value based on the property's definition
|
24
|
+
real_value = prop.resolve_value(provided_value)
|
25
|
+
# Remember the real value in the actual configuration
|
26
|
+
h[name.to_sym] = real_value
|
27
|
+
end
|
20
28
|
|
21
|
-
|
22
|
-
|
23
|
-
provided_value = raw_config[name.to_s]
|
24
|
-
# Determine the real value based on the property's definition
|
25
|
-
real_value = prop.resolve_value(provided_value)
|
26
|
-
# Remember the real value in the actual configuration
|
27
|
-
h[name.to_sym] = real_value
|
29
|
+
# Create a struct from the configuration hash to enable dot-access.
|
30
|
+
@configuration = Struct.new(*final_config.keys).new(*final_config.values)
|
28
31
|
end
|
29
32
|
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
+
# Returns `true` if the configuration is valid. Otherwise, returns a pair
|
34
|
+
# of the property and a reason. If a block is given, this pair is also
|
35
|
+
# passed to the block.
|
36
|
+
def validate_configuration
|
37
|
+
self.class.properties.values.each do |prop|
|
38
|
+
if prop.required?
|
39
|
+
unless config.respond_to?(prop.name)
|
40
|
+
return [prop, nil, :required].tap{ |f| yield f if block_given? }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
value = config.send(prop.name)
|
33
45
|
|
34
|
-
|
35
|
-
|
46
|
+
return [prop, value, :type].tap{ |f| yield f if block_given? } unless prop.matches_type?(value)
|
47
|
+
end
|
48
|
+
|
49
|
+
return true
|
50
|
+
end
|
51
|
+
|
52
|
+
def config
|
53
|
+
@configuration
|
54
|
+
end
|
36
55
|
end
|
37
56
|
end
|
@@ -1,24 +1,73 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
module WRKFLO
|
2
|
+
module Configurable
|
3
|
+
class Property
|
4
|
+
# The name of the property as it should appear in the configuration
|
5
|
+
attr_accessor :name
|
6
|
+
# Whether the property is required to be provided by the user
|
7
|
+
attr_accessor :required
|
8
|
+
alias_method :required?, :required
|
9
|
+
# The expected type of the value
|
10
|
+
attr_accessor :type
|
11
|
+
# The default value to be given to this property if one is not provided
|
12
|
+
attr_accessor :default
|
10
13
|
|
11
14
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def initialize name, is_required, expected_type, default_value
|
16
|
+
@name = name
|
17
|
+
@required = is_required
|
18
|
+
@default = default_value
|
19
|
+
@type = expected_type
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
# Assign a value to this property
|
24
|
+
def resolve_value value
|
25
|
+
value.nil? ? @default : value
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns true if `value` is of the type expected by this property. Returns
|
29
|
+
# false otherwise.
|
30
|
+
# For simple types, this is a simple `is_a?` check.
|
31
|
+
# For arrays, two different rules apply:
|
32
|
+
# - `Array[]` expects an arbitrary array of values.
|
33
|
+
# - `Array[Float]` expects an arbitrary-length array of `Float` values.
|
34
|
+
# - `Array[Float, String, ...]` expects an Array of exactly those types.
|
35
|
+
def matches_type? value, expected_type: type
|
36
|
+
case expected_type
|
37
|
+
# Raw class types
|
38
|
+
when Array
|
39
|
+
case expected_type.length
|
40
|
+
when 0
|
41
|
+
return value.is_a?(Array)
|
42
|
+
when 1
|
43
|
+
return value.all?{ |v| matches_type?(v, expected_type: expected_type[0]) }
|
44
|
+
else
|
45
|
+
return expected_type.zip([value].flatten(1)).all?{ |t, v| matches_type?(v, expected_type: t) }
|
46
|
+
end
|
47
|
+
else
|
48
|
+
value.is_a?(expected_type)
|
49
|
+
end
|
50
|
+
end
|
17
51
|
|
52
|
+
def type_as_string expected_type: type
|
53
|
+
case expected_type
|
54
|
+
when Array
|
55
|
+
value_types = expected_type.map{ |t| t.to_s }
|
56
|
+
"Array[#{value_types.join(',')}]"
|
57
|
+
else
|
58
|
+
expected_type.to_s
|
59
|
+
end
|
60
|
+
end
|
18
61
|
|
19
|
-
|
20
|
-
|
21
|
-
|
62
|
+
def value_type_as_string value
|
63
|
+
case value
|
64
|
+
when Array
|
65
|
+
value_types = value.map{ |v| v.class.to_s }
|
66
|
+
"Array[#{value_types.join(',')}]"
|
67
|
+
else
|
68
|
+
value.class.to_s
|
69
|
+
end
|
70
|
+
end
|
22
71
|
end
|
23
72
|
end
|
24
73
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module WRKFLO
|
2
|
+
module Notifier
|
3
|
+
FOOTER_TEXT = <<-END_FOOTER
|
4
|
+
Run `wrkflo --help` for usage information.
|
5
|
+
END_FOOTER
|
6
|
+
|
7
|
+
# Write an error message to stderr and abort execution, exiting with the
|
8
|
+
# given status code, or `1` if no status code is specified.
|
9
|
+
def self.error_out *messages, type: "Error", status: 1
|
10
|
+
$stderr.puts "#{type}: #{messages.first}"
|
11
|
+
messages.drop(1).each{ |msg| $stderr.puts "\t#{msg}" }
|
12
|
+
$stderr.puts FOOTER_TEXT
|
13
|
+
exit status
|
14
|
+
end
|
15
|
+
|
16
|
+
# Write an arbitrary message to stdout.
|
17
|
+
def self.log message
|
18
|
+
$stdout.puts message
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/wrkflo/profile.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
1
|
+
module WRKFLO
|
2
|
+
class Profile
|
3
|
+
def self.load source
|
4
|
+
@projects = YAML.load_file(source)
|
5
|
+
@options = @projects.delete("options")
|
6
|
+
rescue
|
7
|
+
Notifier.error_out("Could not load configuration at '#{source}'.", type: "ConfigurationError")
|
8
|
+
end
|
10
9
|
|
11
|
-
|
12
|
-
|
10
|
+
def self.projects; @projects; end
|
11
|
+
def self.options; @options; end
|
12
|
+
end
|
13
13
|
end
|
data/lib/wrkflo/project.rb
CHANGED
@@ -1,67 +1,67 @@
|
|
1
|
-
|
1
|
+
module WRKFLO
|
2
|
+
class Project
|
3
|
+
attr_accessor :name, :steps
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
+
def initialize name
|
6
|
+
# The name of this project workflow
|
7
|
+
@name = name
|
8
|
+
# The raw configuration used by this project
|
9
|
+
@config = Profile.projects[@name]
|
10
|
+
# The steps that make up this workflow
|
11
|
+
@steps = @config.map{ |name, conf| Step.create(name, conf, self) }
|
12
|
+
# The step currently being executed
|
13
|
+
@current_step = 0
|
14
|
+
end
|
5
15
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
# Run each step in the order they are specified
|
17
|
+
def run
|
18
|
+
meta_log "Running workflow '#{@name}'"
|
19
|
+
# Reset the current step number
|
20
|
+
@current_step_num = 0
|
21
|
+
# Run the steps
|
22
|
+
@steps.each do |step|
|
23
|
+
# Remember the step being run
|
24
|
+
@current_step = step
|
25
|
+
# Increment the current step so that the first step is 1
|
26
|
+
@current_step_num += 1
|
27
|
+
# Run the step
|
28
|
+
@current_step.setup
|
29
|
+
@current_step.run
|
30
|
+
end
|
16
31
|
|
17
|
-
|
18
|
-
def run
|
19
|
-
meta_log "Running workflow '#{@name}'"
|
20
|
-
# Reset the current step number
|
21
|
-
@current_step_num = 0
|
22
|
-
# Run the steps
|
23
|
-
@steps.each do |step|
|
24
|
-
# Remember the step being run
|
25
|
-
@current_step = step
|
26
|
-
# Increment the current step so that the first step is 1
|
27
|
-
@current_step_num += 1
|
28
|
-
# Run the step
|
29
|
-
@current_step.setup
|
30
|
-
@current_step.run
|
32
|
+
meta_log "Workflow complete"
|
31
33
|
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
+
# Undo the steps in reverse order
|
36
|
+
def unrun
|
37
|
+
meta_log "Reversing workflow '#{@name}'"
|
38
|
+
# Reset the current step number
|
39
|
+
@current_step_num = @steps.size
|
40
|
+
# Run the steps
|
41
|
+
@steps.each do |step|
|
42
|
+
# Track the step being run
|
43
|
+
@current_step = step
|
44
|
+
# Run the step
|
45
|
+
@current_step.setup
|
46
|
+
@current_step.unrun
|
47
|
+
# Decrement the current step so that the last step is 1
|
48
|
+
@current_step_num -= 1
|
49
|
+
end
|
35
50
|
|
36
|
-
|
37
|
-
def unrun
|
38
|
-
meta_log "Reversing workflow '#{@name}'"
|
39
|
-
# Reset the current step number
|
40
|
-
@current_step_num = @steps.size
|
41
|
-
# Run the steps
|
42
|
-
@steps.each do |step|
|
43
|
-
# Track the step being run
|
44
|
-
@current_step = step
|
45
|
-
# Run the step
|
46
|
-
@current_step.setup
|
47
|
-
@current_step.unrun
|
48
|
-
# Decrement the current step so that the last step is 1
|
49
|
-
@current_step_num -= 1
|
51
|
+
meta_log "Workflow reversed"
|
50
52
|
end
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
def log message
|
57
|
-
puts " - Step ##{@current_step_num} (#{@current_step.name}): #{message}"
|
58
|
-
end
|
54
|
+
# Post a message to the terminal with some identifying information
|
55
|
+
def log message
|
56
|
+
puts " - Step ##{@current_step_num} (#{@current_step.name}): #{message}"
|
57
|
+
end
|
59
58
|
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
60
|
+
private
|
61
|
+
# Write a log message with a different prefix marker to visually
|
62
|
+
# indicate a meta-type message
|
63
|
+
def meta_log message
|
64
|
+
puts ">> #{message}"
|
65
|
+
end
|
66
|
+
end
|
67
67
|
end
|
data/lib/wrkflo/step.rb
CHANGED
@@ -1,79 +1,96 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module WRKFLO
|
2
|
+
class Step
|
3
|
+
attr_accessor :name, :raw_config, :project
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
# A hash of step aliases to their respective classes. This map determines
|
6
|
+
# the class that a given step in a project will be transformed into.
|
7
|
+
@@step_map = { }
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
class << self
|
10
|
+
# Add an alias for this class to the step map. Used by subclasses to
|
11
|
+
# register their definitions
|
12
|
+
def add_alias name
|
13
|
+
@@step_map[name.to_sym] = self
|
14
|
+
end
|
10
15
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
# Create a new instance of a Step based on the step map entry. If none
|
17
|
+
# exists, a generic Step is created.
|
18
|
+
def create name='', config={}, project=nil
|
19
|
+
@@step_map[name.to_sym].new(name, config, project) || Step.new(name, config, project)
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
|
-
# Create a new instance of a Step based on the step map entry. If none
|
19
|
-
# exists, a generic Step is created.
|
20
|
-
def create name='', config={}, project=nil
|
21
|
-
@@step_map[name.to_sym].new(name, config, project) || Step.new(name, config, project)
|
22
|
-
end
|
23
|
-
end
|
24
23
|
|
24
|
+
include Configurable
|
25
25
|
|
26
|
-
include Configurable
|
27
26
|
|
27
|
+
def initialize name, raw_config, project=nil
|
28
|
+
# The name for this step
|
29
|
+
@name = name
|
30
|
+
# The options that define this step
|
31
|
+
@raw_config = raw_config
|
32
|
+
# The project to which this step belongs
|
33
|
+
@project = project
|
34
|
+
# Generate the finalized step configuration
|
35
|
+
apply_configuration(@raw_config)
|
36
|
+
# Always validate the new configuration unless specifically told not to.
|
37
|
+
ensure_valid_configuration
|
38
|
+
# Run step-specific initialization
|
39
|
+
init
|
40
|
+
end
|
28
41
|
|
29
|
-
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
# The project to which this step belongs
|
35
|
-
@project = project
|
36
|
-
# Generate the finalized step configuration
|
37
|
-
apply_configuration(@raw_config)
|
38
|
-
# Run step-specific initialization
|
39
|
-
init
|
40
|
-
end
|
42
|
+
# A pass through to this step's project's log. If this step has no project,
|
43
|
+
# a simple puts call is used instead.
|
44
|
+
def log message
|
45
|
+
@project ? @project.log(message) : puts(message)
|
46
|
+
end
|
41
47
|
|
42
|
-
# A pass through to this step's project's log. If this step has no project,
|
43
|
-
# a simple puts call is used instead.
|
44
|
-
def log message
|
45
|
-
@project ? @project.log(message) : puts(message)
|
46
|
-
end
|
47
48
|
|
49
|
+
# STEP METHODS
|
50
|
+
#
|
51
|
+
# These methods should be defined by all Step subclasses as given by their
|
52
|
+
# descriptions.
|
48
53
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
54
|
+
# Work done immediately after initializing this step
|
55
|
+
def init; end
|
56
|
+
# Common work done before running and unrunning.
|
57
|
+
def setup; end
|
58
|
+
# The code to run when running this step normally
|
59
|
+
def run
|
60
|
+
log "Nothing to do."
|
61
|
+
end
|
62
|
+
# The code to run when running this step backwards
|
63
|
+
def unrun
|
64
|
+
log "Nothing to do."
|
65
|
+
end
|
53
66
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
# The code to run when running this step backwards
|
63
|
-
def unrun
|
64
|
-
log "Nothing to do."
|
65
|
-
end
|
67
|
+
|
68
|
+
protected
|
69
|
+
|
70
|
+
# Return true if being run on the given platform. If a block is given, run
|
71
|
+
# the block only if being run on the given platform and return the result.
|
72
|
+
def on platform
|
73
|
+
return OS.send("#{platform}?").tap{ |yn| yield yn if block_given? }
|
74
|
+
end
|
66
75
|
|
67
76
|
|
68
|
-
|
77
|
+
private
|
69
78
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
79
|
+
def ensure_valid_configuration
|
80
|
+
validate_configuration do |prop, value, reason|
|
81
|
+
prop_name = "`#{@name}.#{prop.name}`"
|
82
|
+
case reason
|
83
|
+
when :required
|
84
|
+
Notifier.error_out("required property #{prop_name} not provided for `#{@project.name}`.", type: "ConfigurationError")
|
85
|
+
when :type
|
86
|
+
Notifier.error_out(
|
87
|
+
"property #{prop_name} for `#{@project.name}` does not match expected type.",
|
88
|
+
"expected: #{prop.type_as_string}",
|
89
|
+
"got: #{prop.value_type_as_string(value)}")
|
90
|
+
else
|
91
|
+
Notifier.error_out("Unknown error", type: "ConfigurationError")
|
92
|
+
end
|
93
|
+
end
|
77
94
|
end
|
78
|
-
|
95
|
+
end
|
79
96
|
end
|
data/lib/wrkflo/steps/atom.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module WRKFLO
|
2
|
+
class AtomStep < Step
|
3
|
+
add_alias :atom
|
3
4
|
|
4
|
-
|
5
|
+
property :path, required: true, type: String
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def run
|
8
|
+
log "Opening an Atom Window at #{config.path}"
|
9
|
+
`atom #{config.path}`
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
data/lib/wrkflo/steps/editor.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module WRKFLO
|
2
|
+
class Editor < Step
|
3
|
+
add_alias :editor
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
property :which, required: false, type: String, default: Profile.options['editor']
|
6
|
+
property :path, required: true, type: String
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def init
|
9
|
+
@editor = config.which
|
10
|
+
@step = Step.create(@editor.to_sym, @raw_config, project)
|
11
|
+
@name = "editor[#{@step.name}]"
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
def run; @step.run; end
|
15
|
+
def unrun; @step.unrun; end
|
16
|
+
end
|
15
17
|
end
|
data/lib/wrkflo/steps/emacs.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module WRKFLO
|
2
|
+
class EmacsStep < Step
|
3
|
+
add_alias :emacs
|
3
4
|
|
4
|
-
|
5
|
+
property :path, required: true, type: String
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def run
|
8
|
+
log "Opening an Emacs frame at #{config.path}"
|
9
|
+
`emacsclient -c -a "" -n #{config.path}`
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
@@ -1,18 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module WRKFLO
|
2
|
+
class FileSystem < Step
|
3
|
+
add_alias :filesystem
|
4
|
+
add_alias :fs
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
property :which, required: false, type: String, default: Profile.options['filesystem']
|
7
|
+
property :host, required: true, type: String
|
8
|
+
property :remote_path, required: true, type: String
|
9
|
+
property :local_path, required: true, type: String
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
def init
|
12
|
+
@filesystem = config.which
|
13
|
+
@step = Step.create(@filesystem.to_sym, @raw_config, project)
|
14
|
+
@name = "filesystem[#{@step.name}]"
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
def run; @step.run; end
|
18
|
+
def unrun; @step.unrun; end
|
19
|
+
end
|
18
20
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module WRKFLO
|
2
|
+
class NFSStep < Step
|
3
|
+
add_alias :nfs
|
4
|
+
|
5
|
+
property :host, required: true, type: String
|
6
|
+
property :remote_path, required: true, type: String
|
7
|
+
property :local_path, required: true, type: String
|
8
|
+
|
9
|
+
def run
|
10
|
+
log "Mounting #{config.host}:#{config.remote_path} at #{config.local_path}"
|
11
|
+
`mount -t nfs #{config.host}:#{config.remote_path} #{config.local_path}`
|
12
|
+
end
|
13
|
+
|
14
|
+
def unrun
|
15
|
+
log "Unmounting #{config.host}:#{config.remote_path} from #{config.local_path}"
|
16
|
+
`umount #{config.local_path}`
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/wrkflo/steps/ssh.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module WRKFLO
|
2
|
+
class SSHStep < Step
|
3
|
+
add_alias :ssh
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
property :host, required: true, type: String
|
6
|
+
property :directory, required: true, type: String
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
def run
|
9
|
+
log "SSHing into #{config.host} at #{config.directory}"
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
ssh_command = "ssh -t #{config.host} \\\"#{config.directory}; bash --login\\\""
|
12
|
+
`osascript -e 'tell application "Terminal" to activate' -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' -e 'tell application "Terminal" to do script "#{ssh_command}" in selected tab of the front window'`
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
data/lib/wrkflo/steps/sshfs.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module WRKFLO
|
2
|
+
class SSHFSStep < Step
|
3
|
+
add_alias :sshfs
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
property :host, required: true, type: String
|
6
|
+
property :remote_path, required: true, type: String
|
7
|
+
property :local_path, required: true, type: String
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def run
|
10
|
+
log "Mounting #{config.host}:#{config.remote_path} at #{config.local_path}"
|
11
|
+
`sshfs #{config.host}:#{config.remote_path} #{config.local_path}`
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
def unrun
|
15
|
+
log "Unmounting #{config.host}:#{config.remote_path} from #{config.local_path}"
|
16
|
+
`umount #{config.local_path}`
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
data/lib/wrkflo/steps/sublime.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module WRKFLO
|
2
|
+
class SublimeStep < Step
|
3
|
+
add_alias :sublime
|
4
|
+
add_alias :subl
|
4
5
|
|
5
|
-
|
6
|
+
property :path, required: true, type: String
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def run
|
9
|
+
log "Opening a Sublime Window at #{config.path}"
|
10
|
+
`subl -n #{config.path}`
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
data/lib/wrkflo/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = '0.1.
|
1
|
+
module WRKFLO
|
2
|
+
VERSION = '0.1.1'
|
3
3
|
end
|
data/lib/wrkflo/wrkflo.rb
CHANGED
@@ -1,51 +1,51 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
class WrkFlo
|
6
|
-
attr_accessor :direction, :profile, :profile_source
|
7
|
-
|
8
|
-
DEFAULT_STEP_PATHS = [
|
9
|
-
File.join(__dir__, 'steps'),
|
10
|
-
File.join(ENV['HOME'], '.wrkflo', 'steps'),
|
11
|
-
File.join('.', '.wrkflo', 'steps')
|
12
|
-
]
|
13
|
-
|
14
|
-
def initialize options
|
15
|
-
@profile_source = options[:profile]
|
16
|
-
Profile.load(@profile_source)
|
17
|
-
load_step_definitions
|
18
|
-
@direction = options[:backward] ? :backward : :forward
|
19
|
-
end
|
1
|
+
module WRKFLO
|
2
|
+
class WrkFlo
|
3
|
+
attr_accessor :direction, :profile, :profile_source
|
20
4
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
5
|
+
DEFAULT_STEP_PATHS = [
|
6
|
+
File.join(__dir__, 'steps'),
|
7
|
+
File.join(ENV['HOME'], '.wrkflo', 'steps'),
|
8
|
+
File.join('.', '.wrkflo', 'steps')
|
9
|
+
]
|
10
|
+
|
11
|
+
def initialize options
|
12
|
+
@profile_source = options[:profile]
|
13
|
+
Profile.load(@profile_source)
|
14
|
+
load_step_definitions
|
15
|
+
@direction = options[:backward] ? :backward : :forward
|
28
16
|
end
|
29
17
|
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
Dir
|
35
|
-
|
36
|
-
|
18
|
+
# Load all step definitions from various default and configured paths.
|
19
|
+
def load_step_definitions
|
20
|
+
# For the default directories, try to scan them if they exist.
|
21
|
+
DEFAULT_STEP_PATHS.each do |path|
|
22
|
+
if Dir.exists?(path)
|
23
|
+
Dir[File.join(path, '*')].each{ |step_file| require step_file }
|
24
|
+
end
|
37
25
|
end
|
38
|
-
end
|
39
|
-
end
|
40
26
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
27
|
+
# For configured paths, try to require each entry and error out if one is
|
28
|
+
# not available.
|
29
|
+
configured_step_paths.each do |path|
|
30
|
+
if Dir.exists?(path)
|
31
|
+
Dir[File.join(path, '*')].each{ |step_file| require step_file }
|
32
|
+
else
|
33
|
+
require path
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
46
37
|
|
47
|
-
|
48
|
-
|
49
|
-
|
38
|
+
# Get a specific project out of the profile. If the profile does not define
|
39
|
+
# the given project, return nil.
|
40
|
+
def [] project
|
41
|
+
Project.new(project) if Profile.projects[project]
|
50
42
|
end
|
43
|
+
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def configured_step_paths
|
48
|
+
Profile.options['step_definitions'] || []
|
49
|
+
end
|
50
|
+
end
|
51
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wrkflo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Egeland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: os
|
@@ -60,8 +60,10 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- bin/wrkflo
|
63
|
+
- lib/wrkflo.rb
|
63
64
|
- lib/wrkflo/configurable.rb
|
64
65
|
- lib/wrkflo/configurable/property.rb
|
66
|
+
- lib/wrkflo/notifier.rb
|
65
67
|
- lib/wrkflo/profile.rb
|
66
68
|
- lib/wrkflo/project.rb
|
67
69
|
- lib/wrkflo/step.rb
|
@@ -69,6 +71,7 @@ files:
|
|
69
71
|
- lib/wrkflo/steps/editor.rb
|
70
72
|
- lib/wrkflo/steps/emacs.rb
|
71
73
|
- lib/wrkflo/steps/filesystem.rb
|
74
|
+
- lib/wrkflo/steps/nfs.rb
|
72
75
|
- lib/wrkflo/steps/ssh.rb
|
73
76
|
- lib/wrkflo/steps/sshfs.rb
|
74
77
|
- lib/wrkflo/steps/sublime.rb
|
@@ -82,7 +85,6 @@ post_install_message:
|
|
82
85
|
rdoc_options: []
|
83
86
|
require_paths:
|
84
87
|
- lib
|
85
|
-
- lib/wrkflo
|
86
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
89
|
requirements:
|
88
90
|
- - ">="
|