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.
- checksums.yaml +4 -4
- data/.gitignore +14 -14
- data/.rspec +2 -2
- data/.rubocop.yml +118 -118
- data/.travis.yml +11 -11
- data/Gemfile +6 -6
- data/Guardfile +22 -22
- data/LICENSE.txt +21 -21
- data/README.md +7 -1
- data/Rakefile +59 -59
- data/autowow.gemspec +42 -42
- 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 +133 -128
- data/lib/autowow/commands/gem.rb +58 -54
- data/lib/autowow/commands/heroku.rb +23 -23
- data/lib/autowow/commands/os.rb +11 -11
- data/lib/autowow/commands/rbenv.rb +19 -19
- data/lib/autowow/commands/vcs.rb +104 -104
- data/lib/autowow/decorators/string_decorator.rb +11 -11
- data/lib/autowow/executor.rb +100 -100
- data/lib/autowow/features/fs.rb +49 -49
- data/lib/autowow/features/gem.rb +8 -1
- data/lib/autowow/features/heroku.rb +21 -21
- data/lib/autowow/features/os.rb +16 -16
- data/lib/autowow/features/rbenv.rb +50 -50
- data/lib/autowow/features/vcs.rb +0 -0
- data/lib/autowow/log_formatter.rb +25 -25
- data/lib/autowow/time_difference.rb +29 -29
- data/lib/autowow/version.rb +1 -1
- metadata +3 -4
data/lib/autowow/features/fs.rb
CHANGED
@@ -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
|
data/lib/autowow/features/gem.rb
CHANGED
@@ -17,13 +17,14 @@ module Autowow
|
|
17
17
|
return
|
18
18
|
end
|
19
19
|
pretty_with_output.run(git_status)
|
20
|
+
pretty_with_output.run(bundle_install)
|
20
21
|
start_branch = Vcs.working_branch
|
21
22
|
logger.error("Not on master.") and return unless start_branch.eql?("master")
|
22
23
|
pretty.run(pull)
|
23
24
|
version = nil
|
24
25
|
|
25
26
|
if version_bump
|
26
|
-
version = pretty_with_output.run(bump(version_bump)).out.clean_lines.select { |line| line.match(/Bumping|bump/) }.first.split(" ").last
|
27
|
+
version = pretty_with_output.run(bump(version_bump)).out.clean_lines.select { |line| line.match(/Bumping|bump/) }.first.split("to ").last
|
27
28
|
bump_readme_version_information(version)
|
28
29
|
# Full command is needed because of faulty escaping otherwise
|
29
30
|
pretty.run("git add README.md *version.rb")
|
@@ -73,6 +74,12 @@ module Autowow
|
|
73
74
|
Autowow::Executor.pretty_with_output.run(["bundle", "exec"] + cmd)
|
74
75
|
end
|
75
76
|
|
77
|
+
def ruby_check
|
78
|
+
rubocop_parallel_autocorrect
|
79
|
+
bundle_exec(["rspec"])
|
80
|
+
pretty_with_output.run(git_status)
|
81
|
+
end
|
82
|
+
|
76
83
|
def db_migrate
|
77
84
|
pretty_with_output.run(rake_db_migrate)
|
78
85
|
end
|
@@ -1,21 +1,21 @@
|
|
1
|
-
require_relative "../commands/heroku"
|
2
|
-
|
3
|
-
module Autowow
|
4
|
-
module Features
|
5
|
-
module Gem
|
6
|
-
include Commands::Heroku
|
7
|
-
include Executor
|
8
|
-
|
9
|
-
def app_name
|
10
|
-
quiet.run(info).out.clean_lines.select { |line| line.start_with?("===") }.first.split(" ").last
|
11
|
-
end
|
12
|
-
|
13
|
-
def db_migrate
|
14
|
-
current_app_name = app_name
|
15
|
-
|
16
|
-
pretty_with_output.run(pb_reset(current_app_name))
|
17
|
-
pretty_with_output.run(migrate(current_app_name))
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
require_relative "../commands/heroku"
|
2
|
+
|
3
|
+
module Autowow
|
4
|
+
module Features
|
5
|
+
module Gem
|
6
|
+
include Commands::Heroku
|
7
|
+
include Executor
|
8
|
+
|
9
|
+
def app_name
|
10
|
+
quiet.run(info).out.clean_lines.select { |line| line.start_with?("===") }.first.split(" ").last
|
11
|
+
end
|
12
|
+
|
13
|
+
def db_migrate
|
14
|
+
current_app_name = app_name
|
15
|
+
|
16
|
+
pretty_with_output.run(pb_reset(current_app_name))
|
17
|
+
pretty_with_output.run(migrate(current_app_name))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/autowow/features/os.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require_relative "../commands/os"
|
2
|
-
|
3
|
-
module Autowow
|
4
|
-
module Features
|
5
|
-
module Os
|
6
|
-
include Commands::Os
|
7
|
-
include Executor
|
8
|
-
|
9
|
-
def exists?(cmd)
|
10
|
-
quiet.run!(which(cmd)).success?
|
11
|
-
end
|
12
|
-
|
13
|
-
include ReflectionUtils::CreateModuleFunctions
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
1
|
+
require_relative "../commands/os"
|
2
|
+
|
3
|
+
module Autowow
|
4
|
+
module Features
|
5
|
+
module Os
|
6
|
+
include Commands::Os
|
7
|
+
include Executor
|
8
|
+
|
9
|
+
def exists?(cmd)
|
10
|
+
quiet.run!(which(cmd)).success?
|
11
|
+
end
|
12
|
+
|
13
|
+
include ReflectionUtils::CreateModuleFunctions
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,50 +1,50 @@
|
|
1
|
-
require_relative "../commands/rbenv"
|
2
|
-
require_relative "../commands/vcs"
|
3
|
-
|
4
|
-
require_relative "fs"
|
5
|
-
require_relative "vcs"
|
6
|
-
|
7
|
-
module Autowow
|
8
|
-
module Features
|
9
|
-
module Rbenv
|
10
|
-
include EasyLogging
|
11
|
-
include Commands::Rbenv
|
12
|
-
include Executor
|
13
|
-
include StringDecorator
|
14
|
-
|
15
|
-
def ruby_versions
|
16
|
-
logger.info(used_versions)
|
17
|
-
end
|
18
|
-
|
19
|
-
def used_versions
|
20
|
-
rubies = []
|
21
|
-
Fs.in_place_or_subdirs(Vcs.is_git?) do
|
22
|
-
result = quiet.run!(version)
|
23
|
-
rubies.concat(result.out.clean_lines) if result.success?
|
24
|
-
end
|
25
|
-
rubies.uniq
|
26
|
-
end
|
27
|
-
|
28
|
-
def ruby_aliases
|
29
|
-
ret = {}
|
30
|
-
result = quiet.run!(aliases)
|
31
|
-
return ret unless result.success?
|
32
|
-
result.out.clean_lines.each do |line|
|
33
|
-
ret[line.split(" => ")[0]] = line.split(" => ")[1]
|
34
|
-
end
|
35
|
-
ret
|
36
|
-
end
|
37
|
-
|
38
|
-
def obsolete_versions
|
39
|
-
alias_map = ruby_aliases
|
40
|
-
used_versions_and_aliases = used_versions
|
41
|
-
used_versions.each do |v|
|
42
|
-
used_versions_and_aliases.push(alias_map[v]) if alias_map.has_key?(v)
|
43
|
-
end
|
44
|
-
quiet.run(installed_versions).out.clean_lines - used_versions_and_aliases
|
45
|
-
end
|
46
|
-
|
47
|
-
include ReflectionUtils::CreateModuleFunctions
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
1
|
+
require_relative "../commands/rbenv"
|
2
|
+
require_relative "../commands/vcs"
|
3
|
+
|
4
|
+
require_relative "fs"
|
5
|
+
require_relative "vcs"
|
6
|
+
|
7
|
+
module Autowow
|
8
|
+
module Features
|
9
|
+
module Rbenv
|
10
|
+
include EasyLogging
|
11
|
+
include Commands::Rbenv
|
12
|
+
include Executor
|
13
|
+
include StringDecorator
|
14
|
+
|
15
|
+
def ruby_versions
|
16
|
+
logger.info(used_versions)
|
17
|
+
end
|
18
|
+
|
19
|
+
def used_versions
|
20
|
+
rubies = []
|
21
|
+
Fs.in_place_or_subdirs(Vcs.is_git?) do
|
22
|
+
result = quiet.run!(version)
|
23
|
+
rubies.concat(result.out.clean_lines) if result.success?
|
24
|
+
end
|
25
|
+
rubies.uniq
|
26
|
+
end
|
27
|
+
|
28
|
+
def ruby_aliases
|
29
|
+
ret = {}
|
30
|
+
result = quiet.run!(aliases)
|
31
|
+
return ret unless result.success?
|
32
|
+
result.out.clean_lines.each do |line|
|
33
|
+
ret[line.split(" => ")[0]] = line.split(" => ")[1]
|
34
|
+
end
|
35
|
+
ret
|
36
|
+
end
|
37
|
+
|
38
|
+
def obsolete_versions
|
39
|
+
alias_map = ruby_aliases
|
40
|
+
used_versions_and_aliases = used_versions
|
41
|
+
used_versions.each do |v|
|
42
|
+
used_versions_and_aliases.push(alias_map[v]) if alias_map.has_key?(v)
|
43
|
+
end
|
44
|
+
quiet.run(installed_versions).out.clean_lines - used_versions_and_aliases
|
45
|
+
end
|
46
|
+
|
47
|
+
include ReflectionUtils::CreateModuleFunctions
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/autowow/features/vcs.rb
CHANGED
File without changes
|
@@ -1,25 +1,25 @@
|
|
1
|
-
require "pastel"
|
2
|
-
|
3
|
-
module Autowow
|
4
|
-
class LogFormatter
|
5
|
-
def self.beautify(severity, msg)
|
6
|
-
log_msg = msg.to_s.end_with?($/) ? msg : "#{msg}#{$/}"
|
7
|
-
log_msg = " $ #{log_msg}" if severity.eql?("DEBUG")
|
8
|
-
color(severity, log_msg)
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.color(severity, msg)
|
12
|
-
pastel = Pastel.new
|
13
|
-
case severity
|
14
|
-
when "DEBUG"
|
15
|
-
pastel.yellow(msg)
|
16
|
-
when "WARN"
|
17
|
-
pastel.red(msg)
|
18
|
-
when "ERROR"
|
19
|
-
pastel.bright_red(msg)
|
20
|
-
else
|
21
|
-
msg
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
require "pastel"
|
2
|
+
|
3
|
+
module Autowow
|
4
|
+
class LogFormatter
|
5
|
+
def self.beautify(severity, msg)
|
6
|
+
log_msg = msg.to_s.end_with?($/) ? msg : "#{msg}#{$/}"
|
7
|
+
log_msg = " $ #{log_msg}" if severity.eql?("DEBUG")
|
8
|
+
color(severity, log_msg)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.color(severity, msg)
|
12
|
+
pastel = Pastel.new
|
13
|
+
case severity
|
14
|
+
when "DEBUG"
|
15
|
+
pastel.yellow(msg)
|
16
|
+
when "WARN"
|
17
|
+
pastel.red(msg)
|
18
|
+
when "ERROR"
|
19
|
+
pastel.bright_red(msg)
|
20
|
+
else
|
21
|
+
msg
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,29 +1,29 @@
|
|
1
|
-
require "time_difference"
|
2
|
-
|
3
|
-
module RefinedTimeDifference
|
4
|
-
refine(TimeDifference) do
|
5
|
-
def humanize_higher_than(limit)
|
6
|
-
limit_index = TimeDifference::TIME_COMPONENTS.index(limit)
|
7
|
-
|
8
|
-
diff_parts = []
|
9
|
-
in_general.each_with_index do |array, index|
|
10
|
-
part, quantity = array
|
11
|
-
next if (quantity <= 0) || (limit_index < index)
|
12
|
-
part = part.to_s.humanize
|
13
|
-
|
14
|
-
if quantity <= 1
|
15
|
-
part = part.singularize
|
16
|
-
end
|
17
|
-
|
18
|
-
diff_parts << "#{quantity} #{part}"
|
19
|
-
end
|
20
|
-
|
21
|
-
last_part = (diff_parts.pop or "")
|
22
|
-
if diff_parts.empty?
|
23
|
-
return last_part
|
24
|
-
else
|
25
|
-
return [diff_parts.join(", "), last_part].join(" and ")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
1
|
+
require "time_difference"
|
2
|
+
|
3
|
+
module RefinedTimeDifference
|
4
|
+
refine(TimeDifference) do
|
5
|
+
def humanize_higher_than(limit)
|
6
|
+
limit_index = TimeDifference::TIME_COMPONENTS.index(limit)
|
7
|
+
|
8
|
+
diff_parts = []
|
9
|
+
in_general.each_with_index do |array, index|
|
10
|
+
part, quantity = array
|
11
|
+
next if (quantity <= 0) || (limit_index < index)
|
12
|
+
part = part.to_s.humanize
|
13
|
+
|
14
|
+
if quantity <= 1
|
15
|
+
part = part.singularize
|
16
|
+
end
|
17
|
+
|
18
|
+
diff_parts << "#{quantity} #{part}"
|
19
|
+
end
|
20
|
+
|
21
|
+
last_part = (diff_parts.pop or "")
|
22
|
+
if diff_parts.empty?
|
23
|
+
return last_part
|
24
|
+
else
|
25
|
+
return [diff_parts.join(", "), last_part].join(" and ")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/autowow/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autowow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thisismydesign
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: easy_logging
|
@@ -308,8 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
308
308
|
- !ruby/object:Gem::Version
|
309
309
|
version: '0'
|
310
310
|
requirements: []
|
311
|
-
|
312
|
-
rubygems_version: 2.7.7
|
311
|
+
rubygems_version: 3.0.3
|
313
312
|
signing_key:
|
314
313
|
specification_version: 4
|
315
314
|
summary: Set of commands to AUTOmate Way Of Working
|