autowow 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +14 -14
- data/.rspec +2 -2
- data/.rubocop.yml +118 -116
- data/.travis.yml +11 -11
- data/Gemfile +6 -6
- data/Guardfile +22 -22
- data/LICENSE.txt +21 -21
- data/README.md +143 -139
- data/Rakefile +59 -59
- data/autowow.gemspec +41 -41
- data/bin/autowow +5 -5
- data/bin/aw +5 -5
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/lib/autowow.rb +13 -13
- data/lib/autowow/cli.rb +91 -91
- data/lib/autowow/commands/gem.rb +27 -27
- data/lib/autowow/commands/os.rb +11 -11
- data/lib/autowow/commands/rbenv.rb +19 -19
- data/lib/autowow/commands/vcs.rb +87 -87
- data/lib/autowow/decorators/string_decorator.rb +11 -11
- data/lib/autowow/executor.rb +56 -49
- data/lib/autowow/features/fs.rb +49 -49
- data/lib/autowow/features/gem.rb +48 -48
- data/lib/autowow/features/os.rb +16 -16
- data/lib/autowow/features/rbenv.rb +50 -50
- data/lib/autowow/features/vcs.rb +272 -272
- data/lib/autowow/log_formatter.rb +25 -25
- data/lib/autowow/time_difference.rb +29 -29
- data/lib/autowow/version.rb +3 -3
- metadata +3 -3
data/lib/autowow/commands/gem.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
module Autowow
|
2
|
-
module Commands
|
3
|
-
module Gem
|
4
|
-
def release
|
5
|
-
[
|
6
|
-
end
|
7
|
-
|
8
|
-
def clean
|
9
|
-
[
|
10
|
-
end
|
11
|
-
|
12
|
-
def rubocop_parallel
|
13
|
-
[
|
14
|
-
end
|
15
|
-
|
16
|
-
def rubocop_autocorrect(files)
|
17
|
-
if files.kind_of?(Array)
|
18
|
-
[
|
19
|
-
else
|
20
|
-
[
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
include ReflectionUtils::CreateModuleFunctions
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
1
|
+
module Autowow
|
2
|
+
module Commands
|
3
|
+
module Gem
|
4
|
+
def release
|
5
|
+
["rake", "release"]
|
6
|
+
end
|
7
|
+
|
8
|
+
def clean
|
9
|
+
["gem", "clean"]
|
10
|
+
end
|
11
|
+
|
12
|
+
def rubocop_parallel
|
13
|
+
["rubocop", "--parallel"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def rubocop_autocorrect(files)
|
17
|
+
if files.kind_of?(Array)
|
18
|
+
["rubocop", "--auto-correct"] + files
|
19
|
+
else
|
20
|
+
["rubocop", "--auto-correct"] + files.split(" ")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
include ReflectionUtils::CreateModuleFunctions
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/autowow/commands/os.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
module Autowow
|
2
|
-
module Commands
|
3
|
-
module Os
|
4
|
-
def which(cmd)
|
5
|
-
[
|
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
|
-
[
|
6
|
-
end
|
7
|
-
|
8
|
-
def aliases
|
9
|
-
[
|
10
|
-
end
|
11
|
-
|
12
|
-
def installed_versions
|
13
|
-
[
|
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
|
data/lib/autowow/commands/vcs.rb
CHANGED
@@ -1,87 +1,87 @@
|
|
1
|
-
module Autowow
|
2
|
-
module Commands
|
3
|
-
module Vcs
|
4
|
-
def cmd
|
5
|
-
[
|
6
|
-
end
|
7
|
-
|
8
|
-
def terminal_options
|
9
|
-
[
|
10
|
-
end
|
11
|
-
|
12
|
-
def changes_not_on_remote(branch)
|
13
|
-
cmd + terminal_options + [
|
14
|
-
end
|
15
|
-
|
16
|
-
def branch_list
|
17
|
-
cmd + [
|
18
|
-
end
|
19
|
-
|
20
|
-
def push(branch = nil, remote = nil)
|
21
|
-
cmd + [
|
22
|
-
end
|
23
|
-
|
24
|
-
def rebase(branch)
|
25
|
-
cmd + [
|
26
|
-
end
|
27
|
-
|
28
|
-
def git_status
|
29
|
-
cmd + [
|
30
|
-
end
|
31
|
-
|
32
|
-
def stash
|
33
|
-
cmd + [
|
34
|
-
end
|
35
|
-
|
36
|
-
def stash_pop
|
37
|
-
cmd + [
|
38
|
-
end
|
39
|
-
|
40
|
-
def current_branch
|
41
|
-
cmd + [
|
42
|
-
end
|
43
|
-
|
44
|
-
def checkout(existing_branch)
|
45
|
-
cmd + [
|
46
|
-
end
|
47
|
-
|
48
|
-
def pull
|
49
|
-
cmd + [
|
50
|
-
end
|
51
|
-
|
52
|
-
def branch_force_delete(branch)
|
53
|
-
cmd + [
|
54
|
-
end
|
55
|
-
|
56
|
-
def create(branch)
|
57
|
-
cmd + [
|
58
|
-
end
|
59
|
-
|
60
|
-
def set_upstream(remote, branch)
|
61
|
-
cmd + [
|
62
|
-
end
|
63
|
-
|
64
|
-
def remotes
|
65
|
-
cmd + [
|
66
|
-
end
|
67
|
-
|
68
|
-
def fetch(remote)
|
69
|
-
cmd + [
|
70
|
-
end
|
71
|
-
|
72
|
-
def merge(compare)
|
73
|
-
cmd + [
|
74
|
-
end
|
75
|
-
|
76
|
-
def branch
|
77
|
-
cmd + [
|
78
|
-
end
|
79
|
-
|
80
|
-
def add_remote(name, url)
|
81
|
-
cmd + [
|
82
|
-
end
|
83
|
-
|
84
|
-
include ReflectionUtils::CreateModuleFunctions
|
85
|
-
end
|
86
|
-
end
|
87
|
-
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 changes_not_on_remote(branch)
|
13
|
+
cmd + terminal_options + ["log", branch, "--not", "--remotes"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def branch_list
|
17
|
+
cmd + ["for-each-ref", "--format=%(refname)", "refs/heads/"]
|
18
|
+
end
|
19
|
+
|
20
|
+
def push(branch = nil, remote = nil)
|
21
|
+
cmd + ["push"] + [branch, remote].compact
|
22
|
+
end
|
23
|
+
|
24
|
+
def rebase(branch)
|
25
|
+
cmd + ["rebase", branch]
|
26
|
+
end
|
27
|
+
|
28
|
+
def git_status
|
29
|
+
cmd + ["status"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def stash
|
33
|
+
cmd + ["stash"]
|
34
|
+
end
|
35
|
+
|
36
|
+
def stash_pop
|
37
|
+
cmd + ["stash", "pop"]
|
38
|
+
end
|
39
|
+
|
40
|
+
def current_branch
|
41
|
+
cmd + ["symbolic-ref", "--short", "HEAD"]
|
42
|
+
end
|
43
|
+
|
44
|
+
def checkout(existing_branch)
|
45
|
+
cmd + ["checkout", existing_branch]
|
46
|
+
end
|
47
|
+
|
48
|
+
def pull
|
49
|
+
cmd + ["pull"]
|
50
|
+
end
|
51
|
+
|
52
|
+
def branch_force_delete(branch)
|
53
|
+
cmd + ["branch", "-D", branch]
|
54
|
+
end
|
55
|
+
|
56
|
+
def create(branch)
|
57
|
+
cmd + ["checkout", "-b", branch]
|
58
|
+
end
|
59
|
+
|
60
|
+
def set_upstream(remote, branch)
|
61
|
+
cmd + ["push", "--set-upstream", remote, branch]
|
62
|
+
end
|
63
|
+
|
64
|
+
def remotes
|
65
|
+
cmd + ["remote", "-v"]
|
66
|
+
end
|
67
|
+
|
68
|
+
def fetch(remote)
|
69
|
+
cmd + ["fetch", remote]
|
70
|
+
end
|
71
|
+
|
72
|
+
def merge(compare)
|
73
|
+
cmd + ["merge", compare]
|
74
|
+
end
|
75
|
+
|
76
|
+
def branch
|
77
|
+
cmd + ["branch"]
|
78
|
+
end
|
79
|
+
|
80
|
+
def add_remote(name, url)
|
81
|
+
cmd + ["remote", "add", name, url]
|
82
|
+
end
|
83
|
+
|
84
|
+
include ReflectionUtils::CreateModuleFunctions
|
85
|
+
end
|
86
|
+
end
|
87
|
+
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
|
data/lib/autowow/executor.rb
CHANGED
@@ -1,49 +1,56 @@
|
|
1
|
-
require
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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("")
|
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("")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class RunWrapper
|
23
|
+
def initialize(tty_command, fail_silently: false)
|
24
|
+
@tty_command = tty_command
|
25
|
+
@fail_silently = fail_silently
|
26
|
+
end
|
27
|
+
|
28
|
+
def run(array)
|
29
|
+
begin
|
30
|
+
@tty_command.run(*array)
|
31
|
+
rescue TTY::Command::ExitError => e
|
32
|
+
raise e unless @fail_silently
|
33
|
+
exit 1
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def run!(array)
|
38
|
+
@tty_command.run!(*array)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def pretty
|
43
|
+
@pretty ||= RunWrapper.new(TTY::Command.new(pty: true, printer: Pretty))
|
44
|
+
end
|
45
|
+
|
46
|
+
def pretty_with_output
|
47
|
+
@pretty_with_output ||= RunWrapper.new(TTY::Command.new(pty: true, printer: PrettyWithOutput), fail_silently: true)
|
48
|
+
end
|
49
|
+
|
50
|
+
def quiet
|
51
|
+
@quiet ||= RunWrapper.new(TTY::Command.new(pty: true, printer: :null))
|
52
|
+
end
|
53
|
+
|
54
|
+
include ReflectionUtils::CreateModuleFunctions
|
55
|
+
end
|
56
|
+
end
|
data/lib/autowow/features/fs.rb
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
require_relative
|
2
|
-
|
3
|
-
module Autowow
|
4
|
-
module Features
|
5
|
-
module Fs
|
6
|
-
using RefinedTimeDifference
|
7
|
-
|
8
|
-
def ls_dirs
|
9
|
-
Dir.glob(File.expand_path(
|
10
|
-
end
|
11
|
-
|
12
|
-
def latest(files)
|
13
|
-
files.sort_by { |f| File.mtime(f) }.reverse!.first
|
14
|
-
end
|
15
|
-
|
16
|
-
def older_than(files, quantity, unit)
|
17
|
-
files.select do |dir|
|
18
|
-
TimeDifference.between(File.mtime(dir), Time.now).public_send("in_#{unit}") > quantity
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def for_dirs(dirs)
|
23
|
-
dirs.each do |working_dir|
|
24
|
-
# TODO: add handling of directories via extra param to popen3
|
25
|
-
# https://stackoverflow.com/a/10148084/2771889
|
26
|
-
Dir.chdir(working_dir) do
|
27
|
-
yield working_dir
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def in_place_or_subdirs(in_place)
|
33
|
-
if in_place
|
34
|
-
yield
|
35
|
-
else
|
36
|
-
for_dirs(ls_dirs) do
|
37
|
-
yield
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def git_folder_present
|
43
|
-
File.exist?(
|
44
|
-
end
|
45
|
-
|
46
|
-
include ReflectionUtils::CreateModuleFunctions
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
1
|
+
require_relative "../time_difference"
|
2
|
+
|
3
|
+
module Autowow
|
4
|
+
module Features
|
5
|
+
module Fs
|
6
|
+
using RefinedTimeDifference
|
7
|
+
|
8
|
+
def ls_dirs
|
9
|
+
Dir.glob(File.expand_path("./*/")).select { |f| File.directory? f }
|
10
|
+
end
|
11
|
+
|
12
|
+
def latest(files)
|
13
|
+
files.sort_by { |f| File.mtime(f) }.reverse!.first
|
14
|
+
end
|
15
|
+
|
16
|
+
def older_than(files, quantity, unit)
|
17
|
+
files.select do |dir|
|
18
|
+
TimeDifference.between(File.mtime(dir), Time.now).public_send("in_#{unit}") > quantity
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def for_dirs(dirs)
|
23
|
+
dirs.each do |working_dir|
|
24
|
+
# TODO: add handling of directories via extra param to popen3
|
25
|
+
# https://stackoverflow.com/a/10148084/2771889
|
26
|
+
Dir.chdir(working_dir) do
|
27
|
+
yield working_dir
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def in_place_or_subdirs(in_place)
|
33
|
+
if in_place
|
34
|
+
yield
|
35
|
+
else
|
36
|
+
for_dirs(ls_dirs) do
|
37
|
+
yield
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def git_folder_present
|
43
|
+
File.exist?(".git")
|
44
|
+
end
|
45
|
+
|
46
|
+
include ReflectionUtils::CreateModuleFunctions
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|