autowow 0.8.0 → 0.8.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.
@@ -1,27 +1,27 @@
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
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
@@ -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,87 +1,87 @@
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
+ 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
@@ -1,49 +1,56 @@
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
- def print_command_exit(cmd, status, runtime, *args)
9
- super
10
- write('')
11
- end
12
- end
13
-
14
- class PrettyWithOutput < TTY::Command::Printers::Pretty
15
- def print_command_exit(cmd, status, runtime, *args)
16
- super
17
- write('')
18
- end
19
- end
20
-
21
- class RunWrapper
22
- def initialize(tty_command)
23
- @tty_command = tty_command
24
- end
25
-
26
- def run(array)
27
- @tty_command.run(*array)
28
- end
29
-
30
- def run!(array)
31
- @tty_command.run!(*array)
32
- end
33
- end
34
-
35
- def pretty
36
- @pretty ||= RunWrapper.new(TTY::Command.new(pty: true, printer: Pretty))
37
- end
38
-
39
- def pretty_with_output
40
- @pretty_with_output ||= RunWrapper.new(TTY::Command.new(pty: true, printer: PrettyWithOutput))
41
- end
42
-
43
- def quiet
44
- @quiet ||= RunWrapper.new(TTY::Command.new(pty: true, printer: :null))
45
- end
46
-
47
- include ReflectionUtils::CreateModuleFunctions
48
- end
49
- 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("")
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
@@ -1,49 +1,49 @@
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
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