workon 0.0.12 → 0.0.13
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/.gitignore +2 -0
- data/lib/workon.rb +1 -3
- data/lib/workon/actor.rb +1 -1
- data/lib/workon/actor/base.rb +11 -5
- data/lib/workon/actor/editor.rb +10 -0
- data/lib/workon/actor/finder.rb +1 -1
- data/lib/workon/actor/web_browser.rb +3 -2
- data/lib/workon/cli.rb +5 -0
- data/lib/workon/cli/commands.rb +5 -19
- data/lib/workon/configuration.rb +5 -1
- data/lib/workon/version.rb +1 -1
- metadata +3 -3
- data/lib/workon/actor/text_mate.rb +0 -9
data/.gitignore
CHANGED
data/lib/workon.rb
CHANGED
@@ -5,7 +5,7 @@ require 'workon/actor'
|
|
5
5
|
require "workon/version"
|
6
6
|
|
7
7
|
module Workon
|
8
|
-
WORK_DIRS = '/
|
8
|
+
WORK_DIRS = (ENV['WORKON_ROOT'] || ENV['HOME'] + '/Work') + '/*/*'
|
9
9
|
|
10
10
|
def self.all_directories
|
11
11
|
@_all_directories ||= Dir[WORK_DIRS]
|
@@ -38,8 +38,6 @@ module Workon
|
|
38
38
|
Workon::Actor.ordered.each do |klass|
|
39
39
|
klass.new(project_path).commit
|
40
40
|
end
|
41
|
-
|
42
|
-
Workon::CLI::Commands::InstallHelper.helper_message(project_path)
|
43
41
|
end
|
44
42
|
|
45
43
|
def self.load_configuration(args)
|
data/lib/workon/actor.rb
CHANGED
data/lib/workon/actor/base.rb
CHANGED
@@ -52,19 +52,19 @@ module Workon
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def commit
|
55
|
-
run command
|
55
|
+
run command unless command.nil? || command.empty?
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
58
|
+
def run(command)
|
59
59
|
puts "Running #{command}"
|
60
|
-
Kernel.system command
|
60
|
+
Kernel.system command unless options[:dry_run]
|
61
61
|
end
|
62
62
|
|
63
63
|
def has_command?(command)
|
64
|
-
!`command -v #{command}`.empty?
|
64
|
+
!`command -v '#{command}'`.empty?
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
67
|
+
def capture(command)
|
68
68
|
puts "Running #{command}"
|
69
69
|
output = %x(#{command}) unless options[:dry_run]
|
70
70
|
return output
|
@@ -116,6 +116,12 @@ module Workon
|
|
116
116
|
def tmux_window
|
117
117
|
self.class.actor_name.downcase
|
118
118
|
end
|
119
|
+
|
120
|
+
def open_with_default(thing)
|
121
|
+
$open_command ||= has_command?('xdg-open') ? 'xdg-open' : 'open'
|
122
|
+
|
123
|
+
"#{$open_command} #{thing}"
|
124
|
+
end
|
119
125
|
end
|
120
126
|
end
|
121
127
|
end
|
data/lib/workon/actor/finder.rb
CHANGED
@@ -8,8 +8,9 @@ module Workon
|
|
8
8
|
host_name = fetch_option :host, %{#{project}.local}
|
9
9
|
port_number = fetch_option :port, nil
|
10
10
|
|
11
|
-
command, qualified
|
12
|
-
|
11
|
+
command, qualified = port_number.nil? ? ping_test(host_name) : netstat_test(port_number)
|
12
|
+
opener = open_with_default "http://#{qualified}"
|
13
|
+
%(#{command} && #{opener})
|
13
14
|
end
|
14
15
|
|
15
16
|
private
|
data/lib/workon/cli.rb
CHANGED
data/lib/workon/cli/commands.rb
CHANGED
@@ -30,35 +30,21 @@ module Workon
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.finder
|
33
|
-
"# Created by workon
|
33
|
+
"# Created by workon\n"
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.installed?
|
37
37
|
!(File.read(bash_profile_path) =~ /#{finder}/).nil?
|
38
38
|
end
|
39
39
|
|
40
|
-
def self.helper_message(path)
|
41
|
-
lines = [ "This is for the bash helper function",
|
42
|
-
"cd #{path}" ]
|
43
|
-
|
44
|
-
lines.each {|l| puts l } if installed?
|
45
|
-
end
|
46
|
-
|
47
40
|
def self.helper_function
|
48
41
|
<<'BASH'
|
49
42
|
wo () {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
workon_bin=$(which workon)
|
54
|
-
output=$($workon_bin $@)
|
55
|
-
|
56
|
-
for line in $output; do
|
57
|
-
echo $line
|
58
|
-
done
|
43
|
+
PROJECT=${!#}
|
44
|
+
PROJECT_PATH=$(workon -P ${PROJECT})
|
59
45
|
|
60
|
-
|
61
|
-
|
46
|
+
workon $@
|
47
|
+
eval "cd $PROJECT_PATH"
|
62
48
|
}
|
63
49
|
BASH
|
64
50
|
end
|
data/lib/workon/configuration.rb
CHANGED
@@ -11,7 +11,7 @@ module Workon
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def initialize(*args)
|
14
|
-
@options = { without: [], only: [], install_helper: false, dump_configuration: false, project: nil, show_help: false }
|
14
|
+
@options = { show_project: false, without: [], only: [], install_helper: false, dump_configuration: false, project: nil, show_help: false }
|
15
15
|
parse_options args.first unless args.empty?
|
16
16
|
end
|
17
17
|
|
@@ -68,6 +68,10 @@ module Workon
|
|
68
68
|
options[:install_helper] = true
|
69
69
|
end
|
70
70
|
|
71
|
+
o.on_tail('-P', '--show-project', TrueClass, "Echo project's directory") do
|
72
|
+
options[:show_project] = true
|
73
|
+
end
|
74
|
+
|
71
75
|
o.on_tail('-n', '--dry-run', 'Do not run any commands') do
|
72
76
|
options[:dry_run] = true
|
73
77
|
end
|
data/lib/workon/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: workon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.13
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mike Wyatt
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-29 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: Runs actions based on directories
|
@@ -31,11 +31,11 @@ files:
|
|
31
31
|
- lib/workon.rb
|
32
32
|
- lib/workon/actor.rb
|
33
33
|
- lib/workon/actor/base.rb
|
34
|
+
- lib/workon/actor/editor.rb
|
34
35
|
- lib/workon/actor/finder.rb
|
35
36
|
- lib/workon/actor/git.rb
|
36
37
|
- lib/workon/actor/middleman.rb
|
37
38
|
- lib/workon/actor/passenger.rb
|
38
|
-
- lib/workon/actor/text_mate.rb
|
39
39
|
- lib/workon/actor/watchr.rb
|
40
40
|
- lib/workon/actor/web_browser.rb
|
41
41
|
- lib/workon/cli.rb
|