divide 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/bin/divide +1 -1
- data/lib/divide/cli.rb +28 -4
- data/lib/divide/extractor.rb +7 -6
- data/lib/divide/terminal_bridge.rb +3 -2
- data/lib/divide/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a512929f2f51c821651729499f439bcadda9fcfd
|
4
|
+
data.tar.gz: 7d08b96c59baca380ed17ae956003679fcfbd1d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1ce6bd4737fb526789730cbd9693917149c8878714a37f4c794a004c8ac364894aefc5af85f6725e4dfebe778af22bfb44092dd37b704b6f1f3c8e692db97a5
|
7
|
+
data.tar.gz: 3aa4ee48ea7f797dc79b399988710558ad2c429d275b1a60fa60a676b8b47e263822f405f19ca31914bd4c1d2b774d75d6c0585140c9aaee8a53e891916d5e07
|
data/README.md
CHANGED
data/bin/divide
CHANGED
data/lib/divide/cli.rb
CHANGED
@@ -1,12 +1,36 @@
|
|
1
1
|
module Divide
|
2
2
|
class CLI
|
3
3
|
attr_reader :options, :flags
|
4
|
-
OPTIONS = %w(--tabs)
|
4
|
+
OPTIONS = %w(--tabs? --no-new-tab? --from)
|
5
5
|
|
6
6
|
def initialize(argv=[])
|
7
7
|
@options = {}
|
8
|
-
OPTIONS.each
|
9
|
-
|
8
|
+
OPTIONS.each do |option|
|
9
|
+
is_boolean = option =~ /\?$/
|
10
|
+
option_name = option.sub('--', '')
|
11
|
+
|
12
|
+
if is_boolean
|
13
|
+
option.sub!(/\?$/, '')
|
14
|
+
option_name.sub!(/\?$/, '')
|
15
|
+
|
16
|
+
@options[option_name.to_sym] = argv.include?(option)
|
17
|
+
argv.delete(option)
|
18
|
+
elsif argv.include?(option)
|
19
|
+
value_index = argv.index(option) + 1
|
20
|
+
|
21
|
+
@options[option_name.to_sym] = argv[value_index]
|
22
|
+
argv.delete_at(value_index)
|
23
|
+
argv.delete(option)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if from = @options[:from]
|
28
|
+
@options[:from] = "#{Dir.pwd}/#{from}"
|
29
|
+
else
|
30
|
+
@options[:from] = Dir.pwd
|
31
|
+
end
|
32
|
+
|
33
|
+
@flags = (argv).each_slice(2).to_a
|
10
34
|
|
11
35
|
show_version if argv.grep(/^-v|--version$/).any?
|
12
36
|
show_help if argv.grep(/^-h|--help$/).any?
|
@@ -69,7 +93,7 @@ module Divide
|
|
69
93
|
end
|
70
94
|
|
71
95
|
def extractor
|
72
|
-
@extractor ||= Extractor.new(@flags)
|
96
|
+
@extractor ||= Extractor.new(@flags, @options)
|
73
97
|
end
|
74
98
|
end
|
75
99
|
end
|
data/lib/divide/extractor.rb
CHANGED
@@ -4,24 +4,25 @@ module Divide
|
|
4
4
|
class Extractor
|
5
5
|
DEFAULT_ENV = { 'PORT' => '5000' }.merge(ENV)
|
6
6
|
|
7
|
-
def initialize(
|
7
|
+
def initialize(flags = [], options = {})
|
8
|
+
@flags = flags
|
8
9
|
@options = options
|
9
10
|
|
10
11
|
overwrite_env_variables
|
11
|
-
|
12
|
+
overwrite_flags
|
12
13
|
escape_double_quotes
|
13
14
|
end
|
14
15
|
|
15
16
|
def procfile_content
|
16
|
-
@procfile_content ||= File.read(
|
17
|
+
@procfile_content ||= File.read("#{@options[:from]}/Procfile") rescue ''
|
17
18
|
end
|
18
19
|
|
19
20
|
def env_content
|
20
|
-
@env_content ||= File.read(
|
21
|
+
@env_content ||= File.read("#{@options[:from]}/.env") rescue ''
|
21
22
|
end
|
22
23
|
|
23
|
-
def
|
24
|
-
@
|
24
|
+
def overwrite_flags
|
25
|
+
@flags.each do |option|
|
25
26
|
next if option.length < 2
|
26
27
|
|
27
28
|
key = option[0]
|
@@ -35,7 +35,7 @@ module Divide
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def go_to_current_directory
|
38
|
-
do_script "cd #{
|
38
|
+
do_script "cd #{@options[:from]}"
|
39
39
|
end
|
40
40
|
|
41
41
|
def keystroke(key)
|
@@ -62,7 +62,8 @@ module Divide
|
|
62
62
|
|
63
63
|
scripts = commands.map { |c| do_script(c) }
|
64
64
|
scripts_with_new_tabs = insert_between(scripts, open_new_tab_in_current_directory).flatten
|
65
|
-
scripts_with_new_tabs
|
65
|
+
scripts_with_new_tabs.unshift(open_new_tab_in_current_directory) unless @options[:from] == Dir.pwd
|
66
|
+
scripts_with_new_tabs.push(open_new_tab_in_current_directory) unless @options[:'no-new-tab']
|
66
67
|
|
67
68
|
bridge.apple_script(scripts_with_new_tabs)
|
68
69
|
end
|
data/lib/divide/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: divide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Etienne Lemay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|