autowow 0.14.2 → 0.15.0

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.
@@ -1,23 +1,23 @@
1
- module Autowow
2
- module Commands
3
- module Heroku
4
- def cmd
5
- ["heroku"]
6
- end
7
-
8
- def info
9
- cmd + ["info"]
10
- end
11
-
12
- def pb_reset(app_name)
13
- cmd + ["pg:reset", "DATABASE_URL", "--app", app_name, "--confirm", app_name]
14
- end
15
-
16
- def migrate(app_name)
17
- cmd + ["run", "rake", "db:migrate", "--app", app_name]
18
- end
19
-
20
- include ReflectionUtils::CreateModuleFunctions
21
- end
22
- end
23
- end
1
+ module Autowow
2
+ module Commands
3
+ module Heroku
4
+ def cmd
5
+ ["heroku"]
6
+ end
7
+
8
+ def info
9
+ cmd + ["info"]
10
+ end
11
+
12
+ def pb_reset(app_name)
13
+ cmd + ["pg:reset", "DATABASE_URL", "--app", app_name, "--confirm", app_name]
14
+ end
15
+
16
+ def migrate(app_name)
17
+ cmd + ["run", "rake", "db:migrate", "--app", app_name]
18
+ end
19
+
20
+ include ReflectionUtils::CreateModuleFunctions
21
+ end
22
+ end
23
+ end
@@ -1,11 +1,11 @@
1
- module Autowow
2
- module Commands
3
- module Os
4
- def which(cmd)
5
- ["which", cmd]
6
- end
7
-
8
- include ReflectionUtils::CreateModuleFunctions
9
- end
10
- end
11
- end
1
+ module Autowow
2
+ module Commands
3
+ module Os
4
+ def which(cmd)
5
+ ["which", cmd]
6
+ end
7
+
8
+ include ReflectionUtils::CreateModuleFunctions
9
+ end
10
+ end
11
+ end
@@ -1,19 +1,19 @@
1
- module Autowow
2
- module Commands
3
- module Rbenv
4
- def version
5
- ["rbenv", "local"]
6
- end
7
-
8
- def aliases
9
- ["rbenv", "alias"]
10
- end
11
-
12
- def installed_versions
13
- ["rbenv", "versions", "--bare", "--skip-aliases"]
14
- end
15
-
16
- include ReflectionUtils::CreateModuleFunctions
17
- end
18
- end
19
- end
1
+ module Autowow
2
+ module Commands
3
+ module Rbenv
4
+ def version
5
+ ["rbenv", "local"]
6
+ end
7
+
8
+ def aliases
9
+ ["rbenv", "alias"]
10
+ end
11
+
12
+ def installed_versions
13
+ ["rbenv", "versions", "--bare", "--skip-aliases"]
14
+ end
15
+
16
+ include ReflectionUtils::CreateModuleFunctions
17
+ end
18
+ end
19
+ end
@@ -1,104 +1,104 @@
1
- module Autowow
2
- module Commands
3
- module Vcs
4
- def cmd
5
- ["git"]
6
- end
7
-
8
- def terminal_options
9
- ["--no-pager"]
10
- end
11
-
12
- def commit (msg)
13
- cmd + ["commit", "-m", msg]
14
- end
15
-
16
- def changes_not_on_remote(branch)
17
- cmd + terminal_options + ["log", branch, "--not", "--remotes"]
18
- end
19
-
20
- def branch_list
21
- cmd + ["for-each-ref", "--format=%(refname)", "refs/heads/"]
22
- end
23
-
24
- def push(branch = nil, remote = nil)
25
- cmd + ["push"] + [branch, remote].compact
26
- end
27
-
28
- def rebase(branch)
29
- cmd + ["rebase", branch]
30
- end
31
-
32
- def git_status
33
- cmd + ["status"]
34
- end
35
-
36
- def stash
37
- cmd + ["stash"]
38
- end
39
-
40
- def stash_pop
41
- cmd + ["stash", "pop"]
42
- end
43
-
44
- def current_branch
45
- cmd + ["symbolic-ref", "--short", "HEAD"]
46
- end
47
-
48
- def checkout(existing_branch)
49
- cmd + ["checkout", existing_branch]
50
- end
51
-
52
- def pull
53
- cmd + ["pull"]
54
- end
55
-
56
- def branch_force_delete(branch)
57
- cmd + ["branch", "-D", branch]
58
- end
59
-
60
- def create(branch)
61
- cmd + ["checkout", "-b", branch]
62
- end
63
-
64
- def set_upstream(remote, branch)
65
- cmd + ["push", "--set-upstream", remote, branch]
66
- end
67
-
68
- def remotes
69
- cmd + ["remote", "-v"]
70
- end
71
-
72
- def fetch(remote)
73
- cmd + ["fetch", remote]
74
- end
75
-
76
- def merge(compare)
77
- cmd + ["merge", compare]
78
- end
79
-
80
- def branch
81
- cmd + ["branch"]
82
- end
83
-
84
- def add_remote(name, url)
85
- cmd + ["remote", "add", name, url]
86
- end
87
-
88
- def add(patterns)
89
- cmd + ["add"] + patterns
90
- end
91
-
92
- def hard_reset(branch)
93
- cmd + ["reset", "--hard", branch]
94
- end
95
-
96
- # Doesn't work on Windows
97
- def current_branch_remote
98
- cmd + ["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"]
99
- end
100
-
101
- include ReflectionUtils::CreateModuleFunctions
102
- end
103
- end
104
- end
1
+ module Autowow
2
+ module Commands
3
+ module Vcs
4
+ def cmd
5
+ ["git"]
6
+ end
7
+
8
+ def terminal_options
9
+ ["--no-pager"]
10
+ end
11
+
12
+ def commit (msg)
13
+ cmd + ["commit", "-m", msg]
14
+ end
15
+
16
+ def changes_not_on_remote(branch)
17
+ cmd + terminal_options + ["log", branch, "--not", "--remotes"]
18
+ end
19
+
20
+ def branch_list
21
+ cmd + ["for-each-ref", "--format=%(refname)", "refs/heads/"]
22
+ end
23
+
24
+ def push(branch = nil, remote = nil)
25
+ cmd + ["push"] + [branch, remote].compact
26
+ end
27
+
28
+ def rebase(branch)
29
+ cmd + ["rebase", branch]
30
+ end
31
+
32
+ def git_status
33
+ cmd + ["status"]
34
+ end
35
+
36
+ def stash
37
+ cmd + ["stash"]
38
+ end
39
+
40
+ def stash_pop
41
+ cmd + ["stash", "pop"]
42
+ end
43
+
44
+ def current_branch
45
+ cmd + ["symbolic-ref", "--short", "HEAD"]
46
+ end
47
+
48
+ def checkout(existing_branch)
49
+ cmd + ["checkout", existing_branch]
50
+ end
51
+
52
+ def pull
53
+ cmd + ["pull"]
54
+ end
55
+
56
+ def branch_force_delete(branch)
57
+ cmd + ["branch", "-D", branch]
58
+ end
59
+
60
+ def create(branch)
61
+ cmd + ["checkout", "-b", branch]
62
+ end
63
+
64
+ def set_upstream(remote, branch)
65
+ cmd + ["push", "--set-upstream", remote, branch]
66
+ end
67
+
68
+ def remotes
69
+ cmd + ["remote", "-v"]
70
+ end
71
+
72
+ def fetch(remote)
73
+ cmd + ["fetch", remote]
74
+ end
75
+
76
+ def merge(compare)
77
+ cmd + ["merge", compare]
78
+ end
79
+
80
+ def branch
81
+ cmd + ["branch"]
82
+ end
83
+
84
+ def add_remote(name, url)
85
+ cmd + ["remote", "add", name, url]
86
+ end
87
+
88
+ def add(patterns)
89
+ cmd + ["add"] + patterns
90
+ end
91
+
92
+ def hard_reset(branch)
93
+ cmd + ["reset", "--hard", branch]
94
+ end
95
+
96
+ # Doesn't work on Windows
97
+ def current_branch_remote
98
+ cmd + ["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"]
99
+ end
100
+
101
+ include ReflectionUtils::CreateModuleFunctions
102
+ end
103
+ end
104
+ end
@@ -1,11 +1,11 @@
1
- module StringDecorator
2
- class ::String
3
- def reverse_chomp(str)
4
- reverse.chomp(str.reverse).reverse
5
- end
6
-
7
- def clean_lines
8
- each_line.map(&:strip).reject(&:empty?)
9
- end
10
- end
11
- end
1
+ module StringDecorator
2
+ class ::String
3
+ def reverse_chomp(str)
4
+ reverse.chomp(str.reverse).reverse
5
+ end
6
+
7
+ def clean_lines
8
+ each_line.map(&:strip).reject(&:empty?)
9
+ end
10
+ end
11
+ end
@@ -1,100 +1,100 @@
1
- require "tty-command"
2
-
3
- module Autowow
4
- module Executor
5
- class Pretty < TTY::Command::Printers::Pretty
6
- def print_command_out_data(cmd, *args); end
7
- def print_command_err_data(cmd, *args); end
8
-
9
- def print_command_exit(cmd, status, runtime, *args)
10
- super
11
- write(TTY::Command::Cmd.new("dummy"), "")
12
- end
13
- end
14
-
15
- class PrettyWithOutput < TTY::Command::Printers::Pretty
16
- def print_command_exit(cmd, status, runtime, *args)
17
- super
18
- write(TTY::Command::Cmd.new("dummy"), "")
19
- end
20
- end
21
-
22
- class BufferingPretty < TTY::Command::Printers::Pretty
23
- def initialize(*)
24
- super
25
- @out = ""
26
- end
27
-
28
- def print_command_out_data(cmd, *args)
29
- @out << args.join(" ")
30
- return unless multiple_lines?(@out)
31
- finished_lines(@out).each { |line| write(cmd, line) }
32
- @out = unfinished_line(@out)
33
- end
34
- alias_method :print_command_err_data, :print_command_out_data
35
-
36
- def print_command_exit(cmd, status, runtime, *args)
37
- @out.each_line.map(&:chomp).each { |line| write(cmd, line) }
38
- super
39
- write(TTY::Command::Cmd.new("dummy"), "", false)
40
- end
41
-
42
- def write(cmd, message, uuid_needed = true)
43
- out = []
44
- out << "[#{decorate(cmd.uuid, :green)}] " if uuid_needed && !cmd.uuid.nil?
45
- out << "#{message}\n"
46
- output << out.join
47
- end
48
-
49
- def finished_lines(string)
50
- string.each_line.to_a[0..-2].map(&:chomp)
51
- end
52
-
53
- def unfinished_line(string)
54
- string.each_line.to_a[-1]
55
- end
56
-
57
- def multiple_lines?(string)
58
- string.each_line.count > 1
59
- end
60
- end
61
-
62
- class RunWrapper
63
- def initialize(tty_command, fail_silently: false)
64
- @tty_command = tty_command
65
- @fail_silently = fail_silently
66
- end
67
-
68
- def run(array)
69
- begin
70
- @tty_command.run(*array)
71
- rescue TTY::Command::ExitError => e
72
- raise e unless @fail_silently
73
- exit 1
74
- end
75
- end
76
-
77
- def run!(array)
78
- @tty_command.run!(*array)
79
- end
80
- end
81
-
82
- def pretty
83
- @pretty ||= RunWrapper.new(TTY::Command.new(tty_params.merge(printer: Pretty)))
84
- end
85
-
86
- def pretty_with_output
87
- @pretty_with_output ||= RunWrapper.new(TTY::Command.new(tty_params.merge(printer: BufferingPretty)), fail_silently: true)
88
- end
89
-
90
- def quiet
91
- @quiet ||= RunWrapper.new(TTY::Command.new(tty_params.merge(printer: :null)))
92
- end
93
-
94
- def tty_params
95
- { pty: true, verbose: false }
96
- end
97
-
98
- include ReflectionUtils::CreateModuleFunctions
99
- end
100
- end
1
+ require "tty-command"
2
+
3
+ module Autowow
4
+ module Executor
5
+ class Pretty < TTY::Command::Printers::Pretty
6
+ def print_command_out_data(cmd, *args); end
7
+ def print_command_err_data(cmd, *args); end
8
+
9
+ def print_command_exit(cmd, status, runtime, *args)
10
+ super
11
+ write(TTY::Command::Cmd.new("dummy"), "")
12
+ end
13
+ end
14
+
15
+ class PrettyWithOutput < TTY::Command::Printers::Pretty
16
+ def print_command_exit(cmd, status, runtime, *args)
17
+ super
18
+ write(TTY::Command::Cmd.new("dummy"), "")
19
+ end
20
+ end
21
+
22
+ class BufferingPretty < TTY::Command::Printers::Pretty
23
+ def initialize(*)
24
+ super
25
+ @out = ""
26
+ end
27
+
28
+ def print_command_out_data(cmd, *args)
29
+ @out << args.join(" ")
30
+ return unless multiple_lines?(@out)
31
+ finished_lines(@out).each { |line| write(cmd, line) }
32
+ @out = unfinished_line(@out)
33
+ end
34
+ alias_method :print_command_err_data, :print_command_out_data
35
+
36
+ def print_command_exit(cmd, status, runtime, *args)
37
+ @out.each_line.map(&:chomp).each { |line| write(cmd, line) }
38
+ super
39
+ write(TTY::Command::Cmd.new("dummy"), "", false)
40
+ end
41
+
42
+ def write(cmd, message, uuid_needed = true)
43
+ out = []
44
+ out << "[#{decorate(cmd.uuid, :green)}] " if uuid_needed && !cmd.uuid.nil?
45
+ out << "#{message}\n"
46
+ output << out.join
47
+ end
48
+
49
+ def finished_lines(string)
50
+ string.each_line.to_a[0..-2].map(&:chomp)
51
+ end
52
+
53
+ def unfinished_line(string)
54
+ string.each_line.to_a[-1]
55
+ end
56
+
57
+ def multiple_lines?(string)
58
+ string.each_line.count > 1
59
+ end
60
+ end
61
+
62
+ class RunWrapper
63
+ def initialize(tty_command, fail_silently: false)
64
+ @tty_command = tty_command
65
+ @fail_silently = fail_silently
66
+ end
67
+
68
+ def run(array)
69
+ begin
70
+ @tty_command.run(*array)
71
+ rescue TTY::Command::ExitError => e
72
+ raise e unless @fail_silently
73
+ exit 1
74
+ end
75
+ end
76
+
77
+ def run!(array)
78
+ @tty_command.run!(*array)
79
+ end
80
+ end
81
+
82
+ def pretty
83
+ @pretty ||= RunWrapper.new(TTY::Command.new(tty_params.merge(printer: Pretty)))
84
+ end
85
+
86
+ def pretty_with_output
87
+ @pretty_with_output ||= RunWrapper.new(TTY::Command.new(tty_params.merge(printer: BufferingPretty)), fail_silently: true)
88
+ end
89
+
90
+ def quiet
91
+ @quiet ||= RunWrapper.new(TTY::Command.new(tty_params.merge(printer: :null)))
92
+ end
93
+
94
+ def tty_params
95
+ { pty: true, verbose: false }
96
+ end
97
+
98
+ include ReflectionUtils::CreateModuleFunctions
99
+ end
100
+ end